/* ─────────────────────────────────────────────────────────────────────────────
   NEREO space — style.css
   Layout, colori, animazioni. Zero logica applicativa.
   ───────────────────────────────────────────────────────────────────────────── */

/* ── Google Fonts ──────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@300;400&family=Inter:wght@300;400;700;900&display=swap');

/* ── Design tokens ─────────────────────────────────────────────────────────── */
:root {
  /* Palette */
  --red:      #ff5a36;
  --orange:   #ffb238;
  --green:    #22c55e;
  --white:    #f8fafc;
  --dim:      #94a3b8;
  --border:   rgba(255,255,255,.08);

  /* Surfaces */
  --card-bg:  linear-gradient(160deg, rgba(255,255,255,.05), rgba(255,255,255,.025));
  --shadow:   0 16px 40px rgba(0,0,0,.38);

  /* Radius */
  --r-card:   22px;
  --r-btn:    18px;
  --r-chip:   999px;

  /* Typography */
  --font-mono: 'IBM Plex Mono', monospace;
  --font-sans: 'Inter', sans-serif;

  /* Transitions */
  --t-fast:   .15s ease;
  --t-mid:    .4s ease;
  --t-slow:   1.2s ease;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: var(--font-mono);
  font-weight: 300;
  color: var(--white);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

/* ── Background — radial glow rosso-arancio ────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 90% 38% at 50% -2%, rgba(255,90,54,.18) 0%, transparent 68%),
    linear-gradient(180deg, #0b0b0b 0%, #060606 100%);
  pointer-events: none;
}

/* ── App wrapper ───────────────────────────────────────────────────────────── */
#app {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

/* ── HUD ───────────────────────────────────────────────────────────────────── */
.hud {
  position: fixed;
  z-index: 10;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: rgba(255,178,56,.3);
  pointer-events: none;
  transition: opacity var(--t-slow);
}

#hud-tl { top: 18px; left: 20px; }
.hud-tr { top: 18px; right: 20px; text-align: right; }
.hud-sub { opacity: .45; }

/* ── Screens ───────────────────────────────────────────────────────────────── */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 24px;
  max-width: 430px;
  width: 100%;
  margin: 0 auto;
  opacity: 0;
  pointer-events: none;
  transition: opacity .5s ease;
}

.screen.active {
  opacity: 1;
  pointer-events: all;
}

.screen.flash {
  animation: flash .25s ease;
}

@keyframes flash {
  0%   { opacity: 0; }
  50%  { opacity: 1; }
  100% { opacity: 1; }
}

/* ── Start screen ──────────────────────────────────────────────────────────── */
#logo-name {
  font-family: var(--font-sans);
  font-size: clamp(36px, 10vw, 56px);
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--white);
  margin-bottom: 4px;
}

#logo-sub {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 44px;
}

/* ── Card ──────────────────────────────────────────────────────────────────── */
.card {
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  padding: 24px 22px;
}

.fadein {
  animation: fadein-up .5s ease both;
}

@keyframes fadein-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Section label ─────────────────────────────────────────────────────────── */
.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--orange);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Intro card ────────────────────────────────────────────────────────────── */
.intro-desc {
  font-size: 13px;
  color: var(--dim);
  line-height: 1.9;
  letter-spacing: .01em;
  text-align: center;
  margin-bottom: 18px;
}

.step-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.step-list li {
  font-size: 11px;
  color: var(--dim);
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: .02em;
}

.step-n {
  color: var(--orange);
  font-weight: 700;
  font-size: 11px;
  min-width: 20px;
}

/* ── Liquid button ─────────────────────────────────────────────────────────── */
#start-btn-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: 100%;
  margin-top: 28px;
}

#start-btn {
  position: relative;
  width: 100%;
  height: clamp(60px, 14vw, 76px);
  border: none;
  outline: none;
  cursor: pointer;
  border-radius: var(--r-btn);
  overflow: hidden;
  background: transparent;
  box-shadow: 0 8px 32px rgba(255,90,54,.28);
  transition: transform var(--t-fast);
}

#start-btn:active { transform: scale(.98); }

#btn-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: var(--r-btn);
}

#btn-label {
  position: relative;
  z-index: 2;
  font-family: var(--font-sans);
  font-weight: 900;
  font-size: 13px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.85);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ── Swipe hint ────────────────────────────────────────────────────────────── */
#swipe-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transition: opacity .8s;
  pointer-events: none;
}

#swipe-hint.visible { opacity: 1; }

#swipe-arrow {
  width: 1px;
  height: 28px;
  background: linear-gradient(to top, rgba(255,107,43,.7), transparent);
  position: relative;
  animation: swipe-up 1.6s ease-in-out infinite;
}

#swipe-arrow::before {
  content: '';
  position: absolute;
  top: -4px;
  left: 50%;
  width: 6px;
  height: 6px;
  border-top: 1px solid rgba(255,107,43,.7);
  border-right: 1px solid rgba(255,107,43,.7);
  transform: translateX(-50%) rotate(-45deg);
}

#swipe-hint-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: rgba(255,107,43,.45);
}

@keyframes swipe-up {
  0%   { transform: translateY(6px);  opacity: 0; }
  30%  { opacity: 1; }
  100% { transform: translateY(-6px); opacity: 0; }
}

/* ── Phase content ─────────────────────────────────────────────────────────── */
.phase-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  width: 100%;
}

.phase-text {
  font-family: var(--font-mono);
  font-size: clamp(24px, 6vw, 38px);
  font-weight: 400;
  letter-spacing: -.01em;
  color: rgba(255,255,255,.88);
  text-align: center;
  line-height: 1.35;
  white-space: pre-line;
  transition: opacity .7s ease;
}

.phase-text--sm {
  font-size: clamp(18px, 4vw, 26px);
}

.phase-sub {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--dim);
  opacity: 0;
  transition: opacity .5s;
}

/* ── Chip ──────────────────────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  border-radius: var(--r-chip);
  padding: 8px 14px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  animation: chip-pop .35s cubic-bezier(.34,1.56,.64,1) both;
}

@keyframes chip-pop {
  from { transform: scale(.7); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}

.chip-active  { background: rgba(255,90,54,.15);  color: var(--red);    border: 1px solid rgba(255,90,54,.3);   }
.chip-loading { background: rgba(255,178,56,.12); color: var(--orange); border: 1px solid rgba(255,178,56,.25); }
.chip-done    { background: rgba(34,197,94,.12);  color: var(--green);  border: 1px solid rgba(34,197,94,.25);  }
.chip-idle    { background: rgba(255,255,255,.06); color: var(--dim);   border: 1px solid var(--border);         }

/* ── Dots ──────────────────────────────────────────────────────────────────── */
.dots {
  display: flex;
  gap: 8px;
  align-items: center;
  opacity: 0;
  transition: opacity .4s;
}

.dots.visible { opacity: 1; }

.dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--orange);
  animation: dot-pulse 1.4s ease-in-out infinite;
}

.dot:nth-child(2) { animation-delay: .2s; }
.dot:nth-child(3) { animation-delay: .4s; }

@keyframes dot-pulse {
  0%, 80%, 100% { transform: scale(.55); opacity: .3; }
  40%           { transform: scale(1);   opacity: 1;  }
}

/* ── Camera circle ─────────────────────────────────────────────────────────── */
#cam-wrap {
  position: relative;
  width: clamp(140px, 38vw, 180px);
  height: clamp(140px, 38vw, 180px);
  flex-shrink: 0;
}

#cam-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#cam-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  pointer-events: none;
}

#cam-status {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: rgba(255,178,56,.8);
  transition: color .5s;
}

#cam-sub {
  font-size: 8px;
  letter-spacing: .18em;
  color: rgba(255,255,255,.2);
  text-transform: uppercase;
  text-align: center;
  line-height: 1.8;
  transition: opacity .5s;
}

/* ── Typewriter ────────────────────────────────────────────────────────────── */
#typewriter {
  font-family: var(--font-mono);
  font-size: clamp(10px, 2.5vw, 13px);
  font-weight: 300;
  letter-spacing: .1em;
  color: rgba(255,178,56,.7);
  text-align: center;
  line-height: 1.9;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity .8s ease;
  max-width: 32ch;
  min-height: 1.5em;
}

/* ── Result screen ─────────────────────────────────────────────────────────── */
.result-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  overflow-y: auto;
  max-height: 100vh;
  padding: 20px 0 32px;
  scrollbar-width: none;
}
.result-content::-webkit-scrollbar { display: none; }

/* ── Score bar verticale ───────────────────────────────────────────────────── */
#score-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

#score-bar-track {
  width: 5px;
  height: clamp(140px, 24vh, 200px);
  background: rgba(255,255,255,.06);
  border-radius: 999px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
}

#score-bar-fill {
  width: 100%;
  height: 0%;
  background: linear-gradient(to top, var(--red), var(--orange) 55%, #fff 90%);
  border-radius: 999px;
  transition: height 1.8s cubic-bezier(.16,1,.3,1);
  box-shadow: 0 0 18px rgba(255,107,43,.5);
}

#score-number {
  font-family: var(--font-sans);
  font-size: clamp(52px, 12vw, 72px);
  font-weight: 900;
  letter-spacing: -.06em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--white);
}

#score-tier {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--orange);
  min-height: 1.2em;
  transition: opacity .8s;
}

/* ── Result card commento ──────────────────────────────────────────────────── */
.result-card {
  width: 100%;
}

#result-comment {
  font-family: var(--font-mono);
  font-size: clamp(12px, 3vw, 15px);
  font-weight: 300;
  letter-spacing: .04em;
  color: rgba(255,255,255,.65);
  line-height: 1.9;
  text-align: center;
  min-height: 3em;
}

/* ── KPI grid ──────────────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}

.kpi-box {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 16px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.kpi-val {
  font-family: var(--font-sans);
  font-size: clamp(22px, 6vw, 32px);
  font-weight: 900;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--white);
}

.kpi-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--dim);
}

/* ── Training progress ─────────────────────────────────────────────────────── */
#training-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.progress-track {
  width: 100%;
  height: 12px;
  background: rgba(255,255,255,.06);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--red), var(--orange), var(--green));
  border-radius: 999px;
  width: 0%;
  transition: width .4s ease;
}

.training-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--dim);
  text-align: right;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  width: 100%;
  border: none;
  outline: none;
  cursor: pointer;
  border-radius: var(--r-btn);
  padding: 18px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
  transition: transform var(--t-fast), opacity var(--t-fast);
}

.btn:active { transform: scale(.98); }

.btn-primary {
  background: linear-gradient(135deg, var(--red), var(--orange));
  color: #000;
  box-shadow: 0 8px 24px rgba(255,90,54,.35);
}

.btn-secondary {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  color: var(--dim);
}

.btn-danger {
  background: rgba(255,90,54,.08);
  border: 1px solid rgba(255,90,54,.25);
  color: #ffb4a6;
}

/* ── iOS install hint ──────────────────────────────────────────────────────── */
#ios-hint {
  position: fixed;
  bottom: 52px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.88);
  border: 1px solid rgba(255,107,43,.18);
  border-radius: 14px;
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 9998;
  opacity: 0;
  transition: opacity .8s ease;
  pointer-events: none;
  white-space: nowrap;
  max-width: 90vw;
}

#ios-hint.visible {
  opacity: 1;
  pointer-events: all;
}

#ios-hint[hidden] { display: none; }

#ios-hint-text {
  font-size: 11px;
  letter-spacing: .08em;
  color: rgba(255,255,255,.55);
  text-align: center;
  line-height: 1.8;
}

#ios-hint-text strong { color: rgba(255,178,56,.8); }

#ios-hint-close {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: rgba(255,255,255,.2);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
}

/* ── Utility: hidden ───────────────────────────────────────────────────────── */
[hidden] { display: none !important; }

/* ── Responsive — landscape forzato su mobile ─────────────────────────────── */
@media (orientation: landscape) and (max-height: 500px) {
  /* Schermate in landscape su mobile — comprime il layout */
  .phase-text     { font-size: clamp(18px, 4vw, 28px); }
  .phase-content  { gap: 16px; }
  #cam-wrap       { width: 110px; height: 110px; }
  #logo-name      { font-size: clamp(28px, 7vw, 42px); }
  #logo-sub       { margin-bottom: 20px; }
  #start-btn-wrap { margin-top: 16px; }
  .result-content { gap: 12px; }
  #score-bar-track { height: 100px; }
  #score-number   { font-size: clamp(40px, 9vw, 56px); }
}

/* ── Reduced motion ────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
