/* ============================================================
   PASTAVERSE — warm Italian dark theme
   ============================================================ */
:root {
  --page: #100d09;
  --surface: #1a1610;
  --surface-2: #221c13;
  --surface-3: #2b2317;
  --line: #352c1d;
  --ink: #f4ead6;
  --ink-2: #cbbfa4;
  --ink-3: #93866c;
  --gold: #e8b84b;
  --gold-deep: #b98a1e;
  --terracotta: #c8552e;
  --basil: #7ba05b;
  --wine: #8e3b52;
  --radius: 16px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.6;
  overflow-x: hidden;
}
/* subtle grain */
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 1;
  opacity: .04; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}
::selection { background: var(--gold); color: #1a1206; }
.gold { color: var(--gold); }
a { color: var(--gold); }

/* ---------- NAV ---------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 32px;
  background: color-mix(in srgb, var(--page) 82%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.nav-logo {
  font-family: var(--font-display); font-weight: 800; font-size: 1.3rem;
  letter-spacing: .06em; color: var(--ink); text-decoration: none;
}
.nav-logo span { color: var(--gold); }
.nav-links { display: flex; gap: 4px; flex-wrap: wrap; }
.nav-links a {
  color: var(--ink-2); text-decoration: none; font-size: .84rem; font-weight: 600;
  padding: 7px 13px; border-radius: 99px; transition: all .2s;
}
.nav-links a:hover { color: var(--ink); background: var(--surface-3); }

/* ---------- HERO ---------- */
.hero {
  position: relative; min-height: 100svh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 120px 24px 60px;
  background:
    radial-gradient(1100px 600px at 50% -10%, #2e2410 0%, transparent 60%),
    radial-gradient(800px 500px at 85% 90%, #24160e 0%, transparent 55%),
    var(--page);
}
.hero-pasta-field { position: absolute; inset: 0; overflow: hidden; }
.floaty {
  position: absolute; font-size: 2rem; opacity: .16; user-select: none;
  animation: floatUp linear infinite;
}
@keyframes floatUp {
  from { transform: translateY(110vh) rotate(0deg); }
  to   { transform: translateY(-15vh) rotate(360deg); }
}
.hero-inner { position: relative; z-index: 2; max-width: 880px; }
.hero-eyebrow {
  font-family: var(--font-display); font-style: italic; font-size: 1.2rem;
  color: var(--terracotta); margin-bottom: 8px;
}
.hero-title {
  font-family: var(--font-display); font-weight: 900;
  font-size: clamp(3.2rem, 11vw, 7.5rem); line-height: .95; letter-spacing: .01em;
  text-shadow: 0 20px 60px rgba(232,184,75,.15);
}
.hero-sub {
  margin: 22px auto 0; max-width: 560px; color: var(--ink-2); font-size: 1.05rem;
}
.hero-counter { margin-top: 44px; }
.counter-num {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(2.2rem, 6vw, 4rem); color: var(--gold);
  font-variant-numeric: tabular-nums; letter-spacing: .02em;
}
.counter-label { color: var(--ink-3); font-size: .85rem; letter-spacing: .12em; text-transform: uppercase; }
.hero-cta { margin-top: 36px; display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.hero-stats {
  position: relative; z-index: 2; margin-top: 70px;
  display: flex; gap: 14px; flex-wrap: wrap; justify-content: center;
}
.stat-tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 30px; min-width: 150px;
}
.stat-tile .v { font-family: var(--font-display); font-size: 2rem; font-weight: 700; color: var(--ink); }
.stat-tile .l { font-size: .75rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .1em; }

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-block; padding: 13px 28px; border-radius: 99px;
  font-weight: 700; font-size: .95rem; text-decoration: none; cursor: pointer;
  border: none; font-family: var(--font-body); transition: transform .15s, box-shadow .15s;
}
.btn:active { transform: scale(.97); }
.btn-gold {
  background: linear-gradient(135deg, var(--gold), var(--gold-deep)); color: #221703;
  box-shadow: 0 8px 30px rgba(232,184,75,.25);
}
.btn-gold:hover { transform: translateY(-2px); box-shadow: 0 12px 36px rgba(232,184,75,.4); }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--gold); color: var(--gold); }
.btn-big { font-size: 1.15rem; padding: 18px 40px; }

/* ---------- SECTIONS ---------- */
.section { max-width: 1220px; margin: 0 auto; padding: 110px 24px 30px; }
.section-head { text-align: center; margin-bottom: 44px; }
.section-eyebrow {
  font-family: var(--font-display); font-style: italic; color: var(--terracotta);
  font-size: 1.05rem;
}
.section-head h2 {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1.1; margin: 6px 0 12px;
}
.section-sub { color: var(--ink-2); max-width: 620px; margin: 0 auto; }

/* ---------- ENCYCLOPEDIA ---------- */
.controls { display: flex; flex-direction: column; gap: 16px; margin-bottom: 8px; }
.search {
  width: 100%; max-width: 460px; margin: 0 auto; display: block;
  background: var(--surface); border: 1px solid var(--line); border-radius: 99px;
  padding: 13px 22px; color: var(--ink); font-size: 1rem; font-family: var(--font-body);
  outline: none; transition: border-color .2s;
}
.search:focus { border-color: var(--gold); }
.search::placeholder { color: var(--ink-3); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.chip {
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2);
  border-radius: 99px; padding: 7px 16px; font-size: .84rem; font-weight: 600;
  cursor: pointer; transition: all .18s; font-family: var(--font-body);
}
.chip:hover { border-color: var(--gold-deep); color: var(--ink); }
.chip.active { background: var(--gold); border-color: var(--gold); color: #221703; }
.result-count { text-align: center; color: var(--ink-3); font-size: .84rem; margin: 14px 0 22px; }

.shape-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 16px;
}
.shape-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; cursor: pointer; position: relative; overflow: hidden;
  transition: transform .2s, border-color .2s, box-shadow .2s;
}
.shape-card:hover {
  transform: translateY(-4px); border-color: var(--gold-deep);
  box-shadow: 0 16px 40px rgba(0,0,0,.45);
}
.shape-card .icon { height: 54px; margin-bottom: 12px; color: var(--gold); }
.shape-card h3 { font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; }
.shape-card .meaning { font-style: italic; color: var(--terracotta); font-size: .86rem; margin-bottom: 8px; }
.shape-card .desc { color: var(--ink-2); font-size: .87rem; }
.shape-card .meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.tag {
  font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 99px; background: var(--surface-3); color: var(--ink-2);
}
.tag.region { color: var(--basil); }
.shape-card .best {
  margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line);
  font-size: .8rem; color: var(--ink-3); display: none;
}
.shape-card.open .best { display: block; }
.shape-card .best strong { color: var(--gold); font-weight: 600; }

/* ---------- PAIRING ENGINE ---------- */
.engine {
  background: var(--surface); border: 1px solid var(--line); border-radius: 24px;
  padding: 34px; max-width: 860px; margin: 0 auto;
}
.engine-pickers { display: flex; gap: 18px; align-items: end; flex-wrap: wrap; }
.picker { flex: 1; min-width: 220px; }
.picker label { display: block; font-size: .8rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 8px; }
.picker select {
  width: 100%; background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  font-size: .95rem; font-family: var(--font-body); outline: none; cursor: pointer;
}
.picker select:focus { border-color: var(--gold); }
.picker-or { color: var(--ink-3); font-family: var(--font-display); font-style: italic; padding-bottom: 12px; }
.engine-hint { color: var(--ink-3); text-align: center; padding: 26px 0 6px; }
.engine-results { margin-top: 20px; }
.match-row {
  display: grid; grid-template-columns: 26px 1fr 120px 64px; gap: 14px; align-items: center;
  padding: 11px 10px; border-radius: 12px; transition: background .15s;
}
.match-row:hover { background: var(--surface-2); }
.match-rank { color: var(--ink-3); font-size: .82rem; font-variant-numeric: tabular-nums; text-align: right; }
.match-name { font-weight: 600; font-size: .95rem; }
.match-name .sub { display: block; font-weight: 400; font-size: .78rem; color: var(--ink-3); }
.match-bar { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.match-bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--gold-deep), var(--gold)); }
.match-score { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--gold); text-align: right; font-size: .95rem; }
.match-verdict { grid-column: 2 / -1; margin-top: -6px; font-size: .78rem; font-style: italic; color: var(--ink-3); }
.canon-star { color: var(--terracotta); }

/* ---------- MATRIX ---------- */
.matrix-legend {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin-bottom: 18px; color: var(--ink-3); font-size: .8rem;
}
.legend-ramp { display: flex; border-radius: 6px; overflow: hidden; }
.legend-ramp i { width: 26px; height: 12px; }
.matrix-wrap {
  overflow: auto; max-height: 74vh; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface);
}
.matrix { border-collapse: separate; border-spacing: 2px; margin: 6px; }
.matrix th { font-size: .68rem; font-weight: 600; color: var(--ink-2); background: var(--surface); }
.matrix thead th {
  position: sticky; top: 0; z-index: 3; padding: 6px 3px; vertical-align: bottom;
}
.matrix thead th > div {
  writing-mode: vertical-rl; transform: rotate(180deg);
  max-height: 118px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0 auto;
}
.matrix tbody th {
  position: sticky; left: 0; z-index: 2; text-align: right;
  padding: 0 10px 0 12px; white-space: nowrap; font-size: .74rem;
}
.matrix thead th:first-child { z-index: 4; left: 0; }
.matrix td {
  width: 22px; height: 22px; min-width: 22px; border-radius: 4px; cursor: pointer;
  transition: transform .08s;
}
.matrix td:hover { transform: scale(1.35); outline: 2px solid var(--ink); z-index: 5; position: relative; }
.matrix-tooltip {
  position: fixed; z-index: 200; pointer-events: none; display: none;
  background: #0c0a06; border: 1px solid var(--gold-deep); border-radius: 12px;
  padding: 12px 16px; max-width: 280px; box-shadow: 0 16px 44px rgba(0,0,0,.6);
  font-size: .85rem;
}
.matrix-tooltip .t-title { font-weight: 700; color: var(--gold); font-family: var(--font-display); font-size: .98rem; }
.matrix-tooltip .t-score { font-variant-numeric: tabular-nums; }

/* ---------- LAB ---------- */
.lab { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 26px; align-items: start; }
.lab-controls { display: flex; flex-direction: column; gap: 22px; }
.lab-step {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px;
}
.lab-step h3 {
  font-family: var(--font-display); font-size: 1.15rem; margin-bottom: 14px;
  display: flex; align-items: center; gap: 10px;
}
.step-n {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  background: var(--gold); color: #221703; font-family: var(--font-body);
  font-size: .85rem; font-weight: 800;
}
.servings-row { display: flex; align-items: center; gap: 18px; }
.servings-row input[type=range] { flex: 1; accent-color: var(--gold); }
.servings-val { font-family: var(--font-display); font-size: 1.1rem; white-space: nowrap; }
.servings-val span { color: var(--gold); font-weight: 800; font-size: 1.5rem; }
.option-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.opt {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; cursor: pointer; transition: all .15s; font-family: var(--font-body);
  text-align: left; color: var(--ink);
}
.opt:hover { border-color: var(--gold-deep); }
.opt.active { border-color: var(--gold); background: var(--surface-3); box-shadow: 0 0 0 1px var(--gold); }
.opt .o-name { font-weight: 700; font-size: .88rem; display: block; }
.opt .o-note { font-size: .74rem; color: var(--ink-3); font-style: italic; }
.swatch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.swatch {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 8px; cursor: pointer; text-align: center; transition: all .15s;
  color: var(--ink); font-family: var(--font-body);
}
.swatch:hover { border-color: var(--gold-deep); }
.swatch.active { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.swatch .dot {
  width: 30px; height: 30px; border-radius: 50%; margin: 0 auto 7px;
  border: 2px solid rgba(255,255,255,.18);
}
.swatch .s-name { font-size: .74rem; font-weight: 600; display: block; }

.lab-output { position: sticky; top: 84px; }
.recipe-card {
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  border: 1px solid var(--gold-deep); border-radius: 24px; padding: 30px;
  box-shadow: 0 24px 70px rgba(0,0,0,.5);
}
.recipe-card h3 {
  font-family: var(--font-display); font-size: 1.7rem; font-weight: 800;
  line-height: 1.15; color: var(--gold);
}
.recipe-card .r-sub { font-style: italic; color: var(--ink-3); margin: 4px 0 18px; font-size: .9rem; }
.pasta-preview { margin: 6px 0 18px; }
.r-block { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--line); }
.r-block h4 {
  font-size: .74rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 9px;
}
.ing-row { display: flex; justify-content: space-between; font-size: .92rem; padding: 3px 0; }
.ing-row b { font-variant-numeric: tabular-nums; color: var(--gold); font-weight: 700; }
.timeline { display: flex; flex-direction: column; gap: 8px; }
.tl-step { display: flex; gap: 12px; font-size: .86rem; color: var(--ink-2); }
.tl-step .tl-time { color: var(--gold); font-weight: 700; min-width: 64px; font-variant-numeric: tabular-nums; }
.diff-dots { letter-spacing: 3px; color: var(--gold); }
.r-tip {
  margin-top: 18px; background: var(--surface-3); border-radius: 12px; padding: 12px 16px;
  font-size: .84rem; color: var(--ink-2); font-style: italic;
}
.r-tip::before { content: "👵 Nonna says: "; font-style: normal; font-weight: 700; color: var(--gold); }
.r-pairing { font-size: .88rem; color: var(--ink-2); }
.r-pairing strong { color: var(--gold); }

/* ---------- ROULETTE ---------- */
.roulette-box { text-align: center; padding: 10px 0 30px; }
.roulette-result { max-width: 620px; margin: 28px auto 0; min-height: 40px; }
.roulette-card {
  background: var(--surface); border: 1px solid var(--gold-deep); border-radius: 24px;
  padding: 34px; animation: popIn .4s cubic-bezier(.2,1.4,.4,1);
}
@keyframes popIn { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.roulette-card .rc-combo { font-family: var(--font-display); font-size: 1.8rem; font-weight: 800; line-height: 1.2; }
.roulette-card .rc-x { color: var(--terracotta); font-style: italic; padding: 0 10px; }
.roulette-card .rc-score { margin-top: 10px; font-size: 1rem; color: var(--ink-2); }
.roulette-card .rc-score b { color: var(--gold); font-size: 1.3rem; }
.roulette-card .rc-verdict { margin-top: 6px; font-style: italic; color: var(--ink-3); }

/* ---------- FOOTER ---------- */
.footer {
  margin-top: 110px; padding: 54px 24px; text-align: center;
  border-top: 1px solid var(--line); color: var(--ink-3); font-size: .88rem;
}
.footer-logo { font-family: var(--font-display); font-weight: 800; font-size: 1.2rem; color: var(--ink); margin-bottom: 10px; }
.footer-logo span { color: var(--gold); }
.footer-fine { margin-top: 12px; font-size: .76rem; }

/* ---------- REVEAL ANIMATION ---------- */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .6s, transform .6s; }
.reveal.in { opacity: 1; transform: none; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 900px) {
  .lab { grid-template-columns: 1fr; }
  .lab-output { position: static; }
  .nav { padding: 12px 16px; }
  .nav-links a { padding: 6px 9px; font-size: .78rem; }
}
@media (max-width: 700px) {
  .nav { flex-direction: column; align-items: center; gap: 4px; }
  .nav-links {
    flex-wrap: nowrap; overflow-x: auto; max-width: 100%;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-links a { white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) {
  .floaty { animation: none; }
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
}
