:root {
  --bg:         #080205;
  --card:       #120810;
  --card-hi:    #1b0d17;
  --primary:    #6B1D2E;
  --accent:     #C0906A;
  --accent-dim: rgba(192, 144, 106, 0.14);
  --text:       #F0E6D4;
  --muted:      #8A7468;
  --border:     rgba(192, 144, 106, 0.13);
  --border-hi:  rgba(192, 144, 106, 0.48);
  --r:          3px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-weight: 400;
  overflow: hidden;
}

/* Glow ambientale */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 50% at 50% 10%, rgba(107, 29, 46, 0.24) 0%, transparent 65%),
    radial-gradient(ellipse 45% 35% at 85% 90%, rgba(90, 22, 38, 0.12) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ── App shell ── */
#app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 24px 32px;
}

/* ── Header ── */
.app-header {
  padding: 26px 0 18px;
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: 'DM Sans', sans-serif;
  font-size: .62rem;
  font-weight: 500;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--accent);
}

.logo::before,
.logo::after {
  content: '';
  flex: 1;
  height: 1px;
}

.logo::before {
  background: linear-gradient(90deg, transparent, var(--border-hi));
}

.logo::after {
  background: linear-gradient(90deg, var(--border-hi), transparent);
}

.logo-text span { color: var(--muted); }

/* ── Progress ── */
.progress-wrap {
  flex-shrink: 0;
  margin-bottom: 32px;
}

.progress-bar {
  height: 1px;
  background: rgba(255,255,255,.06);
  position: relative;
}

.progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width .5s cubic-bezier(.4, 0, .2, 1);
  width: 0%;
}

.progress-fill::after {
  content: '';
  position: absolute;
  right: -1px;
  top: -2px;
  width: 3px;
  height: 5px;
  background: var(--accent);
  border-radius: 2px;
  opacity: .9;
}

.progress-label {
  font-size: .6rem;
  font-weight: 500;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 10px;
  text-align: right;
}

/* ── Slide area ── */
.slides { flex: 1; position: relative; overflow: hidden; }

.slide {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateX(48px);
  transition: opacity .38s ease, transform .38s cubic-bezier(.25, .46, .45, .94);
  pointer-events: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.slide.active {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.slide.exit {
  opacity: 0;
  transform: translateX(-28px);
  transition: opacity .25s ease, transform .25s ease;
}

/* ── Senso tag ── */
.senso-tag {
  font-size: .58rem;
  font-weight: 500;
  letter-spacing: 3.5px;
  text-transform: uppercase;
  color: var(--accent);
  opacity: .8;
  margin-bottom: 0;
  flex-shrink: 0;
  padding-bottom: 16px;
  position: relative;
}

.senso-tag::after {
  content: '';
  position: absolute;
  bottom: 8px;
  left: 0;
  width: 22px;
  height: 1px;
  background: var(--accent);
  opacity: .4;
}

.question-text {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 2.05rem;
  font-weight: 600;
  font-style: italic;
  line-height: 1.24;
  margin-bottom: 28px;
  flex-shrink: 0;
  color: var(--text);
  letter-spacing: -0.2px;
}

/* ── Answers ── */
.answers { display: flex; flex-direction: column; gap: 8px; }

.btn-answer {
  display: flex;
  align-items: center;
  gap: 18px;
  background: rgba(255,255,255,.018);
  border: none;
  border-left: 2px solid rgba(255,255,255,.06);
  border-radius: var(--r);
  padding: 18px 20px;
  cursor: pointer;
  transition: border-color .2s, background .2s, padding-left .2s;
  text-align: left;
  color: var(--text);
  width: 100%;
}

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

.btn-answer.selected,
.btn-answer:hover {
  border-left-color: var(--accent);
  background: var(--accent-dim);
  padding-left: 24px;
}

.btn-icon {
  font-size: 1.3rem;
  width: 32px;
  text-align: center;
  flex-shrink: 0;
  opacity: .72;
}

.btn-label {
  font-size: .96rem;
  font-weight: 300;
  letter-spacing: 0.3px;
}

/* ── Loading ── */
#slide-loading {
  justify-content: center;
  align-items: center;
  gap: 22px;
}

.spinner {
  width: 34px; height: 34px;
  border: 1.5px solid rgba(255,255,255,.07);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1.2s linear infinite;
}

.loading-text {
  color: var(--muted);
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-align: center;
  max-width: 200px;
  line-height: 1.7;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Result slide ── */
#slide-result { overflow-y: auto; padding-bottom: 10px; }

/* ── Identity card ── */
.identity-card {
  position: relative;
  background: var(--card);
  border-radius: var(--r);
  padding: 32px 26px;
  text-align: center;
  margin-bottom: 22px;
  border: 1px solid var(--border);
  flex-shrink: 0;
  overflow: hidden;
}

.identity-card::before {
  content: '';
  position: absolute;
  top: 0; left: 20%; right: 20%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.identity-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 90% 65% at 50% 0%, rgba(107, 29, 46, 0.28) 0%, transparent 70%);
  pointer-events: none;
}

.identity-label {
  font-size: .58rem;
  font-weight: 500;
  letter-spacing: 3.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
  position: relative;
  z-index: 1;
}

.identity-name {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 2.5rem;
  font-weight: 700;
  font-style: italic;
  color: var(--accent);
  margin-bottom: 14px;
  line-height: 1.12;
  position: relative;
  z-index: 1;
}

.identity-desc {
  font-size: .83rem;
  font-weight: 300;
  color: rgba(240, 230, 212, 0.6);
  line-height: 1.7;
  position: relative;
  z-index: 1;
}

/* ── Wine list ── */
.wines-intro {
  font-size: .62rem;
  font-weight: 500;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  margin-bottom: 14px;
}

.wine-cards { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }

.wine-card {
  background: var(--card);
  border-radius: var(--r);
  padding: 20px 22px;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.wine-card::before {
  content: '';
  position: absolute;
  top: 0; left: 18%; right: 18%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(192, 144, 106, 0.4), transparent);
}

.wine-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

/* ── Category strip — sostituisce .wine-badge ── */
.wine-card-cat {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 22px;
  margin: -20px -22px 16px;
  font-size: .52rem;
  font-weight: 600;
  letter-spacing: 3.5px;
  text-transform: uppercase;
  border-bottom: 1px solid transparent;
  position: relative;
  overflow: hidden;
}

.cat-icon {
  font-size: .95rem;
  flex-shrink: 0;
  line-height: 1;
  filter: drop-shadow(0 0 5px currentColor);
}

.cat-label { flex: 1; }

.wine-price-cat {
  font-size: .72rem;
  font-weight: 400;
  letter-spacing: 0;
  opacity: .65;
  margin-left: auto;
}

/* ── Badge numero + fascia (Guida Vini 2026) — angolo alto a destra ── */
.wine-card-cat { padding-right: 70px; }   /* spazio riservato al badge */

.wine-tag {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 7px 10px 9px;
  background: linear-gradient(180deg, rgba(20, 13, 18, 0.55), rgba(20, 13, 18, 0));
  border-bottom-left-radius: 14px;
}

.wine-tag-fascia {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1;
  color: #1a1014;
  background: #b9b3ad;                       /* fallback se fascia ignota */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.wine-tag-num {
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: #f3e4d6;
  background: rgba(0, 0, 0, 0.55);
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}

/* Colori fascia coerenti con la guida cartacea */
.wine-tag[data-fascia="A"] .wine-tag-fascia { background: #E6BE44; }   /* giallo  */
.wine-tag[data-fascia="B"] .wine-tag-fascia { background: #E5893A; }   /* arancio */
.wine-tag[data-fascia="C"] .wine-tag-fascia { background: #5DAA5D; color: #0f210e; }  /* verde */
.wine-tag[data-fascia="D"] .wine-tag-fascia { background: #4F95C6; color: #061320; }  /* blu   */

/* Rosso */
.wine-card[data-cat="rosso"] {
  border-left: 2px solid rgba(214, 50, 78, 0.65);
}
.wine-card[data-cat="rosso"] .wine-card-cat {
  color: #F07090;
  background: linear-gradient(90deg, rgba(180, 38, 65, 0.28) 0%, transparent 75%);
  border-bottom-color: rgba(180, 38, 65, 0.28);
}

/* Bianco */
.wine-card[data-cat="bianco"] {
  border-left: 2px solid rgba(196, 161, 80, 0.65);
}
.wine-card[data-cat="bianco"] .wine-card-cat {
  color: #D4BC6E;
  background: linear-gradient(90deg, rgba(178, 144, 58, 0.22) 0%, transparent 75%);
  border-bottom-color: rgba(178, 144, 58, 0.28);
}

/* Bollicine */
.wine-card[data-cat="bollicine"] {
  border-left: 2px solid rgba(130, 188, 208, 0.65);
}
.wine-card[data-cat="bollicine"] .wine-card-cat {
  color: #A0CCDC;
  background: linear-gradient(90deg, rgba(88, 162, 190, 0.18) 0%, transparent 75%);
  border-bottom-color: rgba(88, 162, 190, 0.26);
}

/* Dolce */
.wine-card[data-cat="dolce"] {
  border-left: 2px solid rgba(200, 112, 55, 0.65);
}
.wine-card[data-cat="dolce"] .wine-card-cat {
  color: #E09868;
  background: linear-gradient(90deg, rgba(196, 108, 48, 0.22) 0%, transparent 75%);
  border-bottom-color: rgba(196, 108, 48, 0.28);
}

.wine-price {
  font-size: .8rem;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0.3px;
}

.wine-img {
  width: 100%;
  max-height: 140px;
  object-fit: contain;
  margin-bottom: 14px;
  border-radius: 2px;
  opacity: .88;
}

.wine-name {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.45rem;
  font-weight: 600;
  line-height: 1.18;
  margin-bottom: 5px;
  color: var(--text);
}

/* Lascia spazio al badge numero/fascia (angolo alto destro) per nomi lunghi */
.wine-card:has(.wine-tag) .wine-name,
.wine-card:has(.wine-tag) .wine-producer { padding-right: 58px; }

.wine-producer {
  font-size: .76rem;
  font-weight: 500;
  color: var(--accent);
  margin-bottom: 4px;
  letter-spacing: 0.2px;
}

.wine-region {
  font-size: .68rem;
  font-weight: 400;
  color: var(--muted);
  margin-bottom: 10px;
  letter-spacing: 0.5px;
}

.wine-desc {
  font-size: .79rem;
  font-weight: 300;
  color: rgba(240, 230, 212, 0.5);
  line-height: 1.65;
}

/* ── Restart ── */
.btn-restart {
  width: 100%;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border-hi);
  border-radius: var(--r);
  padding: 16px;
  font-family: 'DM Sans', sans-serif;
  font-size: .65rem;
  font-weight: 500;
  letter-spacing: 3px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .2s, border-color .2s;
}

.btn-restart:hover { background: var(--accent-dim); }
.btn-restart:active { opacity: .7; }

/* ── Condividi su Instagram ── */
.btn-share-ig {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  margin-bottom: 12px;
  padding: 15px;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--border-hi);
  border-radius: var(--r);
  font-family: 'DM Sans', sans-serif;
  font-size: .62rem;
  font-weight: 500;
  letter-spacing: 3px;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: background .2s, border-color .2s;
}
.btn-share-ig svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-share-ig:hover { background: rgba(192, 144, 106, .2); border-color: var(--accent); }
.btn-share-ig:active { opacity: .7; }

/* ── "Analisi conclusa" state ── */
@keyframes doneIconIn {
  0%   { transform: scale(0) rotate(-30deg); opacity: 0; }
  60%  { transform: scale(1.18) rotate(6deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
@keyframes doneTextIn {
  from { opacity: 0; letter-spacing: 10px; transform: translateY(6px); }
  to   { opacity: 1; letter-spacing: 4px;  transform: translateY(0); }
}
@keyframes donePulse {
  0%, 100% { text-shadow: 0 0 0 transparent; }
  50%       { text-shadow: 0 0 24px rgba(192, 144, 106, 0.7); }
}

.loading-done-icon {
  font-size: 2.6rem;
  color: var(--accent);
  animation: doneIconIn .55s cubic-bezier(.34, 1.56, .64, 1) both,
             donePulse 2.2s ease .6s infinite;
  display: block;
  margin-bottom: 14px;
}
.loading-done-text {
  font-size: .58rem;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--accent);
  animation: doneTextIn .7s ease .28s both;
}

/* ── Identity card — animated entrance ── */
@keyframes identityIn {
  from { opacity: 0; transform: translateY(28px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}
@keyframes identityGlow {
  0%, 100% { box-shadow: 0 0  0px 0px rgba(192, 144, 106, 0); }
  50%       { box-shadow: 0 0 36px 4px rgba(192, 144, 106, 0.11); }
}
@keyframes nameReveal {
  from { opacity: 0; filter: blur(10px); transform: scale(1.05); }
  to   { opacity: 1; filter: blur(0);    transform: scale(1); }
}
@keyframes descFade {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.identity-card-anim {
  animation: identityIn .8s cubic-bezier(.16, 1, .3, 1) both,
             identityGlow 3s ease 1s infinite;
}
.identity-name-anim {
  animation: nameReveal .85s cubic-bezier(.16, 1, .3, 1) .2s both;
}
.identity-desc-anim {
  animation: descFade .7s ease .42s both;
}

/* ── Profile bars ── */
.profile-divider {
  width: 100%;
  height: 1px;
  background: var(--border);
  margin: 20px 0 16px;
  position: relative;
  z-index: 1;
}

.profile-bars {
  display: flex;
  flex-direction: column;
  gap: 9px;
  position: relative;
  z-index: 1;
}

.profile-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bar-label {
  font-size: .48rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  width: 68px;
  flex-shrink: 0;
  text-align: right;
  transition: color .3s;
}
.bar-label.bar-dom { color: var(--accent); }

.bar-track {
  flex: 1;
  height: 2px;
  background: rgba(255,255,255,.05);
  border-radius: 2px;
  overflow: hidden;
}

@keyframes barReveal {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 2px;
  transform-origin: left;
  animation: barReveal .9s cubic-bezier(.16, 1, .3, 1) both;
}
.bar-fill.bar-dom {
  background: linear-gradient(90deg, #9B2840, var(--accent), #F0D0A0);
  box-shadow: 0 0 8px rgba(192, 144, 106, 0.55);
}

.bar-val {
  width: 24px;
  flex-shrink: 0;
  font-size: .52rem;
  color: var(--muted);
  text-align: right;
}
.bar-val.bar-dom { color: var(--accent); font-weight: 600; }

/* ── Wine cards staggered entrance ── */
@keyframes cardReveal {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: translateY(0); }
}
.wine-card-anim { animation: cardReveal .65s cubic-bezier(.16, 1, .3, 1) both; }

/* ── Scrollbar ── */
@media (hover: hover) {
  .slide::-webkit-scrollbar,
  #slide-result::-webkit-scrollbar { width: 2px; }
  .slide::-webkit-scrollbar-track,
  #slide-result::-webkit-scrollbar-track { background: transparent; }
  .slide::-webkit-scrollbar-thumb,
  #slide-result::-webkit-scrollbar-thumb {
    background: rgba(192, 144, 106, .22);
    border-radius: 2px;
  }
  .slide, #slide-result {
    scrollbar-width: thin;
    scrollbar-color: rgba(192, 144, 106, .22) transparent;
  }
}

/* ── Altezza ridotta ── */
@media (max-height: 700px) {
  #app { padding-bottom: 16px; }
  .app-header { padding: 14px 0 10px; }
  .progress-wrap { margin-bottom: 20px; }
  .senso-tag { margin-bottom: 8px; }
  .question-text { font-size: 1.65rem; margin-bottom: 20px; }
  .answers { gap: 6px; }
  .btn-answer { padding: 14px 18px; }
  .btn-icon { font-size: 1.25rem; width: 30px; }
  .identity-card { padding: 22px 20px; margin-bottom: 16px; }
  .identity-name { font-size: 2.1rem; }
}

@media (max-height: 580px) {
  .question-text { font-size: 1.4rem; margin-bottom: 14px; }
  .answers { gap: 5px; }
  .btn-answer { padding: 11px 16px; }
  .senso-tag { display: none; }
}

/* ── Schermi stretti ── */
@media (max-width: 360px) {
  #app { padding: 0 16px 20px; }
  .question-text { font-size: 1.7rem; }
  .btn-label { font-size: .9rem; }
  .identity-name { font-size: 2.1rem; }
}
