/*
 * Stoei Core — settings (design tokens) for websites.
 *
 * Every look value lives here, once. Components (base.css, web.css,
 * recipes/) only read these names; they never set a color, font, size,
 * corner or space of their own. To restyle a site, a developer overrides
 * these names in the site's theme file (e.g. site.css). Nothing else.
 *
 * Three levels ("tiers"):
 *   1. Scales:   raw steps (space, text size, corner rounding, font stacks).
 *   2. Meanings: what a value is for (text color, card corner, body text).
 *                They point at the scales. A theme mostly changes these.
 *   3. Component settings: a few per-component knobs (button height,
 *                field padding), set at the end of this file. Apps set
 *                them in their theme (see themes/app-starter.css).
 *
 * Light and dark: each color is written once as light-dark(light, dark).
 * The page follows the device until the visitor uses the switch, which sets
 * data-theme="light" or "dark" on <html>. A theme never touches that part.
 *
 * Full list with what each setting changes: docs/THEME-SETTINGS.md.
 */

/* ---------- Light and dark switching (do not override) ---------- */

:root { color-scheme: light dark; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

:root {
  /* ---------- Tier 1: scales ---------- */

  /* Space: 4px grid. */
  --st-space-1: 0.25rem;  /*  4px */
  --st-space-2: 0.5rem;   /*  8px */
  --st-space-3: 0.75rem;  /* 12px */
  --st-space-4: 1rem;     /* 16px */
  --st-space-5: 1.25rem;  /* 20px */
  --st-space-6: 1.5rem;   /* 24px */
  --st-space-7: 2rem;     /* 32px */
  --st-space-8: 2.5rem;   /* 40px */
  --st-space-9: 3rem;     /* 48px */
  --st-space-10: 4rem;    /* 64px */
  --st-space-11: 5rem;    /* 80px */

  /* Text sizes. */
  --st-text-0: 0.625rem;    /* 10px: tiny labels in app sidebars only */
  --st-text-1: 0.75rem;     /* 12px */
  --st-text-2: 0.8125rem;   /* 13px */
  --st-text-3: 0.875rem;    /* 14px */
  --st-text-4: 0.9375rem;   /* 15px */
  --st-text-5: 1rem;        /* 16px */
  --st-text-6: 1.0625rem;   /* 17px */
  --st-text-7: 1.125rem;    /* 18px */
  --st-text-8: 1.25rem;     /* 20px */
  --st-text-9: 1.375rem;    /* 22px */
  --st-text-10: 1.5rem;     /* 24px */
  --st-text-11: 1.625rem;   /* 26px */
  --st-text-12: 1.75rem;    /* 28px */
  --st-text-13: 2rem;       /* 32px */
  --st-text-14: 2.375rem;   /* 38px */

  /* Corner rounding. */
  --st-radius-1: 4px;
  --st-radius-2: 6px;
  --st-radius-3: 8px;
  --st-radius-4: 10px;
  --st-radius-5: 12px;
  --st-radius-6: 14px;
  --st-radius-7: 18px;
  --st-radius-full: 999px;

  /* Shadows: small (buttons), medium (menus, cards that float), large (dialogs). */
  --st-shadow-1: 0 1px 2px light-dark(rgb(20 16 12 / 0.06), rgb(0 0 0 / 0.35));
  --st-shadow-2: 0 6px 20px light-dark(rgb(20 16 12 / 0.1), rgb(0 0 0 / 0.45));
  --st-shadow-3: 0 24px 60px light-dark(rgb(20 16 12 / 0.18), rgb(0 0 0 / 0.6));

  /* Font stacks. */
  --st-font-sans: system-ui, sans-serif;
  --st-font-serif: Georgia, serif;
  --st-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* ---------- Tier 2: meanings ---------- */

  /* Colors: light-dark(light mode, dark mode). Neutral defaults, so any
     page is readable before a theme exists. */
  --st-color-bg: light-dark(#FFFFFF, #141414);              /* page background */
  --st-color-surface: light-dark(#FFFFFF, #1D1D1D);         /* cards, boxes, fields */
  --st-color-sunk: light-dark(#F4F4F2, #242424);            /* sunken areas: callouts, tags, notes */
  --st-color-text: light-dark(#1A1A1A, #EDEDEA);            /* main text */
  --st-color-text-muted: light-dark(#5A5A5A, #AFAFAA);      /* secondary text */
  --st-color-line: light-dark(#DDDDDA, #363636);            /* borders and dividers */
  --st-color-accent: light-dark(#1F5FBF, #8DB4F0);          /* links, main buttons, highlights */
  --st-color-on-accent: light-dark(#FFFFFF, #141414);       /* text on the accent color */
  --st-color-accent-hover: color-mix(in srgb, var(--st-color-accent) 85%, #000);
  --st-color-ok: light-dark(#2E6B3F, #7CC48F);              /* success, "open now" */
  --st-color-bad: light-dark(#A3271F, #F08A80);             /* errors, "closed" */
  --st-color-band: light-dark(#1E2A33, #1E2A33);            /* header, hero, footer background */
  --st-color-on-band: light-dark(#F2F2EF, #F2F2EF);         /* text on the band */
  --st-color-band-accent: light-dark(#E8A462, #E8A462);     /* highlights on the band; focus ring */
  --st-color-featured: light-dark(#FFF6EC, #2A2018);        /* featured card background */
  --st-color-placeholder: light-dark(#E6E3DE, #2C2C2A);     /* empty photo or map box */
  --st-color-on-placeholder: light-dark(#5C5850, #B0ADA6);  /* text and icons on it */
  --st-color-focus: var(--st-color-accent);                 /* keyboard focus ring */

  /* More colors, mainly for apps (stoei.css, app-shell.css). Defaults are
     worked out from the colors above, so a site never has to set them. */
  --st-color-raised: var(--st-color-surface);               /* popovers, dialogs, fields */
  --st-color-line-strong: color-mix(in srgb, var(--st-color-line), var(--st-color-text) 25%); /* field borders, outline buttons */
  --st-color-text-soft: var(--st-color-text);               /* long body text in apps */
  --st-color-text-faint: color-mix(in srgb, var(--st-color-text-muted), var(--st-color-bg) 25%); /* disabled, done */
  --st-color-eyebrow: var(--st-color-text-muted);           /* small uppercase labels */
  --st-color-accent-tint: color-mix(in srgb, var(--st-color-accent) 12%, var(--st-color-surface)); /* soft accent background */
  --st-color-accent-fill: var(--st-color-accent);           /* solid buttons, active nav */
  --st-color-accent-fill-hover: var(--st-color-accent-hover);
  --st-color-warn: light-dark(#8A6317, #D4AA5C);            /* warnings */
  --st-color-info: light-dark(#3D5F7A, #8FB3CF);            /* notes, "for your information" */
  --st-color-bad-hover: color-mix(in srgb, var(--st-color-bad) 85%, var(--st-color-text));
  --st-color-ok-tint: color-mix(in srgb, var(--st-color-ok) 12%, var(--st-color-surface));
  --st-color-warn-tint: color-mix(in srgb, var(--st-color-warn) 12%, var(--st-color-surface));
  --st-color-bad-tint: color-mix(in srgb, var(--st-color-bad) 12%, var(--st-color-surface));
  --st-color-info-tint: color-mix(in srgb, var(--st-color-info) 12%, var(--st-color-surface));
  --st-color-ok-fill: var(--st-color-ok);                   /* solid status badges and banners */
  --st-color-warn-fill: var(--st-color-warn);
  --st-color-bad-fill: var(--st-color-bad);
  --st-color-info-fill: var(--st-color-info);
  --st-color-backdrop: light-dark(rgb(20 20 18 / 0.38), rgb(0 0 0 / 0.6)); /* behind a dialog */

  /* App sidebar (app-shell.css; the admin sets its own in admin-theme.css).
     Defaults follow the band (header) colors. "on-" means text on it. */
  --st-color-sidebar: var(--st-color-band);
  --st-color-on-sidebar: var(--st-color-on-band);
  --st-color-on-sidebar-strong: var(--st-color-on-band);       /* logo, headings */
  --st-color-on-sidebar-muted: color-mix(in srgb, var(--st-color-on-band) 70%, var(--st-color-band));
  --st-color-on-sidebar-accent: var(--st-color-band-accent);   /* accent text and icons */
  --st-color-on-sidebar-bad: light-dark(#F08A80, #F08A80);     /* sign out, delete */
  --st-color-sidebar-line: color-mix(in srgb, var(--st-color-on-band) 12%, var(--st-color-band));
  --st-color-sidebar-hover: color-mix(in srgb, var(--st-color-on-band) 8%, transparent);
  --st-color-sidebar-active: var(--st-color-accent-fill);
  --st-color-on-sidebar-active: var(--st-color-on-accent);

  /* Fonts. */
  --st-font-body: var(--st-font-sans);
  --st-font-display: var(--st-font-serif);     /* headings, logo, card titles */

  /* Text sizes by job. */
  --st-text-hero: clamp(2.375rem, 5.5vw, 4rem);     /* home page title */
  --st-text-h1: clamp(2.125rem, 4.5vw, 3.25rem);    /* page titles */
  --st-text-h2: var(--st-text-13);
  --st-text-h3: var(--st-text-9);
  --st-text-lead: 1.1875rem;                        /* intro under a title, 19px (approved mockups) */
  --st-text-body: var(--st-text-6);
  --st-text-prose: var(--st-text-lead);             /* article and page text */
  --st-text-small: var(--st-text-4);
  --st-text-caption: var(--st-text-3);              /* hints, captions, dates */
  --st-text-label: var(--st-text-2);                /* eyebrows, small capitals */
  --st-text-logo: clamp(1.25rem, 6vw, 1.625rem);
  --st-text-card-title: var(--st-text-9);
  --st-text-box-title: var(--st-text-11);           /* "Nothing found", "Sent" boxes */
  --st-text-code: 0.9em;                            /* code and tables inside text: a bit smaller than the text around */

  /* Line height, weight and letter spacing. */
  --st-leading-body: 1.55;
  --st-leading-prose: 1.7;
  --st-leading-heading: 1.15;
  --st-leading-title: 1.08;          /* h1 and page titles */
  --st-leading-tight: 1.2;           /* h3, card titles, buttons */
  --st-weight-heading: 600;
  --st-weight-strong: 600;           /* buttons, labels, links in lists */
  --st-tracking-heading: -0.01em;
  --st-tracking-title: -0.02em;
  --st-tracking-label: 0.08em;       /* eyebrows, small capitals */

  /* Shadows by job. */
  --st-shadow-raised: var(--st-shadow-2);          /* menus, sign-in card */
  --st-shadow-dialog: var(--st-shadow-3);          /* dialogs */
  --st-ring-field: 0 0 0 3px color-mix(in srgb, var(--st-color-accent) 22%, transparent); /* field in use */

  /* Corners by job. */
  --st-radius-card: var(--st-radius-6);
  --st-radius-control: var(--st-radius-4);          /* buttons, fields */
  --st-radius-big: var(--st-radius-7);              /* callouts, wide photos */
  --st-radius-pill: var(--st-radius-full);
  --st-radius-focus: var(--st-radius-1);

  /* Layout and sizes. */
  --st-container: 75rem;           /* widest content, 1200px */
  --st-measure-wide: 56.25rem;     /* search results, 900px */
  --st-measure: 47.5rem;           /* narrow pages, article heads, 760px */
  --st-measure-reading: 42.5rem;   /* reading column, 680px */
  --st-gutter: var(--st-space-6);  /* side space of the page */
  --st-scroll-offset: 96px;        /* room above a section reached by a #link */
  --st-touch: 44px;                /* smallest tap target */
  --st-control-height: 48px;       /* buttons and fields */
  --st-control-height-sm: 36px;    /* tags, check boxes, small buttons */
  --st-control-height-lg: 52px;    /* the big search box */
  --st-line-width: 1px;            /* borders */
  --st-focus-width: 3px;
  --st-focus-offset: 2px;
  --st-focus-ring: var(--st-focus-width) solid var(--st-color-focus);
  --st-motion: 0.15s ease;         /* color changes on hover */
  --st-motion-spin: 0.8s;          /* one turn of a loading spinner */
  --st-opacity-disabled: 0.5;      /* buttons and fields that can't be used */
  --st-icon-stroke: 2px;           /* line width of the loading ring */
  --st-icon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E"); /* tick on a "Saved" button */
  --st-textarea-height: 7.5rem;    /* a text box's starting height, 120px */
  --st-color-line-hover: color-mix(in srgb, var(--st-color-line-strong), var(--st-color-text) 30%); /* field border on hover */
  --st-color-icon-line: color-mix(in srgb, currentColor 30%, transparent);  /* ring of round icon buttons and the light/dark switch */
  --st-color-icon-hover: color-mix(in srgb, currentColor 10%, transparent); /* their hover; both follow the text color around them */

  /* ---------- Tier 3: component settings ----------
     Buttons and fields (controls.css). Websites keep these defaults; the app
     starter theme sets the compact app sizes. Size classes (.st-btn--sm,
     .st-btn--lg) change the button ones on that button only. */
  --st-button-height: var(--st-control-height);
  --st-button-pad: var(--st-space-6);              /* space left and right of the words */
  --st-button-text: var(--st-text-body);
  --st-button-weight: var(--st-weight-strong);
  --st-button-secondary-bg: var(--st-color-surface);
  --st-button-secondary-text: var(--st-color-text);
  --st-button-secondary-line: var(--st-color-line);
  --st-button-secondary-hover-bg: var(--st-color-surface);
  --st-field-height: var(--st-control-height);
  --st-field-pad: var(--st-space-4);

  /* Error page (error.css): "Page not found", "Something went wrong". */
  --st-error-width: var(--st-measure-reading);     /* widest the words get */
  --st-error-code-text: var(--st-text-hero);       /* the big 404 or 500 */
  --st-error-code-color: var(--st-color-accent);
  --st-error-title-text: var(--st-text-h2);
}

@media (max-width: 480px) {
  :root { --st-gutter: var(--st-space-5); --st-text-h2: var(--st-text-12); }
}
