/* =============================================================================
   STR4TUM DESIGN SYSTEM — TOKENS (v2.0)
   Unified design tokens for a suite of operational dashboards.
   Aesthetic: Anthropic-style — warm-ivory parchment (light) and slate-dark
   (dark), achromatic palette + accent ridotto (link/positive/negative/warn),
   Geist Mono throughout, zero shadow, flat-first radius.
   ============================================================================= */

:root {
  /* ---------------------------------------------------------------------------
     COLOR — BACKGROUNDS & SURFACES (light = default)
     Warm-ivory scale: parchment paper feel, leggermente più chiara in v2.0.
     --------------------------------------------------------------------------- */
  --bg-base:            #fdfdfc;   /* Ivory Light — page background */
  --bg-panel:           #f5f4f1;   /* Ivory Medium — card / panel */
  --bg-panel-elevated:  #eceae4;   /* Oat — hover, nested panel */
  --bg-elevated:        var(--bg-panel-elevated);  /* alias v2.0 */
  --bg-input:           var(--bg-base);
  --bg-code:            var(--bg-panel);

  /* ---------------------------------------------------------------------------
     COLOR — HAIRLINES & BORDERS
     v2.0 unifica i tre border-* in una hairline solid (no più alpha).
     I nomi --border-* sono mantenuti come alias retro-compat.
     --------------------------------------------------------------------------- */
  --hairline:        #e8e6e0;
  --hairline-strong: #0e0d0c;
  --hairline-w:      0.5px;

  --border-subtle:   var(--hairline);
  --border-default:  var(--hairline);
  --border-strong:   var(--hairline-strong);
  --border-focus:    var(--accent-link);    /* input focus ring */

  /* ---------------------------------------------------------------------------
     COLOR — TEXT
     --------------------------------------------------------------------------- */
  --text-primary:       #0e0d0c;   /* Slate Dark — body, headings */
  --text-secondary:     #3a3936;   /* Slate Medium — subtitles */
  --text-muted:         #6e6c66;   /* Cloud Dark — labels, captions */
  --text-dim:           #a8a59c;   /* Cloud Medium — placeholder, disabled */

  /* ---------------------------------------------------------------------------
     COLOR — SEMANTIC ACCENTS (v2.0 — drasticamente ridotti)
     - link     → grey neutro (= text-primary), distinto via underline
     - positive → verde profondo
     - negative → rosso terracotta
     - warn     → ocra
     RIMOSSI: header (Fig), secondary (Cactus), info→link rinominato
     --------------------------------------------------------------------------- */
  --accent-link:        #0e0d0c;
  --accent-positive:    #1f7a3a;
  --accent-negative:    #a8341c;
  --accent-warn:        #9a6b1c;

  /* Dim wash — per row highlight, mai per fill primario */
  --link-dim:           rgba( 14,  13,  12, 0.06);
  --positive-dim:       rgba( 31, 122,  58, 0.08);
  --negative-dim:       rgba(168,  52,  28, 0.08);
  --warn-dim:           rgba(154, 107,  28, 0.10);

  /* ---------------------------------------------------------------------------
     TYPOGRAPHY
     Single monospace family throughout (Anthropic-style identity).
     --------------------------------------------------------------------------- */
  --font-mono: 'Geist Mono', ui-monospace, 'Cascadia Mono', 'SF Mono',
               Menlo, Consolas, monospace;
  --font-print: Arial, Helvetica, sans-serif;

  /* Font sizes — modular scale, 4px-based */
  --fs-xs:   0.6875rem;   /* 11px — tag labels, micro */
  --fs-sm:   0.75rem;     /* 12px — section labels UPPERCASE, captions */
  --fs-base: 0.875rem;    /* 14px — body, tables */
  --fs-md:   1rem;        /* 16px — emphasized body */
  --fs-lg:   1.25rem;     /* 20px — subtitle, card value secondary */
  --fs-xl:   1.75rem;     /* 28px — KPI value */
  --fs-2xl:  2.25rem;     /* 36px — hero number */

  /* Line heights */
  --lh-tight:  1.2;
  --lh-snug:   1.4;
  --lh-normal: 1.6;

  /* Font weights */
  --fw-regular:  400;
  --fw-medium:   500;
  --fw-semibold: 600;
  --fw-bold:     700;

  /* Letter spacing */
  --tracking-tight:  -0.01em;
  --tracking-normal: 0;
  --tracking-wide:   0.05em;
  --tracking-wider:  0.1em;    /* UPPERCASE labels */

  /* ---------------------------------------------------------------------------
     SPACING — 4px base scale
     --------------------------------------------------------------------------- */
  --space-0:    0;
  --space-1:    0.25rem;   /* 4px */
  --space-2:    0.5rem;    /* 8px */
  --space-3:    0.75rem;   /* 12px */
  --space-4:    1rem;      /* 16px */
  --space-5:    1.25rem;   /* 20px */
  --space-6:    1.5rem;    /* 24px */
  --space-8:    2rem;      /* 32px */
  --space-10:   2.5rem;    /* 40px */
  --space-12:   3rem;      /* 48px */
  --space-16:   4rem;      /* 64px */
  --space-20:   5rem;      /* 80px */

  /* ---------------------------------------------------------------------------
     RADIUS — flat-first (Anthropic v2.0)
     Drastically simplified: 0 / 0 / 4 / 8. xl/2xl rimossi (mappati a md/lg).
     --------------------------------------------------------------------------- */
  --r-none:  0;
  --r-sm:    0;       /* tag, input, button, badge */
  --r-md:    4px;     /* card, panel */
  --r-lg:    8px;     /* modal, featured */

  /* Asymmetric radius — opt-in via data-asym="true" sul btn primary */
  --r-cta-asym: 0 0 8px 8px;

  /* ---------------------------------------------------------------------------
     SHADOWS / GLOW — zero, by design.
     --------------------------------------------------------------------------- */
  --shadow-sm:  none;
  --shadow-md:  none;
  --shadow-lg:  none;
  --glow-info:    none;
  --glow-success: none;

  /* ---------------------------------------------------------------------------
     TRANSITIONS
     --------------------------------------------------------------------------- */
  --ease-out:     cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out:  cubic-bezier(0.65, 0, 0.35, 1);
  --duration-fast:    120ms;
  --duration-normal:  200ms;
  --duration-slow:    320ms;

  /* ---------------------------------------------------------------------------
     LAYOUT
     --------------------------------------------------------------------------- */
  --container-max:     1400px;
  --container-padding: var(--space-6);
  --panel-padding:     var(--space-6);
  --panel-padding-sm:  var(--space-4);

  /* ---------------------------------------------------------------------------
     Z-INDEX SCALE
     --------------------------------------------------------------------------- */
  --z-base:      0;
  --z-elevated:  10;
  --z-sticky:    100;
  --z-overlay:   1000;
  --z-modal:     2000;
  --z-toast:     3000;
}

/* =============================================================================
   DARK THEME — Override via [data-theme="dark"] on <html> or <body>
   Slate-dark surfaces + ivory text. Same accent palette + radius + zero shadow.
   ============================================================================= */
:root[data-theme="dark"],
:root[data-theme="dark"] body {
  /* Backgrounds — slate-dark scale */
  --bg-base:            #0a0a0a;
  --bg-panel:           #141413;
  --bg-panel-elevated:  #1f1e1c;
  --bg-input:           var(--bg-base);
  --bg-code:            var(--bg-panel);

  /* Hairlines */
  --hairline:        #1f1e1c;
  --hairline-strong: #f5f4f1;

  /* Text — ivory scale on slate */
  --text-primary:       #f5f4f1;
  --text-secondary:     #c8c6c0;
  --text-muted:         #8a8880;
  --text-dim:           #5a5852;

  /* Accents — dark mode */
  --accent-link:        #f5f4f1;          /* grey neutro = text-primary in dark */
  --accent-positive:    #3ba864;
  --accent-negative:    #d96a52;
  --accent-warn:        #d4a04a;

  /* Dim wash — dark */
  --link-dim:           rgba(245, 244, 241, 0.06);
  --positive-dim:       rgba( 59, 168, 100, 0.12);
  --negative-dim:       rgba(217, 106,  82, 0.12);
  --warn-dim:           rgba(212, 160,  74, 0.12);
}

/* Light theme is the :root default; nessun override esplicito necessario. */

/* Auto-detect system preference: se il browser è dark e nessun data-theme
   è impostato, applica i token dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]),
  :root:not([data-theme]) body {
    --bg-base:            #0a0a0a;
    --bg-panel:           #141413;
    --bg-panel-elevated:  #1f1e1c;
    --bg-input:           var(--bg-base);
    --bg-code:            var(--bg-panel);
    --hairline:        #1f1e1c;
    --hairline-strong: #f5f4f1;
    --text-primary:       #f5f4f1;
    --text-secondary:     #c8c6c0;
    --text-muted:         #8a8880;
    --text-dim:           #5a5852;
    --accent-link:        #f5f4f1;
    --accent-positive:    #3ba864;
    --accent-negative:    #d96a52;
    --accent-warn:        #d4a04a;
    --link-dim:           rgba(245, 244, 241, 0.06);
    --positive-dim:       rgba( 59, 168, 100, 0.12);
    --negative-dim:       rgba(217, 106,  82, 0.12);
    --warn-dim:           rgba(212, 160,  74, 0.12);
  }
}

/* Smooth transition when toggling theme */
html, body, .page, .panel, .kpi, .stato-progetto,
.nav-section, .btn, .table, .input, .tag, .toggle-group {
  transition:
    background-color var(--duration-normal) var(--ease-out),
    border-color var(--duration-normal) var(--ease-out),
    color var(--duration-normal) var(--ease-out);
}

/* =============================================================================
   BASE RESET — Minimal, opinionated
   ============================================================================= */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  font-variant-numeric: tabular-nums;
}

/* Typographic rhythm */
h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-tight);
}

p { margin: 0; }

/* Links — subtle, inherit color by default, underline on hover */
a {
  color: var(--accent-link);
  text-decoration: none;
  transition: opacity var(--duration-fast) var(--ease-out);
}
a:hover { opacity: 0.8; }

/* Code */
code, pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}
