/* ==========================================================================
   دور كمان — the brand on the web (Brand Book V2, docs/DESIGN.md).
   Tokens, base, and the few components every page shares: the button, the
   playing card, the pill, the header and the footer.

   Mirrors lib/theme/tokens.dart (AppPalette.forest / .brick). This file and
   nothing downstream holds a palette hex: pages and components name ROLES.
   One theme, like the app: it opens in forest whatever the phone says.
   Brick is a SECOND GROUND for a whole section (`.ground-brick`), never a
   colour on its own — the roles swap, the geometry does not.

   The rules the book sets, as the web keeps them:
   - Orange is ACTION only — the beta button. Never a heading, never
     decoration, never a link colour.
   - Depth without gloss: a solid, unblurred toy edge under cards and
     buttons; pressed things sink onto it. No blurred drop shadows.
   - Cream is the ink. Never pure white.
   ========================================================================== */

:root {
  color-scheme: dark;

  /* ---- Forest (page 12, 13) -------------------------------------------- */
  --bg: #102f15;              /* Forest — the ground */
  --surface: #21420d;         /* Pine — cards, tiles, name bands */
  --elevated: #2a4e10;        /* pressed / inset */
  --moss: #305711;            /* pressed and disabled fills */
  --on-bg: #fff1dc;           /* Cream — 13.1:1 on forest, 10.2:1 on pine */
  --muted: #a9bc93;           /* Sage light — 7.2:1 on forest, 5.6:1 on pine */
  --icon: #728c5a;            /* Sage — icons only, never small text (3.9:1) */
  --accent: #ff9f24;          /* Orange — THE action */
  --on-accent: #102f15;       /* 7.1:1 on orange */
  --accent-edge: #b8650c;     /* Play edge — the toy edge under PLAY */
  --positive: #5ccb5f;        /* 7.1:1 on forest */
  --on-positive: #0b2410;
  --gold: #ffc940;            /* winning and coins */
  --edge: #0a2410;            /* Edge — the solid toy edge under tiles */
  --glow: #1e4a24;            /* Glow — the light behind the logo only */
  --hairline: rgba(169, 188, 147, 0.2);
  --border: rgba(169, 188, 147, 0.3);
  --inset: rgba(255, 241, 220, 0.14);  /* the inset stroke inside a card's rim */

  /* ---- Type (page 16) --------------------------------------------------- */
  --font-display: "Grandstander", "Lalezar", system-ui, sans-serif;
  --font-body: "Rubik", system-ui, -apple-system, "Segoe UI", sans-serif;

  --text-sm: 0.875rem;                               /* 14 — captions */
  --text-base: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  --text-lead: clamp(1.0625rem, 0.98rem + 0.45vw, 1.3rem);
  --text-h3: clamp(1.3rem, 1.15rem + 0.7vw, 1.65rem);
  --text-h2: clamp(1.9rem, 1.35rem + 2.4vw, 3.2rem);
  --text-h1: clamp(2.4rem, 1.5rem + 4.6vw, 5rem);

  --leading-tight: 1.08;
  --leading-body: 1.65;

  /* ---- Space (8-point grid, page 20) ------------------------------------ */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4.5rem;
  --space-section: clamp(4rem, 2.8rem + 5vw, 7.5rem);
  --gutter: clamp(1rem, 0.4rem + 2.6vw, 2.5rem);   /* 16px at phone width */
  --shell: 1180px;
  --measure: 64ch;

  /* ---- Geometry (page 15, AppRadius / AppEdge) --------------------------- */
  --radius-card: 16px;
  --radius-tile: 14px;
  --radius-pill: 999px;
  --edge-card: 6px;
  --edge-hero: 8px;
  --press: 5px;
  --tap: 48px;

  /* ---- Motion ----------------------------------------------------------- */
  --dur-fast: 140ms;
  --dur-normal: 280ms;
  --dur-reveal: 640ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.42, 0.44, 1);
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);

  /* Mirrors a decorative tilt under RTL, so a card fan reads the same way
     in both directions instead of being hand-flipped. */
  --push: 1;
}

[dir="rtl"] {
  --push: -1;
}

/* The second ground (brand page 12 «Brick», DESIGN.md two themes). Same
   roles, the ground swaps; orange stays the action. */
.ground-brick {
  --bg: #6e170b;
  --surface: #82200f;
  --elevated: #5a1208;
  --muted: #f2c9b4;           /* 7.7:1 on brick, 6.4:1 on its surface */
  --edge: #4a0e05;
  --glow: rgba(149, 34, 16, 0.6);
  --hairline: rgba(242, 201, 180, 0.25);
  --border: rgba(242, 201, 180, 0.35);
  --inset: rgba(255, 241, 220, 0.16);
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-fast: 1ms;
    --dur-normal: 1ms;
    --dur-reveal: 1ms;
  }
}

/* ==========================================================================
   Base
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--on-bg);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--text-base);
  line-height: var(--leading-body);
  overflow-x: hidden;
  overflow-x: clip;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

img,
svg {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  line-height: var(--leading-tight);
  color: var(--on-bg);
  text-wrap: balance;
}

/* Lalezar is one weight, and Arabic display reads a touch bigger than Latin
   at the same size — so the Arabic side opens its line-height a little. */
html[lang="ar"] h1,
html[lang="ar"] h2,
html[lang="ar"] h3 {
  line-height: 1.3;
}

p,
ul,
ol,
dl,
figure {
  margin: 0;
}

a {
  color: var(--on-bg);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.2em;
  text-decoration-color: var(--muted);
}

a:hover {
  text-decoration-color: var(--on-bg);
}

strong,
b {
  font-weight: 700;
}

:focus-visible {
  outline: 3px solid var(--on-bg);
  outline-offset: 3px;
  border-radius: 6px;
}

::selection {
  background: var(--accent);
  color: var(--on-accent);
}

[hidden] {
  display: none !important;
}

/* ---- Both languages ship in the markup (site/README.md «Editing copy») --
   `.both` opts an element out: the mode-still bands show the Arabic AND the
   English name in every language (brand page 28), and still want a real
   lang attribute for screen readers. */
html[lang="ar"] [lang="en"]:not(.both),
html[lang="en"] [lang="ar"]:not(.both) {
  display: none !important;
}

/* Codes, emails and URLs keep their own direction inside an Arabic line. */
.ltr {
  direction: ltr;
  unicode-bidi: isolate;
}

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

.skip-link {
  position: absolute;
  inset-inline-start: var(--space-4);
  top: var(--space-3);
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--on-bg);
  color: var(--bg);
  border-radius: var(--radius-pill);
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-200%);
}

.skip-link:focus-visible {
  transform: none;
}

/* JS-only controls are hidden until boot.js marks the document. */
html:not(.js) .js-only {
  display: none !important;
}

.shell {
  width: 100%;
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.muted {
  color: var(--muted);
}

.eyebrow {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

html[lang="ar"] .eyebrow {
  letter-spacing: 0;
}

.lead {
  font-size: var(--text-lead);
  line-height: 1.6;
  color: var(--muted);
  max-width: 46ch;
}

/* ==========================================================================
   Button — PressButton on the web (page 15): flat fill, an inset stroke,
   a solid edge, and a press that sinks onto it. transform only.
   ========================================================================== */

.btn {
  --btn-bg: var(--surface);
  --btn-ink: var(--on-bg);
  --btn-edge: var(--edge);
  --btn-rim: var(--inset);

  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: 0.7em 1.35em;
  border: 0;
  border-radius: var(--radius-card);
  background: var(--btn-bg);
  color: var(--btn-ink);
  box-shadow: inset 0 0 0 2px var(--btn-rim), 0 var(--edge-card) 0 var(--btn-edge);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  line-height: 1.15;
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-standard),
    box-shadow var(--dur-fast) var(--ease-standard),
    filter var(--dur-fast) var(--ease-standard);
  -webkit-tap-highlight-color: transparent;
}

html[lang="ar"] .btn {
  font-weight: 400;
  font-size: 1.25rem;
}

.btn:hover {
  filter: brightness(1.07);
}

.btn:active {
  transform: translateY(var(--press));
  box-shadow: inset 0 0 0 2px var(--btn-rim), 0 1px 0 var(--btn-edge);
}

.btn:focus-visible {
  outline: 3px solid var(--on-bg);
  outline-offset: 4px;
  border-radius: var(--radius-card);
}

.btn[disabled] {
  --btn-bg: var(--moss);
  --btn-ink: var(--muted);
  --btn-edge: var(--edge);
  cursor: default;
  filter: none;
  transform: none;
}

/* The one orange thing on the page. */
.btn--play {
  --btn-bg: var(--accent);
  --btn-ink: var(--on-accent);
  --btn-edge: var(--accent-edge);
  --btn-rim: rgba(16, 47, 21, 0.22);
}

/* Secondary: outlined, on the ground. */
.btn--line {
  --btn-bg: transparent;
  --btn-rim: var(--border);
  --btn-edge: transparent;
}

.btn--line:active {
  box-shadow: inset 0 0 0 2px var(--btn-rim);
}

.btn--sm {
  min-height: 40px;
  padding: 0.45em 1em;
  font-size: 1rem;
  --edge-card: 4px;
}

html[lang="ar"] .btn--sm {
  font-size: 1.05rem;
}

/* ==========================================================================
   Card — a playing card: pine, a 16px corner, an inset stroke, a toy edge.
   ========================================================================== */

.card {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: inset 0 0 0 2px var(--inset), 0 var(--edge-card) 0 var(--edge);
}

/* ==========================================================================
   Pill
   ========================================================================== */

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.3em 0.85em;
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--on-bg);
  box-shadow: inset 0 0 0 1px var(--border);
  font-size: var(--text-sm);
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}

.pill__dot {
  width: 0.55em;
  height: 0.55em;
  border-radius: 50%;
  background: var(--positive);
  flex: none;
}

/* ==========================================================================
   Header
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-block-end: 1px solid transparent;
  transition: border-color var(--dur-normal) var(--ease-standard);
}

.site-header.is-stuck {
  border-block-end-color: var(--hairline);
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: 64px;
}

.brandmark {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--on-bg);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.2rem;
  line-height: 1;
  flex: none;
}

html[lang="ar"] .brandmark {
  font-weight: 400;
  font-size: 1.35rem;
}

.brandmark img {
  width: 36px;
  height: 40px;
}

.site-nav {
  display: none;
  gap: var(--space-5);
  margin-inline-start: var(--space-4);
}

.site-nav a {
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
  padding-block: var(--space-2);
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--on-bg);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-inline-start: auto;
}

/* The language pill, like the app's welcome screen (01-03). */
.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  min-height: 40px;
  min-width: 40px;
  padding: 0.3em 0.9em;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--on-bg);
  box-shadow: inset 0 0 0 1px var(--border), 0 3px 0 var(--edge);
  font: 700 0.95rem/1 var(--font-body);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-standard);
}

.lang-btn:active {
  transform: translateY(3px);
  box-shadow: inset 0 0 0 1px var(--border);
}

.lang-btn svg {
  width: 18px;
  height: 18px;
  color: var(--icon);
}

.lang-btn:hover svg {
  color: var(--on-bg);
}

@media (min-width: 900px) {
  .site-nav {
    display: flex;
  }
}

/* Below ~400px the header CTA would crowd the language pill; the hero's
   own button is one thumb away. */
@media (max-width: 399px) {
  .header-actions .btn--play {
    display: none;
  }
}

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  padding-block: var(--space-7) var(--space-6);
  border-block-start: 1px solid var(--hairline);
  background: var(--bg);
}

.site-footer__grid {
  display: grid;
  gap: var(--space-6);
}

.site-footer h2 {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-block-end: var(--space-3);
}

html[lang="ar"] .site-footer h2 {
  letter-spacing: 0;
}

.site-footer ul {
  list-style: none;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}

.site-footer li a {
  display: inline-block;
  padding-block: 0.2em;
  text-decoration: none;
}

.site-footer li a:hover {
  text-decoration: underline;
}

.footer-brand {
  display: grid;
  gap: var(--space-3);
  justify-items: start;
}

.footer-brand .brandmark img {
  width: 54px;
  height: 59px;
}

.site-footer__legal {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-block-start: var(--space-7);
  padding-block-start: var(--space-5);
  border-block-start: 1px solid var(--hairline);
  color: var(--muted);
  font-size: var(--text-sm);
}

/* The publisher's wordmark, built as type like lib/widgets/zema_wordmark.dart:
   «zema» in cream over a small, tracked «GAMES» — the publisher's mark,
   and the only orange that is not an action, exactly as in the app (01-01). */
.zema {
  display: inline-grid;
  justify-items: center;
  direction: ltr;
  color: var(--on-bg);
  text-decoration: none;
  line-height: 1;
}

.zema__name {
  font-family: "Grandstander", system-ui, sans-serif;
  font-weight: 800;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
}

.zema__games {
  font-family: "Grandstander", system-ui, sans-serif;
  font-weight: 700;
  font-size: 0.56rem;
  letter-spacing: 0.24em;
  margin-inline-start: 0.24em;
  color: var(--accent);
}

@media (min-width: 440px) {
  .site-footer__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .footer-brand {
    grid-column: 1 / -1;
  }
}

@media (min-width: 720px) {
  .site-footer__grid {
    grid-template-columns: 1.4fr 1fr 1fr 1fr;
  }

  .footer-brand {
    grid-column: auto;
  }
}
