/* Tema: le variabili sotto sono i DEFAULT; app.js le sovrascrive da config.json (tema). */
:root {
  --bg: #120B0E;
  --bg-deep: #0D080A;
  --text: #F7EFE3;
  --text-2: #E3D2B8;
  --text-3: #C9B9A6;
  --accent: #D9B84E;
  --accent-2: #C9A227;
  --ok: #7BAE63;
  --off: #C25450;
  --line: rgba(247, 239, 227, 0.12);
  --font-title: 'Fraunces', Georgia, serif;
  --font-text: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* Font self-hosted (nessuna chiamata a Google Fonts). Solo sottoinsieme latino. */
@font-face { font-family: 'Fraunces'; font-style: normal; font-weight: 600 780; font-display: swap; src: url('../assets/fonts/fraunces-normal.woff2') format('woff2'); }
@font-face { font-family: 'Fraunces'; font-style: italic; font-weight: 780; font-display: swap; src: url('../assets/fonts/fraunces-italic.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400 600; font-display: swap; src: url('../assets/fonts/inter-normal.woff2') format('woff2'); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg-deep); color: var(--text); font-family: var(--font-text); }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { position: relative; max-width: 480px; min-height: 100dvh; margin: 0 auto; background: var(--bg); padding-bottom: 110px; }

/* HERO */
.hero { position: relative; height: 228px; background: linear-gradient(160deg, #3A1418 0%, #200D11 55%, var(--bg) 100%); overflow: hidden; }
.hero-glow { position: absolute; inset: 0; background: radial-gradient(ellipse at 30% 20%, rgba(201, 162, 39, 0.22), transparent 55%); }
.hero-fade { position: absolute; inset: 0; background: linear-gradient(to top, var(--bg) 0%, rgba(18, 11, 14, 0.15) 55%, rgba(18, 11, 14, 0.35) 100%); }
.hero-text { position: absolute; left: 20px; right: 20px; bottom: 20px; }
.hero-title { margin: 0; font-family: var(--font-title); font-weight: 780; font-style: italic; font-size: 34px; line-height: 1.02; letter-spacing: -0.3px; }
.hero-tag { margin: 6px 0 0; font-size: 13px; color: var(--text-2); }
.hero-tools { position: absolute; top: 16px; right: 16px; z-index: 3; display: flex; align-items: flex-start; gap: 6px; }
.pill { position: relative; display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: #F3E9D8; background: rgba(18, 11, 14, 0.45); border: 1px solid rgba(247, 239, 227, 0.25); border-radius: 20px; padding: 5px 10px; white-space: nowrap; }
.pill::after { content: ''; position: absolute; inset: -8px -3px; } /* area di tocco più grande dell'etichetta */
.pill[aria-pressed='true'] { background: var(--accent-2); border-color: var(--accent-2); color: #120B0E; }
.lang-wrap { position: relative; }
.lang-menu { position: absolute; top: calc(100% + 6px); right: 0; min-width: 130px; margin: 0; padding: 4px; list-style: none; background: #241519; border: 1px solid rgba(247, 239, 227, 0.2); border-radius: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); }
.lang-opt { display: block; width: 100%; text-align: left; background: none; border: none; border-radius: 8px; padding: 10px 12px; font-size: 14px; color: var(--text); }
.lang-opt[aria-selected='true'] { color: var(--accent); font-weight: 600; }
.review { display: inline-flex; align-items: center; gap: 5px; margin-top: 10px; font-size: 11.5px; font-weight: 500; color: var(--text-2); text-decoration: none; border-bottom: 1px solid rgba(227, 210, 184, 0.35); padding-bottom: 1px; }

/* BARRA FISSA: ricerca, filtri alimentari e categorie restano sempre visibili */
.stickybar { position: sticky; top: 0; z-index: 20; background: var(--bg); }
.searchrow { display: flex; gap: 8px; padding: 10px 20px 8px; }
.searchbar { flex: 1; display: flex; align-items: center; gap: 8px; background: rgba(247, 239, 227, 0.07); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; color: #A8998A; min-height: 42px; }
.searchbar input { flex: 1; min-width: 0; background: none; border: none; outline: none; font: inherit; font-size: 16px; color: #F3E9D8; }
.searchbar:focus-within { border-color: var(--accent-2); }
.searchbar input::placeholder { color: #A8998A; }
.filters { display: flex; gap: 8px; padding: 0 20px 8px; overflow-x: auto; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters .chip { flex-shrink: 0; }
.chip { display: inline-block; font-size: 11px; font-weight: 500; color: #F3E9D8; background: rgba(247, 239, 227, 0.12); border: 1px solid rgba(247, 239, 227, 0.2); border-radius: 20px; padding: 4px 10px; }
.chip-toggle { min-height: 34px; padding: 4px 12px; }
.chip-toggle[aria-pressed='true'] { background: var(--accent-2); border-color: var(--accent-2); color: #120B0E; font-weight: 600; }

/* PIÙ AMATI */
.trend { padding: 2px 20px 12px; }
.trend-head { margin: 0; font-size: 12px; font-weight: 600; color: var(--text-3); }
.demo-tag { font-weight: 400; font-style: italic; color: #A8998A; margin-left: 4px; }
.trend-row { display: flex; gap: 9px; overflow-x: auto; margin-top: 8px; padding-bottom: 2px; scrollbar-width: none; }
.trend-row::-webkit-scrollbar { display: none; }
.trend-item { flex-shrink: 0; width: 62px; padding: 0; border: none; background: none; text-align: left; display: flex; flex-direction: column; justify-content: flex-start; align-self: flex-start; }
.trend-thumb { display: block; position: relative; width: 62px; height: 78px; border-radius: 8px; overflow: hidden; background: #3A3028; }
.trend-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.trend-fade { position: absolute; inset: 0; background: linear-gradient(to top, rgba(15, 9, 12, 0.9), rgba(15, 9, 12, 0) 60%); }
.trend-price { position: absolute; left: 5px; bottom: 4px; font-size: 10.5px; font-weight: 600; color: var(--accent); }
.trend-name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 4px; font-size: 10.5px; line-height: 1.2; color: var(--text-2); }
.trend-rank { position: absolute; z-index: 1; top: 4px; left: 5px; font-family: var(--font-title); font-style: italic; font-weight: 780; font-size: 13px; color: #F3E9D8; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8); }

/* TAB CATEGORIE (dentro la barra fissa) */
.tabs { display: flex; overflow-x: auto; padding: 2px 20px 0; background: var(--bg); border-bottom: 1px solid rgba(247, 239, 227, 0.08); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex-shrink: 0; background: none; border: none; border-bottom: 2px solid transparent; font-size: 13px; font-weight: 500; letter-spacing: 0.2px; color: var(--text-3); padding: 12px 0 10px; margin-right: 18px; white-space: nowrap; }
.tab[aria-selected='true'] { color: #F3E9D8; border-bottom-color: var(--accent-2); }

/* GRIGLIA */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--bg-deep); margin-top: 1px; }
.tile { position: relative; aspect-ratio: 3 / 4; background: #3A3028; overflow: hidden; }
.tile.soldout .tile-main { opacity: 0.55; }
.tile-main { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: none; background: none; text-align: left; overflow: hidden; }
.tile-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #3A3028; }
.tile-fade { position: absolute; inset: 0; background: linear-gradient(to top, rgba(15, 9, 12, 0.95) 0%, rgba(15, 9, 12, 0.35) 48%, rgba(15, 9, 12, 0) 72%); }
.tile-caption { position: absolute; left: 9px; right: 9px; bottom: 8px; }
.tile-name { display: block; font-family: var(--font-title); font-size: 13.5px; line-height: 1.15; font-weight: 600; color: var(--text); }
.tile-price { display: block; margin-top: 2px; font-size: 12px; font-weight: 600; color: var(--accent); }
.tile-likes { position: absolute; right: 0; bottom: 0; display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; color: #F3E9D8; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7); }
.tile-likes svg { color: var(--accent); }
.tile-status { position: absolute; top: 8px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(123, 174, 99, 0.18); pointer-events: none; }
.tile.soldout .tile-status { display: none; }
.tile-soldout { position: absolute; top: 8px; right: 8px; font-size: 9.5px; font-weight: 600; letter-spacing: 0.3px; color: #fff; background: rgba(194, 84, 80, 0.9); padding: 2px 6px; border-radius: 3px; pointer-events: none; }
/* Cuoricino: area di tocco 44x44 con icona piccola */
.tile-heart { position: absolute; top: 0; left: 0; width: 44px; height: 44px; padding: 0; background: none; border: none; display: flex; align-items: flex-start; justify-content: flex-start; padding: 7px 0 0 8px; color: var(--text); }
.tile-heart svg { width: 16px; height: 16px; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6)); }
.heart-path { fill: none; stroke: currentColor; stroke-width: 1.8; }
[aria-pressed='true'] > svg .heart-path, [aria-pressed='true'] > svg .rec-path { fill: var(--accent); stroke: var(--accent); }
.empty { margin: 40px 20px; text-align: center; color: var(--text-3); font-size: 14px; line-height: 1.5; }

.legal { padding: 28px 20px 40px; text-align: center; }
.legal a { font-size: 12px; color: var(--text-3); text-decoration: underline; }

/* ACCESSIBILITÀ: testo solo per lettori di schermo */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* SCHERMATA DI ATTESA (c'è nell'HTML: compare prima che arrivi qualsiasi script) */
.boot { position: fixed; inset: 0; z-index: 200; background: var(--bg-deep); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; gap: 8px; }
.boot-name { margin: 0; font-family: var(--font-title); font-size: 28px; font-weight: 700; line-height: 1.1; color: var(--text); }
.boot-msg { margin: 0; font-size: 14px; color: var(--text-3); }
.boot-late { margin: 14px 0 0; max-width: 300px; font-size: 13px; line-height: 1.5; color: var(--text-2); opacity: 0; visibility: hidden; animation: boot-late 0.01s linear 12s forwards; }
.boot-late a { color: var(--accent); }
@keyframes boot-late { to { opacity: 1; visibility: visible; } }

/* ERRORE */
.fatal { position: absolute; inset: 0; z-index: 40; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; gap: 4px; font-family: var(--font-title); font-size: 20px; }
.fatal p { margin: 0; }
.fatal-sub { font-family: var(--font-text); font-size: 13px; color: var(--text-3); }

/* DETTAGLIO */
.detail { position: fixed; inset: 0; z-index: 100; background: #000; display: flex; justify-content: center; }
.detail > * { max-width: 480px; }
.d-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; left: 50%; transform: translateX(-50%); max-width: 480px; background: #1B0E0E; }
.d-scrim { position: absolute; inset: 0; left: 50%; transform: translateX(-50%); width: 100%; background: linear-gradient(to top, rgba(15, 9, 12, 0.96) 0%, rgba(15, 9, 12, 0.55) 32%, rgba(15, 9, 12, 0) 62%); }
.detail > .d-progress, .detail > .icon-btn, .detail > .rail, .detail > .d-text { position: absolute; }
.d-progress { top: calc(14px + env(safe-area-inset-top)); left: 50%; width: calc(100% - 32px); max-width: 448px; transform: translateX(-50%); height: 2px; border-radius: 2px; background: rgba(247, 239, 227, 0.25); overflow: hidden; }
.d-progress-fill { height: 100%; width: 0; background: #F3E9D8; }
.icon-btn { top: calc(30px + env(safe-area-inset-top)); width: 44px; height: 44px; border-radius: 50%; background: rgba(18, 11, 14, 0.5); border: 1px solid rgba(247, 239, 227, 0.2); display: flex; align-items: center; justify-content: center; color: var(--text); }
.d-close { left: max(12px, calc(50vw - 240px + 12px)); }
.rail { right: max(14px, calc(50vw - 240px + 14px)); bottom: calc(34px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; align-items: center; }
.d-play { position: absolute; z-index: 1; top: 40%; left: 50%; transform: translate(-50%, -50%); width: 72px; height: 72px; border-radius: 50%; background: rgba(18, 11, 14, 0.55); border: 1px solid rgba(247, 239, 227, 0.35); color: #F3E9D8; display: flex; align-items: center; justify-content: center; }
.rail-btn { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.rail-circle { width: 44px; height: 44px; border-radius: 50%; background: rgba(18, 11, 14, 0.45); border: 1px solid rgba(247, 239, 227, 0.18); display: flex; align-items: center; justify-content: center; color: var(--text); }
.rail-circle[aria-pressed='true'] { border-color: var(--accent); color: var(--accent); }
.rail-circle:disabled { opacity: 0.6; }
.rail-label { display: flex; flex-direction: column; align-items: center; font-size: 11px; line-height: 1.15; color: #F3E9D8; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }
.rail-count { font-size: 13px; font-weight: 700; }
/* Schermi bassi (telefoni piccoli, orizzontale): pulsanti più compatti, numero e parola sulla stessa riga */
@media (max-height: 640px) {
  .rail { gap: 8px; }
  .rail-btn { gap: 2px; }
}
@media (max-height: 540px) {
  .rail-circle { width: 40px; height: 40px; }
}
/* Orizzontale (schermo molto basso): numero e parola sulla stessa riga */
@media (max-height: 450px) {
  .rail-circle { width: 38px; height: 38px; }
  .rail-label { flex-direction: row; gap: 3px; }
}
.d-text { left: max(20px, calc(50vw - 240px + 20px)); width: calc(min(100vw, 480px) - 116px); max-height: calc(100vh - 140px); max-height: calc(100dvh - 140px); overflow-y: auto; scrollbar-width: none; bottom: calc(34px + env(safe-area-inset-bottom)); }
@media (max-height: 450px) { .d-text { width: calc(min(100vw, 480px) - 136px); } } /* orizzontale: più spazio ai pulsanti */
.d-name { margin: 0; font-family: var(--font-title); font-weight: 700; font-size: 26px; line-height: 1.05; }
.d-price { margin: 4px 0 0; font-weight: 600; font-size: 16px; color: var(--accent); }
.d-desc { margin: 8px 0 0; font-size: 13px; line-height: 1.4; color: var(--text-2); }
.d-pairing { display: flex; align-items: center; gap: 6px; margin: 10px 0 0; font-size: 12px; font-style: italic; color: var(--text-3); }
.d-chips { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; }

/* INFO: bottom sheet */
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.45); max-width: none !important; }
.sheet { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); width: 100%; height: 72%; background: #1B1013; border-radius: 20px 20px 0 0; box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.4); overflow-y: auto; overscroll-behavior: contain; }
.sheet-handle { width: 36px; height: 4px; border-radius: 2px; background: rgba(247, 239, 227, 0.25); margin: 10px auto 0; }
.sheet-close { position: absolute; top: 10px; right: 12px; width: 44px; height: 44px; border-radius: 50%; background: none; border: none; display: flex; align-items: center; justify-content: center; color: var(--text); }
.sheet-body { padding: 22px 22px 40px; }
.s-name { margin: 0; font-family: var(--font-title); font-weight: 700; font-size: 21px; }
.s-price { margin: 2px 0 0; font-weight: 600; font-size: 14px; color: var(--accent); }
.s-section { margin-top: 20px; }
.s-label { margin: 0 0 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.2px; color: var(--accent-2); }
.s-story { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--text-2); }
.s-ingredients { margin: 0; font-size: 13px; line-height: 1.6; color: #F3E9D8; }
.s-alcohol { margin: 8px 0 0; font-size: 12.5px; line-height: 1.45; color: #D98784; }
.s-allergens { list-style: none; margin: 0; padding: 0; }
.allergen-row { display: flex; align-items: center; gap: 9px; padding: 8px 0; border-top: 1px solid rgba(247, 239, 227, 0.08); }
.allergen-row:first-child { border-top: none; }
.allergen-icon { flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%; background: rgba(194, 84, 80, 0.16); display: flex; align-items: center; justify-content: center; color: #D98784; }
.allergen-text { font-size: 13px; color: #F3E9D8; }
.allergen-none { font-size: 13px; color: var(--text-3); margin: 0; }
.allergen-ask { font-size: 13px; font-weight: 600; color: #F3E9D8; margin: 0; }
.s-disclaimer { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid rgba(247, 239, 227, 0.1); font-size: 11.5px; font-style: italic; line-height: 1.5; color: #B6A68C; }

@media (prefers-reduced-motion: no-preference) {
  .sheet { animation: sheet-in 0.25s ease-out; }
  .detail { animation: fade-in 0.18s ease-out; }
}
@keyframes sheet-in { from { transform: translate(-50%, 24px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
