/*
 * FogForge design values (docs/design/02-design-system.md section 2 is the source; docs/adr/0018).
 * Load this file FIRST: its first rule fixes the order of the cascade layers for the whole page. A later layer always wins
 * over an earlier one, whatever the selector. Plain CSS without a layer (the old app.css and shell.css) wins over every layer.
 *
 * Three steps of tokens:
 *   1. palette   --ff-color-*   raw values, used ONLY in this file and in themes/
 *   2. semantic  --ff-bg, --ff-text, ...  the names from 02 section 2; components and pages use only these
 *   3. component --ff-<block>-<property>  public knobs with a fallback in components.css (list below)
 *
 * THEME TOKENS (themes/<site>.css may set only these semantic tokens, in dark AND light, with measured contrast):
 *   --ff-accent --ff-accent-hover --ff-accent-active --ff-accent-text --ff-on-accent --ff-focus
 *   --ff-radius-control --ff-radius-card --ff-radius-panel --ff-border-width
 *   --ff-font-display --ff-tracking-display --ff-content-max
 *   --ff-space-1 --ff-space-2 --ff-space-3 --ff-space-4 --ff-space-6 --ff-space-8 --ff-space-12
 *   and every palette token --ff-color-* and every component token below.
 *
 * COMPONENT TOKENS (public, optional; each has a fallback to a semantic token):
 *   --ff-button-font-size       button text size
 *   --ff-button-weight          button font weight
 *   --ff-button-tracking        letter spacing of the button text
 *   --ff-button-transform       text-transform of the button text
 *   --ff-label-font             font family of field labels
 *   --ff-label-size             size of field labels
 *   --ff-label-tracking         letter spacing of field labels
 *   --ff-label-transform        text-transform of field labels
 *   --ff-label-color            colour of field labels
 *   --ff-input-size             text size inside fields (keep at 16px or more: iOS zooms smaller ones)
 *   --ff-input-tracking         letter spacing inside fields
 *   --ff-check-size             size of the checkbox
 *   --ff-check-label-size       size of the checkbox text
 *   --ff-check-label-tracking   letter spacing of the checkbox text
 *   --ff-card-bg                card background
 *   --ff-card-blur              blur behind a glass card (needs a translucent --ff-card-bg)
 *   --ff-card-padding           inner space of the card
 *   --ff-card-width             maximum width of the card
 *   --ff-wordmark-font          font family of the wordmark
 *   --ff-wordmark-size          size of the wordmark
 *   --ff-wordmark-tracking      letter spacing of the wordmark
 *   --ff-spark-size             width and height of the spark mark
 */
@layer ff.tokens, ff.theme, ff.base, ff.components, ff.shell, ff.page, app, page;

@layer ff.tokens {
  :root {
    color-scheme: dark;

    /* Palette, dark (names from 01-marke.md section 5) */
    --ff-color-obsidian: #0B0E11;
    --ff-color-charcoal: #141A1F;
    --ff-color-graphite: #202930;
    --ff-color-slate: #33414B;
    --ff-color-steel: #64747F;
    --ff-color-fog: #A9B6BE;
    --ff-color-mist: #DDE3E6;
    --ff-color-ash: #8494A0;
    --ff-color-ember: #E2A34D;
    --ff-color-ember-hover: #F3BD70;
    --ff-color-ember-deep: #A66E26;
    --ff-color-critical: #ED7272;
    --ff-color-success: #65C6A1;

    /* Palette, light variant (02 section 2) */
    --ff-color-paper: #F4F6F7;
    --ff-color-white: #FFFFFF;
    --ff-color-cloud: #EAEEF0;
    --ff-color-haze: #D5DCE0;
    --ff-color-pewter: #8796A1;
    --ff-color-ink-muted: #4E5D68;
    --ff-color-ink-placeholder: #5F6E79;
    --ff-color-ember-ink: #8A5A14;
    --ff-color-critical-ink: #B42318;
    --ff-color-success-ink: #13795B;

    /* Surfaces */
    --ff-bg: var(--ff-color-obsidian);
    --ff-surface: var(--ff-color-charcoal);
    --ff-surface-hover: var(--ff-color-graphite);
    --ff-divider: var(--ff-color-slate);
    --ff-border-control: var(--ff-color-steel);

    /* Text */
    --ff-text: var(--ff-color-mist);
    --ff-text-muted: var(--ff-color-fog);
    --ff-text-placeholder: var(--ff-color-ash);

    /* Accent */
    --ff-accent: var(--ff-color-ember);
    --ff-accent-hover: var(--ff-color-ember-hover);
    --ff-accent-active: var(--ff-color-ember-deep);
    --ff-accent-text: var(--ff-color-ember);
    --ff-on-accent: var(--ff-color-obsidian);

    /* States */
    --ff-danger: var(--ff-color-critical);
    --ff-on-danger: var(--ff-color-obsidian);
    --ff-success: var(--ff-color-success);
    --ff-focus: 0 0 0 3px rgb(226 163 77 / 45%);

    /* Additions of the shared CSS (not in 02 section 2 as a block of their own; documented in 02 "Theme-Vertrag") */
    --ff-surface-glass: rgb(20 26 31 / 72%);
    --ff-scrim: rgb(11 14 17 / 70%);

    /* Charts (Finance), all at least 6.7 on surface, always with a label */
    --ff-chart-1: #E2A34D;
    --ff-chart-2: #8FB3C9;
    --ff-chart-3: #B39DDB;
    --ff-chart-4: #D98E73;
    --ff-chart-5: #C9C2B0;
    --ff-chart-6: #7CC4B0;

    /* Type (files are served from the own server, see fonts.css) */
    --ff-font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --ff-font-mono: "IBM Plex Mono", ui-monospace, monospace;
    --ff-font-display: "Michroma", var(--ff-font-ui);
    --ff-tracking-display: 0.32em;
    --ff-tracking-label: 0.2em;
    --ff-text-sm: 0.875rem;
    --ff-text-md: 1rem;
    --ff-text-lg: 1.25rem;
    --ff-text-xl: 1.75rem;

    /* Shape */
    --ff-radius-control: 6px;
    --ff-radius-card: 8px;
    --ff-radius-panel: 10px;
    --ff-border-width: 1px;
    --ff-target-min: 44px;
    --ff-content-max: 1200px;
    --ff-page-pad: clamp(16px, 4vw, 40px);

    /* Space */
    --ff-space-1: 4px;
    --ff-space-2: 8px;
    --ff-space-3: 12px;
    --ff-space-4: 16px;
    --ff-space-6: 24px;
    --ff-space-8: 32px;
    --ff-space-12: 48px;

    /* Motion */
    --ff-duration: 160ms;
  }

  /* Light variant: prepared (ADR 0009); switch and sign-off come with R1.5 */
  :root[data-theme="light"] {
    color-scheme: light;
    --ff-bg: var(--ff-color-paper);
    --ff-surface: var(--ff-color-white);
    --ff-surface-hover: var(--ff-color-cloud);
    --ff-divider: var(--ff-color-haze);
    --ff-border-control: var(--ff-color-pewter);
    --ff-text: var(--ff-color-charcoal);
    --ff-text-muted: var(--ff-color-ink-muted);
    --ff-text-placeholder: var(--ff-color-ink-placeholder);
    --ff-accent: var(--ff-color-ember);
    --ff-accent-text: var(--ff-color-ember-ink);
    --ff-on-accent: var(--ff-color-charcoal);
    --ff-danger: var(--ff-color-critical-ink);
    --ff-on-danger: var(--ff-color-white);
    --ff-success: var(--ff-color-success-ink);
    --ff-surface-glass: rgb(255 255 255 / 80%);
    --ff-scrim: rgb(244 246 247 / 70%);
  }
}
