/*
 * Sol na Prova · mundo: carta de percurso + fotômetro.
 * Material: papel de mapa morno, régua de quilometragem. Profundidade: borda de 1px, sem sombra (exceto o que flutua no mapa).
 * Ação: azul-petróleo (uma só). Luz no trecho: musgo / ocre / tijolo — estados, nunca botão.
 * Voz: uma família só, Archivo — larga (112–118%) nos títulos e números, como número de peito; normal no texto.
 */
@font-face { font-family: "Archivo"; src: url(fonts/archivo-latin-wdth-normal.woff2) format("woff2"); font-weight: 100 900; font-stretch: 62% 125%; font-display: swap; }

:root {
  --fundo: #f2f0ea;
  --superficie: #fbfaf6;
  --rebaixo: #e8e5dc;
  --tinta: #1d1c19;
  --tinta-2: #4b4842;
  --tinta-3: #67635b;
  --linha: rgba(29, 28, 25, 0.12);
  --linha-forte: rgba(29, 28, 25, 0.24);

  --acao: #1d5764;
  --acao-forte: #143f49;
  --acao-suave: color-mix(in srgb, var(--acao) 10%, transparent);
  --acao-texto: #ffffff;

  /* luz no trecho (estados) */
  --favor: #2e7547;  --favor-suave: #e3efe5;
  --lado: #a8730c;   --lado-suave: #f6ecd6;
  --contra: #ad3a2a; --contra-suave: #f7e3df;
  --noite: #7c786f;  --noite-suave: #e9e7e1;
  --sol: #e3a21c;
  --erro: #ad3a2a;
  --foco: #1d5764;

  --sombra-alta: 0 1px 2px rgba(29, 28, 25, 0.08), 0 10px 28px -10px rgba(29, 28, 25, 0.28);

  --font-display: "Archivo", ui-sans-serif, system-ui, sans-serif;
  --font-sans: "Archivo", ui-sans-serif, system-ui, sans-serif;
  --t-rotulo: 13px;
  --t-corpo: 16px;
  --t-1: 20px;
  --t-2: 25px;
  --t-3: 31px;
  --t-4: 39px;

  --e-meio: 4px; --e-1: 8px; --e-2: 16px; --e-3: 24px; --e-4: 32px; --e-5: 40px; --e-6: 48px;
  --r-controle: 10px; --r-card: 14px; --r-pilula: 999px;
  --alvo: 44px; --alvo-cta: 48px;
  --z-mapa-ui: 500; --z-inicio: 1050; --z-gaveta: 1100; --z-aviso: 1200; /* Leaflet usa até 1000 nos controles */
  --curva: cubic-bezier(0.2, 0.8, 0.2, 1);
  --d-rapida: 120ms; --d-media: 180ms;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #121210;
    --superficie: #1b1b18;
    --rebaixo: #262521;
    --tinta: #f1efe8;
    --tinta-2: #c3beb3;
    --tinta-3: #9a958a;
    --linha: rgba(255, 250, 240, 0.1);
    --linha-forte: rgba(255, 250, 240, 0.2);
    --acao: #7cc0cf;
    --acao-forte: #a3d6e1;
    --acao-texto: #0d1f24;
    --favor: #6fbf87;  --favor-suave: rgba(111, 191, 135, 0.15);
    --lado: #e3b04f;   --lado-suave: rgba(227, 176, 79, 0.15);
    --contra: #ec8a78; --contra-suave: rgba(236, 138, 120, 0.15);
    --noite: #a19c91;  --noite-suave: rgba(161, 156, 145, 0.14);
    --sol: #f2bd45;
    --foco: #7cc0cf;
    --sombra-alta: 0 12px 32px -12px rgba(0, 0, 0, 0.7);
    color-scheme: dark;
  }
}
@media (prefers-reduced-motion: reduce) {
  :root { --d-rapida: 0ms; --d-media: 0ms; }
}

*, *::before, *::after { box-sizing: border-box; }
* { min-width: 0; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--fundo); color: var(--tinta);
  font: var(--t-corpo)/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased; overflow-x: clip;
}
h1, h2, h3 { font-family: var(--font-display); font-stretch: 112%; line-height: 1.1; letter-spacing: -0.022em; margin: 0; text-wrap: balance; }
h1 { letter-spacing: -0.03em; }
p { margin: 0; text-wrap: pretty; }
.num { font-family: var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.rotulo { font-size: var(--t-rotulo); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--tinta-3); }
:focus-visible { outline: 2px solid var(--foco); outline-offset: 2px; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- moldura ---------- */
.app { display: grid; grid-template-rows: auto 1fr; min-height: 100dvh; }
.topo {
  display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: var(--e-2);
  padding: calc(var(--e-2) + env(safe-area-inset-top)) max(var(--e-2), env(safe-area-inset-right)) var(--e-2) max(var(--e-2), env(safe-area-inset-left));
  border-bottom: 1px solid var(--linha);
}
.topo .sobre { color: var(--acao); font-size: var(--t-rotulo); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.topo h1 { font-size: var(--t-3); margin-top: 2px; }
.topo h1 .pt { color: var(--sol); }
.topo .sub { color: var(--tinta-2); margin-top: 2px; }
.topo .acoes { display: flex; gap: var(--e-1); flex-wrap: wrap; }

/* ---------- botões ---------- */
.btn {
  min-height: var(--alvo); padding: 0 var(--e-2); border-radius: var(--r-controle);
  border: 1px solid var(--linha-forte); background: var(--superficie); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--e-1); font-weight: 700;
  transition: background-color var(--d-rapida) var(--curva), border-color var(--d-rapida) var(--curva);
  white-space: nowrap;
}
.btn:hover { background: var(--rebaixo); }
.btn.cheio { background: var(--acao); color: var(--acao-texto); border-color: var(--acao); min-height: var(--alvo-cta); }
.btn.cheio:hover { background: var(--acao-forte); }
.btn.sutil { border-color: transparent; background: transparent; }
.btn.sutil:hover { background: var(--acao-suave); }
.btn svg { width: 20px; height: 20px; flex: none; }

/* ---------- corpo: mapa 8 / painel 4 ---------- */
.corpo { display: grid; grid-template-columns: minmax(0, 1fr); }
.corpo:has(.painel[hidden]) .mapa-caixa { height: auto; }
.mapa-caixa { position: relative; overflow: hidden; height: 56dvh; min-height: 320px; background: var(--rebaixo); }
#mapa { position: absolute; inset: 0; }
.painel { padding: var(--e-3) var(--e-2) calc(var(--e-5) + env(safe-area-inset-bottom)); display: flex; flex-direction: column; }
@media (min-width: 960px) {
  .app { height: 100dvh; }
  .corpo { grid-template-columns: minmax(0, 8fr) minmax(360px, 4fr); min-height: 0; }
  .mapa-caixa { height: auto; }
  .corpo:has(.painel[hidden]) { grid-template-columns: minmax(0, 1fr); }
  .painel { overflow-y: auto; border-left: 1px solid var(--linha); padding: var(--e-3); }
}

/* ritmo do painel: 1× quando continua, 2× quando muda de assunto */
.bloco + .bloco { margin-top: var(--e-4); }
.bloco > .rotulo { display: block; margin-bottom: var(--e-1); }

/* ---------- pelotão ---------- */
.chips { display: flex; gap: var(--e-1); flex-wrap: wrap; }
.chip {
  min-height: var(--alvo); padding: 0 14px; border-radius: var(--r-pilula); border: 1px solid var(--linha-forte);
  background: transparent; cursor: pointer; font-weight: 700;
  transition: background-color var(--d-rapida) var(--curva), color var(--d-rapida) var(--curva);
}
.chip[aria-pressed="true"] { background: var(--tinta); color: var(--fundo); border-color: var(--tinta); }
.leitura { display: flex; align-items: baseline; gap: var(--e-2); flex-wrap: wrap; margin-top: var(--e-2); }
.leitura .grande { font-family: var(--font-display); font-stretch: 118%; font-weight: 800; font-size: var(--t-4); line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.leitura .apoio { color: var(--tinta-2); }
input[type="range"] { width: 100%; height: var(--alvo); accent-color: var(--acao); margin: var(--e-1) 0 0; }
.escala { display: flex; justify-content: space-between; font-size: var(--t-rotulo); color: var(--tinta-3); }

/* ---------- régua do percurso (estrutura dominante do painel) ---------- */
.regua { position: relative; margin-top: var(--e-1); }
.faixa { display: flex; height: 36px; border-radius: 6px; overflow: hidden; border: 1px solid var(--linha-forte); cursor: pointer; }
.faixa > i { display: block; height: 100%; }
.c-favor { background: var(--favor); } .c-lado { background: var(--lado); } .c-contra { background: var(--contra); } .c-noite { background: var(--noite); }
.marcas { position: relative; height: 22px; font-size: var(--t-rotulo); color: var(--tinta-3); font-variant-numeric: tabular-nums; }
.marcas span { position: absolute; top: 4px; transform: translateX(-50%); white-space: nowrap; }
.marcas span:first-child { transform: none; } .marcas span:last-child { transform: translateX(-100%); }
.cursor { position: absolute; top: -6px; width: 3px; height: 48px; margin-left: -1.5px; background: var(--tinta); border-radius: 2px; pointer-events: none; }
.legenda { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--e-1) var(--e-2); margin-top: var(--e-2); }
.legenda div { display: flex; align-items: center; gap: var(--e-1); }
@media (max-width: 420px) { .legenda { grid-template-columns: minmax(0, 1fr); } }
.legenda b { font-family: var(--font-display); font-variant-numeric: tabular-nums; margin-left: auto; }
.ponto-cor { width: 12px; height: 12px; border-radius: 3px; flex: none; }

.linha-titulo { display: flex; align-items: center; justify-content: space-between; gap: var(--e-2); flex-wrap: wrap; margin-bottom: var(--e-1); }
.linha-titulo .btn.cheio { min-height: var(--alvo); }
.ceu { position: relative; height: 150px; margin-top: var(--e-1); }
.ceu > svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.dados-sol { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--e-1) var(--e-2); margin: var(--e-2) 0 0; }
.dados-sol div { border-top: 1px solid var(--linha); padding-top: 6px; }
.dados-sol dt { font-size: var(--t-rotulo); color: var(--tinta-3); font-weight: 700; }
.dados-sol dd { margin: 0; font-family: var(--font-display); font-stretch: 112%; font-weight: 700; font-size: var(--t-1); font-variant-numeric: tabular-nums; white-space: nowrap; }
.dados-sol dd small { font-family: var(--font-sans); font-stretch: 100%; font-weight: 400; font-size: 14px; color: var(--tinta-2); margin-left: 4px; }
.sem-mapa { position: absolute; z-index: var(--z-mapa-ui); left: 68px; right: 136px; top: 12px; margin: 0; max-width: 420px; padding: 10px 12px; font-size: 14px; background: var(--superficie); border: 1px solid var(--linha-forte); border-radius: var(--r-controle); color: var(--tinta-2); }
.sol-mapa { color: var(--sol); }
.sol-mapa svg { display: block; filter: drop-shadow(0 1px 2px rgba(0,0,0,.35)); }
.rotulo-sol { background: var(--superficie); color: var(--tinta); border: 1px solid var(--sol); border-radius: 6px; font: 700 12px/20px var(--font-sans); text-align: center; white-space: nowrap; font-variant-numeric: tabular-nums; }
.nuvem { margin-top: var(--e-2); padding: var(--e-1) var(--e-2); border-radius: var(--r-controle); background: var(--rebaixo); color: var(--tinta-2); font-size: 15px; }

/* ---------- melhores trechos: lista com hora pendurada ---------- */
.lista { list-style: none; margin: 0; padding: 0; }
.lista li { border-top: 1px solid var(--linha); }
.lista li:last-child { border-bottom: 1px solid var(--linha); }
.lista button {
  width: 100%; display: grid; grid-template-columns: 4.6em minmax(0, 1fr); gap: var(--e-2); align-items: start; text-align: left;
  padding: 12px 4px; border: 0; background: transparent; cursor: pointer; min-height: var(--alvo);
}
.lista button:hover { background: var(--acao-suave); }
.lista .hora { font-family: var(--font-display); font-weight: 700; font-size: var(--t-1); font-variant-numeric: tabular-nums; line-height: 1.2; white-space: nowrap; }
.lista .t1 { font-weight: 700; }
.lista .t2 { color: var(--tinta-2); font-size: 15px; }
.vazio { color: var(--tinta-2); padding: var(--e-2) 0; }

/* ---------- ponto escolhido: o fotômetro ---------- */
.ponto { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: var(--e-2); align-items: center; padding: var(--e-2); border: 1px solid var(--linha-forte); border-radius: var(--r-card); background: var(--superficie); }
.ponto > svg { width: 132px; height: 132px; }
.ponto .veredito { font-family: var(--font-display); font-stretch: 110%; font-weight: 800; font-size: var(--t-1); line-height: 1.15; }
.ponto .veredito.favor { color: var(--favor); } .ponto .veredito.lado { color: var(--lado); } .ponto .veredito.contra { color: var(--contra); } .ponto .veredito.noite { color: var(--noite); }
.ponto .dados { color: var(--tinta-2); font-size: 15px; margin-top: 4px; }
.ponto .dica { grid-column: 1 / -1; font-size: 15px; }
.ponto .dica p + p { margin-top: 6px; }
.ponto .linha-acoes { grid-column: 1 / -1; display: flex; gap: var(--e-1); flex-wrap: wrap; }
.ponto .linha-acoes .btn { white-space: normal; text-align: left; }
@media (max-width: 380px) { .ponto { grid-template-columns: minmax(0, 1fr); justify-items: start; } }

/* meus pontos: horários por pelotão */
.meus { width: 100%; border-collapse: collapse; font-size: 15px; }
.meus th, .meus td { padding: 8px 4px; border-top: 1px solid var(--linha); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.meus th:first-child, .meus td:first-child { text-align: left; white-space: normal; }
.meus thead th { border-top: 0; font-size: var(--t-rotulo); color: var(--tinta-3); font-weight: 700; }
.meus td button { border: 0; background: none; cursor: pointer; padding: 0; font-weight: 700; text-align: left; text-decoration: underline; text-underline-offset: 3px; min-height: var(--alvo); }
.tabela-rola { overflow-x: auto; }

/* ---------- configurações ---------- */
details.config { border-top: 1px solid var(--linha); padding-top: var(--e-2); }
details.config summary { cursor: pointer; font-weight: 700; min-height: var(--alvo); display: flex; align-items: center; }
.campos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--e-2); margin-top: var(--e-2); }
.campos .cheia { grid-column: 1 / -1; }
.campo label { display: block; font-size: var(--t-rotulo); font-weight: 700; color: var(--tinta-2); margin-bottom: 4px; }
.campo input, .campo select {
  width: 100%; min-height: var(--alvo); padding: 0 12px; border-radius: var(--r-controle);
  border: 1px solid var(--linha-forte); background: var(--superficie); font-size: 16px;
}
.campo small { display: block; color: var(--tinta-3); font-size: var(--t-rotulo); margin-top: 4px; }
.config .linha-acoes { display: flex; gap: var(--e-1); flex-wrap: wrap; margin-top: var(--e-2); }

/* ---------- sobre o mapa ---------- */
.bussola {
  position: absolute; z-index: var(--z-mapa-ui); top: 12px; right: 12px; width: 112px; padding: 8px; text-align: center;
  background: var(--superficie); border: 1px solid var(--linha-forte); border-radius: var(--r-card); box-shadow: var(--sombra-alta);
  font-size: var(--t-rotulo); color: var(--tinta-2);
}
.bussola svg { width: 72px; height: 72px; display: block; margin: 0 auto 2px; }
.bussola b { display: block; color: var(--tinta); font-family: var(--font-display); font-size: 15px; font-variant-numeric: tabular-nums; }
.mapa-botoes { position: absolute; z-index: var(--z-mapa-ui); left: 12px; bottom: 12px; display: flex; gap: var(--e-1); flex-wrap: wrap; }
.mapa-botoes .btn { box-shadow: var(--sombra-alta); }

.desenho {
  position: absolute; z-index: var(--z-mapa-ui); left: 12px; right: 12px; top: 12px; max-width: 520px;
  background: var(--superficie); border: 1px solid var(--linha-forte); border-radius: var(--r-card); box-shadow: var(--sombra-alta);
  padding: 12px; display: grid; gap: var(--e-1);
}
.desenho .linha-acoes { display: flex; gap: var(--e-1); flex-wrap: wrap; }

/* estado vazio: começa a prova */
.inicio { position: absolute; inset: 0; z-index: var(--z-inicio); display: grid; place-items: center; padding: var(--e-3); background: color-mix(in srgb, var(--fundo) 88%, transparent); }
.inicio .cartao { max-width: 440px; display: grid; gap: var(--e-2); }
.inicio h2 { font-size: var(--t-3); }
.inicio p { color: var(--tinta-2); }
.inicio .linha-acoes { display: flex; gap: var(--e-1); flex-wrap: wrap; }
.inicio.arrastando { outline: 3px dashed var(--acao); outline-offset: -12px; }

/* gaveta das provas salvas */
.gaveta-fundo { position: fixed; inset: 0; z-index: var(--z-gaveta); background: rgba(10, 10, 8, 0.4); display: flex; justify-content: flex-end; }
.gaveta { width: min(420px, 100%); height: 100%; background: var(--superficie); padding: calc(var(--e-3) + env(safe-area-inset-top)) var(--e-3) var(--e-3); overflow-y: auto; display: flex; flex-direction: column; gap: var(--e-2); }
.gaveta header { display: flex; justify-content: space-between; align-items: center; gap: var(--e-2); }
.gaveta h2 { font-size: var(--t-2); }
.salvas { list-style: none; margin: 0; padding: 0; }
.salvas li { display: flex; align-items: center; gap: var(--e-1); border-top: 1px solid var(--linha); padding: 8px 0; }
.salvas li button.abrir { flex: 1; text-align: left; border: 0; background: none; cursor: pointer; padding: 6px 4px; min-height: var(--alvo); }
.salvas li .t2 { color: var(--tinta-2); font-size: 15px; display: block; }

.aviso {
  position: fixed; z-index: var(--z-aviso); left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--tinta); color: var(--fundo); padding: 12px 18px; border-radius: var(--r-controle); max-width: calc(100% - 32px); font-weight: 700;
}

/* Leaflet no nosso mundo */
.leaflet-tile-pane { filter: saturate(0.55) sepia(0.12) contrast(0.96); } /* puxa o mapa colorido para o papel morno */
@media (prefers-color-scheme: dark) { .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) saturate(0.4) brightness(0.88) contrast(0.92); } }
.leaflet-container { font: 15px/1.4 var(--font-sans); background: var(--rebaixo); }
.leaflet-container .leaflet-control-attribution { font-size: 12px; background: color-mix(in srgb, var(--superficie) 90%, transparent); color: var(--tinta-2); }
.leaflet-container .leaflet-control-attribution a { color: var(--tinta); }
.leaflet-bar a { width: 44px !important; height: 44px !important; line-height: 44px !important; background: var(--superficie); color: var(--tinta); border-color: var(--linha) !important; } /* !important: sobrescreve o tamanho fixo do Leaflet */
.km-rotulo { background: var(--superficie); color: var(--tinta); border: 1px solid var(--linha-forte); border-radius: 6px; font: 700 12px/18px var(--font-display); text-align: center; font-variant-numeric: tabular-nums; }
.seta { color: var(--tinta); }
.seta svg { width: 18px; height: 18px; display: block; }
.pino-meu { color: var(--acao); }
.pino-meu { display: grid; place-items: center; }
.pino-meu svg, .pino-grupo svg { display: block; filter: drop-shadow(0 1px 1px rgba(0,0,0,.35)); }
.pino-grupo { background: var(--tinta); color: var(--fundo); border-radius: var(--r-pilula); font: 700 12px/22px var(--font-sans); text-align: center; white-space: nowrap; }
