/* ============================================
   FAR GAMES — Design System & Base
   Redesign: motherduck-inspired, neo-brutalist
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=Inter:wght@300;400;500;600;700;800&family=Noto+Kufi+Arabic:wght@300;400;500;600;700;800&display=swap');

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
  -webkit-text-size-adjust: 100%;
}

:root {
  --eggshell: #f4f1de;
  --burnt-peach: #e07a5f;
  --twilight-indigo: #3d405b;
  --muted-teal: #81b29a;
  --apricot-cream: #f2cc8f;

  --eggshell-rgb: 244, 241, 222;
  --burnt-peach-rgb: 224, 122, 95;
  --twilight-indigo-rgb: 61, 64, 91;
  --muted-teal-rgb: 129, 178, 154;
  --apricot-cream-rgb: 242, 204, 143;

  /* Semantic — Light */
  --bg-primary: #f7f5ee;
  --bg-secondary: var(--eggshell);
  --bg-card: #ffffff;
  --bg-card-hover: #fefdfb;
  --bg-nav: rgba(247, 245, 238, 0.88);
  --bg-footer: var(--twilight-indigo);

  --text-primary: #2c2e3f;
  --text-secondary: #5d6078;
  --text-tertiary: #8b8da3;
  --text-inverse: var(--eggshell);

  --border-color: rgba(61, 64, 91, 0.12);
  --border-strong: var(--twilight-indigo);

  --shadow-card: 5px 5px 0px var(--twilight-indigo);
  --shadow-card-hover: 7px 7px 0px var(--twilight-indigo);
  --shadow-sm: 0 1px 3px rgba(61,64,91,0.06);
  --shadow-md: 0 4px 16px rgba(61,64,91,0.08);

  --accent: var(--burnt-peach);
  --accent-secondary: var(--muted-teal);
  --accent-warm: var(--apricot-cream);

  --game-photo: var(--burnt-peach);
  --game-cells: var(--muted-teal);
  --game-feud: var(--apricot-cream);

  --font-display: 'DM Serif Display', 'Noto Kufi Arabic', Georgia, serif;
  --font-body: 'Inter', 'Noto Kufi Arabic', system-ui, sans-serif;

  --text-xs: clamp(0.7rem, 0.65rem + 0.2vw, 0.78rem);
  --text-sm: clamp(0.82rem, 0.78rem + 0.2vw, 0.92rem);
  --text-base: clamp(0.95rem, 0.9rem + 0.25vw, 1.05rem);
  --text-lg: clamp(1.05rem, 0.98rem + 0.35vw, 1.2rem);
  --text-xl: clamp(1.2rem, 1.08rem + 0.6vw, 1.5rem);
  --text-2xl: clamp(1.5rem, 1.25rem + 1.2vw, 2rem);
  --text-3xl: clamp(1.9rem, 1.5rem + 2vw, 2.8rem);
  --text-4xl: clamp(2.4rem, 1.7rem + 3vw, 4rem);
  --text-5xl: clamp(3rem, 2rem + 4.5vw, 5.5rem);

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px;
  --space-12: 48px; --space-16: 64px; --space-20: 80px; --space-24: 96px;

  --container-max: 1180px;
  --nav-height: 72px;
  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px;
  --radius-xl: 20px; --radius-full: 9999px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast: 0.15s; --dur: 0.3s; --dur-slow: 0.6s;
}

/* --- Color Palettes --- */
[data-palette="rose"] {
  --eggshell: #ffc8dd;
  --burnt-peach: #d63e6c;
  --twilight-indigo: #590d22;
  --muted-teal: #3d85d4;
  --apricot-cream: #a880bf;
  --eggshell-rgb: 255, 200, 221;
  --burnt-peach-rgb: 214, 62, 108;
  --twilight-indigo-rgb: 89, 13, 34;
  --muted-teal-rgb: 61, 133, 212;
  --apricot-cream-rgb: 168, 128, 191;
  --bg-primary: #fff5f8;
  --bg-secondary: #ffe4ed;
  --bg-card: #ffffff;
  --bg-card-hover: #fff8fa;
  --bg-nav: rgba(255, 245, 248, 0.88);
  --bg-footer: #590d22;
  --text-primary: #3a0d1b;
  --text-secondary: #6e2d44;
  --text-tertiary: #996075;
  --border-color: rgba(89, 13, 34, 0.12);
  --border-strong: #590d22;
  --shadow-card: 5px 5px 0px #590d22;
  --shadow-card-hover: 7px 7px 0px #590d22;
}
[data-palette="ocean"] {
  --eggshell: #bde0fe;
  --burnt-peach: #c62b38;
  --twilight-indigo: #1d3557;
  --muted-teal: #3a8a8d;
  --apricot-cream: #8db87a;
  --eggshell-rgb: 189, 224, 254;
  --burnt-peach-rgb: 198, 43, 56;
  --twilight-indigo-rgb: 29, 53, 87;
  --muted-teal-rgb: 58, 138, 141;
  --apricot-cream-rgb: 141, 184, 122;
  --bg-primary: #f0f7ff;
  --bg-secondary: #deedf9;
  --bg-card: #ffffff;
  --bg-card-hover: #f6faff;
  --bg-nav: rgba(240, 247, 255, 0.88);
  --bg-footer: #1d3557;
  --text-primary: #14253d;
  --text-secondary: #33506e;
  --text-tertiary: #6a88a6;
  --border-color: rgba(29, 53, 87, 0.12);
  --border-strong: #1d3557;
  --shadow-card: 5px 5px 0px #1d3557;
  --shadow-card-hover: 7px 7px 0px #1d3557;
}

/* Dark mode overrides for palettes */
[data-theme="dark"][data-palette="rose"] {
  --burnt-peach: #ff6b9d;
  --muted-teal: #7bb8f0;
  --apricot-cream: #c9a4de;
  --burnt-peach-rgb: 255, 107, 157;
  --muted-teal-rgb: 123, 184, 240;
  --apricot-cream-rgb: 201, 164, 222;
  --bg-primary: #1f0a12;
  --bg-secondary: #2d1420;
  --bg-card: #3a1a2a;
  --bg-card-hover: #4a2238;
  --bg-nav: rgba(31, 10, 18, 0.92);
  --bg-footer: #150812;
  --text-primary: #f5dde5;
  --text-secondary: #d4aabb;
  --text-tertiary: #9a6878;
  --border-color: rgba(255, 200, 221, 0.1);
  --border-strong: rgba(255, 200, 221, 0.25);
  --shadow-card: 5px 5px 0px rgba(255, 107, 157, 0.25);
  --shadow-card-hover: 7px 7px 0px rgba(255, 107, 157, 0.35);
}
[data-theme="dark"][data-palette="ocean"] {
  --burnt-peach: #f05a66;
  --muted-teal: #6ec4c7;
  --apricot-cream: #aed49e;
  --burnt-peach-rgb: 240, 90, 102;
  --muted-teal-rgb: 110, 196, 199;
  --apricot-cream-rgb: 174, 212, 158;
  --bg-primary: #0d1a2d;
  --bg-secondary: #152640;
  --bg-card: #1d3050;
  --bg-card-hover: #243c5e;
  --bg-nav: rgba(13, 26, 45, 0.92);
  --bg-footer: #0a1425;
  --text-primary: #e0ecf5;
  --text-secondary: #a4bdd5;
  --text-tertiary: #6888a6;
  --border-color: rgba(189, 224, 254, 0.1);
  --border-strong: rgba(189, 224, 254, 0.25);
  --shadow-card: 5px 5px 0px rgba(240, 90, 102, 0.25);
  --shadow-card-hover: 7px 7px 0px rgba(240, 90, 102, 0.35);
}

[data-theme="dark"] {
  --bg-primary: #1a1b2e;
  --bg-secondary: #222338;
  --bg-card: #2a2b44;
  --bg-card-hover: #32334f;
  --bg-nav: rgba(26, 27, 46, 0.92);
  --bg-footer: #15162a;

  --text-primary: #edebe0;
  --text-secondary: #a8a9bc;
  --text-tertiary: #6e7089;
  --text-inverse: var(--twilight-indigo);

  --border-color: rgba(244, 241, 222, 0.08);
  --border-strong: rgba(244, 241, 222, 0.25);

  --shadow-card: 5px 5px 0px rgba(224, 122, 95, 0.25);
  --shadow-card-hover: 7px 7px 0px rgba(224, 122, 95, 0.35);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.25);
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 400;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-primary);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--dur-slow) var(--ease), color var(--dur-slow) var(--ease);
}

[dir="rtl"] body { font-family: 'Noto Kufi Arabic', 'Inter', sans-serif; }
[dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3, [dir="rtl"] h4 {
  font-family: 'Noto Kufi Arabic', 'DM Serif Display', serif;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: 1.12;
  letter-spacing: -0.025em;
  color: var(--text-primary);
}
h1 { font-size: var(--text-5xl); }
h2 { font-size: var(--text-4xl); }
h3 { font-size: var(--text-3xl); }
h4 { font-size: var(--text-2xl); }

p { line-height: 1.65; color: var(--text-secondary); }
a { color: inherit; text-decoration: none; transition: color var(--dur-fast) var(--ease); }
img { max-width: 100%; height: auto; display: block; }
ul, ol { list-style: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; font-size: inherit; }

.container { width: 100%; max-width: var(--container-max); margin: 0 auto; padding: 0 var(--space-6); }
.section { padding: var(--space-24) 0; position: relative; }

.label {
  display: inline-block;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  padding: 6px 14px;
  border: 2px solid var(--accent);
  border-radius: var(--radius-full);
  margin-bottom: var(--space-4);
}

.text-gradient {
  background: linear-gradient(135deg, var(--accent), var(--accent-warm));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

::selection { background: rgba(var(--burnt-peach-rgb), 0.2); color: var(--text-primary); }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: rgba(var(--twilight-indigo-rgb), 0.15); border-radius: var(--radius-full); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(var(--eggshell-rgb), 0.1); }

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

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
