/* Cogwood — a página é o menu inicial do jogo: diorama 3D atrás, janelas de madeira na frente.
   Molduras, botões e slots usam as mesmas texturas da interface do jogo (tools/ui/build_ui.py --web, em 2x);
   as fatias do border-image = margens do nine-patch em src/UI/UiTheme.cs × 2. */

@font-face {
  font-family: "Fredoka";
  src: url("assets/fonts/Fredoka.ttf") format("truetype");
  font-weight: 300 700;
  font-stretch: 75% 125%;
  font-display: swap;
}
@font-face {
  font-family: "Nunito";
  src: url("assets/fonts/Nunito.ttf") format("truetype");
  font-weight: 200 1000;
  font-display: swap;
}

:root {
  --ink: #120b07;
  --walnut: #2e2119;
  --walnut-deep: #211812;
  --wood: #704828;
  --brass: #d6a84a;
  --brass-light: #f6dc8c;
  --gold: #f0c766;
  --parchment: #eedfbc;
  --muted: #cdb995;
  --leaf: #8fbf5a;
  --night: 0; /* 0 = dia, 1 = noite (o diorama escreve conforme a rolagem) */
  --display: "Fredoka", "Nunito", system-ui, sans-serif;
  --body: "Nunito", system-ui, sans-serif;
  color-scheme: dark;
  scrollbar-color: var(--brass) var(--walnut-deep);
}

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

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background-color: var(--walnut-deep);
  color: var(--parchment);
  font: 600 1.0625rem/1.6 var(--body);
  font-size-adjust: from-font;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection { background: var(--gold); color: var(--ink); }

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

a { color: var(--gold); text-underline-offset: 0.2em; text-decoration-thickness: 2px; }
a:hover { color: var(--brass-light); }

:focus-visible { outline: 3px solid var(--brass-light); outline-offset: 3px; border-radius: 4px; }

h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.1; margin: 0; text-wrap: balance; }

h2 {
  font-size: clamp(1.75rem, 1.2rem + 1.8vw, 2.6rem);
  color: var(--gold);
  -webkit-text-stroke: 5px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 3px 0 rgb(0 0 0 / 0.45);
}

h3 { font-size: 1.3rem; color: var(--parchment); }

p { margin: 0; }

.skip {
  position: absolute; left: 1rem; top: -4rem; z-index: 20;
  padding: 0.6rem 1rem; background: var(--gold); color: var(--ink); border-radius: 8px;
}
.skip:focus { top: 1rem; }
.skip:hover { color: var(--ink); }

/* ---------- materiais do jogo ---------- */

.window {
  position: relative;
  border: 22px solid transparent;
  border-image-source: url("assets/ui/panel.png");
  border-image-slice: 60 fill;
  border-image-width: 30px;
  border-image-repeat: round;
  padding: 0.75rem 0.9rem;
  filter: drop-shadow(0 18px 28px rgb(0 0 0 / 0.5));
}

.plate {
  border: 10px solid transparent;
  border-image: url("assets/ui/plate.png") 28 fill / 14px;
  padding: 0.15rem 0.35rem;
  color: var(--parchment);
}

.slot {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 4rem; height: 4rem;
  border: 4px solid transparent;
  border-image: url("assets/ui/slot.png") 28 fill / 14px;
}
.slot img { width: 78%; height: auto; filter: drop-shadow(0 2px 2px rgb(0 0 0 / 0.5)); }
.slot-on { border-image-source: url("assets/ui/slot_selected.png"); }

.ornament { width: 240px; height: auto; margin: 0.65rem 0 1.1rem; opacity: 0.95; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 3rem;
  border-style: solid;
  border-color: transparent;
  border-width: 6px 16px 9px;
  border-image: url("assets/ui/button.png") 20 20 26 20 fill / 10px 10px 13px 10px;
  padding: 0.2rem 0.4rem;
  font: 800 1.05rem/1.1 var(--body);
  color: var(--parchment);
  text-decoration: none;
  text-shadow: 0 1px 0 rgb(18 11 7 / 0.8);
  cursor: pointer;
  background: none;
  transition: transform 0.12s cubic-bezier(0.2, 0.8, 0.2, 1), filter 0.2s;
}
.btn:hover { border-image-source: url("assets/ui/button_hover.png"); color: #fff; }
.btn:active { border-image-source: url("assets/ui/button_pressed.png"); border-width: 9px 16px 6px; color: var(--gold); }

.btn-primary { border-image-source: url("assets/ui/button_primary.png"); color: var(--ink); text-shadow: 0 1px 0 rgb(255 245 200 / 0.4); }
.btn-primary:hover { border-image-source: url("assets/ui/button_primary_hover.png"); color: var(--ink); filter: brightness(1.04); }
.btn-primary:active { border-image-source: url("assets/ui/button_primary_pressed.png"); color: var(--ink); }

/* ---------- cena 3D ---------- */

.scene { position: fixed; inset: 0; z-index: 0; }
.scene-fallback {
  position: absolute; inset: 0;
  background: #3d5a2e url("assets/hero.jpg") 70% 40% / cover no-repeat;
  transition: opacity 1.2s ease-out;
}
#scene {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0;
  transition: opacity 1.2s ease-out;
  touch-action: pan-y;
  cursor: grab;
}
#scene.ready { opacity: 1; }
.scene-ready .scene-fallback { opacity: 0; }
#scene.dragging { cursor: grabbing; }
/* vinheta suave nas bordas, como a do menu do jogo */
.scene::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(90deg, rgb(18 11 7 / 0.55), rgb(18 11 7 / 0) 38%),
    radial-gradient(ellipse at 60% 45%, transparent 55%, rgb(18 11 7 / 0.45));
}

/* o conteúdo passa por cima; só as janelas pegam o mouse, o resto deixa arrastar a cena */
.hero, main, .footer { position: relative; z-index: 1; pointer-events: none; }
.hero > *, .stop, .finale-window, .footer > * { pointer-events: auto; }

/* ---------- primeira tela: o menu ---------- */

.hero {
  min-height: 100svh;
  padding: clamp(1rem, 3vw, 2.5rem);
  display: grid;
  align-items: center;
}

.menu {
  width: min(27rem, 100%);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 1rem 1.25rem 1.35rem;
  container-type: inline-size; /* o título e a engrenagem medem pela largura do painel, não da tela */
}

.logo { display: flex; align-items: center; gap: 0.6rem; margin-left: -0.35rem; }
.logo-gear { width: clamp(2.5rem, 19cqi, 4.75rem); animation: turn 24s linear infinite; filter: drop-shadow(0 4px 3px rgb(0 0 0 / 0.5)); }
@keyframes turn { to { transform: rotate(360deg); } }

h1 {
  font-size: clamp(2rem, 20cqi, 4.6rem);
  letter-spacing: -0.01em;
  color: var(--gold);
  -webkit-text-stroke: 9px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 5px 0 rgb(0 0 0 / 0.5);
}

.tagline {
  font: 600 clamp(1.15rem, 1rem + 0.5vw, 1.45rem)/1.2 var(--display);
  color: var(--parchment);
  margin-top: 0.35rem;
}

.menu .ornament { margin: 0.7rem 0 0.9rem; }

.lead { color: var(--parchment); max-width: 36ch; }
.lead strong { color: var(--gold); font-weight: 800; }

.btn-download { margin-top: 1.35rem; min-height: 3.75rem; font-size: 1.2rem; }

.download-meta { margin-top: 0.5rem; text-align: center; font-size: 0.9rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.menu-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-top: 1.1rem; }

.update-plate {
  position: absolute;
  top: clamp(1rem, 3vw, 2.5rem);
  right: clamp(1rem, 3vw, 2.5rem);
  display: flex; align-items: center; gap: 0.6rem;
  max-width: 19rem;
}
.update-plate img { width: 2.5rem; animation: turn 12s linear infinite reverse; }
.update-plate p { display: grid; line-height: 1.25; }
.update-plate strong { font: 600 1.15rem var(--display); color: var(--gold); font-variant-numeric: tabular-nums; }
.update-plate span span, .update-plate p > span { font-size: 0.85rem; color: var(--muted); }

.drag-hint {
  position: absolute;
  right: clamp(1rem, 3vw, 2.5rem);
  bottom: clamp(1rem, 3vw, 2.5rem);
  display: flex; align-items: center; gap: 0.45rem;
  font-size: 0.85rem; color: var(--muted);
  opacity: 0; transition: opacity 0.6s;
}
.scene-ready .drag-hint { opacity: 0.9; }

/* barra que aparece depois da primeira tela */
.topbar {
  position: fixed; top: 0.75rem; left: 50%; z-index: 10;
  translate: -50% 0;
  display: flex; align-items: center; gap: 1.25rem;
  border: 10px solid transparent;
  border-image: url("assets/ui/plate.png") 28 fill / 14px;
  padding: 0.1rem 0.15rem 0.1rem 0.4rem;
  filter: drop-shadow(0 8px 14px rgb(0 0 0 / 0.45));
  transition: translate 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.35s;
}
.topbar[hidden] { display: flex; translate: -50% -140%; opacity: 0; pointer-events: none; }
.topbar-brand { display: flex; align-items: center; gap: 0.45rem; color: var(--gold); text-decoration: none; font: 600 1.35rem var(--display); }
.topbar-brand img { width: 2.1rem; }
.btn-small { min-height: 2.5rem; font-size: 0.95rem; }

/* ---------- janelas sobre a cena ---------- */

main { padding: 0 clamp(1rem, 3vw, 2.5rem); }

.stop { margin-block: 42vh; width: min(36rem, 100%); }
.stop, .finale { scroll-margin-top: 5.5rem; }
.stop-left { margin-right: auto; }
.stop-right { margin-left: auto; }
.stop-wide { width: min(70rem, 100%); margin-inline: auto; }
#jogo { margin-top: 18vh; }

.stop > h2, .finale-window h2 { margin-top: 0.15rem; }

.chain {
  list-style: none; margin: 0 0 1.4rem; padding: 0;
  display: flex; align-items: flex-start; gap: 0.35rem;
}
.chain li { display: grid; justify-items: center; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); }
.chain li + li { position: relative; padding-left: 1.75rem; }
.chain li + li::before {
  content: ""; position: absolute; left: 0.15rem; top: 1.55rem;
  width: 1.3rem; height: 0.9rem;
}

.features { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.1rem; }
.features li { display: flex; gap: 0.95rem; align-items: flex-start; }
.features .slot { width: 3.6rem; height: 3.6rem; }
.features h3 { margin-top: 0.15rem; }
.features p { color: var(--muted); margin-top: 0.2rem; max-width: 60ch; }

.fine { margin-top: 1.4rem; font-size: 0.9rem; color: var(--muted); border-top: 2px solid rgb(214 168 74 / 0.3); padding-top: 0.9rem; }

/* galeria */
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.gallery figure { margin: 0; display: grid; gap: 0.5rem; }
.gallery figcaption { text-align: center; font: 600 1.05rem var(--display); color: var(--gold); }
.shot {
  padding: 0; cursor: zoom-in; background: var(--ink);
  border: 4px solid transparent;
  border-image: url("assets/ui/slot.png") 28 fill / 14px;
  overflow: hidden;
}
.shot img { aspect-ratio: 4 / 3; object-fit: cover; width: 100%; border-radius: 6px; transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1); }
.shot:hover img { transform: scale(1.04); }
.shot:hover { border-image-source: url("assets/ui/slot_selected.png"); }

/* passos de instalação */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.35rem; counter-reset: none; }
.steps li { display: flex; gap: 1rem; align-items: flex-start; position: relative; }
.steps li:not(:last-child)::after {
  content: ""; position: absolute; left: 1.55rem; top: 3.4rem; bottom: -1.2rem;
  translate: -50% 0;
  border-left: 4px dotted var(--brass);
  opacity: 0.6;
}
.step-n {
  flex: none; display: grid; place-items: center;
  width: 3.1rem; height: 3.1rem;
  border: 4px solid transparent;
  border-image: url("assets/ui/slot_selected.png") 28 fill / 14px;
  font: 700 1.5rem var(--display); color: var(--gold);
}
.steps h3 { margin-top: 0.4rem; }
.steps p { color: var(--muted); margin-top: 0.3rem; }
.steps em { color: var(--parchment); font-style: normal; }
.steps strong { color: var(--parchment); font-weight: 800; }
/* miniatura do aviso do SmartScreen: só ilustração, os nomes dos botões estão no texto acima */
.smartscreen { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.75rem; }
.ss-box {
  flex: 1; display: grid; gap: 0.55rem; align-content: start;
  padding: 0.6rem 0.7rem 0.7rem;
  background: #1f5fa8; color: #fff;
  border: 3px solid var(--ink); border-radius: 4px;
  box-shadow: 0 6px 12px rgb(0 0 0 / 0.35);
  font: 600 0.72rem/1.25 "Segoe UI", system-ui, sans-serif;
}
.ss-title { font-size: 0.82rem; font-weight: 700; }
.ss-link { text-decoration: underline; text-underline-offset: 0.2em; }
.ss-btn { justify-self: end; background: #e9e6df; color: #1d1d1d; padding: 0.2rem 0.55rem; border-radius: 2px; font-weight: 700; outline: 2px solid #fff; outline-offset: 1px; }
.ss-arrow, .chain li + li::before {
  background: var(--gold);
  clip-path: polygon(0 35%, 55% 35%, 55% 0, 100% 50%, 55% 100%, 55% 65%, 0 65%);
  filter: drop-shadow(0 2px 0 var(--ink));
}
.ss-arrow { flex: none; width: 1.3rem; height: 0.9rem; }

/* novidades */
.changelog { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.log-entry {
  border: 10px solid transparent;
  border-image: url("assets/ui/section.png") 20 fill / 10px;
  padding: 0.35rem 0.5rem 0.45rem;
}
.log-entry h3 { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.25rem 1rem; font-size: 1.15rem; color: var(--gold); }
.log-entry time { font: 700 0.85rem var(--body); color: var(--muted); }
.log-entry p { color: var(--parchment); margin-top: 0.3rem; max-width: 62ch; }

/* fecho: noite, lampiões acesos, foguete pronto */
.finale { min-height: 100svh; display: grid; place-items: center; padding-block: 20vh 8vh; }
.finale-window { width: min(34rem, 100%); text-align: center; display: grid; justify-items: center; gap: 0.9rem; padding: 1.4rem 1.5rem 1.6rem; }
.finale-window h2 { font-size: clamp(1.9rem, 1.4rem + 1.8vw, 2.8rem); }
.finale-window > p:not(.download-meta) { color: var(--muted); max-width: 36ch; }
.finale-window .btn-download { margin-top: 0.4rem; min-width: 18rem; }
.finale-window .download-meta { margin-top: -0.35rem; }

.footer { display: grid; place-items: center; padding: 0 1rem 2rem; }
.footer .plate { font-size: 0.85rem; color: var(--muted); text-align: center; }

/* imagem ampliada */
#lightbox {
  max-width: min(92vw, 1200px);
  padding: 0.4rem;
  background: none;
  color: inherit;
  overflow: visible;
}
#lightbox::backdrop { background: rgb(18 11 7 / 0.82); }
#lightbox img { border-radius: 6px; max-height: 82vh; width: auto; margin-inline: auto; }
.lightbox-close { position: absolute; top: -1.75rem; right: -1.75rem; min-height: 2.75rem; }

/* ---------- telas menores ---------- */

@media (max-width: 64rem) {
  .gallery { grid-template-columns: 1fr 1fr; }
  .gallery figure:last-child { grid-column: 1 / -1; }
}

@media (max-width: 47.5rem) {
  .scene::after { background: linear-gradient(rgb(18 11 7 / 0) 50%, rgb(18 11 7 / 0.3)); }
  .hero { align-items: end; padding-top: 42svh; }
  .menu { width: 100%; }
  /* no celular a placa de versão vai para baixo do menu (no alto ela cobriria o foguete) */
  .update-plate { position: static; justify-self: center; margin-top: 0.75rem; max-width: 100%; }
  .smartscreen { flex-direction: column; align-items: stretch; }
  .ss-arrow { align-self: center; rotate: 90deg; }
  .drag-hint { display: none; }
  .stop { margin-block: 30vh; }
  #jogo { margin-top: 30vh; }
  .gallery { grid-template-columns: 1fr; }
  .chain { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4rem; }
  .chain li { font-size: 0.72rem; }
  .chain li + li { padding-left: 0; }
  .chain li + li::before { width: 0.8rem; height: 0.7rem; left: -0.6rem; top: 1.15rem; }
  .chain .slot { width: 3rem; height: 3rem; }
  .features .slot { width: 3rem; height: 3rem; }
  .features li { gap: 0.75rem; }
  .lightbox-close { top: -1.25rem; right: -0.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .logo-gear, .update-plate img { animation: none; }
  .btn, .shot img, .topbar, #scene, .scene-fallback { transition: none; }
}
