/* ============================================================
   ui-tokens.css — DESIGN DIRECTION (handoff/) — caricato PER ULTIMO
   ------------------------------------------------------------
   Introduce i primitivi del nuovo design system:
     • scala tipografica  (--text-*)
     • scala spazi        (--space-*)
     • token di motion    (--ease, --dur)
     • primitivo modale   (.scrim / .modal / .modal__*)  → components/ui/Modal.tsx
     • option card        (.optcard)                     → components/ui/OptionCard.tsx

   NOTE DI CASCATA (importante):
   - Questo foglio è caricato in layout.tsx DOPO styles.css + styles-v14/16/19,
     così i nuovi primitivi VINCONO la cascata.
   - Il sistema .btn vive già in styles-v19.css (primary/ghost/save/waste/sm/lg):
     NON lo ridefiniamo qui per non alterarne il rendering esistente.
   - styles-v14.css definisce un VECCHIO `.modal` (position:fixed centrato): qui
     lo neutralizziamo per il nuovo primitivo (.scrim fa il centraggio flex).
   ============================================================ */

:root {
  /* Type scale (1 fonte di verità per i font-size) */
  /* Scala +2 (richiesta leggibilità). Questo foglio è caricato per ultimo:
     è qui che i token --text-* vincono la cascata. Tenere allineato a nuova.css. */
  --text-2xs: 12.5px;
  --text-xs:  14px;
  --text-sm:  15px;
  --text-md:  16px;   /* corpo default UI */
  --text-lg:  18px;
  --text-xl:  22px;
  --text-2xl: 28px;
  --text-3xl: 36px;
  --text-4xl: 48px;

  /* Spacing scale (base 4px) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur:  0.18s;
}

/* ============================================================
   PRIMITIVO MODALE  (usato da components/ui/Modal.tsx)
   ============================================================ */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: color-mix(in oklch, var(--bg-deep, oklch(0.18 0.012 250)), transparent 45%);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.scrim--enter { animation: scrimIn var(--dur) var(--ease); }
@keyframes scrimIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  /* reset esplicito del vecchio .modal di styles-v14 (position:fixed centrato) */
  position: static;
  inset: auto;
  top: auto;
  left: auto;
  transform: none;

  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: calc(100vh - 40px);
}
.modal--enter { animation: modalIn 0.22s var(--ease); }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal--sm { max-width: 460px; }
.modal--md { max-width: 640px; }
.modal--lg { max-width: 1000px; }

@media (prefers-reduced-motion: reduce) {
  .scrim--enter, .modal--enter { animation: none; }
}

.modal__head {
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  /* reset: il vecchio .modal__head di styles-v14 imposta space-between */
  justify-content: flex-start;
  gap: 14px;
  background: var(--bg-elev);
  flex-shrink: 0;
}
.modal__eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-mute);
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}
.modal__title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--text-md);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.modal__progress { display: flex; gap: 4px; flex: 1; max-width: 220px; }
.modal__progress span {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--line);
  transition: background var(--dur) var(--ease);
}
.modal__progress span.on { background: var(--primary); }
.modal__close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink-mute);
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--dur) var(--ease);
}
.modal__close:hover { background: var(--bg-sunken); color: var(--ink); }
.modal__body { padding: 24px; overflow-y: auto; flex: 1; min-height: 0; }
.modal__foot {
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: var(--bg-sunken);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* ============================================================
   OPTION CARD  (usato da components/ui/OptionCard.tsx)
   ============================================================ */
.optcard {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  width: 100%;
  text-align: left;
  font-family: inherit;
  color: inherit;
}
.optcard:hover { border-color: var(--ink-soft); transform: translateY(-1px); }
.optcard:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.optcard.is-active {
  border-color: var(--primary);
  background: color-mix(in oklch, var(--primary-soft), var(--bg-elev) 55%);
}
.optcard__icn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-sunken);
  color: var(--primary-ink);
  display: flex;
  align-items: center;
  justify-content: center;
}
.optcard.is-active .optcard__icn { background: var(--primary); color: white; }
.optcard__t { font-size: var(--text-sm); font-weight: 600; letter-spacing: -0.005em; display: block; }
.optcard__s { font-size: var(--text-xs); color: var(--ink-mute); margin-top: 2px; display: block; }
