/*
 * آيات — design tokens, three layers: primitive → semantic → component.
 * System: Elaya (landing-page-design + redesign-existing-projects).
 *  - Owner decision 2026-11-29: the neutral gray ground read as faded. The ground is now deep
 *    emerald (dark) or parchment (light) with one large shamsa medallion behind the page, and gold is a
 *    real second colour for ornaments. Cards stay flat.
 *  - Type sizes on the Tailwind scale, spacing on 0 2 4 8 12 16 24 32 40 48 64 80 96,
 *    radius on Tailwind steps, one easing curve (0.22, 1, 0.36, 1), 300ms colour, 500ms movement.
 *  - One UI typeface. The approved Latin families (Geist, Manrope, Poppins) have no Arabic
 *    letters, so the UI keeps IBM Plex Sans Arabic for both scripts. Amiri Quran is used only
 *    for the Quran text itself, where a mushaf face is functionally required.
 * Components read semantic or component tokens only, never a raw value.
 */

/* === PRIMITIVES ============================================================ */
:root {
  --gray-0: #000000;
  --gray-180: #181818;
  --gray-1f: #1f1f1f;
  --gray-27: #272727;
  --gray-31: #313131;
  --gray-66: #666666;
  --gray-9b: #9b9b9b;
  --white: #ffffff;

  --emerald-900: #083526;
  --emerald-800: #0a4633;
  --emerald-700: #0e5a43;
  --emerald-300: #86d3b4;
  --emerald-200: #b4e4cf;

  --red-700: #9a2b2b;
  --red-300: #f3a59d;

  --white-rgb: 255 255 255;
  --black-rgb: 0 0 0;

  /* Spacing scale: 0 2 4 8 12 16 24 32 40 48 64 80 96 */
  --space-0: 0;
  --space-px2: 0.125rem;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-6-5: 2.5rem;
  --space-7: 3rem;
  --space-8: 4rem;
  --space-9: 5rem;
  --space-10: 6rem;

  /* Radius: Tailwind steps only */
  --radius-xs: 0.25rem;  /* rounded */
  --radius-sm: 0.5rem;   /* rounded-lg */
  --radius-md: 0.75rem;  /* rounded-xl: controls, rows, inputs */
  --radius-lg: 1rem;     /* rounded-2xl: cards on phones */
  --radius-xl: 1.5rem;   /* rounded-3xl: slabs, dialogs */
  --radius-pill: 9999px; /* rounded-full */

  /* Type families */
  --font-quran: "Amiri Quran", "Amiri", "Scheherazade New", "Traditional Arabic", serif;
  --font-ui: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, "Noto Sans Arabic", sans-serif;
  --font-display: var(--font-ui);

  /* Type scale (Tailwind default). Old token names keep working, snapped down to a step. */
  --text-xs: 0.75rem;     /* 12 / 16 */
  --text-sm: 0.875rem;    /* 14 / 20 */
  --text-base: 1rem;      /* 16 / 24 */
  --text-md: 1.125rem;    /* lg 18 / 28 */
  --text-lg: 1.25rem;     /* xl 20 / 28 */
  --text-xl: 1.5rem;      /* 2xl 24 / 32 */
  --text-2xl: 2.25rem;    /* 4xl 36 / 40 */
  --text-3xl: 3rem;       /* 5xl 48 / 1 */
  --text-4xl: 3.75rem;    /* 6xl 60 / 1 */
  --text-30: 1.875rem;    /* 3xl 30 / 36 */

  --leading-xs: 1rem;
  --leading-sm: 1.25rem;
  --leading-base: 1.5rem;
  --leading-md: 1.75rem;
  --leading-lg: 1.75rem;
  --leading-xl: 2rem;
  --leading-30: 2.25rem;
  --leading-2xl: 2.5rem;
  --leading-3xl: 1;

  /* Weights: no italics, nothing above semibold in this face */
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;

  /* Quran text steps, on the scale, in rem so browser zoom and text scaling still apply.
     The mushaf keeps its own tall leading: Uthmani marks above and below need the room. */
  --quran-step-0: 1.25rem;
  --quran-step-1: 1.5rem;
  --quran-step-2: 1.875rem;
  --quran-step-3: 2.25rem;
  --quran-step-4: 3rem;
  --quran-step-5: 3.75rem;

  /* Motion: one curve, 300ms for colour and opacity, 500ms for movement */
  --duration-fast: 300ms;
  --duration-base: 300ms;
  --duration-move: 500ms;
  --duration-enter: 500ms;
  --duration-reveal: 700ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-nav: var(--ease-out);
  --ease-spring: var(--ease-out);
  --stagger: 60ms;

  /* Layout */
  --measure-reading: 50rem;
  --measure-page: 75rem;     /* 1200px */
  --measure-hero: 42.5rem;   /* 680px */
  --tap: 3rem;               /* 48px touch target, easy for small and older hands */

  /* Z scale */
  --z-backdrop: -1;
  --z-chrome: 40;
  --z-player: 50;
  --z-dialog: 60;
  --z-toast: 70;
  --z-tour: 80;

  /* Blur, used only by the floating bars */
  --blur-chrome: blur(16px) saturate(1.4);
  --blur-panel: blur(0);
  --blur-card: blur(0);
  --blur-bead: blur(0);
}

/* === SEMANTIC: light ======================================================= */
:root,
html[data-theme="light"] {
  color-scheme: light;
  --color-bg: #f6f0e1;
  --color-text: #14201b;
  --color-text-muted: #55635c;
  --color-accent: #0b6b4c;
  --color-accent-hover: #095a40;
  --color-accent-active: #07442f;
  --color-on-accent: var(--white);
  --color-accent-soft: rgb(11 107 76 / 0.12);
  --color-on-accent-soft: var(--emerald-900);
  --color-gold: #8a5d0c;
  --color-danger: var(--red-700);
  --color-ring: #0b6b4c;
  --color-selection: rgb(14 90 67 / 0.2);
  --color-backdrop: rgb(var(--black-rgb) / 0.4);
  --tour-dim: rgb(var(--black-rgb) / 0.6);
  --tour-halo: rgb(14 90 67 / 0.22);

  --shell: rgb(253 250 242 / 0.86);
  --card-top: rgb(255 255 255 / 0.9);
  --card-edge: rgb(11 80 58 / 0.12);
  --card-lip: rgb(255 255 255 / 0.9);
  --card-shadow: 0 1px 2px rgb(40 30 10 / 0.05), 0 24px 48px -30px rgb(40 50 30 / 0.35);
  --button-shadow: inset 0 1px 0 rgb(255 255 255 / 0.25), 0 14px 28px -14px rgb(11 107 76 / 0.7);
  --color-surface: rgb(20 70 48 / 0.07);
  --color-surface-2: rgb(20 70 48 / 0.12);
  --color-surface-raised: #fffdf7;
  --color-border: rgb(var(--black-rgb) / 0.1);
  --color-border-strong: rgb(var(--black-rgb) / 0.32);
  --frame: rgb(var(--black-rgb) / 0.14);
  --shell-shadow: 0 1px 2px rgb(var(--black-rgb) / 0.05), 0 12px 32px -16px rgb(var(--black-rgb) / 0.16);

  --chrome-bg: rgb(251 247 236 / 0.82);
  --hero-from: #10241c;
  --hero-to: #0b6b4c;
  --grain-opacity: 0.035;

  /* Old glass names now point at flat surfaces */
  --glass: var(--shell);
  --glass-strong: var(--shell);
  --glass-sheet: var(--shell);
  --glass-edge: var(--color-border);
  --glass-lip: transparent;
  --glass-sheen: transparent;
  --glass-shadow: var(--shell-shadow);
  --bead: var(--color-surface-raised);
  --bead-shadow: 0 1px 2px rgb(var(--black-rgb) / 0.12);

  --scene-base: var(--color-bg);
  --scene-top: #efe6cf;
  --scene-bottom: #f8f3e6;
  --scene-glow-1: rgb(11 107 76 / 0.2);
  --scene-glow-2: rgb(200 150 40 / 0.2);
  --scene-ink-1: rgb(138 93 12 / 0.34);
  --scene-ink-2: rgb(11 107 76 / 0.2);
  --scene-vignette: rgb(120 100 50 / 0.12);
}

/* === SEMANTIC: dark ======================================================== */
html[data-theme="dark"] {
  color-scheme: dark;
  --color-bg: #050f0b;
  --color-text: #f3f7f4;
  --color-text-muted: #a3b8ae;
  --color-accent: #5fd6a6;
  --color-accent-hover: #86e3bd;
  --color-accent-active: #a9eccf;
  --color-on-accent: var(--gray-0);
  --color-accent-soft: rgb(95 214 166 / 0.16);
  --color-on-accent-soft: var(--white);
  --color-gold: #e0bb6e;
  --color-danger: var(--red-300);
  --color-ring: #5fd6a6;
  --color-selection: rgb(134 211 180 / 0.28);
  --color-backdrop: rgb(var(--black-rgb) / 0.6);
  --tour-dim: rgb(var(--black-rgb) / 0.72);
  --tour-halo: rgb(134 211 180 / 0.22);

  --shell: rgb(11 30 23 / 0.84);
  --card-top: rgb(22 52 41 / 0.9);
  --card-edge: rgb(150 225 190 / 0.11);
  --card-lip: rgb(231 207 149 / 0.28);
  --card-shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 30px 60px -34px rgb(0 0 0 / 0.9);
  --button-shadow: inset 0 1px 0 rgb(255 255 255 / 0.45), 0 14px 32px -14px rgb(95 214 166 / 0.65);
  --color-surface: #132720;
  --color-surface-2: #1b352c;
  --color-surface-raised: #0f211a;
  --color-border: rgb(var(--white-rgb) / 0.08);
  --color-border-strong: rgb(var(--white-rgb) / 0.28);
  --frame: rgb(var(--white-rgb) / 0.12);
  --shell-shadow: 0 1px 2px rgb(var(--black-rgb) / 0.3), 0 16px 40px -20px rgb(var(--black-rgb) / 0.7);

  --chrome-bg: rgb(9 22 17 / 0.8);
  --hero-from: #ffffff;
  --hero-to: #e7cf95;
  --grain-opacity: 0.05;

  --glass: var(--shell);
  --glass-strong: var(--shell);
  --glass-sheet: var(--shell);
  --glass-edge: var(--color-border);
  --glass-shadow: var(--shell-shadow);
  --bead: #1b352c;

  --scene-base: var(--color-bg);
  --scene-top: #0c3024;
  --scene-bottom: #030907;
  --scene-glow-1: rgb(40 170 120 / 0.38);
  --scene-glow-2: rgb(224 187 110 / 0.16);
  --scene-ink-1: rgb(231 207 149 / 0.55);
  --scene-ink-2: rgb(95 214 166 / 0.28);
  --scene-vignette: rgb(0 0 0 / 0.55);
  --bead-shadow: 0 1px 2px rgb(var(--black-rgb) / 0.4);
}

/* === COMPONENT ============================================================= */
:root {
  --page-gutter: var(--space-4);

  --button-height: var(--tap);
  --button-radius: var(--radius-md);
  --button-bg: var(--color-accent);
  --button-bg-hover: var(--color-accent-hover);
  --button-bg-active: var(--color-accent-active);
  --button-fg: var(--color-on-accent);

  --input-height: var(--tap);
  --input-bg: var(--color-surface-raised);
  --input-border: var(--color-border-strong);
  --input-radius: var(--radius-md);

  --dialog-radius: var(--radius-xl);
  --dialog-width: 28rem;

  --topbar-height: 4rem;
  --topbar-gap: var(--space-3);
  --header-height: calc(var(--topbar-height) + 2 * var(--topbar-gap));
  --reader-bar-height: var(--header-height);
  --dock-height: 4rem;

  --quran-size: var(--quran-step-2);
  --quran-leading: 2.3;

  --ayah-mark-fg: var(--color-accent);
  --ayah-active-bg: var(--color-accent-soft);
}

html[data-size="0"] { --quran-size: var(--quran-step-0); }
html[data-size="1"] { --quran-size: var(--quran-step-1); }
html[data-size="2"] { --quran-size: var(--quran-step-2); }
html[data-size="3"] { --quran-size: var(--quran-step-3); }
html[data-size="4"] { --quran-size: var(--quran-step-4); }
html[data-size="5"] { --quran-size: var(--quran-step-5); }

@media (min-width: 48rem) {
  :root {
    --page-gutter: var(--space-6);
    --topbar-gap: var(--space-4);
  }
}
