/* ==========================================================================
   APP — base, cabeçalho, controles, transições e índice mobile
   ========================================================================== */

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

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--navy);
  color: #fff;
  font-family: var(--font);
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  overscroll-behavior: none;
}

img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
h1, h2, h3, p, ol, ul, dl, dd, figure { margin: 0; }
ol, ul { padding: 0; list-style: none; }

:focus-visible {
  outline: 2px solid var(--focus, #8ea2ff);
  outline-offset: 3px;
  border-radius: 6px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Cores da interface fixa (acompanha o tema da tela) ---------- */
body[data-chrome="dark"] {
  --c: #fff;
  --c-2: rgba(255, 255, 255, .7);
  --glass: rgba(255, 255, 255, .07);
  --glass-strong: rgba(10, 14, 90, .55);
  --glass-line: rgba(255, 255, 255, .16);
  --ind-bg: #fff;
  --ind-fg: var(--navy);
  --bar-bg: rgba(0, 1, 50, .72);
  --focus: #a9b5ff;
}
body[data-chrome="light"] {
  --c: var(--navy);
  --c-2: rgba(0, 1, 66, .62);
  --glass: rgba(255, 255, 255, .6);
  --glass-strong: rgba(255, 255, 255, .78);
  --glass-line: rgba(0, 1, 66, .12);
  --ind-bg: var(--navy);
  --ind-fg: #fff;
  --bar-bg: rgba(243, 241, 236, .84);
  --focus: #2b3aa8;
}

/* ---------- Cabeçalho ---------- */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 20;
  height: clamp(72px, 10vh, 96px);
  padding: 0 var(--pad-x);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.topbar::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--bar-bg);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  backdrop-filter: blur(18px) saturate(150%);
  border-bottom: 1px solid var(--glass-line);
  opacity: 0;
  transition: opacity .35s var(--ease);
}
body.is-scrolled .topbar::before { opacity: 1; }

.brand {
  position: relative;
  justify-self: start;
  display: block;
  width: clamp(104px, 9.6vmin + 30px, 150px);
  aspect-ratio: 603 / 109;
}
.brand__img, .brand__sym {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: left center;
  transition: opacity .45s var(--ease);
}
.brand__sym { display: none; }
.brand__img--navy { opacity: 0; }
body[data-chrome="light"] .brand__img--white { opacity: 0; }
body[data-chrome="light"] .brand__img--navy { opacity: 1; }

/* Navegação em cápsula */
.chapters {
  position: relative;
  display: flex;
  align-items: center;
  padding: 5px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  backdrop-filter: blur(20px) saturate(150%);
  transition: background .45s var(--ease), border-color .45s var(--ease);
}
.chapters button {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 clamp(14px, 1.5vw, 22px);
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--c-2);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  transition: color .4s var(--ease);
}
.chapters button .n {
  font-weight: 500;
  letter-spacing: .06em;
  opacity: .55;
  font-variant-numeric: tabular-nums;
}
.chapters button + button::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 1px;
  height: 12px;
  transform: translateY(-50%);
  background: var(--glass-line);
  transition: opacity .3s;
}
.chapters button.is-active::before,
.chapters button.is-active + button::before { opacity: 0; }
.chapters button:hover { color: var(--c); }
.chapters button.is-active { color: var(--ind-fg); }
.chapters button.is-active .n { opacity: .6; }
.chapters__ind {
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: 0;
  width: 0;
  border-radius: 999px;
  background: var(--ind-bg);
  transition: transform .6s var(--ease-out), width .6s var(--ease-out), background .45s var(--ease);
}
.no-anim .chapters__ind { transition: none; }

.topbar__end {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 18px;
}
.credit {
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--c-2);
  transition: color .45s var(--ease);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--glass-line);
  background: var(--glass);
  color: var(--c);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  cursor: pointer;
  transition: background .3s var(--ease), border-color .3s var(--ease), color .45s var(--ease);
}
.icon-btn:hover { border-color: var(--c-2); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn[hidden] { display: none; }
#fs-btn .i-exit { display: none; }
#fs-btn.is-on .i-exit { display: block; }
#fs-btn.is-on .i-enter { display: none; }

.mbar { display: none; }

/* ---------- Telas ---------- */
.deck {
  position: fixed;
  inset: 0;
  --dir: 1;
}

.slide {
  position: absolute;
  inset: 0;
  background: var(--bg);
  color: var(--fg);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
  visibility: hidden;
  opacity: 0;
  z-index: 0;
}
.slide.is-active {
  visibility: visible;
  opacity: 1;
  z-index: 2;
  transition: opacity var(--t-in) var(--ease);
}
.slide.is-leaving {
  visibility: visible;
  opacity: 1;
  z-index: 1;
}
.slide.is-leaving .slide__inner,
.slide.is-leaving .bg-grid {
  opacity: 0;
  transform: translate3d(calc(var(--dir) * -28px), 0, 0);
  transition: opacity var(--t-out) var(--ease), transform calc(var(--t-out) + 120ms) var(--ease);
}

/* Revelação progressiva */
.slide.is-active [data-r] {
  animation: reveal 680ms var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 60ms + 140ms);
}
@keyframes reveal {
  from { opacity: 0; transform: translate3d(calc(var(--dir) * 24px), 8px, 0); }
  to   { opacity: 1; transform: none; }
}
.slide.is-active .slide__media img {
  animation: settle 1600ms var(--ease-out) both;
}
@keyframes settle {
  from { transform: scale(1.035); opacity: .4; }
  to   { transform: none; opacity: 1; }
}

/* ---------- Controles ---------- */
.controls {
  position: fixed;
  left: 50%;
  bottom: calc(clamp(16px, 3.2vh, 30px) + var(--safe-b));
  z-index: 20;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border-radius: 999px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  backdrop-filter: blur(20px) saturate(150%);
  transition: background .45s var(--ease), border-color .45s var(--ease);
}
.ctl {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--glass-line);
  background: transparent;
  color: var(--c);
  cursor: pointer;
  transition: transform .35s var(--ease-out), background .3s var(--ease), color .45s var(--ease), border-color .3s var(--ease), opacity .3s;
}
.ctl svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; transition: transform .35s var(--ease-out); }
.ctl--next {
  width: 54px;
  height: 54px;
  border-color: transparent;
  background: var(--ind-bg);
  color: var(--ind-fg);
}
.ctl--prev:hover:not(:disabled) svg { transform: translateX(-3px); }
.ctl--next:hover:not(:disabled) svg { transform: translateX(3px); }
.ctl--prev:hover:not(:disabled) { border-color: var(--c-2); }
.ctl:active:not(:disabled) { transform: scale(.95); }
.ctl:disabled { opacity: .28; cursor: default; }

.count {
  min-width: 92px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: .14em;
  color: var(--c-2);
  font-variant-numeric: tabular-nums;
  transition: color .45s var(--ease);
}
.count b { color: var(--c); font-weight: 700; }
.count__sep { margin: 0 .55em; opacity: .5; }

.progress {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 21;
  height: 2px;
  background: var(--glass-line);
  --p: 0;
}
.progress span {
  display: block;
  height: 100%;
  background: var(--c);
  transform-origin: left center;
  transform: scaleX(var(--p));
  transition: transform .7s var(--ease-out), background .45s var(--ease);
}

/* ---------- Índice (celular) ---------- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: var(--navy);
  color: #fff;
  padding: calc(16px + var(--safe-t)) 20px calc(24px + var(--safe-b));
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity .4s var(--ease), transform .5s var(--ease-out), visibility 0s linear .5s;
  --c: #fff; --c-2: rgba(255,255,255,.7); --glass: rgba(255,255,255,.07); --glass-line: rgba(255,255,255,.16);
}
.sheet.is-open {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity .4s var(--ease), transform .5s var(--ease-out), visibility 0s;
}
.sheet__top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.sheet__logo { width: 120px; height: auto; }
.sheet__list { display: grid; gap: 22px; }
.sheet__chbtn {
  display: flex;
  align-items: baseline;
  gap: 14px;
  width: 100%;
  padding: 0 0 12px;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, .16);
  background: none;
  font-size: 1.6rem;
  font-weight: 500;
  letter-spacing: -.02em;
  text-align: left;
  cursor: pointer;
}
.sheet__chbtn .n { font-size: .72rem; font-weight: 600; letter-spacing: .16em; color: rgba(255,255,255,.5); }
.sheet__ch.is-active .sheet__chbtn { color: #fff; }
.sheet__ch:not(.is-active) .sheet__chbtn { color: rgba(255,255,255,.62); }
.sheet__slides { display: grid; margin-top: 4px; }
.sheet__slides button {
  display: flex;
  gap: 14px;
  width: 100%;
  min-height: 44px;
  align-items: center;
  padding: 6px 0;
  border: 0;
  background: none;
  color: rgba(255, 255, 255, .7);
  font-size: .92rem;
  text-align: left;
  cursor: pointer;
}
.sheet__slides .n { font-size: .7rem; letter-spacing: .12em; color: rgba(255,255,255,.4); font-variant-numeric: tabular-nums; min-width: 20px; }
.sheet__slides button.is-current { color: #fff; font-weight: 600; }
.sheet__slides button.is-current .n { color: var(--steel); }

.noscript { position: fixed; inset: 0; display: grid; place-items: center; color: #fff; }

/* ---------- Tablet e celular ---------- */
@media (max-width: 1023px) {
  .credit { display: none; }
}

@media (max-width: 767px) {
  .topbar {
    height: calc(64px + var(--safe-t));
    padding: var(--safe-t) 14px 0 18px;
    grid-template-columns: auto 1fr;
    gap: 14px;
    background: var(--bar-bg);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
    backdrop-filter: blur(18px) saturate(150%);
    border-bottom: 1px solid var(--glass-line);
    transition: background .45s var(--ease), border-color .45s var(--ease);
  }
  .brand { width: 32px; aspect-ratio: 168 / 143; }
  .brand__img { display: none; }
  .brand__sym { display: block; object-position: center; }
  .chapters, .topbar__end { display: none; }

  .mbar {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
  }
  .mbar__chapter {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding-left: 14px;
    border-left: 1px solid var(--glass-line);
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--c);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color .45s var(--ease);
  }
  .mbar__chapter .n { font-weight: 500; color: var(--c-2); letter-spacing: .08em; }
  .mbar__count {
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .1em;
    color: var(--c-2);
    font-variant-numeric: tabular-nums;
  }

  body::after {
    content: '';
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 19;
    height: calc(96px + var(--safe-b));
    pointer-events: none;
    background: linear-gradient(0deg, var(--fade) 45%, transparent);
    transition: background .45s var(--ease);
  }
  body[data-chrome="dark"] { --fade: rgba(0, 1, 50, .94); }
  body[data-chrome="light"] { --fade: rgba(243, 241, 236, .96); }
  .controls { bottom: calc(14px + var(--safe-b)); }
  .ctl { width: 48px; height: 48px; }
  .ctl--next { width: 52px; height: 52px; }
  .count { min-width: 84px; }

  .progress { top: calc(64px + var(--safe-t)); bottom: auto; height: 2px; }
}

/* ---------- Movimento reduzido ---------- */
@media (prefers-reduced-motion: reduce) {
  .slide.is-active [data-r],
  .slide.is-active .slide__media img { animation: none !important; }
  .slide.is-leaving .slide__inner,
  .slide.is-leaving .bg-grid { transform: none; }
  .slide.is-active { transition: opacity 200ms linear; }
  .chapters__ind, .progress span, .ctl, .ctl svg, .sheet { transition-duration: 1ms !important; }
}
