/* Megarook — shared stylesheet for the studio site.
   Quiet "case notebook" look: warm paper, dark ink, serif headings. The game
   icons carry the colour, so the page itself stays plain. Dark mode follows the
   device setting through the same tokens. */

:root {
  --bg: #f5f2ea;
  --surface: #fffdf8;
  --surface-2: #ece7dc;
  --text: #1d1c1a;
  --muted: #625d54;
  --line: rgba(29, 28, 26, 0.12);
  --line-strong: rgba(29, 28, 26, 0.24);
  --link: #1f4d9c;
  --link-hover: #143670;
  --live: #2d7a4c;
  --warn: #9a5b00;
  --focus: #c98a1a;
  --icon-shadow: 0 1px 2px rgba(29, 28, 26, 0.12), 0 6px 16px rgba(29, 28, 26, 0.1);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  --shell: 1040px;
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218;
    --surface: #161a22;
    --surface-2: #1d222c;
    --text: #ebe7de;
    --muted: #a39e94;
    --line: rgba(235, 231, 222, 0.11);
    --line-strong: rgba(235, 231, 222, 0.22);
    --link: #93b4f0;
    --link-hover: #bdd1f7;
    --live: #6fcf97;
    --warn: #f0b85a;
    --focus: #f0b85a;
    --icon-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 16px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
}

h1, h2, h3 { line-height: 1.2; margin: 0; }
h1, h2 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.01em; }
h3 { font-weight: 650; }
p { margin: 0; }
img { max-width: 100%; display: block; }

a { color: var(--link); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--link-hover); }

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

.shell {
  width: 100%;
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 20px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 650;
  z-index: 20;
}
.skip-link:focus { left: 16px; }

/* ── Header ─────────────────────────────────────────────────────────────── */

.site-header { border-bottom: 1px solid var(--line); }

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 20px;
  min-height: 64px;
  flex-wrap: wrap;
  padding-top: 10px;
  padding-bottom: 10px;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  text-decoration: none;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 20px;
}
.wordmark .studio-icon { width: 24px; height: 24px; flex: none; border-radius: 6px; }
.wordmark:hover { color: var(--text); }

.site-nav { display: flex; align-items: center; gap: 2px 18px; flex-wrap: wrap; }
.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 15px;
  padding: 6px 0;
  border-bottom: 1.5px solid transparent;
}
.site-nav a:hover { color: var(--text); }
.site-nav a[aria-current] { color: var(--text); border-bottom-color: currentColor; }

/* ── Buttons ────────────────────────────────────────────────────────────── */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.button:hover { background: var(--surface-2); color: var(--text); }
.button.primary { background: var(--text); border-color: var(--text); color: var(--bg); }
.button.primary:hover { opacity: 0.88; background: var(--text); color: var(--bg); }
.button[disabled] { opacity: 0.5; cursor: not-allowed; }

.kicker { font-size: 14px; color: var(--muted); margin: 0 0 8px; }

/* ── Home ───────────────────────────────────────────────────────────────── */

.hero { padding: 72px 20px 40px; }
.hero h1 { font-size: clamp(36px, 6.4vw, 60px); max-width: 13em; margin-bottom: 18px; text-wrap: balance; }
.hero .lead { font-size: clamp(16.5px, 2.1vw, 19px); color: var(--muted); max-width: 58ch; }

.section { padding-top: 36px; padding-bottom: 36px; }
.section-title {
  font-size: clamp(24px, 3.4vw, 30px);
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-strong);
}

.games { display: grid; grid-template-columns: 1fr; column-gap: 48px; }

.game {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 20px;
  align-items: start;
  padding: 28px 0;
  border-bottom: 1px solid var(--line);
}
.game img {
  width: 88px;
  height: 88px;
  border-radius: 20px;
  box-shadow: var(--icon-shadow);
}
.game h3 { font-size: 20px; }
.game p { color: var(--muted); font-size: 15px; }
.game .status { font-size: 13.5px; margin: 3px 0 8px; }
.game .status.live { color: var(--live); }
.game .status::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: currentColor;
  vertical-align: 1px;
  opacity: 0.8;
}

.store-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.store {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease;
}
.store:hover { background: var(--surface-2); color: var(--text); }

.principles { display: grid; grid-template-columns: 1fr; gap: 26px 48px; padding-top: 24px; }
.principles h3 { font-size: 16.5px; margin-bottom: 6px; }
.principles p { color: var(--muted); font-size: 15px; }

.note {
  color: var(--muted);
  max-width: 62ch;
  border-left: 2px solid var(--line-strong);
  padding: 4px 0 4px 18px;
}

/* ── Document pages (privacy, terms) and support header ─────────────────── */

.doc-head { padding-top: 56px; padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.doc-head h1 { font-size: clamp(32px, 5.4vw, 46px); margin-bottom: 12px; }
.doc-head .updated { color: var(--muted); font-size: 14px; }
.doc-head .summary { color: var(--muted); margin-top: 14px; max-width: 68ch; }

.doc-layout {
  display: grid;
  gap: 36px;
  grid-template-columns: 1fr;
  padding-top: 34px;
  padding-bottom: 20px;
}

.toc {
  align-self: start;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: var(--surface-2);
}
.toc h2 { font-family: var(--sans); font-size: 14px; font-weight: 650; margin-bottom: 10px; }
.toc ol { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--muted); }
.toc a { font-size: 14px; text-decoration: none; }
.toc a:hover { text-decoration: underline; }

/* Grid children default to min-width:auto, which lets the wide per-game table
   push the whole page sideways instead of scrolling inside its own wrapper. */
.doc-layout > *, .support-layout > * { min-width: 0; }

.doc { max-width: 72ch; }
.doc section { margin-bottom: 32px; scroll-margin-top: 24px; }
.doc h2 { font-size: 23px; margin-bottom: 10px; }
.doc h3 { font-size: 16px; margin: 18px 0 6px; }
.doc p + p { margin-top: 10px; }
.doc ul { margin: 10px 0 0; padding-left: 22px; display: grid; gap: 7px; }

.table-scroll { overflow-x: auto; margin-top: 14px; }
table { border-collapse: collapse; width: 100%; min-width: 540px; font-size: 14.5px; }
caption { text-align: left; color: var(--muted); font-size: 13.5px; padding-bottom: 8px; }
th, td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px 10px 0;
  text-align: left;
  vertical-align: top;
}
thead th { border-bottom-color: var(--line-strong); font-size: 13.5px; }
th { font-weight: 650; }

/* ── Support page ───────────────────────────────────────────────────────── */

.support-layout {
  display: grid;
  gap: 30px;
  grid-template-columns: 1fr;
  padding-top: 30px;
  padding-bottom: 10px;
}

.panel {
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
}
.panel h2 { font-size: 21px; margin-bottom: 6px; }
.panel > p { color: var(--muted); font-size: 15px; }

fieldset { border: 0; margin: 0; padding: 0; }
legend { font-size: 15px; font-weight: 650; padding: 0 0 10px; }

.game-choices { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.game-choice { position: relative; display: block; cursor: pointer; }
.game-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.game-choice .choice-body {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.game-choice img { width: 36px; height: 36px; border-radius: 9px; flex: none; }
.game-choice span { font-weight: 600; font-size: 14.5px; }
.game-choice:hover .choice-body { border-color: var(--line-strong); }
.game-choice input:checked + .choice-body { border-color: var(--text); background: var(--surface-2); }
.game-choice input:focus-visible + .choice-body { outline: 2px solid var(--focus); outline-offset: 3px; }

.field { display: grid; gap: 7px; margin-top: 20px; }
.field label { font-size: 15px; font-weight: 650; }
.field .hint { color: var(--muted); font-size: 13.5px; font-weight: 400; }

input[type="text"], input[type="email"], select, textarea {
  width: 100%;
  padding: 11px 13px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}
textarea { resize: vertical; min-height: 140px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.75; }
input:focus, select:focus, textarea:focus { border-color: var(--text); outline: none; }

.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 24px; }
.form-note { color: var(--muted); font-size: 13.5px; margin-top: 12px; }
.form-status { font-size: 14px; font-weight: 600; min-height: 20px; margin-top: 12px; }
.form-status.ok { color: var(--live); }
.form-status.warn { color: var(--warn); }

.side-list { display: grid; gap: 10px; margin-top: 14px; }
.side-list a { font-size: 15px; }

details { border-top: 1px solid var(--line); padding: 12px 0; }
details:last-of-type { border-bottom: 1px solid var(--line); }
summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; color: var(--muted); font-size: 19px; line-height: 1; }
details[open] summary::after { content: "−"; }
details p { color: var(--muted); font-size: 14.5px; margin-top: 8px; }

/* ── Footer ─────────────────────────────────────────────────────────────── */

.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 48px;
  padding: 26px 0 40px;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 14px;
}
.footer-links { display: flex; flex-wrap: wrap; gap: 18px; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--text); text-decoration: underline; }

@media (max-width: 480px) {
  .game { grid-template-columns: 68px 1fr; gap: 16px; }
  .game img { width: 68px; height: 68px; border-radius: 16px; }
}

@media (min-width: 760px) {
  .games { grid-template-columns: 1fr 1fr; }
  .principles { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 900px) {
  .doc-layout { grid-template-columns: 240px 1fr; gap: 48px; }
  .toc { position: sticky; top: 24px; }
  .support-layout { grid-template-columns: 1.6fr 1fr; align-items: start; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
