/* ══════════════════════════════════════════════════════════
   LUXURY LAYER — Pagina di selezione + vista carta
   Caricato dopo style.css.

   AGGIUNGERE UNA NUOVA CATEGORIA IN FUTURO
   1. In index.html aggiungi una nuova <section class="sezione-vini"
      data-sezione="nome-categoria"> con titolo e descrizione:
      la tessera appare da sola nella pagina di selezione.
   2. (Opzionale) Dai un colore dedicato alla tessera:
        .cat-nome-categoria { --accent: #hex; --deep: #hex; }
      Senza questa riga la tessera usa automaticamente l'oro della casa.
═══════════════════════════════════════════════════════════ */

/* ── Gestione viste ─────────────────────────────────────── */
body.view-selection .carta-head,
body.view-selection #carta,
body.view-selection .carta-fab { display: none; }

body.view-carta .selection { display: none; }

/* Prima che lo script decida la vista, evita il flash della carta */
body:not(.view-carta) #carta { display: none; }

/* ══════════════════════════════════════════════════════════
   PAGINA DI SELEZIONE
═══════════════════════════════════════════════════════════ */
.selection {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1.6rem, 4vh, 2.8rem);
  padding: clamp(4.5rem, 9vh, 6rem) 0 2rem;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(ellipse at 50% -12%, rgba(216, 182, 122, 0.22), transparent 55%),
    radial-gradient(circle at 12% 35%, rgba(163, 64, 80, 0.16), transparent 45%),
    radial-gradient(circle at 88% 65%, rgba(74, 154, 176, 0.14), transparent 45%),
    linear-gradient(180deg, #07111b 0%, #0c1825 100%);
}

/* grana fine */
.selection::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
  opacity: 0.05;
  mix-blend-mode: overlay;
  pointer-events: none;
}

.selection-glow {
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  filter: blur(130px);
  pointer-events: none;
  animation: glowFloat 18s ease-in-out infinite alternate;
}
.glow-a { width: 500px; height: 500px; top: -140px; left: -120px; background: rgba(163, 64, 80, 0.28); }
.glow-b { width: 540px; height: 540px; bottom: -160px; right: -160px; background: rgba(201, 169, 110, 0.18); animation-delay: -7s; }

@keyframes glowFloat {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(50px, 30px) scale(1.15); }
}

/* ── Intestazione ── */
.selection-head {
  text-align: center;
  padding: 0 1.5rem;
  animation: rise 1.1s cubic-bezier(.2, .8, .2, 1) both;
}

.selection-brand {
  font-family: 'Cinzel', serif;
  font-weight: 500;
  font-size: clamp(2.4rem, 6.5vw, 5rem);
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  text-transform: uppercase;
  line-height: 1.05;
  background: linear-gradient(100deg, #b8953a 0%, #f3e2b3 35%, #c9a96e 55%, #f3e2b3 75%, #b8953a 100%);
  background-size: 220% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: goldShine 8s linear infinite;
}

@keyframes goldShine { to { background-position: 220% center; } }

.selection-tagline {
  margin-top: 0.6rem;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: clamp(1.15rem, 2.2vw, 1.5rem);
  letter-spacing: 0.1em;
  color: rgba(232, 220, 200, 0.8);
}

.selection-hint {
  margin-top: 1.3rem;
  font-family: 'Cinzel', serif;
  font-size: 0.68rem;
  letter-spacing: 0.5em;
  text-indent: 0.5em;
  text-transform: uppercase;
  color: var(--oro);
  display: inline-flex;
  align-items: center;
  gap: 1rem;
}
.selection-hint::before,
.selection-hint::after {
  content: '';
  width: 36px;
  height: 1px;
  background: linear-gradient(90deg, transparent, currentColor);
  opacity: 0.45;
}
.selection-hint::after {
  background: linear-gradient(90deg, currentColor, transparent);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: none; }
}

/* ── Griglia scalabile ──
   Flex-wrap centrato: con qualsiasi numero di categorie
   le righe incomplete restano centrate ed eleganti. */
.selection-grid {
  --gap: 16px;
  --cols: 3;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--gap);
  width: min(1180px, 92vw);
}

/* ── Tessera categoria ── */
.cat-tile {
  --accent: #c9a96e;   /* default: oro della casa */
  --deep:   #1c160b;
  position: relative;
  flex: 0 1 calc((100% - (var(--cols) - 1) * var(--gap)) / var(--cols));
  min-height: clamp(190px, 27vh, 280px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.7rem 1.8rem;
  text-decoration: none;
  color: var(--bianco);
  border-radius: 20px;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(120% 90% at 100% 110%, color-mix(in srgb, var(--accent) 50%, transparent) 0%, transparent 60%),
    linear-gradient(160deg, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.38)),
    var(--deep);
  box-shadow: 0 12px 32px -4px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  transition: transform .5s cubic-bezier(.2, .8, .2, 1), box-shadow .5s;
  animation: tileIn .9s cubic-bezier(.2, .8, .2, 1) both;
  animation-delay: calc(.3s + var(--i) * .08s);
}

@keyframes tileIn {
  from { opacity: 0; transform: translateY(36px); }
  to   { opacity: 1; transform: none; }
}

/* cornice dorata interna */
.cat-frame {
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(201, 169, 110, 0.28);
  border-radius: 14px;
  pointer-events: none;
  transition: inset .5s cubic-bezier(.2, .8, .2, 1), border-color .4s;
}

/* riflesso che attraversa la tessera */
.cat-tile::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: -70%;
  width: 45%;
  z-index: 1;
  background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.12), transparent);
  transform: skewX(-18deg);
  transition: left 1s ease;
  pointer-events: none;
}

/* alone colorato */
.cat-tile::after {
  content: '';
  position: absolute;
  inset: auto -20% -60% auto;
  width: 80%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--accent);
  filter: blur(70px);
  opacity: 0.18;
  z-index: -1;
  transition: opacity .6s, transform .8s;
}

.cat-tile:hover,
.cat-tile:focus-visible {
  transform: translateY(-6px);
  box-shadow: 0 22px 50px -6px rgba(0, 0, 0, 0.6), 0 0 25px -2px color-mix(in srgb, var(--accent) 35%, transparent), 0 0 0 1px color-mix(in srgb, var(--accent) 50%, transparent);
  outline: none;
}
.cat-tile:hover::before,
.cat-tile:focus-visible::before { left: 130%; }
.cat-tile:hover::after { opacity: 0.42; transform: scale(1.25); }
.cat-tile:hover .cat-frame { inset: 7px; border-color: rgba(243, 226, 179, 0.65); }

.cat-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  position: relative;
  z-index: 2;
}

.cat-index {
  font-family: 'Cinzel', serif;
  font-size: 0.75rem;
  letter-spacing: 0.3em;
  color: var(--oro);
}

.cat-count {
  font-family: 'Cinzel', serif;
  font-size: 0.6rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: rgba(232, 220, 200, 0.55);
}
.cat-count b {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 400;
  font-size: 1.4rem;
  letter-spacing: 0.05em;
  color: var(--oro-chiaro);
}

.cat-body {
  position: relative;
  z-index: 2;
  display: block;
}

.cat-name {
  display: block;
  font-family: 'Cormorant Garamond', serif;
  font-weight: 400;
  font-size: clamp(1.8rem, 2.6vw, 2.4rem);
  line-height: 1.05;
  letter-spacing: 0.02em;
  color: var(--bianco);
}

.cat-desc {
  display: block;
  margin-top: 0.45rem;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 1.02rem;
  line-height: 1.35;
  color: rgba(232, 220, 200, 0.68);
  max-width: 30ch;
}

.cat-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1rem;
  font-family: 'Cinzel', serif;
  font-size: 0.62rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--oro-chiaro);
  opacity: 0.55;
  transition: opacity .4s, gap .4s;
}
.cat-cta i { font-style: normal; transition: transform .4s; }
.cat-tile:hover .cat-cta { opacity: 1; gap: 1rem; }
.cat-tile:hover .cat-cta i { transform: translateX(4px); }

/* ── Colori per categoria (nuove categorie => oro di default) ── */
.cat-liguri              { --accent: #c9a96e; --deep: #161c16; }
.cat-trentino-alto-adige { --accent: #78a87b; --deep: #101c13; }
.cat-friuli-venezia-giulia { --accent: #e2ba6f; --deep: #1a160d; }
.cat-calici              { --accent: #d46b7a; --deep: #210d13; }
.cat-birre-mezzebottiglie { --accent: #d99e4b; --deep: #1c150b; }
.cat-bianchi             { --accent: #e6d396; --deep: #1f1d12; }
.cat-rossi               { --accent: #a3243b; --deep: #22080d; }
.cat-rose                { --accent: #e3949f; --deep: #2a141a; }
.cat-bollicine           { --accent: #d9b44f; --deep: #211b0b; }
.cat-triple-a            { --accent: #4a9ab0; --deep: #0b1e28; }

/* ── Colori per categorie Menù Digitale ── */
.cat-antipasti           { --accent: #e6d396; --deep: #1f1d12; }
.cat-primi               { --accent: #d9b44f; --deep: #211b0b; }
.cat-secondi             { --accent: #a3243b; --deep: #22080d; }
.cat-dolci               { --accent: #e3949f; --deep: #2a141a; }
.cat-degustazione        { --accent: #c9a96e; --deep: #161c16; }

/* ── "Tutta la carta": fascia orizzontale in fondo ── */
.cat-tile.cat-all {
  --accent: #c9a96e;
  --deep: #0e1925;
  flex-basis: 100%;
  min-height: 0;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.25rem 2rem;
  border-radius: 20px;
  background:
    linear-gradient(90deg, rgba(201, 169, 110, 0.12), transparent 40%, transparent 60%, rgba(201, 169, 110, 0.12)),
    var(--deep);
}
.cat-all .cat-top { order: 2; gap: 1.5rem; }
.cat-all .cat-index { display: none; }
.cat-all .cat-body { display: flex; align-items: baseline; gap: 1.4rem; flex-wrap: wrap; }
.cat-all .cat-name { font-family: 'Cinzel', serif; font-size: 0.95rem; letter-spacing: 0.35em; text-transform: uppercase; }
.cat-all .cat-desc { margin: 0; max-width: none; }
.cat-all .cat-cta { margin: 0; }

.selection-foot {
  font-family: 'Cinzel', serif;
  font-size: 0.62rem;
  letter-spacing: 0.38em;
  text-transform: uppercase;
  color: rgba(201, 169, 110, 0.6);
  text-align: center;
  padding: 0 1rem;
  animation: rise 1.1s 1s cubic-bezier(.2, .8, .2, 1) both;
}

/* ══════════════════════════════════════════════════════════
   VISTA CARTA
═══════════════════════════════════════════════════════════ */
.carta-head {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
  padding: 2.2rem 1.5rem 1.8rem;
  border-bottom: 1px solid rgba(201, 169, 110, 0.18);
  background: linear-gradient(180deg, rgba(8, 17, 26, 0.96), rgba(12, 24, 37, 0.6) 80%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: rise .8s cubic-bezier(.2, .8, .2, 1) both;
}

.carta-head-brand {
  font-family: 'Cinzel', serif;
  font-size: clamp(1.4rem, 3vw, 2rem);
  letter-spacing: 0.25em;
  text-indent: 0.25em;
  text-transform: uppercase;
  text-decoration: none;
  background: linear-gradient(100deg, #b8953a, #f3e2b3, #c9a96e);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.carta-back,
.carta-fab {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-family: 'Cinzel', serif;
  font-size: 0.66rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--oro-chiaro);
  background: rgba(12, 24, 37, 0.75);
  border: 1px solid rgba(201, 169, 110, 0.38);
  border-radius: 999px;
  padding: 0.75rem 1.7rem;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background .35s, color .35s, gap .35s, border-color .35s, box-shadow .35s, transform .35s;
}
.carta-back:hover,
.carta-fab:hover {
  background: var(--oro);
  color: #0c1825;
  border-color: var(--oro-chiaro);
  box-shadow: 0 10px 28px rgba(201, 169, 110, 0.35);
  gap: 1rem;
}

.carta-fab {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  z-index: 900;
  transform: translate(-50%, 140%);
  opacity: 0;
  transition: transform .5s cubic-bezier(.2, .8, .2, 1), opacity .4s, background .35s, color .35s, gap .35s, box-shadow .35s;
}
body.view-carta.scrolled .carta-fab {
  transform: translate(-50%, 0);
  opacity: 1;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1000px) {
  .selection-grid { --cols: 2; }
}

@media (max-width: 640px) {
  .selection { justify-content: flex-start; padding-top: 5rem; }
  .selection-grid { --cols: 1; --gap: 10px; }
  .cat-tile { min-height: 0; padding: 1.3rem 1.4rem; gap: 1.4rem; }
  .cat-name { font-size: 1.75rem; }
  .cat-cta { opacity: 0.85; }
  .cat-tile.cat-all { flex-direction: column; align-items: flex-start; gap: 0.6rem; }
  .cat-all .cat-top { order: 0; }
  .carta-head { padding-top: 4.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  .selection *, .selection, .carta-head { animation: none !important; }
}
