/* Shared page chrome for every game's marketing + legal site.
 *
 * Covers the layouts every page needs except the landing page:
 *   .doc   — rules, guides, free tools and the legal / support pages
 *   .panel — the single centred utility pages (404, /invite, /get)
 *
 * Look: "the table and the rulebook". The page itself is the game's table —
 * the same dark felt / walnut / burgundy / night ground and accent glow as the
 * landing page (landing.css), so moving from the home page to a rules or tool
 * page feels like one site. The reading content sits on raised paper sheets in
 * the app's own card-stock colours, because long Turkish rule text reads best
 * dark-on-light. One signature element per game: a large, faint glyph (a
 * spade, a heart, a die, letters) in the header glow, set by `--pg-mark`.
 *
 * Everything colour- or type-shaped is a custom property, overridden by the
 * site in `assets/theme.css` (loaded AFTER this file):
 *   --wc-*  the PAPER: ink, muted text, deep accent, card colours, badges
 *   --pg-*  the TABLE: felt ground, glow, bright accent and text on the felt
 * The defaults below are Word Clash's.
 */

:root {
  /* Paper (inside .card) */
  --wc-ink: #263238;
  --wc-muted: #546E7A;
  --wc-accent: #0277BD;
  --wc-card-bg: #ffffff;
  --wc-card-border: #D4E8F5;
  --wc-card-radius: 22px;
  --wc-rule: #E3EFF7;
  --wc-badge-bg: #10173D;
  --wc-font-body: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --wc-font-display: var(--wc-font-body);
  /* Legacy light ground; no longer painted, kept so old theme files stay valid. */
  --wc-page-bg: #E8F5FD;

  /* Table (the page around the paper) */
  --pg-felt: #0A0F2E;
  --pg-felt-2: #0F1742;
  --pg-glow: #1C3FA8;
  --pg-accent: #29B6F6;
  --pg-accent-rgb: 41, 182, 246;
  --pg-accent-2-rgb: 255, 167, 38;
  --pg-on-accent: #06122A;
  --pg-ink: #F4F7FF;
  --pg-muted: rgba(228, 234, 255, 0.74);
  --pg-line: rgba(255, 255, 255, 0.12);
  --pg-mark: "Aa";
  --pg-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--wc-font-body);
  font-size: 17px;
  color: var(--pg-ink);
  background-color: var(--pg-felt);
  background-image:
    radial-gradient(ellipse 60% 520px at 82% -60px, rgba(var(--pg-accent-rgb), 0.30), transparent 70%),
    radial-gradient(ellipse 45% 380px at 0% 0%, rgba(var(--pg-accent-2-rgb), 0.14), transparent 70%),
    linear-gradient(180deg, var(--pg-glow) 0px, var(--pg-felt-2) 360px, var(--pg-felt) 760px);
  background-repeat: no-repeat;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
@supports (overflow: clip) { body { overflow-x: clip; } }

a { color: var(--pg-accent); }
img { display: block; max-width: 100%; }
:focus-visible { outline: 3px solid var(--pg-accent); outline-offset: 3px; border-radius: 6px; }

/* ---------- .doc — rules, guides, tools, legal ---------- */

/* The signature: the game's glyph, huge and faint, in the header glow. */
.doc { position: relative; isolation: isolate; }
.doc::before {
  content: var(--pg-mark);
  position: absolute; z-index: -1; pointer-events: none;
  top: 40px; right: max(-40px, calc(50vw - 640px));
  font-family: var(--wc-font-display);
  font-size: clamp(220px, 34vw, 420px); font-weight: 800; line-height: 0.8;
  letter-spacing: -0.06em;
  color: transparent;
  -webkit-text-stroke: 2px rgba(var(--pg-accent-rgb), 0.22);
  background: linear-gradient(170deg, rgba(var(--pg-accent-rgb), 0.16), transparent 75%);
  -webkit-background-clip: text; background-clip: text;
  transform: rotate(-8deg);
}

.doc .wrap { max-width: 800px; margin: 0 auto; padding: 0 22px 88px; }

/* Top bar — a full-bleed glass strip like the landing nav. Rules, guides and
   tools carry a .topbar (home link + a related page); legal pages carry a lone
   a.back, which gets the same strip. */
.doc .topbar,
.doc .wrap > a.back:first-child {
  position: sticky; top: 0; z-index: 30;
  margin: 0 calc(50% - 50vw) 0;
  padding: 0 max(22px, calc(50vw - 378px));
  min-height: 60px;
  background: color-mix(in srgb, var(--pg-felt) 74%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--pg-line);
}
.doc .topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.doc .wrap > a.back:first-child { display: flex; align-items: center; }
.doc a.back, .doc .topbar a.lang {
  color: var(--pg-ink); text-decoration: none; font-weight: 700; font-size: 16px;
  padding: 8px 2px; border-radius: 8px;
}
.doc .topbar a.lang {
  font-size: 15px; font-weight: 600; color: var(--pg-muted);
  padding: 7px 14px; border: 1px solid var(--pg-line); border-radius: 999px;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.doc .topbar a.lang:hover { color: var(--pg-ink); border-color: rgba(var(--pg-accent-rgb), 0.5); background: rgba(var(--pg-accent-rgb), 0.1); }
.doc a.back:hover { color: var(--pg-accent); }

/* Header: the page title on the felt. */
.doc h1 {
  font-family: var(--wc-font-display);
  font-size: clamp(36px, 6.4vw, 60px); line-height: 1.04; font-weight: 800;
  letter-spacing: -0.035em; text-wrap: balance;
  color: var(--pg-ink);
  margin: clamp(40px, 8vw, 76px) 0 16px; max-width: 18ch;
}
.doc > .wrap > .sub, .doc > .wrap > .updated {
  color: var(--pg-muted); font-size: clamp(17px, 2.2vw, 20px); line-height: 1.55;
  margin: 0 0 clamp(32px, 6vw, 52px); max-width: 60ch;
}
.doc > .wrap > .updated { font-size: 15px; }

/* Paper sheets */
.doc .card {
  position: relative;
  background: var(--wc-card-bg);
  color: var(--wc-ink);
  border-radius: var(--wc-card-radius);
  padding: clamp(22px, 4vw, 36px) clamp(20px, 4.6vw, 44px);
  margin-bottom: 20px;
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--wc-card-border) 70%, transparent),
    0 2px 4px rgba(0, 0, 0, 0.18),
    0 24px 48px -22px rgba(0, 0, 0, 0.7);
}
.doc .card:last-of-type { margin-bottom: 0; }
.doc .card a { color: var(--wc-accent); text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
.doc .card a:hover { text-decoration-thickness: 2.5px; }
.doc .card :focus-visible { outline-color: var(--wc-accent); }

.doc h2 {
  font-family: var(--wc-font-display);
  font-size: clamp(22px, 3vw, 27px); line-height: 1.2; font-weight: 800; letter-spacing: -0.02em;
  margin: 34px 0 10px; text-wrap: balance;
}
.doc .card > h2:first-child, .doc h2:first-of-type { margin-top: 0; }
.doc h3 {
  font-family: var(--wc-font-display);
  font-size: 18px; line-height: 1.35; font-weight: 700; color: var(--wc-accent);
  margin: 24px 0 6px;
}
.doc p, .doc li { line-height: 1.7; }
.doc .card p { margin: 0 0 14px; }
.doc .card > :last-child { margin-bottom: 0; }
.doc ol, .doc ul { padding-left: 24px; margin: 0 0 14px; }
.doc li { margin: 4px 0; padding-left: 4px; }
.doc li::marker { color: var(--wc-accent); font-weight: 800; }
.doc strong { font-weight: 700; }
.doc .muted { color: var(--wc-muted); }
.doc .contact { font-size: 18px; }
.doc .contact a { font-weight: 700; }

/* Tables: a tinted header row on the paper, numbers right-aligned by pages. */
.doc table { width: 100%; border-collapse: separate; border-spacing: 0; margin: 8px 0 6px; font-variant-numeric: tabular-nums; }
.doc th, .doc td {
  text-align: left; padding: 10px 12px;
  border-bottom: 1px solid var(--wc-rule);
  vertical-align: top; font-size: 15px;
}
.doc thead th, .doc tr:first-child > th {
  background: color-mix(in srgb, var(--wc-rule) 80%, var(--wc-card-bg));
  color: var(--wc-ink); font-weight: 700; font-size: 14px;
  border-bottom: 0;
}
.doc thead th:first-child, .doc tr:first-child > th:first-child { border-radius: 10px 0 0 10px; }
.doc thead th:last-child, .doc tr:first-child > th:last-child { border-radius: 0 10px 10px 0; }
.doc tbody tr:last-child td { border-bottom: 0; }
.doc tfoot td { font-weight: 800; border-top: 2px solid var(--wc-ink); border-bottom: 0; }

/* Tables are the one element that cannot reflow: a three-column policy table
   at 360px either scrolls or truncates, and truncating a disclosure a store
   reviewer is reading is the worse of the two. */
.doc .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------- Free tools (score sheets, dice, letter picker) ---------- */
.doc .tool fieldset { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
.doc .tool legend, .doc .tool label, .doc .tool .lbl { display: block; font-weight: 700; font-size: 15px; margin: 0 0 6px; }
.doc .tool input:not([type="checkbox"]):not([type="radio"]), .doc .tool select {
  width: 100%; font: inherit; font-size: 16px; color: var(--wc-ink);
  background: color-mix(in srgb, var(--wc-rule) 35%, #fff);
  border: 2px solid var(--wc-card-border); border-radius: 12px;
  padding: 9px 12px; min-height: 48px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.doc .tool input:focus, .doc .tool select:focus {
  outline: none; border-color: var(--wc-accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--wc-accent) 18%, transparent);
}
.doc .tool .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 14px; }
.doc .tool .btn {
  font: inherit; font-size: 16px; font-weight: 700; min-height: 48px; padding: 10px 20px;
  border-radius: 12px; cursor: pointer;
  border: 2px solid var(--wc-card-border); background: var(--wc-card-bg); color: var(--wc-ink);
  transition: transform 0.12s var(--pg-ease), background 0.15s, border-color 0.15s;
}
.doc .tool .btn:hover { border-color: var(--wc-ink); }
.doc .tool .btn:active { transform: translateY(1px) scale(0.98); }
.doc .tool .btn.primary, .doc .tool .seg [aria-pressed="true"] {
  background: var(--wc-badge-bg); border-color: var(--wc-badge-bg); color: #fff;
  box-shadow: 0 6px 16px -8px var(--wc-badge-bg);
}
.doc .tool .seg { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.doc .tool .actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.doc .tool .err { color: #B3261E; font-weight: 700; min-height: 1em; margin: 0 0 10px; }
.doc .tool td.n, .doc .tool th.n { text-align: right; white-space: nowrap; }
.doc .tool .status { font-weight: 700; }

/* ---------- Download call-to-action: a sheet of the table itself ---------- */
.doc .card.get {
  text-align: center; color: var(--pg-ink); overflow: hidden; isolation: isolate;
  background:
    radial-gradient(ellipse 70% 120% at 50% 0%, rgba(var(--pg-accent-rgb), 0.30), transparent 70%),
    linear-gradient(160deg, var(--pg-glow), var(--pg-felt));
  box-shadow: 0 0 0 1px rgba(var(--pg-accent-rgb), 0.35), 0 30px 60px -24px rgba(0, 0, 0, 0.8);
  margin-top: 40px;
  padding-block: clamp(30px, 5vw, 48px);
}
.doc .card.get h2 { color: var(--pg-ink); max-width: 22ch; margin-inline: auto; }
.doc .card.get p { color: var(--pg-muted); max-width: 46ch; margin-inline: auto; }
.doc .card.get a:not(.store-badge) { color: var(--pg-accent); }
.doc .card.get .badges { margin-top: 22px; }
/* `.doc .card a` paints links in the paper accent; a store badge is a button,
   not a link in prose, so it keeps white text and no underline. */
.doc .card a.store-badge { color: #fff; text-decoration: none; }
.doc .card.get .store-badge {
  background: #000;
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.55), 0 10px 24px -10px rgba(0, 0, 0, 0.8);
}
.doc .card.get .store-badge:hover {
  box-shadow: inset 0 0 0 1.5px var(--pg-accent), 0 14px 30px -10px rgba(var(--pg-accent-rgb), 0.55);
}
.doc .card.get .store-badge .bl { opacity: 0.85; }

/* ---------- Footer, on the felt ---------- */
.doc footer { text-align: center; margin-top: 48px; color: var(--pg-muted); font-size: 14px; line-height: 1.9; }
.doc footer a { color: var(--pg-ink); text-decoration: none; font-weight: 600; }
.doc footer a:hover { color: var(--pg-accent); }

@media (max-width: 480px) {
  body { font-size: 16px; }
  .doc .wrap { padding: 0 14px 64px; }
  .doc::before { top: 70px; right: -60px; opacity: 0.8; }
  .doc .card { border-radius: 18px; }
  .doc th, .doc td { padding: 8px 8px; font-size: 14px; }
}

/* ---------- .panel — 404 / invite / get ---------- */
.panel {
  display: flex; align-items: center; justify-content: center;
  text-align: center; min-height: 100vh;
  background-image:
    radial-gradient(ellipse 60% 50% at 50% 30%, rgba(var(--pg-accent-rgb), 0.28), transparent 70%),
    radial-gradient(ellipse 40% 40% at 10% 90%, rgba(var(--pg-accent-2-rgb), 0.12), transparent 70%),
    linear-gradient(170deg, var(--pg-glow) 0%, var(--pg-felt) 75%);
}
.panel .box { padding: 32px 22px; max-width: 460px; }
.panel .logo {
  width: 104px; height: 104px; border-radius: 26px; margin: 0 auto;
  box-shadow: 0 0 0 1px var(--pg-line), 0 18px 48px rgba(var(--pg-accent-rgb), 0.4);
}
.panel h1 {
  font-family: var(--wc-font-display); letter-spacing: -0.03em;
  font-size: clamp(28px, 6vw, 36px); font-weight: 800; color: var(--pg-ink); margin: 24px 0 10px;
  text-wrap: balance;
}
.panel .code {
  font-family: var(--wc-font-display); font-size: clamp(88px, 22vw, 128px); font-weight: 800;
  letter-spacing: -0.06em; line-height: 1;
  background: linear-gradient(180deg, var(--pg-ink), var(--pg-accent));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  color: var(--pg-accent);
}
.panel p { color: var(--pg-muted); font-size: 17px; line-height: 1.55; margin: 0 0 26px; }
.panel .home { margin-top: 30px; font-size: 15px; }
.panel .home a { color: var(--pg-accent); text-decoration: none; font-weight: 700; }
/* Secondary: the store badges are the invite page's main action. invite.js
   reveals this only on a phone, for someone who already has the app. */
.panel .open-app {
  display: none; margin: 20px auto 0; font-size: 15px; font-weight: 600;
  color: inherit; text-decoration: underline; text-underline-offset: 3px;
}
.panel .open-app.visible { display: inline-block; }
.panel .store-badge { background: #000; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.55), 0 10px 24px -10px rgba(0, 0, 0, 0.8); }
.panel .store-badge:hover { box-shadow: inset 0 0 0 1.5px var(--pg-accent), 0 14px 30px -10px rgba(var(--pg-accent-rgb), 0.55); }

/* ---------- Store badges (shared by .panel, .doc and landing pages) ---------- */
.badges {
  /* Equal-width badges: 1fr columns sized to the widest one (see landing.css). */
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  width: max-content; max-width: 100%; gap: 12px; margin-inline: auto;
}
@media (max-width: 420px) { .badges { grid-auto-flow: row; } }
.store-badge {
  display: inline-flex; align-items: center; gap: 10px; padding: 11px 20px;
  background: var(--wc-badge-bg); color: #fff; border-radius: 14px;
  text-decoration: none; text-align: left;
  transition: transform 0.15s var(--pg-ease), background 0.15s, box-shadow 0.15s;
}
.store-badge:hover { transform: translateY(-2px); }
.store-badge svg { width: 26px; height: 26px; flex: none; }
.store-badge > span { display: flex; flex-direction: column; gap: 2px; white-space: nowrap; }
.store-badge br { display: none; }
.store-badge .bl { display: block; font-size: 11px; line-height: 1.1; opacity: 0.8; }
.store-badge .bb { display: block; font-size: 16px; font-weight: 700; line-height: 1.1; }

@media (prefers-reduced-motion: reduce) {
  .store-badge, .doc .tool .btn, .doc .topbar a.lang { transition: none; }
  .store-badge:hover { transform: none; }
}

/* Revealed by wcWireStoreLinks() when the game is on neither store yet. */
[data-store-empty][hidden] { display: none; }
