/* ============================================================
   BASE.CSS — Variabili, reset, tipografia
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Crimson+Pro:ital,wght@0,300;0,400;0,600;1,300;1,400&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Variabili Tema Chiaro ── */
:root {
  /* Colori principali */
  --bg-primary:    #f5f2ee;
  --bg-secondary:  #ede9e3;
  --bg-tertiary:   #e2ddd7;
  --bg-card:       #ffffff;
  --bg-card-hover: #faf8f5;

  /* Testo */
  --text-primary:   #1a1714;
  --text-secondary: #4a4540;
  --text-muted:     #7a736b;
  --text-inverse:   #f5f2ee;

  /* Accenti */
  --accent-primary:   #8b2635;   /* rosso vinaccia */
  --accent-secondary: #c17f3b;   /* oro antico */
  --accent-tertiary:  #2d5a6b;   /* blu grigio */
  --accent-success:   #3a7d44;
  --accent-warning:   #c17f3b;
  --accent-danger:    #8b2635;
  --accent-info:      #2d5a6b;

  /* Bordi */
  --border:        #d4cfc8;
  --border-strong: #b5aea5;
  --border-accent: #8b2635;

  /* Ombre */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg:  0 8px 24px rgba(0,0,0,0.12);
  --shadow-xl:  0 16px 40px rgba(0,0,0,0.14);

  /* Navbar — chiara nel tema chiaro, coerente col resto dell'interfaccia */
  --nav-bg:      #ede9e3;
  --nav-text:    #4a4540;
  --nav-active:  #1a1714;
  --nav-accent:  #8b2635;
  --nav-overlay-weak:   rgba(0,0,0,0.05);
  --nav-overlay-mid:    rgba(0,0,0,0.08);
  --nav-overlay-strong: rgba(0,0,0,0.15);
  --nav-label-color:    rgba(0,0,0,0.35);

  /* Tipografia */
  --font-display: 'Cinzel', serif;
  --font-body:    'Crimson Pro', serif;
  --font-mono:    'JetBrains Mono', monospace;

  /* Spacing */
  --space-xs:  4px;
  --space-sm:  8px;
  --space-md:  16px;
  --space-lg:  24px;
  --space-xl:  32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* Radius */
  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --radius-xl:  16px;
  --radius-full: 9999px;

  /* Transizioni */
  --transition-fast:   150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow:   400ms ease;

  /* Layout */
  --nav-width:     256px;
  --nav-collapsed: 60px;
  --header-height: 56px;
  --dice-size:     52px;
}

/* ── Variabili Tema Scuro ── */
[data-theme="dark"] {
  --bg-primary:    #12100e;
  --bg-secondary:  #1c1916;
  --bg-tertiary:   #252118;
  --bg-card:       #1e1b17;
  --bg-card-hover: #252118;

  --text-primary:   #f0ebe4;
  --text-secondary: #c0b8ae;
  --text-muted:     #9a9088;   /* Fix: era #7a7068 ~3.5:1 contrasto, ora ~4.8:1 WCAG AA */

  --border:        #2e2a24;
  --border-strong: #3e3830;

  --nav-bg:      #0e0c0a;
  --nav-text:    #9a9088;
  --nav-active:  #f0ebe4;
  --nav-overlay-weak:   rgba(255,255,255,0.04);
  --nav-overlay-mid:    rgba(255,255,255,0.08);
  --nav-overlay-strong: rgba(255,255,255,0.15);
  --nav-label-color:    rgba(255,255,255,0.25);

  --shadow-sm:  0 1px 3px rgba(0,0,0,0.30);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.35);
  --shadow-lg:  0 8px 24px rgba(0,0,0,0.40);
  --shadow-xl:  0 16px 40px rgba(0,0,0,0.50);

  --bg-card: #1e1b17;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  transition: background-color var(--transition-normal), color var(--transition-normal);
  overflow-x: hidden;
}

/* ── Tipografia ── */
h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  color: var(--text-primary);
}

h1 { font-size: 1.875rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }
h5 { font-size: 1rem; }

p { margin-bottom: var(--space-md); }
p:last-child { margin-bottom: 0; }

a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--accent-secondary); }

/* ── Utility classi ── */
.text-muted    { color: var(--text-muted); }
.text-sm       { font-size: 0.875rem; }
.text-xs       { font-size: 0.75rem; }
.text-lg       { font-size: 1.125rem; }
.text-xl       { font-size: 1.25rem; }
.text-mono     { font-family: var(--font-mono); }
.text-accent   { color: var(--accent-primary); }
.text-gold     { color: var(--accent-secondary); }
.text-center   { text-align: center; }
.text-right    { text-align: right; }
.font-bold     { font-weight: 700; }
.font-semibold { font-weight: 600; }

.flex          { display: flex; }
.flex-col      { flex-direction: column; }
.flex-wrap     { flex-wrap: wrap; }
.items-center  { align-items: center; }
.items-start   { align-items: flex-start; }
.justify-center{ justify-content: center; }
.justify-between{justify-content: space-between; }
.justify-end   { justify-content: flex-end; }
.gap-xs        { gap: var(--space-xs); }
.gap-sm        { gap: var(--space-sm); }
.gap-md        { gap: var(--space-md); }
.gap-lg        { gap: var(--space-lg); }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

.w-full  { width: 100%; }
.h-full  { height: 100%; }
.hidden  { display: none !important; }
.visible { display: block; }

.badge,
[style*="border-radius:var(--radius-full)"] {
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.badge-primary  { background: var(--accent-primary);   color: #fff; }
.badge-gold     { background: var(--accent-secondary);  color: #fff; }
.badge-blue     { background: var(--accent-tertiary);   color: #fff; }
.badge-success  { background: var(--accent-success);    color: #fff; }
.badge-muted    { background: var(--bg-tertiary);       color: var(--text-muted); }
.badge-warning  { background: var(--accent-warning);    color: #fff; }

/* ── Scrollbar custom ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--accent-primary); }

/* ── Selezione testo ── */
::selection {
  background: var(--accent-primary);
  color: #fff;
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Focus visibile (accessibilità tastiera) ── */
:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}
:focus:not(:focus-visible) {
  outline: none;
}
