/* ==========================================================================
   IronFlow v5.1 — Design System "Ember"
   ========================================================================== */
@font-face { font-family: 'Archivo'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/archivo-400.woff2') format('woff2'); }
@font-face { font-family: 'Archivo'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/archivo-500.woff2') format('woff2'); }
@font-face { font-family: 'Archivo'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/archivo-600.woff2') format('woff2'); }
@font-face { font-family: 'Archivo'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/archivo-700.woff2') format('woff2'); }

:root {
  /* superfici — near-black caldo */
  --bg: #0C0A09;
  --bg-elev: #14100D;
  --surface: #1A1613;
  --surface-2: #241E19;
  --surface-3: #33291F;
  --border: rgba(255, 240, 230, 0.07);
  --border-2: rgba(255, 240, 230, 0.14);

  /* testo caldo */
  --text: #F7F1EB;
  --text-2: #BBAEA2;
  --text-3: #857668;

  /* accento Ember */
  --accent: #FF6A2C;
  --accent-2: #FF8A4D;
  --accent-soft: rgba(255, 106, 44, 0.15);
  --accent-glow: rgba(255, 106, 44, 0.5);
  --coral: #FF4D6D;
  --coral-soft: rgba(255, 77, 109, 0.14);
  /* alias usati altrove (restano coerenti con Ember) */
  --orange: #FF6A2C;
  --orange-soft: rgba(255, 106, 44, 0.15);

  /* funzionali */
  --green: #37D67A;                 /* solo "completato" */
  --green-soft: rgba(55, 214, 122, 0.14);
  --gold: #FFC24B;                  /* record / evidenza calda */
  --lime: #FFC24B;                  /* alias caldo per finish/toast */
  --lime-soft: rgba(255, 194, 75, 0.14);
  --red: #FF5C6E;
  --amber: #FFC24B;

  /* forma */
  --r-sm: 12px; --r: 16px; --r-lg: 22px; --r-xl: 30px;
  --pad: 18px;
  --maxw: 520px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --t: 0.24s var(--ease);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: 'Archivo', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --nav-h: 68px;
}

* , *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: var(--font); background: var(--bg); color: var(--text);
  min-height: 100dvh; line-height: 1.45; overflow-x: hidden;
  overscroll-behavior-y: none; letter-spacing: -0.011em;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }
input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
::selection { background: var(--accent-glow); color: #180a03; }

/* sfondo ambientale caldo */
.ambient { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.ambient::before, .ambient::after { content: ''; position: absolute; border-radius: 50%; filter: blur(75px); }
.ambient::before { top: -20%; right: -22%; width: 68%; height: 58%; opacity: 0.55;
  background: radial-gradient(circle, rgba(255,106,44,0.34), transparent 70%); animation: drift1 26s ease-in-out infinite; }
.ambient::after { bottom: -16%; left: -18%; width: 58%; height: 52%; opacity: 0.4;
  background: radial-gradient(circle, rgba(255,77,109,0.22), transparent 70%); animation: drift2 32s ease-in-out infinite; }
@keyframes drift1 { 0%,100% { transform: translate(0,0); } 50% { transform: translate(-8%, 10%); } }
@keyframes drift2 { 0%,100% { transform: translate(0,0); } 50% { transform: translate(10%, -6%); } }
@media (prefers-reduced-motion: reduce) { .ambient::before, .ambient::after { animation: none; } }

/* layout */
.app { position: relative; z-index: 1; max-width: var(--maxw); margin: 0 auto;
  padding: calc(var(--safe-top) + 6px) var(--pad) calc(var(--nav-h) + var(--safe-bottom) + 22px); }

/* header */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 0 14px; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand-logo { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--accent), #E24817); box-shadow: 0 8px 22px -6px var(--accent-glow); }
.brand-logo svg { width: 23px; height: 23px; color: #fff; }
.brand-name { font-size: 20px; font-weight: 800; letter-spacing: -0.03em; }
.brand-name span { color: var(--accent-2); }
.brand-sub { font-size: 10.5px; color: var(--text-3); font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; margin-top: 1px; }

/* toggle luogo */
.loc-toggle { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px; gap: 2px; }
.loc-toggle button { padding: 8px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 700; color: var(--text-3);
  display: flex; align-items: center; gap: 6px; transition: var(--t); white-space: nowrap; }
.loc-toggle button svg { width: 15px; height: 15px; }
.loc-toggle button.active { background: var(--accent); color: #180a03; box-shadow: 0 4px 14px -4px var(--accent-glow); }

/* card */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--pad); }
.card-glow { position: relative; overflow: hidden; }
.card-glow::before { content: ''; position: absolute; inset: 0; background:
  radial-gradient(130% 90% at 85% -10%, var(--accent-soft), transparent 55%); pointer-events: none; }

/* bottoni */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 9px; width: 100%;
  padding: 16px 20px; border-radius: var(--r); font-size: 16px; font-weight: 700; transition: var(--t);
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border); letter-spacing: -0.01em; }
.btn svg { width: 20px; height: 20px; }
.btn:active { transform: scale(0.975); }
.btn-primary { background: linear-gradient(140deg, var(--accent-2), var(--accent)); border: none; color: #1a0a02;
  box-shadow: 0 10px 30px -10px var(--accent-glow); font-weight: 750; }
.btn-lime { background: linear-gradient(140deg, #FFD37A, var(--gold)); color: #241703; border: none; box-shadow: 0 10px 26px -12px rgba(255,194,75,0.5); font-weight: 750; }
.btn-ghost { background: var(--surface); }
.btn-danger { background: transparent; border: 1px solid rgba(255,92,110,0.4); color: var(--red); }
.btn-sm { padding: 11px 14px; font-size: 14px; border-radius: var(--r-sm); width: auto; }
.btn-sm svg { width: 17px; height: 17px; }

/* kicker / titoli */
.kicker { font-size: 11px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-3); }
.h-row { display: flex; align-items: baseline; justify-content: space-between; margin: 28px 2px 12px; }
.h-row h2 { font-size: 18px; font-weight: 800; letter-spacing: -0.025em; }
.h-row a, .h-row button { font-size: 13px; color: var(--accent-2); font-weight: 700; }

/* chip */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700;
  padding: 5px 11px; border-radius: 999px; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; }

/* bottom nav */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 200; height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom); background: rgba(12,10,9,0.85); backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px);
  border-top: 1px solid var(--border); display: flex; }
.nav-inner { max-width: var(--maxw); margin: 0 auto; width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); }
.nav-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--text-3);
  font-size: 10.5px; font-weight: 700; transition: color var(--t); position: relative; }
.nav-btn svg { width: 23px; height: 23px; }
.nav-btn.active { color: var(--accent-2); }
.nav-btn.active::before { content: ''; position: absolute; top: 5px; width: 36px; height: 30px; border-radius: 11px;
  background: var(--accent-soft); z-index: -1; }

/* ring */
.ring { transform: rotate(-90deg); }
.ring .track { stroke: var(--surface-3); fill: none; }
.ring .val { stroke: var(--accent); fill: none; stroke-linecap: round; transition: stroke-dashoffset 0.6s var(--ease); }

/* stat */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 15px 12px; text-align: center; }
.stat-val { font-size: 23px; font-weight: 800; letter-spacing: -0.035em; }
.stat-val small { font-size: 12px; font-weight: 700; color: var(--text-3); }
.stat-label { font-size: 10.5px; color: var(--text-3); font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; margin-top: 3px; }

/* muscle map (silhouette umana) */
.muscle-map { width: 100%; height: auto; max-height: 240px; display: block; }
.muscle-map .body { fill: var(--surface-3); stroke: rgba(0,0,0,0.28); stroke-width: 2; }
.muscle-map .m-pri { fill: var(--accent); stroke: rgba(0,0,0,0.28); stroke-width: 2; }
.muscle-map .m-sec { fill: var(--accent); fill-opacity: 0.32; stroke: rgba(0,0,0,0.28); stroke-width: 2; }

/* toast */
.toast-wrap { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-bottom) + 14px); z-index: 400;
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: var(--surface-3); color: var(--text); border: 1px solid var(--border-2); padding: 11px 18px;
  border-radius: 999px; font-size: 13.5px; font-weight: 650; box-shadow: 0 12px 30px -10px rgba(0,0,0,0.7);
  animation: toastIn 0.3s var(--ease); max-width: 90%; }
.toast.lime { background: var(--gold); color: #241703; border: none; }
@keyframes toastIn { from { transform: translateY(14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* sheet */
.sheet-back { position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,0.62); backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none; transition: opacity var(--t); }
.sheet-back.open { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 301; max-width: var(--maxw); margin: 0 auto;
  background: var(--bg-elev); border-radius: var(--r-xl) var(--r-xl) 0 0; border-top: 1px solid var(--border-2);
  padding: 10px var(--pad) calc(var(--safe-bottom) + 22px); transform: translateY(100%); transition: transform 0.32s var(--ease);
  max-height: 90dvh; overflow-y: auto; }
.sheet.open { transform: translateY(0); }
.sheet-grip { width: 40px; height: 4px; border-radius: 3px; background: var(--surface-3); margin: 6px auto 14px; }

/* demo box */
.demo-box { position: relative; width: 100%; aspect-ratio: 4/3; border-radius: var(--r); overflow: hidden;
  background: #fff; display: grid; place-items: center; }
.demo-box img { width: 100%; height: 100%; object-fit: contain; }
.demo-badge { position: absolute; top: 9px; left: 9px; background: rgba(0,0,0,0.6); backdrop-filter: blur(6px);
  font-size: 10px; font-weight: 700; padding: 4px 9px; border-radius: 999px; color: #fff; letter-spacing: 0.05em; }

/* utility */
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.center { text-align: center; }
.hidden { display: none !important; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--surface-3); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.view { animation: fadeUp 0.35s var(--ease); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
