/* ════════════════════════════════════════════════════════════════
   STUDIO IRIDE 2100 — DESIGN SYSTEM v3.0
   Spatial · Holographic · AI-native · Time-adaptive
   ════════════════════════════════════════════════════════════════ */

/* ─── TOKENS ─────────────────────────────────────────────────── */
:root {
  /* Core space — graphite neutral */
  --ink-0:     #0e1014;       /* abyss */
  --ink-1:     #13151a;       /* base */
  --ink-2:     #181b21;       /* surface */
  --ink-3:     #1f232b;       /* surface raised */
  --ink-4:     #2c2f39;       /* hairline */

  /* Accents — gold only */
  --violet:        #c2a14e;
  --violet-soft:   #d4b569;
  --violet-deep:   #9a7c3a;
  --aurora:        #d4b569;
  --plasma:        #d4b569;
  --gold:          #c2a14e;
  --gold-soft:     #e0c98a;
  --emerald:       #34d399;
  --electric:      #38bdf8;
  --magenta:       #f472b6;

  /* Glass */
  --glass-thin:    rgba(255,255,255,0.03);
  --glass-base:    rgba(255,255,255,0.05);
  --glass-thick:   rgba(255,255,255,0.07);
  --glass-stroke:  rgba(255,255,255,0.09);
  --glass-stroke-strong: rgba(255,255,255,0.16);

  /* Text */
  --ink-text:      #eef0f4;
  --ink-muted:     rgba(238,240,244,0.6);
  --ink-muted-2:   rgba(238,240,244,0.4);
  --ink-strong:    #ffffff;

  /* Holo gradients — soft gold */
  --holo-aurora: linear-gradient(135deg, #e0c98a, #c2a14e);
  --holo-luxury: linear-gradient(135deg, #e0c98a, #c2a14e);
  --holo-plasma: linear-gradient(135deg, #e0c98a, #c2a14e);
  --holo-iris:   linear-gradient(135deg, #e0c98a, #c2a14e);

  /* Glow — neutralized to soft dark shadow */
  --glow-violet: 0 8px 24px rgba(0,0,0,0.30);
  --glow-gold:   0 8px 24px rgba(0,0,0,0.30);
  --glow-emerald:0 8px 24px rgba(0,0,0,0.30);

  /* Motion */
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-glide:  cubic-bezier(0.22, 1, 0.36, 1);
  --ease-quick:  cubic-bezier(0.4, 0, 0.2, 1);

  /* Radii */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-2xl: 40px;
  --r-pill: 999px;

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;

  /* Typography stack */
  --font-display: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-sans:    'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono:    'Geist Mono', 'JetBrains Mono', ui-monospace, monospace;

  /* Hairline (1px sharp on retina) */
  --hairline: 1px solid var(--glass-stroke);
  --hairline-strong: 1px solid var(--glass-stroke-strong);

  /* Time-of-day adaptive vars (set by JS) */
  --tod-tint-1: var(--gold);
  --tod-tint-2: var(--gold-soft);
}

/* ─── RESET ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-rendering: optimizeLegibility; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-weight: 400;
  color: var(--ink-text);
  background: var(--ink-0);
  font-feature-settings: 'cv11', 'ss01', 'ss03';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  overflow-x: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; }
::selection { background: var(--violet); color: #15171c; }

/* ─── SPATIAL BACKDROP ───────────────────────────────────────── */
/* The whole viewport gets a layered mesh: gradient + noise + parallax orbs */
.v3-spatial {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: var(--ink-1);
  animation: none;
}
.v3-spatial::before {
  content: '';
  position: absolute;
  inset: 0;
  background: none;
}
.v3-spatial::after {
  content: '';
  position: absolute;
  inset: 0;
  background: none;
  pointer-events: none;
}
@keyframes meshDrift {
  0%   { transform: none; }
  100% { transform: none; }
}

/* ─── GLASS PRIMITIVE ────────────────────────────────────────── */
.v3-glass {
  background: var(--ink-2);
  border: 1px solid var(--glass-stroke);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3), 0 10px 30px rgba(0,0,0,0.28);
  position: relative;
  isolation: isolate;
}
.v3-glass--strong {
  background: var(--ink-3);
  border: 1px solid var(--glass-stroke-strong);
}
.v3-glass--caustic::before {
  /* Soft top-edge highlight */
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,0.05) 0%, transparent 30%);
  pointer-events: none;
  z-index: 0;
}
.v3-glass--caustic > * { position: relative; z-index: 1; }

/* ─── HOLO TEXT ──────────────────────────────────────────────── */
.v3-holo-aurora {
  background: none;
  color: var(--ink-text);
  -webkit-text-fill-color: var(--ink-text);
  animation: none;
}
.v3-holo-luxury {
  background: none;
  color: var(--ink-text);
  -webkit-text-fill-color: var(--ink-text);
  animation: none;
}
.v3-holo-plasma {
  background: none;
  color: var(--ink-text);
  -webkit-text-fill-color: var(--ink-text);
  animation: none;
}
@keyframes holoShift {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 0% 50%; }
}

/* ─── TYPOGRAPHY ─────────────────────────────────────────────── */
.v3-display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.v3-display--xl { font-size: clamp(1.9rem, 3.2vw, 2.7rem); }
.v3-display--lg { font-size: clamp(1.6rem, 2.6vw, 2.2rem); }
.v3-display--md { font-size: clamp(1.4rem, 2.2vw, 1.8rem); }

.v3-italic { font-style: italic; }

.v3-eyebrow {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.v3-num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* ─── BUTTONS ────────────────────────────────────────────────── */
.v3-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 11px 18px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: transform 0.18s var(--ease-spring), box-shadow 0.18s var(--ease-glide), background 0.18s;
  white-space: nowrap;
}
.v3-btn:hover { transform: translateY(-1px); }
.v3-btn:active { transform: translateY(0) scale(0.98); }

.v3-btn--primary {
  background: #c2a14e;
  color: #15171c;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.v3-btn--primary:hover { background: #d4b569; box-shadow: 0 4px 12px rgba(0,0,0,0.3); }

.v3-btn--ghost {
  background: var(--glass-base);
  color: var(--ink-text);
  border: 1px solid var(--glass-stroke);
  backdrop-filter: blur(12px);
}
.v3-btn--ghost:hover { background: var(--glass-thick); }

.v3-btn--holo {
  background: #c2a14e;
  color: #15171c;
  animation: none;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.v3-btn--icon {
  padding: 10px;
  border-radius: var(--r-pill);
  width: 38px;
  height: 38px;
  justify-content: center;
}

/* ─── CHIPS / BADGES ─────────────────────────────────────────── */
.v3-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--glass-base);
  border: var(--hairline);
  color: var(--ink-text);
}
.v3-chip--violet { background: rgba(194,161,78,0.14); border-color: rgba(194,161,78,0.40); color: var(--aurora); }
.v3-chip--gold   { background: rgba(194,161,78,0.14); border-color: rgba(194,161,78,0.40); color: var(--gold-soft); }
.v3-chip--em     { background: rgba(52,211,153,0.14); border-color: rgba(52,211,153,0.40); color: var(--emerald); }
.v3-chip--pink   { background: rgba(244,114,182,0.14); border-color: rgba(244,114,182,0.40); color: var(--magenta); }

.v3-chip--pulse::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 0 currentColor;
  animation: pulse 2s var(--ease-glide) infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 currentColor; }
  70%  { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* ─── INPUT ──────────────────────────────────────────────────── */
.v3-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--glass-thin);
  border: var(--hairline);
  border-radius: var(--r-md);
  font-size: 14px;
  color: var(--ink-text);
  outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.v3-input::placeholder { color: var(--ink-muted-2); }
.v3-input:focus {
  border-color: var(--violet);
  background: var(--glass-base);
  box-shadow: 0 0 0 4px rgba(194,161,78,0.18);
}

/* ─── HOLO RING (mandala accent) ─────────────────────────────── */
.v3-holo-ring {
  position: relative;
  border-radius: 50%;
  overflow: hidden;
}
.v3-holo-ring::before {
  content: '';
  position: absolute;
  inset: -50%;
  background: var(--holo-iris);
  animation: none;
}
.v3-holo-ring::after {
  /* Mask center to make a ring */
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--ink-1);
}
@keyframes spinSlow {
  to { transform: rotate(360deg); }
}

/* ─── DOCK & SHELL ───────────────────────────────────────────── */
.v3-shell {
  display: grid;
  grid-template-columns: 84px 1fr;
  grid-template-rows: 64px 1fr;
  min-height: 100vh;
}
.v3-shell-top {
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-5);
  border-bottom: var(--hairline);
  background: linear-gradient(180deg, rgba(10,10,16,0.78), rgba(10,10,16,0.55));
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  /* fixed (sticky inaffidabile con body overflow-x:hidden) — la riga 1 della griglia (64px) resta riservata */
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  z-index: 40;
}
.v3-shell-dock {
  grid-column: 1;
  grid-row: 2;
  padding: var(--sp-4) var(--sp-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border-right: var(--hairline);
  background: linear-gradient(180deg, rgba(17,18,26,0.5), rgba(10,10,16,0.3));
  /* Menu sempre visibile durante lo scroll — fixed (immune a overflow-x:hidden del body che rompe sticky) */
  position: fixed;
  top: 64px;
  left: 0;
  width: 84px;
  bottom: 0;
  z-index: 30;
}
.v3-shell-main {
  grid-column: 2;
  grid-row: 2;
  padding: var(--sp-6) var(--sp-7);
  min-height: calc(100vh - 64px);
}

.v3-dock-tile {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  color: var(--ink-muted);
  position: relative;
  transition: all 0.2s var(--ease-spring);
}
.v3-dock-tile:hover {
  color: var(--ink-strong);
  background: var(--glass-base);
  transform: translateY(-2px);
}
.v3-dock-tile.active {
  color: var(--violet-soft);
  background: rgba(194,161,78,0.14);
  box-shadow: inset 0 0 0 1px rgba(194,161,78,0.30);
}
.v3-dock-tile.active::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 22px;
  background: var(--holo-aurora);
  border-radius: 2px;
}
.v3-dock-tile .v3-dock-label {
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--ink-2);
  border: var(--hairline);
  padding: 5px 10px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 40;
}
.v3-dock-tile:hover .v3-dock-label {
  opacity: 1;
  transform: translateY(-50%) translateX(4px);
}

/* ─── COMMAND BAR ────────────────────────────────────────────── */
.v3-cmdbar {
  flex: 1;
  max-width: 640px;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 8px 14px;
  background: var(--glass-thin);
  border: var(--hairline);
  border-radius: var(--r-md);
  color: var(--ink-muted);
  font-size: 13px;
  cursor: text;
  transition: all 0.15s;
}
.v3-cmdbar:hover { background: var(--glass-base); border-color: var(--glass-stroke-strong); }
.v3-cmdbar kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  background: var(--glass-base);
  border: var(--hairline);
  border-radius: 4px;
}

/* ─── METRIC TILE ────────────────────────────────────────────── */
.v3-metric {
  padding: var(--sp-5);
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, var(--glass-base), var(--glass-thin));
  border: var(--hairline);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s var(--ease-spring), border-color 0.2s;
}
.v3-metric:hover {
  transform: translateY(-3px);
  border-color: var(--glass-stroke-strong);
}
.v3-metric__label {
  font-size: 12px;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
  margin-bottom: 6px;
}
.v3-metric__value {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 38px;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--ink-strong);
}
.v3-metric__delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--emerald);
}
.v3-metric__delta--down { color: var(--magenta); }
.v3-metric__spark {
  position: absolute;
  inset: auto 0 0 0;
  height: 64px;
  opacity: 0.55;
}

/* ─── MOTION HELPERS ─────────────────────────────────────────── */
.v3-fadeup {
  animation: fadeUp 0.6s var(--ease-glide) backwards;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.v3-stagger > * { animation: fadeUp 0.6s var(--ease-glide) backwards; }
.v3-stagger > *:nth-child(1) { animation-delay: 0.02s; }
.v3-stagger > *:nth-child(2) { animation-delay: 0.06s; }
.v3-stagger > *:nth-child(3) { animation-delay: 0.10s; }
.v3-stagger > *:nth-child(4) { animation-delay: 0.14s; }
.v3-stagger > *:nth-child(5) { animation-delay: 0.18s; }
.v3-stagger > *:nth-child(6) { animation-delay: 0.22s; }
.v3-stagger > *:nth-child(7) { animation-delay: 0.26s; }
.v3-stagger > *:nth-child(8) { animation-delay: 0.30s; }

/* ─── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .v3-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 56px 1fr 64px;
  }
  .v3-shell-dock {
    grid-column: 1;
    grid-row: 3;
    flex-direction: row;
    border-right: 0;
    border-top: var(--hairline);
    padding: 8px var(--sp-3);
    background: rgba(10,10,16,0.85);
    backdrop-filter: blur(18px);
    /* Barra di navigazione sempre fissa in basso durante lo scroll */
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: auto;
    align-self: auto;
    z-index: 30;
    overflow-x: auto;
  }
  .v3-shell-top { height: 56px; }
  .v3-shell-main { padding: var(--sp-4); }
  .v3-dock-tile { width: 48px; height: 48px; }
  .v3-dock-tile:hover .v3-dock-label { display: none; }
}

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