/* MindNorth design tokens — single source of truth.
 *
 * Contemporary editorial wellness.
 *
 * Light mode is warm paper: an ivory page, white paper surfaces, deep ink
 * text, and forest green as the single brand colour. Dark mode is its own
 * design, not an inversion: a deep forest-charcoal ground, slightly raised
 * green-tinted surfaces, and a desaturated sage that carries the brand on a
 * dark ground without glare.
 *
 * Every colour is named by the ROLE it plays, never by its hue, so a theme
 * change is a change of values and never a change of meaning.
 *
 * The service worker, cache names, storage keys and scopes are deliberately
 * NOT touched here — see service-worker.js.
 */

/* ═══════════════ Light theme (the default) ═══════════════ */
:root,
[data-theme='light'] {
    color-scheme: light;

    /* Grounds */
    --bg:              #F7F3EA;   /* warm ivory page */
    --bg-nav:          #FCFAF4;   /* the bar sits a shade lighter than the page */
    --bg-raised:       #FFFFFF;   /* paper surface: cards, panels */
    --bg-sunken:       #EFE9D8;   /* insets, quiet fills, table headers */
    --bg-scrim:        rgba(37, 44, 41, 0.42);

    /* Edges */
    --border:          #E2DAC6;
    --border-strong:   #CFC5AC;
    --border-focus:    #365C4D;

    /* Ink */
    --text:            #252C29;   /* deep ink */
    --text-muted:      #5F6E64;
    --text-faint:      #8B978E;
    --text-invert:     #FFFFFF;

    /* Brand — forest green */
    --accent:          #365C4D;
    --accent-hover:    #2C4B3E;
    --accent-soft:     #E1E9E1;

    /* Supporting palette — used sparingly, to mark a thing's kind */
    --sage:            #7C9A82;
    --sage-soft:       #E4EBE3;
    --terracotta:      #B9634C;
    --terracotta-soft: #F4E3DC;
    --apricot:         #B5743C;
    --apricot-soft:    #F6E6D3;
    --amber:           #9E7328;
    --amber-soft:      #F5EAD3;
    --blue:            #4F7189;
    --blue-soft:       #E2EAEF;

    /* Semantic */
    --danger:          #A84A3E;
    --danger-soft:     #F7E6E3;
    --success:         #365C4D;
    --success-soft:    #E1E9E1;

    /* Elevation — restrained. Only overlays and the bar cast a shadow. */
    --shadow-sm: 0 1px 2px rgba(37, 44, 41, 0.05);
    --shadow-md: 0 4px 14px rgba(37, 44, 41, 0.07);
    --shadow-lg: 0 12px 32px rgba(37, 44, 41, 0.13);
}

/* ═══════════════ Dark theme ═══════════════ */
[data-theme='dark'] {
    color-scheme: dark;

    --bg:              #171D1A;   /* deep forest-charcoal */
    --bg-nav:          #1B2320;
    --bg-raised:       #1F2724;
    --bg-sunken:       #141A17;
    --bg-scrim:        rgba(0, 0, 0, 0.58);

    --border:          #2F3A34;
    --border-strong:   #45524A;
    --border-focus:    #A6C9B2;

    --text:            #E9EFEA;
    --text-muted:      #A3B1A7;
    --text-faint:      #78867C;
    --text-invert:     #171D1A;

    --accent:          #8FB79E;   /* sage — legible on a dark ground */
    --accent-hover:    #A6C9B2;
    --accent-soft:     #24322B;

    --sage:            #8FA991;
    --sage-soft:       #25302A;
    --terracotta:      #D08368;
    --terracotta-soft: #33231D;
    --apricot:         #DCA878;
    --apricot-soft:    #322719;
    --amber:           #D3A75E;
    --amber-soft:      #30271A;
    --blue:            #8FB0C6;
    --blue-soft:       #1D272D;

    --danger:          #D4796A;
    --danger-soft:     #31201D;
    --success:         #8FB79E;
    --success-soft:    #24322B;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.30);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.36);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.52);
}

/* ═══════════════ High-contrast theme ═══════════════ */
[data-theme='contrast'] {
    color-scheme: dark;

    --bg:              #000000;
    --bg-nav:          #000000;
    --bg-raised:       #0A0A0A;
    --bg-sunken:       #141414;
    --bg-scrim:        rgba(0, 0, 0, 0.75);

    --border:          #FFFFFF;
    --border-strong:   #FFFFFF;
    --border-focus:    #FFD400;

    --text:            #FFFFFF;
    --text-muted:      #D8D8D8;
    --text-faint:      #B0B0B0;
    --text-invert:     #000000;

    --accent:          #FFD400;
    --accent-hover:    #FFE14D;
    --accent-soft:     #2A2400;

    --sage:            #00E676;
    --sage-soft:       #00240F;
    --terracotta:      #FF9E7D;
    --terracotta-soft: #2A1206;
    --apricot:         #FFB366;
    --apricot-soft:    #2A1A00;
    --amber:           #FFD400;
    --amber-soft:      #2A2400;
    --blue:            #6EAAFF;
    --blue-soft:       #001A2E;

    --danger:          #FF5C5C;
    --danger-soft:     #2A0000;
    --success:         #00E676;
    --success-soft:    #00240F;

    --shadow-sm: none;
    --shadow-md: none;
    --shadow-lg: 0 0 0 2px #FFD400;
}

/* ═══════════════ Compatibility aliases ═══════════════
 * The role names above are the vocabulary the stylesheet uses. These older
 * names are still referenced by page markup, by inline styles and by the
 * JavaScript that reads theme colours for the charts.
 *
 * They are aliases, not a second palette: each one points at a role, so
 * there is still exactly one place where a colour is decided. Because a
 * custom property is substituted where it is used, one block here serves
 * all three themes.
 *
 * A custom property that resolves to nothing is not an error — it is
 * simply unset, and the element that uses it falls back to its own default.
 * That is how the charts lost their theme colour and fell back to the
 * charting library's purple, so the aliases matter.
 */
:root {
    --color-bg-primary:      var(--bg);
    --color-bg-surface:      var(--bg-raised);
    --color-bg-secondary:    var(--bg-sunken);
    --color-bg-surface-soft: var(--bg-sunken);
    --color-border:          var(--border);
    --color-border-soft:     var(--border);
    --color-brand:           var(--accent);
    --color-brand-bright:    var(--accent-hover);
    --color-brand-soft:      var(--accent-soft);
    --color-text:            var(--text);
    --color-text-muted:      var(--text-muted);
    --color-text-soft:       var(--text-faint);
    --color-danger:          var(--danger);
    --color-warning:         var(--amber);
    --color-success:         var(--success);
    --color-accent-sage:     var(--sage);
    --color-accent-terracotta: var(--terracotta);
    --color-accent-apricot:  var(--apricot);
    --color-accent-dusty-blue: var(--blue);
    --color-accent-gold:     var(--amber);
    --color-accent-teal:     var(--blue);
    --color-accent-coral:    var(--terracotta);
}

/* ═══════════════ Typography ═══════════════ */
:root {
    /* A system serif for display type, a system sans for everything else.
       Both are already on the device: nothing is fetched from a third party,
       so the app stays fully offline and discloses no IP address. */
    --font-display: ui-serif, 'Georgia Pro', Georgia, 'Times New Roman', serif;
    --font-ui: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;

    --fs-xs:   0.78rem;
    --fs-sm:   0.875rem;
    --fs-base: 1rem;
    --fs-md:   1.08rem;
    --fs-lg:   1.3rem;
    --fs-xl:   1.65rem;
    --fs-2xl:  2.1rem;

    --lh-tight: 1.2;
    --lh-body:  1.6;

    --tracking-wide: 0.14em;
    --tracking-tight: -0.01em;
}

/* ═══════════════ Space ═══════════════ */
:root {
    --sp-1: 0.25rem;
    --sp-2: 0.5rem;
    --sp-3: 0.75rem;
    --sp-4: 1rem;
    --sp-5: 1.25rem;
    --sp-6: 1.5rem;
    --sp-8: 2rem;
    --sp-10: 2.5rem;
    --sp-12: 3rem;

    /* Page widths — a small, deliberate set. */
    --page-max: 68rem;         /* the default reading + working column */
    --page-max-narrow: 46rem;  /* long-form reading (journal, faq, about) */
    --page-max-wide: 76rem;    /* data-dense screens (insights) */
    --gutter: var(--sp-5);
    --section-gap: var(--sp-8);
}

/* ═══════════════ Shape ═══════════════ */
:root {
    --r-sm: 5px;      /* inputs, small controls */
    --r-md: 8px;      /* buttons, badges */
    --r-lg: 12px;     /* cards, panels */
    --r-pill: 999px;  /* used only for tags and avatars, never for buttons */
}
/* Cohesive compass palette. Existing theme preferences remain intact. */
:root{--font-display:var(--font-ui);--lh-tight:1.2;--tracking-tight:-.025em}
:root:not([data-theme]),[data-theme='light']{--bg:#f2f7f4;--bg-nav:#f9fcfa;--bg-raised:#ffffff;--bg-sunken:#e8f1ec;--text:#183c35;--text-muted:#4f6c62;--text-faint:#5e766d;--accent:#0e5a53;--accent-hover:#094941;--accent-soft:#deeee5;--border:#d6e4dc;--border-strong:#adc5b8;--border-focus:#0e5a53}
[data-theme='dark']{--bg:#122829;--bg-nav:#162e2e;--bg-raised:#1b3735;--bg-sunken:#112a25;--text:#eef7f1;--text-muted:#b2c9be;--text-faint:#9bb7a9;--text-invert:#102c25;--accent:#ace0c4;--accent-hover:#c5eddb;--accent-soft:#25473b;--border:#52766b;--border-strong:#547568;--border-focus:#ace0c4}

[data-theme='dark']{--success:#b8e5c4;--warning:#f4d59d;--danger:#ffb7ad;--info:#b7dbea}
