/*
 * SPDX-FileCopyrightText: 2026 The Atalaia contributors
 * SPDX-License-Identifier: CC-BY-SA-4.0
 *
 * Palette taken from the Atalaia badge: slate tower, sand hills, signal fire.
 * Fonts: Barlow and Barlow Condensed (SIL OFL 1.1), self-hosted in ./fonts.
 */

@font-face { font-family: "Barlow"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/barlow-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-style: italic; font-weight: 400; font-display: swap; src: url("fonts/barlow-latin-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/barlow-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/barlow-condensed-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/barlow-condensed-latin-700-normal.woff2") format("woff2"); }

:root {
  color-scheme: light dark;

  /* brand constants, the same in both themes */
  --slate: #262d34;
  --granite: #4a535c;
  --sand: #e3c48d;
  --sand-deep: #c9a25c;
  --signal: #f07a1a;
  --on-slate: #eef0ee;
  --on-slate-muted: #b3bbc2;

  /* page tokens, light */
  --bg: #f7f8f6;
  --band: #ebeeea;
  --surface: #ffffff;
  --text: #1f262c;
  --muted: #56606a;
  --line: #d3d8db;
  --rule: var(--sand-deep);
  --open: #2f7d4a;
  --code-bg: var(--slate);
  --code-text: #e7eae6;

  --radius: 4px;
  --body: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d2328;
    --band: #232a30;
    --surface: #29313a;
    --text: #e9ece8;
    --muted: #a7b0b8;
    --line: #3a444e;
    --rule: var(--sand);
    --open: #6fcf8f;
    --code-bg: #151a1f;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 var(--body);
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--signal);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
a:hover { color: var(--signal); }
a:focus-visible, .button:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

.skip {
  position: absolute;
  left: -999px;
  top: 8px;
  background: var(--surface);
  padding: 6px 10px;
  border-radius: var(--radius);
  z-index: 10;
}
.skip:focus { left: 8px; }

h1, h2, h3 { margin: 0; font-family: var(--display); font-weight: 700; line-height: 1.05; }
h1 { font-size: clamp(2.8rem, 7.5vw, 5rem); max-width: 14ch; }
h2 { font-size: clamp(2rem, 4vw, 2.6rem); }
h3 { font-size: 1.4rem; font-weight: 600; line-height: 1.15; }

section { padding: 64px 0; }
section .intro { color: var(--muted); max-width: 66ch; margin: 12px 0 32px; font-size: 1.05rem; }
.band { background: var(--band); }

code { font-family: var(--mono); font-size: 0.88em; }
.nowrap { white-space: nowrap; }

/* ---- header: always slate, like the tower ---- */

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--slate);
  color: var(--on-slate);
}
@media (max-width: 640px) { .top { position: static; } }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 58px; flex-wrap: wrap; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--on-slate);
  font: 700 1.5rem/1 var(--display);
  text-decoration: none;
}
.mark { width: 26px; height: 26px; fill: var(--on-slate); }
.mark .fire { fill: var(--signal); }
.mark .ring { fill: none; stroke: var(--signal); stroke-width: 2; stroke-linecap: round; }
nav { display: flex; flex-wrap: wrap; gap: 4px 22px; font-size: 0.98rem; }
nav a { color: var(--on-slate-muted); text-decoration: none; }
nav a:hover { color: var(--on-slate); }
.sections { margin-left: auto; }
/* The link of the page being read. */
.sections a[aria-current="page"] {
  color: var(--on-slate);
  text-decoration: underline;
  text-decoration-color: var(--signal);
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
}

/* Language switcher: PT · EN, the current language lit like a beacon. */
.lang { align-items: center; gap: 2px; font-size: 0.85rem; font-weight: 600; letter-spacing: 0.05em; }
.lang a { padding: 2px 7px; border-radius: var(--radius); }
.lang a[aria-current] { color: var(--slate); background: var(--signal); }
.lang .sep { color: var(--on-slate-muted); }
@media (max-width: 640px) {
  /* Brand and switcher share the first row; the section links wrap below. */
  .lang { order: 2; margin-left: auto; }
  .sections { order: 3; flex-basis: 100%; margin-left: 0; padding-bottom: 10px; }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---- hero: the hill and the watchtower ---- */

.hero {
  padding: 72px 0 clamp(150px, 18vw, 210px);
  color: var(--on-slate);
  background-color: var(--slate);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 52 80'%3E%3Cpath fill='%234a535c' d='M8 24V12h7v5h7.5v-5h7v5H37v-5h7v12zM10 24h32l4 56H6z'/%3E%3Cpath fill='%23f07a1a' d='M26 0c3 4 6 6 4 10-1 2-3 2-4 1-1 1-3 1-4-1-2-4 1-6 4-10z'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 140' preserveAspectRatio='none'%3E%3Cpath fill='%23c9a25c' d='M0 140V80C180 42 360 42 520 70c120 22 200-20 340-32 160-12 320 22 580 34v68z'/%3E%3Cpath fill='%23e3c48d' d='M0 140v-32c220-28 420-22 620-4s380-16 580-20c120-2 200 8 240 12v44z'/%3E%3C/svg%3E");
  background-repeat: no-repeat, no-repeat;
  background-size: 62px 95px, 100% 140px;
  background-position: right max(20px, calc(50% - 400px)) bottom 80px, center bottom;
}
.hero a { color: var(--on-slate); }
.hero .status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 22px;
  padding: 4px 12px 4px 10px;
  border-left: 3px solid var(--signal);
  background: rgba(255, 255, 255, 0.06);
  color: var(--sand);
  font-size: 0.92rem;
}
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--signal); box-shadow: 0 0 0 4px rgba(240, 122, 26, 0.25); }
.lead { font-size: 1.2rem; max-width: 60ch; margin: 22px 0 30px; color: var(--on-slate); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.button {
  display: inline-block;
  padding: 10px 20px;
  border-radius: var(--radius);
  border: 1.5px solid currentColor;
  color: inherit;
  font-weight: 600;
  text-decoration: none;
}
.hero .button { color: var(--on-slate); border-color: rgba(238, 240, 238, 0.45); }
.hero .button:hover { border-color: var(--on-slate); color: var(--on-slate); }
.hero .button.primary { background: var(--signal); border-color: var(--signal); color: var(--slate); }
.hero .button.primary:hover { filter: brightness(1.08); color: var(--slate); }
.name { color: var(--on-slate-muted); font-size: 0.98rem; margin: 30px 0 0; max-width: 62ch; }

/* ---- the head of a subpage: the hero's slate and hills, shorter ---- */

.page-head {
  padding: 56px 0 104px;
  color: var(--on-slate);
  background-color: var(--slate);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 140' preserveAspectRatio='none'%3E%3Cpath fill='%23c9a25c' d='M0 140V80C180 42 360 42 520 70c120 22 200-20 340-32 160-12 320 22 580 34v68z'/%3E%3Cpath fill='%23e3c48d' d='M0 140v-32c220-28 420-22 620-4s380-16 580-20c120-2 200 8 240 12v44z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 100% 72px;
  background-position: center bottom;
}
.page-head h1 { font-size: clamp(2.4rem, 6vw, 3.8rem); max-width: none; }
.page-head .lead { margin-bottom: 0; }
.page-head a { color: var(--on-slate); }
.page-head a:hover { color: var(--sand); }

/* The body of a subpage. Its headings are second-level, drawn like the main page's third-level ones. */
.content { padding: 56px 0 72px; }
.content h2 { font-size: 1.4rem; font-weight: 600; line-height: 1.15; }
/* A jump from a link lands below the sticky header. */
.content [id] { scroll-margin-top: 84px; }
@media (max-width: 640px) { .content [id] { scroll-margin-top: 12px; } }

/* A link onward from a short section of the main page to its page. */
.more { margin: 28px 0 0; font-weight: 600; }

/* ---- illustrations ---- */

.hero-art img, .art img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
}
.hero-art { display: block; margin: 44px 0 0; }
.hero-art img { border: 1px solid rgba(238, 240, 238, 0.14); box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35); }
.art { max-width: 760px; margin: 40px auto 0; }
.art img { border: 1px solid var(--line); background: var(--band); }
.art figcaption { margin-top: 10px; color: var(--muted); font-size: 0.92rem; text-align: center; }
.badge { float: right; width: 136px; height: auto; margin: 0 0 12px 24px; }
@media (max-width: 640px) { .badge { width: 104px; margin-left: 14px; } }

/* ---- features: ruled columns, not boxes ---- */

.features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 32px 36px;
}
.features li { border-top: 3px solid var(--rule); padding-top: 14px; }
.features p { margin: 8px 0 0; color: var(--muted); }

/* "How a game works": the same ruled columns, numbered like beacons along a line. */
.walk { counter-reset: step; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.walk li { counter-increment: step; }
.walk h3::before {
  content: counter(step);
  margin-right: 10px;
  color: var(--signal);
}

/* ---- game mode cards ---- */

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 4px solid var(--slate);
  border-radius: var(--radius);
  padding: 22px;
}
@media (prefers-color-scheme: dark) { .card { border-top-color: var(--sand); } }
.card p { margin: 8px 0 0; color: var(--muted); }
.card .meta { font-size: 0.92rem; color: var(--text); font-weight: 600; }
.card.dashed { border: 1.5px dashed var(--line); background: transparent; }

/* ---- diagram ---- */

.diagram { margin: 0; }
.diagram svg { width: 100%; height: auto; display: block; }
.diagram .links line { stroke: var(--muted); stroke-width: 1.5; }
.diagram .box rect { fill: var(--surface); stroke: var(--line); stroke-width: 1.5; rx: 3; }
.diagram .box.main rect { fill: var(--slate); stroke: var(--slate); }
.diagram .box.main text { fill: var(--on-slate); }
.diagram .box.main text.sub { fill: var(--sand); }
.diagram .box.optional rect { stroke-dasharray: 6 4; }
.diagram text { fill: var(--text); font: 600 14px var(--body); text-anchor: middle; }
.diagram text.sub { fill: var(--muted); font-weight: 400; font-size: 12px; }
.diagram text.label { fill: var(--muted); font-weight: 400; font-size: 12px; text-anchor: start; }
.diagram text.label.accent { fill: var(--signal); font-weight: 600; }
@media (prefers-color-scheme: dark) { .diagram .box.main rect { fill: var(--sand); stroke: var(--sand); } .diagram .box.main text, .diagram .box.main text.sub { fill: var(--slate); } }
.note { color: var(--muted); max-width: 66ch; margin: 28px 0 0; }
.diagram-list { display: none; margin: 0; padding-left: 20px; }
.diagram-list li { margin-bottom: 8px; }
@media (max-width: 640px) {
  .diagram svg { display: none; }
  .diagram-list { display: block; }
}

/* ---- radio diagrams: SVG images with their own light card, so they read in both themes ---- */

.radio-diagram { margin: 0 0 48px; }
.radio-diagram:last-child { margin-bottom: 0; }
.radio-diagram p { color: var(--muted); max-width: 66ch; margin: 8px 0 20px; }
/* Shown at their own size (848 or 420 units wide) or smaller, never stretched. */
.radio-diagram img { display: block; max-width: 100%; height: auto; }

/* ---- try it ---- */

.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin-bottom: 20px; }
.steps h3 { margin-bottom: 10px; }
pre {
  margin: 0;
  padding: 16px 18px;
  border-radius: var(--radius);
  border-left: 3px solid var(--signal);
  background: var(--code-bg);
  color: var(--code-text);
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.55;
}

/* ---- roadmap: a chain of beacons, the current one lit ---- */

.phases { list-style: none; padding: 0; margin: 0; max-width: 720px; }
.phases li { position: relative; padding: 0 0 30px 48px; }
.phases li::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 26px;
  bottom: 2px;
  border-left: 2px dotted var(--muted);
}
.phases li:last-child { padding-bottom: 0; }
.phases li:last-child::before { display: none; }
.phases li::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  background: var(--band);
}
.phases li.now::after {
  border-color: var(--signal);
  background: var(--signal);
  box-shadow: 0 0 0 6px rgba(240, 122, 26, 0.22), 0 0 18px 4px rgba(240, 122, 26, 0.35);
}
.phases p { margin: 6px 0 0; color: var(--muted); }
.phases .gate { font-size: 0.95rem; color: var(--text); }
.tag {
  display: inline-block;
  margin-bottom: 4px;
  padding: 1px 8px;
  border-radius: var(--radius);
  background: var(--slate);
  color: var(--on-slate);
  font-size: 0.8rem;
  font-weight: 600;
}
.phases li.now .tag { background: var(--signal); color: var(--slate); }
@media (prefers-color-scheme: dark) { .tag { background: var(--line); } }

/* The main page's short roadmap: one line per phase, under a sand rule; the current one lit. */
.strip {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 28px 36px;
}
.strip li { border-top: 3px solid var(--rule); padding-top: 12px; }
.strip li.now { border-top-color: var(--signal); }
.strip h3 { font-size: 1.25rem; }
.strip p { margin: 6px 0 0; color: var(--muted); }
.strip li.now .tag { background: var(--signal); color: var(--slate); }

/* ---- community hub: a ruled list ---- */

.hub { list-style: none; padding: 0; margin: 0; border-bottom: 1px solid var(--line); }
.hub li {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 18px;
  align-items: start;
  padding: 18px 0;
  border-top: 1px solid var(--line);
}
.hub h3 { font-size: 1.3rem; }
.hub p { margin: 4px 0 0; color: var(--muted); }
.chip {
  justify-self: start;
  margin-top: 3px;
  padding: 1px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
}
.chip.open { color: var(--open); border-color: currentColor; font-weight: 600; }
@media (max-width: 520px) { .hub li { grid-template-columns: 1fr; gap: 8px; } }

/* ---- glossary: groups under a sand rule, terms in two columns ---- */

.glossary .group {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 12px 36px;
  margin-top: 36px;
  padding-top: 14px;
  border-top: 3px solid var(--rule);
}
.glossary .group:first-child { margin-top: 0; }
.glossary .group h2 { font-size: 1rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding-top: 4px; }
.glossary dl {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 22px 36px;
  margin: 0;
}
.glossary dt { font: 600 1.25rem/1.15 var(--display); }
.glossary dd { margin: 4px 0 0; color: var(--muted); }
/* A jump from a link lands below the sticky header and marks the entry. */
.glossary [id] { scroll-margin-top: 84px; border-radius: var(--radius); }
.glossary [id]:target {
  margin: -8px -12px;
  padding: 8px 12px 8px 9px;
  border-left: 3px solid var(--signal);
  background: var(--surface);
}
@media (max-width: 720px) {
  .glossary .group { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .glossary [id] { scroll-margin-top: 12px; }
}

.ways { padding-left: 20px; }
.ways li { margin-bottom: 6px; }
.ways li::marker { color: var(--signal); }

.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 48px; }
.two p { color: var(--muted); }

/* ---- footer ---- */

.foot { background: var(--slate); color: var(--on-slate-muted); padding: 32px 0 44px; font-size: 0.92rem; }
.foot a { color: var(--on-slate); }
.foot-inner p { margin: 0 0 8px; max-width: 80ch; }

/* Firmware screenshots captured in the emulator */
.screens { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-top: 8px; }
.screens figure { margin: 0; }
.screens img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 4px; }
.screens figcaption { margin-top: 8px; font-size: 0.88rem; color: var(--muted); }
.screens-note { margin-top: 20px; }
.app-screens { grid-template-columns: repeat(auto-fill, minmax(150px, 220px)); }
