/* ==========================================================================
   Proof & Char — a bourbon field guide
   Tokens first; every component styles through them so both themes come free.
   ========================================================================== */

:root {
  /* type roles */
  --font-plate:   Copperplate, "Copperplate Gothic Light", "Engravers Gothic",
                  Optima, "Gill Sans", "Gill Sans MT", sans-serif;
  --font-display: "Hoefler Text", Baskerville, "Iowan Old Style",
                  "Palatino Linotype", Palatino, Georgia, serif;
  --font-body:    "Helvetica Neue", Helvetica, "Segoe UI", system-ui, sans-serif;
  --font-data:    ui-monospace, "SF Mono", SFMono-Regular, Menlo,
                  "DejaVu Sans Mono", monospace;

  /* scale */
  --fs-xs:   0.6875rem;
  --fs-sm:   0.8125rem;
  --fs-base: 1.0625rem;
  --fs-lg:   1.25rem;
  --fs-xl:   1.6rem;
  --fs-2xl:  clamp(1.9rem, 3.4vw, 2.6rem);
  --fs-hero: clamp(3.2rem, 12vw, 8.5rem);

  --sp-1: 0.35rem;
  --sp-2: 0.7rem;
  --sp-3: 1.1rem;
  --sp-4: 1.75rem;
  --sp-5: 2.75rem;
  --sp-6: 4.5rem;
  --sp-7: 7rem;

  --measure: 62ch;
  --gutter: clamp(1.25rem, 5vw, 4rem);
  --maxw: 76rem;

  /* palette — dark is the design's native ground */
  --bg:          #14100d;
  --bg-2:        #1b1613;
  --bg-3:        #221b17;
  --line:        #2e2620;
  --line-strong: #453931;
  --fg:          #e8ddce;
  --fg-2:        #b6a695;
  --fg-3:        #8a7a6b;
  --accent:      #e09540;
  --accent-ink:  #14100d;
  --accent-soft: rgba(224, 149, 64, 0.13);
  --ember:       #c4553a;

  /* grain data hues — semantic, not accent */
  --grain-corn:  #c98a3e;
  --grain-rye:   #b4472a;
  --grain-wheat: #c9b27a;
  --grain-malt:  #6e7a5e;

  --shadow: 0 1px 0 rgba(255, 255, 255, 0.025) inset;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:          #e9e6de;
    --bg-2:        #f3f1ea;
    --bg-3:        #faf8f3;
    --line:        #d2ccbe;
    --line-strong: #b0a794;
    --fg:          #1a1512;
    --fg-2:        #4e453b;
    --fg-3:        #6e6558;
    --accent:      #a45d14;
    --accent-ink:  #faf8f3;
    --accent-soft: rgba(164, 93, 20, 0.09);
    --ember:       #8e3a20;
    --grain-corn:  #b8802f;
    --grain-rye:   #9b4426;
    --grain-wheat: #9d8546;
    --grain-malt:  #5c6a4c;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.02) inset;
    color-scheme: light;
  }
}

/* explicit toggle must beat the media query in both directions */
:root[data-theme="light"] {
  --bg:          #e9e6de;
  --bg-2:        #f3f1ea;
  --bg-3:        #faf8f3;
  --line:        #d2ccbe;
  --line-strong: #b0a794;
  --fg:          #1a1512;
  --fg-2:        #4e453b;
  --fg-3:        #6e6558;
  --accent:      #a45d14;
  --accent-ink:  #faf8f3;
  --accent-soft: rgba(164, 93, 20, 0.09);
  --ember:       #8e3a20;
  --grain-corn:  #b8802f;
  --grain-rye:   #9b4426;
  --grain-wheat: #9d8546;
  --grain-malt:  #5c6a4c;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.02) inset;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg:          #14100d;
  --bg-2:        #1b1613;
  --bg-3:        #221b17;
  --line:        #2e2620;
  --line-strong: #453931;
  --fg:          #e8ddce;
  --fg-2:        #b6a695;
  --fg-3:        #8a7a6b;
  --accent:      #e09540;
  --accent-ink:  #14100d;
  --accent-soft: rgba(224, 149, 64, 0.13);
  --ember:       #c4553a;
  --grain-corn:  #c98a3e;
  --grain-rye:   #b4472a;
  --grain-wheat: #c9b27a;
  --grain-malt:  #6e7a5e;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.025) inset;
  color-scheme: dark;
}

/* --------------------------------------------------------------- base --- */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap {
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.mono {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.plate {
  font-family: var(--font-plate);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: var(--fs-xs);
  font-weight: 400;
  margin: 0;
}

:where(a):focus-visible,
:where(button, select, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 1px;
}

/* --------------------------------------------------------------- hero --- */

.hero {
  padding-block: clamp(3rem, 9vw, var(--sp-7)) var(--sp-6);
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(115% 85% at 8% 0%, var(--accent-soft), transparent 58%),
    var(--bg);
}

.eyebrow { color: var(--accent); }

.hero-title {
  font-family: var(--font-display);
  font-size: var(--fs-hero);
  line-height: 0.86;
  letter-spacing: -0.035em;
  font-weight: 400;
  margin: var(--sp-3) 0 0;
  text-wrap: balance;
}

.hero-title .amp {
  font-style: italic;
  color: var(--accent);
  padding-inline: 0.08em;
  font-size: 0.62em;
  vertical-align: 0.16em;
  letter-spacing: 0;
}

.hero-lede {
  max-width: var(--measure);
  margin: var(--sp-4) 0 0;
  color: var(--fg-2);
  font-size: var(--fs-lg);
  line-height: 1.55;
}

/* --------------------------------------------------------- statute box --- */

.statute {
  margin-top: var(--sp-6);
  border-top: 1px solid var(--line-strong);
  padding-top: var(--sp-3);
}

.statute-h {
  color: var(--fg-3);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: baseline;
}

.cfr {
  font-family: var(--font-data);
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--accent);
}

.statute-list {
  list-style: none;
  margin: var(--sp-4) 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: var(--sp-4) var(--sp-3);
}

.statute-list li {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  border-left: 1px solid var(--line);
  padding-left: var(--sp-3);
}

.statute-n {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
  font-size: 2.1rem;
  line-height: 1;
  color: var(--accent);
  letter-spacing: -0.03em;
}

.statute-n.statute-word {
  font-family: var(--font-display);
  font-style: italic;
  letter-spacing: -0.01em;
}

.statute-t {
  font-size: var(--fs-sm);
  color: var(--fg-2);
  line-height: 1.4;
}

.statute-foot {
  margin: var(--sp-4) 0 0;
  max-width: var(--measure);
  color: var(--fg-3);
  font-size: var(--fs-sm);
}

.statute-foot em { color: var(--fg-2); }

/* ----------------------------------------------------------- sections --- */

.section-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--fs-2xl);
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin: var(--sp-2) 0 0;
  max-width: 20ch;
  text-wrap: balance;
}

.section-lede {
  max-width: var(--measure);
  margin: var(--sp-3) 0 0;
  color: var(--fg-2);
}

.char, .shelf, .glossary { padding-block: var(--sp-6); }
.char { border-bottom: 1px solid var(--line); }
.shelf { border-bottom: 1px solid var(--line); background: var(--bg-2); }

/* --------------------------------------------------------- char figure --- */

.char-fig { margin: var(--sp-5) 0 0; }

.char-canvas {
  display: block;
  width: 100%;
  height: clamp(96px, 15vw, 150px);
  border: 1px solid var(--line-strong);
  background: var(--bg-3);
}

/* gap-as-rule, so the dividers stay correct at one, two or four columns */
.char-scale {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line-strong);
  border-top: 0;
}

.char-scale li {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-3);
  background: var(--bg);
}

.char-n { color: var(--accent); }
.char-t { font-size: var(--fs-sm); color: var(--fg); }
.char-d { font-size: var(--fs-sm); color: var(--fg-3); line-height: 1.4; }

/* ----------------------------------------------------------- controls --- */

.controls {
  margin-top: var(--sp-5);
  padding-block: var(--sp-3);
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  align-items: center;
  justify-content: space-between;
}

.control-group {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.control-label { color: var(--fg-3); }

.chips { display: flex; flex-wrap: wrap; gap: var(--sp-1); }

.chip {
  font: inherit;
  font-size: var(--fs-sm);
  font-family: var(--font-data);
  letter-spacing: 0.02em;
  color: var(--fg-2);
  background: transparent;
  border: 1px solid var(--line-strong);
  padding: 0.32em 0.85em;
  cursor: pointer;
  transition: color 0.18s, background-color 0.18s, border-color 0.18s;
}

.chip:hover { color: var(--fg); border-color: var(--fg-3); }

.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.chip .chip-n {
  opacity: 0.6;
  margin-left: 0.5em;
  font-size: 0.92em;
}

.select {
  font-size: var(--fs-sm);
  color: var(--fg);
  background: var(--bg-3);
  border: 1px solid var(--line-strong);
  padding: 0.38em 0.6em;
  cursor: pointer;
}

.family-note {
  margin: var(--sp-3) 0 0;
  max-width: var(--measure);
  color: var(--fg-3);
  font-size: var(--fs-sm);
  min-height: 1.4em;
}

/* -------------------------------------------------------------- cards --- */

.grid {
  margin-top: var(--sp-4);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 21rem), 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}

.card {
  background: var(--bg);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  box-shadow: var(--shadow);
  transition: background-color 0.2s;
}

.card:hover { background: var(--bg-3); }

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--sp-2);
}

.card-house { color: var(--fg-3); }

.tag {
  font-family: var(--font-data);
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
  color: var(--ember);
  border: 1px solid currentColor;
  padding: 0.1em 0.45em;
  white-space: nowrap;
}

.card-name {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--fs-xl);
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin: 0;
  text-wrap: balance;
}

/* proof instrument */
.proof { display: flex; flex-direction: column; gap: var(--sp-2); }

.proof-read {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.proof-n {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
  font-size: 2.6rem;
  line-height: 0.9;
  letter-spacing: -0.045em;
  color: var(--accent);
}

.proof-unit { color: var(--fg-3); }
.proof-abv { margin-left: auto; font-size: var(--fs-sm); color: var(--fg-3); }

.ruler {
  position: relative;
  height: 20px;
  border-top: 1px solid var(--line-strong);
}

.ruler-tick {
  position: absolute;
  top: 0;
  width: 1px;
  height: 5px;
  background: var(--line-strong);
}

.ruler-tick span {
  position: absolute;
  top: 7px;
  left: 0;
  transform: translateX(-50%);
  font-family: var(--font-data);
  font-size: 0.625rem;
  color: var(--fg-3);
  white-space: nowrap;
}

.ruler-tick:first-child span { transform: none; left: 0; }
.ruler-tick:last-child span { transform: translateX(-100%); }

.ruler-mark {
  position: absolute;
  top: -4px;
  width: 9px;
  height: 9px;
  margin-left: -4.5px;
  background: var(--accent);
  transform: rotate(45deg);
  transition: left 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

/* spec rows */
.specs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-2);
  border-block: 1px solid var(--line);
  padding-block: var(--sp-2);
}

.spec { display: flex; flex-direction: column; gap: 0.15rem; }
.spec-k { font-family: var(--font-plate); text-transform: uppercase;
          letter-spacing: 0.12em; font-size: 0.625rem; color: var(--fg-3); }
.spec-v { font-family: var(--font-data); font-variant-numeric: tabular-nums;
          font-size: var(--fs-sm); color: var(--fg); line-height: 1.35; }
.spec-sub { font-family: var(--font-data); font-variant-numeric: tabular-nums;
            font-size: 0.6875rem; color: var(--fg-3); line-height: 1.3; }

/* mash bill bar */
.mash { display: flex; flex-direction: column; gap: var(--sp-2); }

.mash-bar {
  display: flex;
  height: 10px;
  overflow: hidden;
  background: var(--line);
}

.mash-seg {
  height: 100%;
  width: 0;
  transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.mash-seg[data-grain="corn"]  { background: var(--grain-corn); }
.mash-seg[data-grain="rye"]   { background: var(--grain-rye); }
.mash-seg[data-grain="wheat"] { background: var(--grain-wheat); }
.mash-seg[data-grain="malt"]  { background: var(--grain-malt); }

.mash-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.9rem;
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-xs);
  color: var(--fg-2);
}

.mash-legend li { display: flex; align-items: center; gap: 0.35rem; }
.mash-legend { list-style: none; margin: 0; padding: 0; }

.swatch { width: 8px; height: 8px; flex: none; }
.swatch[data-grain="corn"]  { background: var(--grain-corn); }
.swatch[data-grain="rye"]   { background: var(--grain-rye); }
.swatch[data-grain="wheat"] { background: var(--grain-wheat); }
.swatch[data-grain="malt"]  { background: var(--grain-malt); }

.mash-note { font-size: var(--fs-xs); color: var(--fg-3); font-family: var(--font-data); }

.notes {
  margin: 0;
  font-size: var(--fs-sm);
  line-height: 1.55;
  color: var(--fg-2);
}

.notes b {
  font-family: var(--font-plate);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.625rem;
  font-weight: 400;
  color: var(--fg-3);
  display: block;
  margin-bottom: 0.2rem;
}

.verdict {
  margin: auto 0 0;
  padding-top: var(--sp-2);
  border-top: 1px solid var(--line);
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--fs-sm);
  line-height: 1.5;
  color: var(--fg);
}

.grid-foot {
  margin: var(--sp-3) 0 0;
  font-size: var(--fs-sm);
  color: var(--fg-3);
  max-width: var(--measure);
}

.empty {
  grid-column: 1 / -1;
  background: var(--bg);
  padding: var(--sp-5);
  text-align: center;
  color: var(--fg-3);
}

/* ----------------------------------------------------------- glossary --- */

.gloss-list {
  margin: var(--sp-5) 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: var(--sp-4) var(--sp-5);
}

.gloss-list div {
  border-top: 1px solid var(--line-strong);
  padding-top: var(--sp-2);
}

.gloss-list dt {
  font-family: var(--font-plate);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: var(--fs-xs);
  color: var(--accent);
}

.gloss-list dd {
  margin: var(--sp-1) 0 0;
  font-size: var(--fs-sm);
  color: var(--fg-2);
  line-height: 1.55;
}

/* --------------------------------------------------------------- foot --- */

.foot { padding-block: var(--sp-5); background: var(--bg-2); }
.foot .plate { color: var(--accent); }
.foot-note {
  margin: var(--sp-2) 0 0;
  max-width: var(--measure);
  font-size: var(--fs-sm);
  color: var(--fg-3);
}

/* -------------------------------------------------------------- motion --- */

.card {
  opacity: 0;
  transform: translateY(10px);
  animation: rise 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: var(--d, 0ms);
}

@keyframes rise { to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .card { opacity: 1; transform: none; }
}

@media (max-width: 30rem) {
  .specs { grid-template-columns: repeat(2, 1fr); }
  .controls { flex-direction: column; align-items: flex-start; }
}
