/* ============================================================
   ORDO · APP.CSS — reset, shell, navegação e componentes
   Mobile-first real. Sem zoom, sem scale(), sem overflow-x.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;   /* evita zoom automático de texto */
  text-size-adjust: 100%;
  touch-action: pan-x pan-y;         /* permite rolar, bloqueia pinça-zoom */
}
/* nenhum campo pode ter fonte < 16px (senão iOS dá zoom ao focar) */
input, select, textarea { font-size: 16px !important; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: var(--fs-corpo);
  line-height: var(--lh-normal);
  color: var(--c-txt);
  /* Fundo atmosférico sutil (medido das imagens): verde-petróleo muito
     discreto no topo sobre o preto-esverdeado. Sem verde forte. */
  background:
    radial-gradient(120% 55% at 50% -10%, #0E1615 0%, transparent 60%),
    var(--c-abs);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;               /* spec §34 — nunca overflow horizontal */
  overscroll-behavior-y: none;
}

/* ANTI-TRUNCAMENTO (regra absoluta): texto nunca é cortado.
   Quebra por inteiro; nada de ellipsis. */
* { text-overflow: clip; }
p, span, h1, h2, h3, li, a, button, label, div {
  overflow-wrap: anywhere;
  word-break: normal;
}

/* Impede zoom por double-tap sem bloquear scroll (pan permite rolar) */
button, a, input, select, textarea, label { touch-action: manipulation; }
/* elementos de conteúdo rolável mantêm pan (rolagem), sem pinça */
.rota, .chat, .sheet, .chips, .cats, .habitos-trilha { touch-action: pan-y; }

img { max-width: 100%; display: block; }

h1, h2, h3, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; }

a { color: inherit; text-decoration: none; }

/* Reset de botão: nenhum <button> herda o cinza padrão do navegador.
   Cada componente define seu próprio fundo (glass, dourado, etc.). */
button { background: transparent; border: 0; color: inherit; font: inherit; cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--c-ouro);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---- App frame: uma coluna centralizada, altura real da tela ---- */
#app {
  min-height: 100svh;               /* spec §16 — altura real */
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: var(--largura-conteudo);
  margin-inline: auto;
  position: relative;
}

/* ---- Rota (conteúdo scrollável entre header e bottomnav) ---- */
.rota {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-inline: var(--sp-4);
  padding-top: calc(var(--h-header) + var(--safe-top) + var(--sp-3));
  padding-bottom: calc(var(--h-bottomnav) + var(--safe-bottom) + var(--sp-6));
}
.rota.sem-nav {
  padding-bottom: calc(var(--safe-bottom) + var(--sp-6));
}
.rota.sem-header {
  padding-top: calc(var(--safe-top) + var(--sp-3));
}

/* ---- Header compacto (spec §5) ---- */
.header {
  position: fixed;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--largura-conteudo);
  height: calc(var(--h-header) + var(--safe-top));
  padding-top: var(--safe-top);
  padding-inline: var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  background: var(--glass-nav);
  backdrop-filter: blur(var(--blur-forte)) saturate(1.3);
  -webkit-backdrop-filter: blur(var(--blur-forte)) saturate(1.3);
  border-bottom: 1px solid var(--borda);
  z-index: var(--z-header);
}
.header__titulo { font-family: var(--serif); font-size: var(--fs-h2); font-weight: 500; flex: 1; }
.header__voltar {
  width: var(--toque-min); height: var(--toque-min);
  margin-left: calc(var(--sp-2) * -1);
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; color: var(--c-ouro); background: none; border: 0; cursor: pointer;
}
.header__acao {
  min-width: var(--toque-min); height: var(--toque-min);
  display: flex; align-items: center; justify-content: center;
  background: none; border: 0; color: var(--c-txt-2); font-size: 20px; cursor: pointer;
}

/* ---- Bottom navigation (spec §5 — só destinos prioritários) ---- */
.bottomnav {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--largura-conteudo);
  height: calc(var(--h-bottomnav) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  background: var(--glass-nav);
  backdrop-filter: blur(var(--blur-forte)) saturate(1.3);
  -webkit-backdrop-filter: blur(var(--blur-forte)) saturate(1.3);
  border-top: 1px solid var(--borda);
  box-shadow: var(--brilho-borda);
  z-index: var(--z-bottomnav);
}
.bottomnav__item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  background: none; border: 0; cursor: pointer;
  color: var(--c-txt-3);
  min-height: var(--toque-min);
  transition: color .18s ease;
}
.bottomnav__item .ic { font-size: 20px; line-height: 1; }
.bottomnav__item .lbl { font-size: 10px; letter-spacing: .3px; }
.bottomnav__item[aria-current="page"] { color: var(--c-ouro); }
.bottomnav__item:active { color: var(--c-ouro-claro); }

/* ---- Tipografia utilitária ---- */
.display { font-family: var(--serif); font-size: var(--fs-display); font-weight: 500; letter-spacing: .5px; line-height: var(--lh-tight); }
.h1 { font-family: var(--serif); font-size: var(--fs-h1); font-weight: 500; }
.h2 { font-family: var(--serif); font-size: var(--fs-h2); font-weight: 500; }
.h3 { font-family: var(--serif); font-size: var(--fs-h3); font-weight: 500; }
.corpo { font-size: var(--fs-corpo); color: var(--c-txt-2); }
.peq { font-size: var(--fs-peq); color: var(--c-txt-3); }
.micro { font-size: var(--fs-micro); letter-spacing: 1.2px; text-transform: uppercase; color: var(--c-txt-3); font-weight: 500; }
.micro.ouro { color: var(--c-ouro); }
.italico { font-style: italic; }
.serif { font-family: var(--serif); }

/* ---- Cards (GLASSMORPHISM — translúcido + blur + brilho de borda) ---- */
.card {
  background: var(--glass-1);
  backdrop-filter: blur(var(--blur)) saturate(1.2);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.2);
  border: 1px solid var(--borda);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  box-shadow: var(--sombra-card), var(--brilho-borda);
}
.card-destaque {
  position: relative;
  background: linear-gradient(155deg, var(--glass-2-topo) 0%, var(--glass-2-base) 100%);
  backdrop-filter: blur(var(--blur-forte)) saturate(1.5);
  -webkit-backdrop-filter: blur(var(--blur-forte)) saturate(1.5);
  border: 1px solid var(--borda-ouro);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--sombra-card), var(--brilho-borda);
  overflow: hidden;
}
/* brilho de vidro quente no canto superior — dá o reflexo das imagens */
.card-destaque::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(130% 90% at 15% 0%, var(--glass-brilho), transparent 55%);
  pointer-events: none;
}
.card--press { cursor: pointer; transition: transform .12s ease, opacity .12s ease; }
.card--press:active { transform: scale(.985); opacity: .92; }

/* ---- Barra de progresso ---- */
.barra { height: 6px; background: var(--c-abs); border-radius: var(--r-full); overflow: hidden; }
.barra > i { display: block; height: 100%; background: var(--c-ouro); border-radius: var(--r-full); transition: width .4s ease; }

/* ---- Botões (touch-first, min 44px) ---- */
.btn {
  min-height: var(--toque-min);
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 var(--sp-5);
  border: 0; border-radius: var(--r-full);
  font-family: var(--sans); font-size: var(--fs-corpo); font-weight: 600;
  cursor: pointer; width: 100%;
  transition: transform .12s ease, opacity .12s ease;
}
.btn:active { transform: scale(.98); }
.btn--ouro { background: var(--grad-ouro); color: var(--c-abs); }
.btn--ghost { background: none; border: 1px solid var(--borda-ouro); color: var(--c-ouro); }
.btn--peq { min-height: 38px; width: auto; padding: 0 var(--sp-4); font-size: var(--fs-peq); }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---- Chips / segmented ---- */
.chips { display: flex; gap: var(--sp-2); overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; min-height: 38px;
  display: inline-flex; align-items: center;
  padding: 0 var(--sp-4);
  background: var(--glass-1);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--borda);
  border-radius: var(--r-full); color: var(--c-txt-3);
  font-size: var(--fs-peq); cursor: pointer;
}
.chip[aria-selected="true"] { background: var(--c-petroleo); border-color: var(--borda-ouro); color: var(--c-ouro); }

/* ---- Segmented (abas) ---- */
.segmented { display: flex; gap: var(--sp-5); border-bottom: 1px solid var(--borda); }
.segmented button {
  background: none; border: 0; cursor: pointer;
  padding: var(--sp-2) 0; color: var(--c-txt-3); font-size: var(--fs-peq);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.segmented button[aria-selected="true"] { color: var(--c-txt); border-bottom-color: var(--c-ouro); }

/* ---- Inputs (spec §8 — reconstruídos para toque) ---- */
.campo { display: flex; flex-direction: column; gap: var(--sp-2); }
.campo label { font-size: var(--fs-micro); letter-spacing: 1.1px; text-transform: uppercase; color: var(--c-txt-3); }
.input, .textarea {
  width: 100%;
  min-height: var(--toque-min);
  background: var(--glass-3);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--borda);
  border-radius: var(--r-sm);
  padding: var(--sp-3) var(--sp-4);
  color: var(--c-txt);
  font-family: var(--sans); font-size: 16px;   /* 16px evita zoom no iOS (spec §3) */
}
.textarea { min-height: 120px; padding-top: var(--sp-3); resize: none; line-height: var(--lh-normal); }
.input::placeholder, .textarea::placeholder { color: var(--c-txt-3); }
.input:focus, .textarea:focus { outline: none; border-color: var(--borda-ouro); }

/* ---- Lista (linhas) ---- */
.lista { display: flex; flex-direction: column; }
.lista__item {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%;
  min-height: var(--toque-min);
  padding: var(--sp-3) 0;
  border: 0;
  border-bottom: 1px solid var(--borda);
  background: transparent;      /* herda o glass do card (button não pode ficar cinza) */
  color: var(--c-txt);
  font-family: var(--sans); font-size: var(--fs-corpo);
  text-align: left;
  cursor: pointer;
  transition: opacity .12s ease;
}
.lista__item:active { opacity: .6; }
.lista__item:last-child { border-bottom: 0; }

/* ---- Seção ---- */
.secao { display: flex; flex-direction: column; gap: var(--sp-3); }
.secao__head { display: flex; align-items: center; justify-content: space-between; }

/* pilha vertical padrão de uma tela */
.pilha { display: flex; flex-direction: column; gap: var(--sp-5); }

/* ---- Sheet (bottom sheet — spec §10) ---- */
.overlay {
  position: fixed; inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(2px);
  z-index: var(--z-overlay);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.overlay.aberto { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed;
  left: 50%; bottom: 0;
  transform: translateX(-50%) translateY(100%);
  width: 100%; max-width: var(--largura-conteudo);
  max-height: 88svh;
  background: var(--glass-nav);
  backdrop-filter: blur(var(--blur-forte)) saturate(1.3);
  -webkit-backdrop-filter: blur(var(--blur-forte)) saturate(1.3);
  border-top-left-radius: var(--r-xl);
  border-top-right-radius: var(--r-xl);
  border: 1px solid var(--borda);
  padding: var(--sp-4) var(--sp-4) calc(var(--safe-bottom) + var(--sp-6));
  z-index: var(--z-sheet);
  transition: transform .26s cubic-bezier(.2,.8,.2,1);
  overflow-y: auto;
}
.sheet.aberto { transform: translateX(-50%) translateY(0); }
.sheet__handle { width: 40px; height: 4px; border-radius: var(--r-full); background: var(--c-txt-3); opacity: .4; margin: 0 auto var(--sp-4); }

/* ---- Toast (feedback — spec §18) ---- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--h-bottomnav) + var(--safe-bottom) + var(--sp-4));
  transform: translateX(-50%) translateY(20px);
  background: var(--c-premium); border: 1px solid var(--borda-ouro);
  color: var(--c-txt); padding: var(--sp-3) var(--sp-5); border-radius: var(--r-full);
  font-size: var(--fs-peq); z-index: var(--z-toast);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  box-shadow: var(--sombra-flutuante);
}
.toast.mostra { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- Skeleton (loading — spec §18) ---- */
.sk { background: linear-gradient(90deg, var(--c-bg-2) 25%, var(--c-premium) 37%, var(--c-bg-2) 63%); background-size: 400% 100%; animation: sk 1.4s ease infinite; border-radius: var(--r-sm); }
@keyframes sk { 0% { background-position: 100% 0 } 100% { background-position: -100% 0 } }

/* ---- Estado vazio (spec §24) ---- */
.vazio { text-align: center; padding: var(--sp-10) var(--sp-4); display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); }
.vazio__ic { font-size: 40px; opacity: .5; }
.vazio__txt { color: var(--c-txt-3); max-width: 40ch; }

/* ---- Transições de rota (spec §20 — discretas) ---- */
.rota { animation: entra .22s ease; }
@keyframes entra { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- Redução de movimento (spec §22) ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* utilitários */
.linha { display: flex; align-items: center; gap: var(--sp-3); }
.entre { justify-content: space-between; }
.crescer { flex: 1; }
.centro { text-align: center; }
.mt-2 { margin-top: var(--sp-2); }
.mt-4 { margin-top: var(--sp-4); }
.tabular { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
