/* =============================================================================
   STR4TUM DESIGN SYSTEM — TOKENS
   Unified design tokens for a suite of operational dashboards.
   Aesthetic: Anthropic-style — warm-ivory parchment (light) and slate-dark
   (dark), achromatic palette + accent (Sky/Olive/Ember/Clay/Fig/Cactus),
   JetBrains Mono throughout, zero shadow, flat-first radius.
   ============================================================================= */

:root {
  /* ---------------------------------------------------------------------------
     COLOR — BACKGROUNDS & SURFACES (light = default)
     Warm-ivory scale: parchment paper feel, not clinical white.
     --------------------------------------------------------------------------- */
  --bg-base:            #faf9f5;   /* Ivory Light — page background */
  --bg-panel:           #f0eee6;   /* Ivory Medium — card / panel */
  --bg-panel-elevated:  #e3dacc;   /* Oat — hover, nested panel */
  --bg-input:           #faf9f5;   /* form controls */
  --bg-code:            #f0eee6;   /* inline code, tag chips */

  /* ---------------------------------------------------------------------------
     COLOR — BORDERS & DIVIDERS
     Slate-dark with alpha for hairlines, full slate for emphasis.
     --------------------------------------------------------------------------- */
  --border-subtle:      rgba(20, 20, 19, 0.08);   /* barely visible */
  --border-default:     rgba(20, 20, 19, 0.18);   /* card borders */
  --border-strong:      #141413;                  /* emphasis */
  --border-focus:       var(--accent-info);       /* input focus ring */

  /* ---------------------------------------------------------------------------
     COLOR — TEXT
     --------------------------------------------------------------------------- */
  --text-primary:       #141413;   /* Slate Dark — body, headings */
  --text-secondary:     #3d3d3a;   /* Slate Medium — subtitles */
  --text-muted:         #87867f;   /* Cloud Dark — labels, captions */
  --text-dim:           #b0aea5;   /* Cloud Medium — placeholder, disabled */

  /* ---------------------------------------------------------------------------
     COLOR — SEMANTIC ACCENTS (Anthropic palette mapping)
     - info     → Sky    (achromatic blue)
     - success  → Olive  (muted green)
     - danger   → Ember  (deep terracotta)
     - warning  → Clay   (terracotta — same family as Ember)
     - header   → Fig    (rose/magenta — replaces purple)
     - secondary → Cactus (pastel teal)
     --------------------------------------------------------------------------- */
  --accent-info:        #6a9bcc;   /* Sky */
  --accent-success:     #788c5d;   /* Olive */
  --accent-danger:      #c6613f;   /* Ember */
  --accent-warning:     #d97757;   /* Clay */
  --accent-header:      #c46686;   /* Fig */
  --accent-secondary:   #bcd1ca;   /* Cactus */

  /* Dim variants — light surface (lower alpha would be invisible) */
  --accent-info-dim:       rgba(106, 155, 204, 0.14);
  --accent-success-dim:    rgba(120, 140,  93, 0.16);
  --accent-danger-dim:     rgba(198,  97,  63, 0.14);
  --accent-warning-dim:    rgba(217, 119,  87, 0.16);
  --accent-header-dim:     rgba(196, 102, 134, 0.14);
  --accent-secondary-dim:  rgba(188, 209, 202, 0.30);

  /* ---------------------------------------------------------------------------
     TYPOGRAPHY
     Single monospace family throughout (Anthropic-style identity for STR4TUM).
     --------------------------------------------------------------------------- */
  --font-mono: 'JetBrains Mono', 'IBM Plex Mono', 'Berkeley Mono', ui-monospace,
               'SF Mono', Menlo, Consolas, monospace;

  /* 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 signature)
     0px on badges/buttons (intentional formal signal); 8px on cards;
     16px on panels/modals; 24px on featured cards.
     --------------------------------------------------------------------------- */
  --radius-none:  0;
  --radius-sm:    0;       /* tags, inputs, badges */
  --radius-md:    0;       /* buttons */
  --radius-lg:    8px;     /* cards (release/kpi) */
  --radius-xl:    16px;    /* panels, modals */
  --radius-2xl:   24px;    /* featured cards */

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

  /* ---------------------------------------------------------------------------
     SHADOWS / GLOW — zero, by design.
     Surface depth = background contrast, not blur fx.
     I token --shadow-* sono dichiarati come `none` come marker esplicito
     "il sistema disabilita le shadow", così chi cerca un token shadow trova
     la regola invece di reinventare un hex. Stesso per --glow-*.
     --------------------------------------------------------------------------- */
  --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:            #141413;   /* Slate Dark */
  --bg-panel:           #1c1c1a;   /* Lifted */
  --bg-panel-elevated:  #2a2a27;   /* Hover / nested */
  --bg-input:           #141413;
  --bg-code:            #1c1c1a;

  /* Borders — ivory alpha */
  --border-subtle:      rgba(250, 249, 245, 0.08);
  --border-default:     rgba(250, 249, 245, 0.16);
  --border-strong:      rgba(250, 249, 245, 0.32);

  /* Text — ivory scale on slate */
  --text-primary:       #faf9f5;   /* Ivory Light */
  --text-secondary:     #e8e6dc;   /* Ivory Dark */
  --text-muted:         #b0aea5;   /* Cloud Medium */
  --text-dim:           #87867f;   /* Cloud Dark */

  /* Dim variants on slate-dark — slightly stronger to be visible */
  --accent-info-dim:       rgba(106, 155, 204, 0.18);
  --accent-success-dim:    rgba(120, 140,  93, 0.20);
  --accent-danger-dim:     rgba(198,  97,  63, 0.18);
  --accent-warning-dim:    rgba(217, 119,  87, 0.20);
  --accent-header-dim:     rgba(196, 102, 134, 0.18);
  --accent-secondary-dim:  rgba(188, 209, 202, 0.16);
}

/* =============================================================================
   LIGHT THEME — explicit
   Equivalente a :root (default). Block esplicito per chiarezza e per chi
   imposta data-theme="light" via toggle: i token sono già nel :root.
   ============================================================================= */
/* :root[data-theme="light"] non serve: il default :root è già il light theme. */

/* Auto-detect system preference: se il browser è dark e nessun data-theme
   è impostato, applica i token dark. Se è light, lascia il default. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]),
  :root:not([data-theme]) body {
    --bg-base:            #141413;
    --bg-panel:           #1c1c1a;
    --bg-panel-elevated:  #2a2a27;
    --bg-input:           #141413;
    --bg-code:            #1c1c1a;
    --border-subtle:      rgba(250, 249, 245, 0.08);
    --border-default:     rgba(250, 249, 245, 0.16);
    --border-strong:      rgba(250, 249, 245, 0.32);
    --text-primary:       #faf9f5;
    --text-secondary:     #e8e6dc;
    --text-muted:         #b0aea5;
    --text-dim:           #87867f;
    --accent-info-dim:       rgba(106, 155, 204, 0.18);
    --accent-success-dim:    rgba(120, 140,  93, 0.20);
    --accent-danger-dim:     rgba(198,  97,  63, 0.18);
    --accent-warning-dim:    rgba(217, 119,  87, 0.20);
    --accent-header-dim:     rgba(196, 102, 134, 0.18);
    --accent-secondary-dim:  rgba(188, 209, 202, 0.16);
  }
}

/* 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-feature-settings: 'ss01', 'cv01'; /* stylistic alternates in JetBrains Mono */
}

/* 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-info);
  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;
}
