/* =====================================================================
   cib — tokens.css
   The "Cib" design language for cib studio. Calm, cool-neutral, one
   colour per app. Three independent axes, each set by one attribute:

     theme     html[data-theme="system|light|dark"]   (default: system)
     contrast  html[data-contrast="normal|more"]       (default: follows OS)
     text size html[data-text="md|lg|xl"]               (Normal / Böyük / Çox böyük)

   An app changes exactly one thing: --accent-hue (and optionally
   --accent-chroma). Every accent colour below is computed from it.
   ===================================================================== */

/* ---------------------------------------------------------------------
   1. App identity: the only lines an app edits
   --------------------------------------------------------------------- */
:root {
  --accent-hue: 255;    /* 0–360. Hesabla 170, Cütünü tap 320, Valyuta 245 */
  --accent-chroma: 1;   /* 0–1.2 colourfulness. The studio itself uses .35 (slate) */
}

/* ---------------------------------------------------------------------
   2. Text size. Everything is in rem, so this scales the whole UI.
   Percentages keep the user's own browser default as the base.
   --------------------------------------------------------------------- */
html { font-size: 100%; }
html[data-text="lg"] { font-size: 112.5%; }  /* Böyük:     body 18px */
html[data-text="xl"] { font-size: 125%; }    /* Çox böyük: body 20px */

/* ---------------------------------------------------------------------
   3. Theme steps. Lightness (L) and chroma (C) per role, in OKLCH.
   Neutrals use a fixed cool hue (255). Accent steps take the app hue.
   --dir says which way "more contrast" pushes a foreground colour.
   --------------------------------------------------------------------- */
:root,
[data-theme="light"] {
  color-scheme: light;
  --dir: -1;
  --n-bg: .975;  --n-surface: 1;  --n-surface-2: .955;  --n-raised: 1;
  --n-border: .9;  --n-border-strong: .62;  --n-stitch: .8;
  --n-text: .23;  --n-muted: .47;  --n-inverse: .25;  --n-on-inverse: .97;

  --a-subtle-l: .965; --a-subtle-c: .022;   /* result panels, quiet wells   */
  --a-tint-l:   .93;  --a-tint-c:   .045;   /* selected backgrounds         */
  --a-line-l:   .8;   --a-line-c:   .08;    /* stitches, accent hairlines   */
  --a-solid-l:  .5;   --a-solid-c:  .13;    /* primary button, icon tile    */
  --a-hover-l:  .44;  --a-hover-c:  .12;
  --a-text-l:   .47;  --a-text-c:   .12;    /* accent text, links, focus    */
  --a-strong-l: .4;   --a-strong-c: .11;    /* key result on subtle panel   */
  --a-on-l:     1;    --a-on-c:     0;      /* text on solid accent         */

  --shadow-1: 0 1px 2px oklch(.25 .02 255 / .06), 0 3px 10px -4px oklch(.25 .02 255 / .14);
  --shadow-2: 0 2px 6px oklch(.25 .02 255 / .06), 0 18px 44px -14px oklch(.25 .02 255 / .3);
  --scrim: oklch(.2 .02 255 / .42);
}

[data-theme="dark"] {
  color-scheme: dark;
  --dir: 1;
  --n-bg: .2;  --n-surface: .24;  --n-surface-2: .28;  --n-raised: .27;
  --n-border: .35;  --n-border-strong: .6;  --n-stitch: .45;
  --n-text: .955;  --n-muted: .78;  --n-inverse: .93;  --n-on-inverse: .22;

  --a-subtle-l: .27;  --a-subtle-c: .025;
  --a-tint-l:   .31;  --a-tint-c:   .05;
  --a-line-l:   .48;  --a-line-c:   .08;
  --a-solid-l:  .8;   --a-solid-c:  .11;
  --a-hover-l:  .86;  --a-hover-c:  .09;
  --a-text-l:   .81;  --a-text-c:   .11;
  --a-strong-l: .87;  --a-strong-c: .09;
  --a-on-l:     .2;   --a-on-c:     .03;

  --shadow-1: 0 1px 2px oklch(0 0 0 / .35), 0 3px 10px -4px oklch(0 0 0 / .45);
  --shadow-2: 0 2px 6px oklch(0 0 0 / .35), 0 18px 44px -12px oklch(0 0 0 / .6);
  --scrim: oklch(.08 .01 255 / .6);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --dir: 1;
    --n-bg: .2;  --n-surface: .24;  --n-surface-2: .28;  --n-raised: .27;
    --n-border: .35;  --n-border-strong: .6;  --n-stitch: .45;
    --n-text: .955;  --n-muted: .78;  --n-inverse: .93;  --n-on-inverse: .22;

    --a-subtle-l: .27;  --a-subtle-c: .025;
    --a-tint-l:   .31;  --a-tint-c:   .05;
    --a-line-l:   .48;  --a-line-c:   .08;
    --a-solid-l:  .8;   --a-solid-c:  .11;
    --a-hover-l:  .86;  --a-hover-c:  .09;
    --a-text-l:   .81;  --a-text-c:   .11;
    --a-strong-l: .87;  --a-strong-c: .09;
    --a-on-l:     .2;   --a-on-c:     .03;

    --shadow-1: 0 1px 2px oklch(0 0 0 / .35), 0 3px 10px -4px oklch(0 0 0 / .45);
    --shadow-2: 0 2px 6px oklch(0 0 0 / .35), 0 18px 44px -12px oklch(0 0 0 / .6);
    --scrim: oklch(.08 .01 255 / .6);
  }
}

/* ---------------------------------------------------------------------
   4. Contrast: "more" pushes every foreground away from its background
   and turns hairlines into 3:1 borders. Works for both themes.
   --------------------------------------------------------------------- */
:root { --push: 0; --focus-width: 3px; --focus-offset: 2px; }

@media (prefers-contrast: more) {
  :root:not([data-contrast="normal"]) {
    --push: .1;
    --n-border: var(--n-border-strong);
    --focus-width: 4px;
    --shadow-1: none;
  }
}
:root[data-contrast="more"],
[data-contrast="more"] {
  --push: .1;
  --n-border: var(--n-border-strong);
  --focus-width: 4px;
  --shadow-1: none;
}

/* ---------------------------------------------------------------------
   5. Colour roles: what components use. Recomputed on any element that
   carries a theme, contrast or accent override (for side-by-side demos).
   --------------------------------------------------------------------- */
:root,
[data-theme],
[data-contrast],
[data-accent] {
  /* neutrals */
  --bg:             oklch(var(--n-bg) .004 255);
  --surface:        oklch(var(--n-surface) .003 255);
  --surface-2:      oklch(var(--n-surface-2) .007 255);
  --surface-raised: oklch(var(--n-raised) .005 255);
  --border:         oklch(var(--n-border) .01 255);
  --border-strong:  oklch(calc(var(--n-border-strong) + var(--dir) * var(--push) * 2) .015 255);
  --stitch:         oklch(calc(var(--n-stitch) + var(--dir) * var(--push) * 2) .012 255);
  --text:           oklch(calc(var(--n-text) + var(--dir) * var(--push)) .015 255);
  --text-muted:     oklch(calc(var(--n-muted) + var(--dir) * var(--push) * 1.5) .015 255);
  --inverse:        oklch(var(--n-inverse) .015 255);
  --on-inverse:     oklch(var(--n-on-inverse) .005 255);

  /* accent: one hue in, nine roles out */
  --accent-subtle:  oklch(var(--a-subtle-l) calc(var(--a-subtle-c) * var(--accent-chroma)) var(--accent-hue));
  --accent-tint:    oklch(var(--a-tint-l) calc(var(--a-tint-c) * var(--accent-chroma)) var(--accent-hue));
  --accent-line:    oklch(calc(var(--a-line-l) + var(--dir) * var(--push) * 3) calc(var(--a-line-c) * var(--accent-chroma)) var(--accent-hue));
  --accent:         oklch(calc(var(--a-solid-l) + var(--dir) * var(--push)) calc(var(--a-solid-c) * var(--accent-chroma)) var(--accent-hue));
  --accent-hover:   oklch(calc(var(--a-hover-l) + var(--dir) * var(--push)) calc(var(--a-hover-c) * var(--accent-chroma)) var(--accent-hue));
  --accent-text:    oklch(calc(var(--a-text-l) + var(--dir) * var(--push)) calc(var(--a-text-c) * var(--accent-chroma)) var(--accent-hue));
  --accent-strong:  oklch(calc(var(--a-strong-l) + var(--dir) * var(--push)) calc(var(--a-strong-c) * var(--accent-chroma)) var(--accent-hue));
  --on-accent:      oklch(calc(var(--a-on-l) - var(--dir) * var(--push)) calc(var(--a-on-c) * var(--accent-chroma)) var(--accent-hue));
  --focus:          var(--accent-text);

  /* status: same steps, fixed hues */
  --success:        oklch(calc(var(--a-text-l) + var(--dir) * var(--push)) var(--a-text-c) 150);
  --success-subtle: oklch(var(--a-subtle-l) var(--a-subtle-c) 150);
  --warning:        oklch(calc(var(--a-text-l) + var(--dir) * var(--push)) var(--a-text-c) 70);
  --warning-subtle: oklch(var(--a-subtle-l) var(--a-subtle-c) 70);
  --danger:         oklch(calc(var(--a-text-l) + var(--dir) * var(--push)) var(--a-text-c) 25);
  --danger-subtle:  oklch(var(--a-subtle-l) var(--a-subtle-c) 25);
  --danger-solid:   oklch(calc(var(--a-solid-l) + var(--dir) * var(--push)) var(--a-solid-c) 25);
  --on-danger:      oklch(calc(var(--a-on-l) - var(--dir) * var(--push)) var(--a-on-c) 25);
}

/* Old browsers without OKLCH (pre-2023): light theme, studio slate accent. */
@supports not (color: oklch(50% 0.1 100)) {
  :root, [data-theme], [data-contrast], [data-accent] {
    color-scheme: light;
    --bg: #f5f7f9; --surface: #ffffff; --surface-2: #edf0f5; --surface-raised: #ffffff;
    --border: #dadee5; --border-strong: #80878f; --stitch: #b9bec6;
    --text: #181d24; --text-muted: #555b63; --inverse: #1d2229; --on-inverse: #f3f5f8;
    --accent-subtle: #f0f4f9; --accent-tint: #e1e9f3; --accent-line: #b2bfd0;
    --accent: #52657d; --accent-hover: #43546a; --accent-text: #4b5c72; --accent-strong: #3a495c;
    --on-accent: #ffffff; --focus: #4b5c72;
    --success: #146d34; --success-subtle: #eaf8ec; --warning: #7e4f00; --warning-subtle: #fdf1e4;
    --danger: #923a37; --danger-subtle: #ffefee; --danger-solid: #a03f3c; --on-danger: #ffffff;
    --shadow-1: 0 1px 2px rgba(20,30,45,.06), 0 3px 10px -4px rgba(20,30,45,.14);
    --shadow-2: 0 2px 6px rgba(20,30,45,.06), 0 18px 44px -14px rgba(20,30,45,.3);
    --scrim: rgba(20,25,35,.42);
  }
}

/* ---------------------------------------------------------------------
   6. Play-area hues (games only, never in the shell). Eight hues spaced
   for colour-blind separation; each card also carries a unique symbol.
   --------------------------------------------------------------------- */
:root {
  --play-1: 25;   /* red    */
  --play-2: 60;   /* orange */
  --play-3: 95;   /* gold   */
  --play-4: 145;  /* green  */
  --play-5: 195;  /* teal   */
  --play-6: 250;  /* blue   */
  --play-7: 295;  /* violet */
  --play-8: 345;  /* pink   */
}

/* ---------------------------------------------------------------------
   7. Type. One family. Rounded but clean, glyph-checked for
   ə Ə ğ ı İ ş ç ö ü ₼ and Cyrillic. System fallback keeps it usable
   (and rounded on Apple devices) when the web font does not load.
   --------------------------------------------------------------------- */
:root {
  --font-sans: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;

  --fs-sm:  .875rem;   --lh-sm:  1.25rem;   /* help text, meta (never below 14px) */
  --fs-md:  1rem;      --lh-md:  1.5rem;    /* body, inputs, buttons              */
  --fs-lg:  1.125rem;  --lh-lg:  1.625rem;  /* list titles, section headings      */
  --fs-xl:  1.375rem;  --lh-xl:  1.875rem;  /* page title inside an app           */
  --fs-2xl: 1.75rem;   --lh-2xl: 2.25rem;   /* the key result                     */
  --fs-3xl: 2.5rem;    --lh-3xl: 2.875rem;  /* studio home only                   */

  --fw-regular: 420;
  --fw-medium: 600;
  --fw-bold: 750;
  --fw-heavy: 850;    /* wordmark only */
  --tracking-tight: -.012em;
}

/* ---------------------------------------------------------------------
   8. Space (4px base), radius, size, layout
   --------------------------------------------------------------------- */
:root {
  --space-0-5: .125rem; --space-1: .25rem; --space-2: .5rem; --space-3: .75rem;
  --space-4: 1rem; --space-5: 1.25rem; --space-6: 1.5rem; --space-8: 2rem;
  --space-10: 2.5rem; --space-12: 3rem; --space-16: 4rem;

  --radius-sm: .625rem;    /* inner parts: segment thumbs, badges   */
  --radius-md: .875rem;    /* controls: buttons, inputs (14px)      */
  --radius-lg: 1.25rem;    /* containers: cards, pockets, sheets    */
  --radius-pill: 999px;    /* chips, switches, progress             */

  --tap-min: 2.75rem;      /* 44px: every control                   */
  --tap: 3rem;             /* 48px: primary controls                */
  --icon: 1.25rem;

  --gutter: 1rem;          /* phone side gutter                     */
  --measure: 40rem;        /* app content column                    */
  --page: 72rem;           /* studio pages                          */
}

/* ---------------------------------------------------------------------
   9. Motion and layers
   --------------------------------------------------------------------- */
:root {
  --dur-fast: 120ms;
  --dur-base: 200ms;
  --dur-slow: 320ms;
  --ease-standard: cubic-bezier(.4, 0, .2, 1);
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-pop: cubic-bezier(.3, 1.35, .5, 1);   /* game feedback only */

  --z-bar: 10;
  --z-sticky: 20;
  --z-sheet: 100;
  --z-toast: 200;
}
@media (prefers-reduced-motion: reduce) {
  :root { --dur-fast: 1ms; --dur-base: 1ms; --dur-slow: 1ms; }
}

/* ---------------------------------------------------------------------
   10. The pocket: the studio's signature shape (viewBox 100 × 100).
   A soft squircle whose top edge dips like a pocket opening, plus the
   stitched seam that follows it. Used as CSS masks so they take any colour.
   --------------------------------------------------------------------- */
:root {
  --pocket-shape: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M0 50C0 11 11 0 33 .6Q50 9 67 .6C89 0 100 11 100 50C100 89 89 100 50 100C11 100 0 89 0 50Z'/%3E%3C/svg%3E");
  --pocket-seam: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M20 17Q50 30 80 17' fill='none' stroke='%23000' stroke-width='4.5' stroke-linecap='round' stroke-dasharray='5 7'/%3E%3C/svg%3E");
  --pocket-outline: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath transform='translate(3.5 3.5) scale(.93)' d='M0 50C0 11 11 0 33 .6Q50 9 67 .6C89 0 100 11 100 50C100 89 89 100 50 100C11 100 0 89 0 50Z' fill='none' stroke='%23000' stroke-width='6.5'/%3E%3C/svg%3E");
}
