/* The site's shared look, matching the game (docs/art-direction.md): a dusk
   sky with the sun and mesas over dark saddle leather, parchment cards,
   brass edges and the game's orange for the main button. Colours are the
   game's UI_* palette (game.gd). Every text colour is at least 4.5:1 on
   the surface it sits on; text drawn on the sky gets the dark outline. */

/* Fredoka (SIL Open Font License), cut from game/assets/fonts to Latin
   and weights 400-700 so it stays small. Served from this site, so no
   request leaves it. */
@font-face {
  font-family: "Fredoka";
  src: url("fonts/fredoka.woff") format("woff");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --sky: linear-gradient(180deg, #2a1c30 0%, #4b2733 30%, #7a3b3a 55%, #e08a4c 88%);
  --sun: #ffd27a;
  --mesa: #5c2f25;
  --bg: #1f150e;
  --leather: #4a301c;
  --leather-2: #382314;
  --brass: #c9963f;
  --edge: #8a6a3e;
  --text: #f6ead0;
  --text-2: #ecd9b4;
  --text-3: #dcc49c;
  --gold: #ffc247;
  --ink: #1a0d08;
  --ink-2: #3d2410;
  --ink-3: #5e3f22;
  --parch: #fbf1da;
  --parch-2: #ecd9b4;
  --heading: #7a3b3a;
  --link-ink: #8a2c10;
  --primary: #ff5c39;
  --primary-2: #ff8a6b;
  --outline: #14121a;
  --ok: #86efac;
  --err: #fca5a5;
  --danger: #b3261e;
  --well: #241810;
  --fill-primary: linear-gradient(var(--primary-2), var(--primary));
  --fill-leather: linear-gradient(var(--leather) 50%, var(--leather-2) 50%);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; background: var(--bg); color-scheme: dark; }
body {
  min-height: 100%;
  background: radial-gradient(900px 500px at 50% 0%, #3a2616 0%, var(--bg) 70%) no-repeat, var(--bg);
  color: var(--text);
  font-family: "Fredoka", ui-rounded, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}
a { color: var(--gold); }
a:hover { filter: brightness(1.1); }
a, button, input, textarea, label { touch-action: manipulation; }
a, button { -webkit-tap-highlight-color: rgba(255, 194, 71, 0.25); }
h1, h2, [id] { scroll-margin-top: 1rem; }
/* Focus rings (web interface review item 1): gold on the dark page, the dark outline colour on parchment,
   and both at once on the sky, whose bottom stop is orange. */
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.card :focus-visible { outline-color: var(--outline); outline-offset: 2px; }
.sky .btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 5px; box-shadow: 0 5px 0 var(--outline), 0 0 0 5px var(--outline); }
.sky .btn-leather:focus-visible { box-shadow: inset 0 0 0 2px var(--brass), 0 5px 0 var(--outline), 0 0 0 5px var(--outline); }
.sky .btn:focus-visible:active { box-shadow: 0 2px 0 var(--outline), 0 0 0 5px var(--outline); }
.sky .btn-leather:focus-visible:active { box-shadow: inset 0 0 0 2px var(--brass), 0 2px 0 var(--outline), 0 0 0 5px var(--outline); }
/* "Skip to content" (item 4): off-screen until it has keyboard focus. */
.skip { position: absolute; left: 1rem; top: -100px; z-index: 10; padding: 0.6rem 1rem; border-radius: 10px; background: var(--parch); color: var(--ink); border: 3px solid var(--outline); font-weight: 600; text-decoration: none; }
.skip:focus { top: calc(1rem + env(safe-area-inset-top, 0px)); outline-color: var(--gold); }
img { max-width: 100%; }

/* ---------- sky header ---------- */
.sky {
  position: relative;
  overflow: hidden;
  background: var(--sky);
  padding: calc(1.75rem + env(safe-area-inset-top, 0px)) calc(clamp(1rem, 4vw, 3.5rem) + env(safe-area-inset-right, 0px)) 0 calc(clamp(1rem, 4vw, 3.5rem) + env(safe-area-inset-left, 0px));
}
/* the sun sits on the horizon behind the mesas, as on the game's level menu */
.sky::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(var(--mesa-h) * 0.38 - var(--sun-size) * 0.32);
  width: var(--sun-size);
  height: var(--sun-size);
  transform: translateX(-50%);
  border-radius: 50%;
  background: var(--sun);
  box-shadow: 0 0 0 calc(var(--sun-size) / 7) rgba(255, 210, 122, 0.22),
              0 0 0 calc(var(--sun-size) / 3.5) rgba(255, 210, 122, 0.10);
}
.sky::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--mesa-h);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1400 190' preserveAspectRatio='none'%3E%3Cpath vector-effect='non-scaling-stroke' fill='%235c2f25' stroke='%2314121a' stroke-width='4' stroke-linejoin='round' d='M0 190 L0 118 L84 118 L126 57 L294 57 L336 118 L728 118 L770 34 L980 34 L1029 118 L1204 118 L1232 76 L1330 76 L1358 118 L1400 118 L1400 190 Z'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}
.sky > .inner { position: relative; z-index: 1; }
.on-sky { color: var(--text); text-shadow: 2px 2px 0 var(--outline), -2px 2px 0 var(--outline), 2px -2px 0 var(--outline), -2px -2px 0 var(--outline), 0 4px 0 var(--outline); }
.on-sky-thin { color: var(--text); text-shadow: 1px 1px 0 var(--outline), -1px 1px 0 var(--outline), 1px -1px 0 var(--outline), -1px -1px 0 var(--outline), 0 3px 0 var(--outline); }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.links { display: flex; gap: 0 0.65rem; flex-wrap: wrap; justify-content: center; align-items: center; font-size: 1.1rem; }
.links a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 0.25rem; text-decoration: none; }
.links .dot { color: var(--text-3); }
.sky .links a { color: var(--text); }
.sky .links a:hover { text-decoration: underline; }

.badge {
  display: inline-block;
  padding: 0.3rem 1rem;
  border-radius: 999px;
  background: var(--leather-2);
  border: 2px solid var(--brass);
  color: var(--gold);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.pill {
  display: inline-block;
  padding: 0.35rem 0.85rem;
  border-radius: 10px;
  background: var(--well);
  border: 2px solid var(--edge);
  color: var(--text-2);
  font-size: 0.95rem;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.9rem 1.7rem;
  border-radius: 14px;
  border: 3px solid var(--outline);
  box-shadow: 0 5px 0 var(--outline);
  font: inherit;
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover, .panel button:not(:disabled):hover { filter: brightness(0.92); }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--outline); }
.btn-primary, .panel button { background: var(--fill-primary); color: var(--ink); }
.btn-leather, .panel button.secondary { background: var(--fill-leather); color: var(--text); font-weight: 500; }
.btn-leather {
  font-size: 1.15rem;
  box-shadow: inset 0 0 0 2px var(--brass), 0 5px 0 var(--outline);
}
.btn-leather:active { box-shadow: inset 0 0 0 2px var(--brass), 0 2px 0 var(--outline); }
.btn svg { flex-shrink: 0; }
/* A store button: plain text while the store is "coming", a link once it's live. */
.btn-store { background: var(--well); color: var(--text-2); font-size: 1.05rem; padding: 0.7rem 1.2rem; box-shadow: none; cursor: default; }
a.btn-store { background: var(--fill-leather); color: var(--text); box-shadow: 0 5px 0 var(--outline); cursor: pointer; }
span.btn-store:active { transform: none; }
span.btn-store:hover { filter: none; }   /* not clickable, so no hover change */

/* ---------- parchment cards ---------- */
.card {
  background: linear-gradient(var(--parch), var(--parch-2));
  color: var(--ink-2);
  border: 4px solid var(--outline);
  border-radius: 16px;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.45);
  padding: 1.5rem clamp(1.1rem, 3vw, 2.5rem);
}
.card h2 {
  color: var(--heading);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 0.9rem;
}
.card a { color: var(--link-ink); font-weight: 500; }
.card a:hover { filter: none; color: var(--ink); text-decoration-thickness: 2px; }
.card .note { color: var(--ink-3); }
.card code { background: rgba(61, 36, 16, 0.08); border-radius: 4px; padding: 0.05em 0.3em; }

/* ---------- secondary pages ---------- */
.page-head { --mesa-h: 70px; --sun-size: 150px; padding-bottom: calc(var(--mesa-h) + 12px); }
.page-head .home { display: inline-flex; align-items: center; gap: 0.6rem; text-decoration: none; }
.page-head .home img:first-child { width: 64px; height: 64px; }
.page-head .home img:last-child { width: 200px; height: auto; }
.wrap { max-width: 760px; margin: 0 auto; padding: 2rem calc(1rem + env(safe-area-inset-right, 0px)) calc(3.5rem + env(safe-area-inset-bottom, 0px)) calc(1rem + env(safe-area-inset-left, 0px)); }
.wrap.narrow { max-width: 520px; }
.wrap > h1 { font-size: clamp(1.8rem, 5vw, 2.4rem); font-weight: 700; line-height: 1.15; margin-bottom: 0.4rem; color: var(--text); }
.wrap > h1 .amp { color: var(--gold); }
.wrap > .sub { color: var(--text-3); margin-bottom: 1.75rem; }
.foot { margin-top: 2.75rem; }
.foot a { color: var(--text-2); }
.foot .dot { color: var(--edge); }

/* ---------- home page ---------- */
.hero { --mesa-h: 190px; --sun-size: 340px; padding-bottom: calc(var(--mesa-h) + 24px); }
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 680px) minmax(0, 560px);
  grid-template-rows: 1fr auto auto 1fr;
  grid-template-areas: "pic ." "pic brand" "pic copy" "pic .";
  column-gap: 48px;
  row-gap: 20px;
  justify-content: center;
  max-width: 1288px;
  margin: 0 auto;
  padding-top: 2.75rem;
}
.brand { grid-area: brand; display: flex; align-items: center; gap: 16px; }
.brand .emblem { width: 132px; height: 132px; flex-shrink: 0; }
.brand .wordmark { width: 412px; height: auto; min-width: 0; }
.frame {
  grid-area: pic;
  align-self: center;
  padding: 12px;
  border-radius: 18px;
  background: var(--fill-leather);
  border: 4px solid var(--outline);
  box-shadow: inset 0 0 0 3px var(--brass), 0 10px 0 rgba(20, 18, 26, 0.55);
}
.frame img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 10px; border: 3px solid var(--outline); }
.copy { grid-area: copy; display: flex; flex-direction: column; gap: 20px; align-items: flex-start; }
.tagline { font-size: 1.65rem; font-weight: 600; line-height: 1.25; }
.lead { font-size: 1.25rem; line-height: 1.5; }
.actions { display: flex; flex-direction: column; gap: 16px; align-items: flex-start; padding-top: 8px; }
.actions-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.steam-line { font-size: 1.05rem; margin-top: -6px; }
.below { display: flex; flex-direction: column; align-items: center; padding: 4rem calc(1rem + env(safe-area-inset-right, 0px)) calc(3.5rem + env(safe-area-inset-bottom, 0px)) calc(1rem + env(safe-area-inset-left, 0px)); }
.below .card { width: 100%; max-width: 900px; padding: 2.25rem clamp(1.1rem, 4vw, 3rem); }
.steps { list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: 16px; font-size: 1.25rem; line-height: 1.45; }
.steps li { counter-increment: step; display: flex; gap: 14px; align-items: flex-start; }
.steps li::before {
  content: counter(step);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin-top: -2px;
  border-radius: 50%;
  background: linear-gradient(#ffe07a, #f0a21e);
  border: 3px solid var(--outline);
  color: var(--ink-2);
  font-size: 1.05rem;
  font-weight: 700;
}

@media (max-width: 960px) {
  .hero { --mesa-h: 110px; --sun-size: 200px; }
  .hero-grid {
    grid-template-columns: minmax(0, 560px);
    grid-template-rows: none;
    grid-template-areas: "brand" "pic" "copy";
    row-gap: 18px;
    padding-top: 1.25rem;
  }
  .hero .topbar .links { display: none; }  /* on a phone the site links sit at the bottom only */
  .brand .emblem { width: 120px; height: 120px; }
  .brand .wordmark { width: 380px; }
  .frame { padding: 8px; border-radius: 14px; }
  .frame img { border-radius: 7px; }
  .tagline { font-size: 1.35rem; }
  .lead { font-size: 1.1rem; }
  .actions, .actions .btn-primary { width: 100%; }
  .below { padding-top: 2.25rem; }
  .below .card { padding: 1.5rem 1.25rem; }
  .steps { font-size: 1.08rem; gap: 14px; }
}

/* ---------- privacy and terms ---------- */
.doc section { margin-bottom: 1.1rem; }
.doc section h2 { font-size: 1.1rem; letter-spacing: 0.04em; text-transform: none; margin-bottom: 0.5rem; }
.doc p { margin-bottom: 0.7rem; font-size: 1.05rem; line-height: 1.6; }
.doc p:last-child { margin-bottom: 0; }
.doc ul { margin: 0.4rem 0 0.7rem 1.3rem; font-size: 1.05rem; line-height: 1.55; }
.doc li { margin-bottom: 0.35rem; }
.doc code { font-size: 0.9em; }
.doc .note { font-size: 0.98rem; }

/* ---------- changelog ---------- */
.changelog #status { color: var(--text-3); font-size: 1.05rem; }
.entry { margin-bottom: 1rem; padding: 1.1rem 1.4rem; overflow-wrap: anywhere; }
.entry-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; }
.entry-version { font-weight: 700; color: var(--heading); font-size: 1.2rem; }
.entry-date { color: var(--ink-3); font-size: 0.95rem; white-space: nowrap; }
.entry-text { margin-top: 0.3rem; font-size: 1.08rem; }
.earlier { color: var(--text-3); margin-top: 1.5rem; }

/* ---------- account ---------- */
.panel { margin-bottom: 1.25rem; }
.panel h2 { font-size: 1rem; letter-spacing: 0.14em; }
.panel .sub { color: var(--ink-3); font-size: 1rem; margin-bottom: 0.5rem; overflow-wrap: anywhere; }
.panel label { display: block; font-size: 1rem; font-weight: 500; color: var(--ink-2); margin: 0.9rem 0 0.3rem; }
.panel label span { color: var(--ink-3); font-weight: 400; }
.panel input, .panel textarea {
  width: 100%;
  background: #fffaf0;
  border: 2px solid var(--edge);
  border-radius: 10px;
  color: var(--ink);
  padding: 0.6rem 0.75rem;
  font: inherit;
}
.panel textarea { min-height: 140px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85rem; }
.panel input:focus-visible, .panel textarea:focus-visible { outline: 3px solid var(--link-ink); outline-offset: 1px; }
/* Light controls on a dark page: the page's color-scheme is dark, these fields are parchment, so Chrome's
   autofill text stays dark on them. */
.panel input, .panel textarea { color-scheme: light; }
.panel input[aria-invalid="true"] { border-color: var(--danger); }
/* Always in the page (a live region must exist before its text changes); no height while empty. */
.panel .field-error { color: var(--danger); font-size: 0.95rem; margin-top: 0.3rem; }
.panel .field-error:empty { margin-top: 0; }
.panel .row { display: flex; gap: 0.7rem; flex-wrap: wrap; margin-top: 1.1rem; }
.panel button {
  flex: 1;
  min-width: 120px;
  border: 3px solid var(--outline);
  border-radius: 12px;
  box-shadow: 0 4px 0 var(--outline);
  padding: 0.6rem 0.9rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.panel button.secondary { box-shadow: inset 0 0 0 2px var(--brass), 0 4px 0 var(--outline); }
.panel button:active { transform: translateY(2px); }
.panel button:disabled { opacity: 0.5; cursor: not-allowed; }
.panel button[aria-busy="true"] { opacity: 0.85; }
.panel button[aria-busy="true"]::after { content: ""; display: inline-block; width: 0.8em; height: 0.8em; margin-left: 0.5em; vertical-align: -0.1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .panel button[aria-busy="true"]::after { animation: none; border-right-color: currentColor; opacity: 0.5; } }
.panel.danger { border-color: var(--danger); }
.panel.danger h2 { color: var(--danger); }
.panel.danger button { background: var(--danger); color: #ffffff; }
.panel .who { color: var(--ink-3); margin-bottom: 0.5rem; overflow-wrap: anywhere; }
.panel .who strong { color: var(--ink); }
.account #status {
  font-size: 1rem;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 2px solid var(--edge);
  background: var(--well);
  color: var(--text-2);
  margin-bottom: 1.25rem;
  word-break: break-word;
}
.account #status.ok { color: var(--ok); border-color: #3f7a4f; }
.account #status.err { color: var(--err); border-color: #8a3a3a; }
.hidden { display: none !important; }

@media (max-width: 560px) {
  .page-head { --mesa-h: 56px; --sun-size: 110px; }
  .page-head .links { font-size: 1rem; gap: 0 0.6rem; }
  .links .dot { display: none; }  /* a wrapped row would leave a dot hanging at a line end */
  .page-head .home img:first-child { width: 52px; height: 52px; }
  .page-head .home img:last-child { width: 160px; }
  .brand .emblem { width: 92px; height: 92px; }
  .brand .wordmark { width: 256px; }
  .btn { font-size: 1.15rem; padding: 0.85rem 1.2rem; }
}
