/* ===========================================================
   Ahlchemist — styles
   Palette pulled from the logo: gunmetal navy, copper, silver.
   Display: Fraunces (apothecary serif). Body: Inter.
   Measurements/labels: Spline Sans Mono (a formula reads precise).
   =========================================================== */

:root {
  --bg:          #12161d;
  --bg-raised:   #1a2029;
  --bg-sunk:     #0d1116;
  --ink:         #e9ebef;
  --ink-dim:     #aab2bf;
  --muted:       #7b8494;
  --line:        rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);

  --copper:      #c67c4e;
  --copper-lit:  #e0996a;
  --copper-deep: #9a5c37;
  --silver:      #b7bec8;
  --verdigris:   #66c3a0;   /* "ready to pour" glow */
  --verdigris-d: rgba(102, 195, 160, 0.14);

  --shadow: 0 18px 44px rgba(0, 0, 0, 0.5);

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "Spline Sans Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --radius: 14px;
  --radius-sm: 9px;
  --wrap: 1080px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 600px at 50% -180px, rgba(198, 124, 78, 0.12), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--copper-lit); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 500; letter-spacing: 0.2px; margin: 0; }

/* ---------- Layout ---------- */
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }

.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(13, 17, 22, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 50%;
  box-shadow: 0 0 0 1px var(--line-strong), 0 4px 14px rgba(0,0,0,0.45);
}
.brand-name { font-family: var(--font-display); font-size: 1.28rem; color: var(--ink); line-height: 1; }
.brand-name b { color: var(--copper-lit); font-weight: 600; }
.brand-text { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.ver-badge {
  font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.08em;
  color: var(--copper-lit); background: rgba(198, 124, 78, 0.12);
  border: 1px solid rgba(198, 124, 78, 0.4); border-radius: 999px;
  padding: 2px 8px; text-decoration: none; line-height: 1.4; white-space: nowrap;
}
.ver-badge:hover { background: rgba(198, 124, 78, 0.22); text-decoration: none; }
.brand-sub {
  font-family: var(--font-mono); font-size: 0.58rem; letter-spacing: 0.28em;
  text-transform: uppercase; color: var(--muted); margin-top: 4px;
}
.nav-install {
  font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: 0.06em;
  text-transform: uppercase; color: #1a120b; background: var(--copper);
  border: 1px solid var(--copper); padding: 8px 12px; border-radius: 8px; cursor: pointer;
}
.nav-install:hover { background: var(--copper-lit); border-color: var(--copper-lit); }

/* ---------- Nav ---------- */
.nav { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; }
.nav a {
  font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-dim);
  padding: 8px 12px; border-radius: 8px; border: 1px solid transparent;
}
.nav a:hover { color: var(--ink); background: var(--bg-raised); text-decoration: none; }
.nav a.active { color: var(--copper-lit); border-color: var(--line-strong); background: var(--bg-raised); }

.nav-toggle {
  display: none; margin-left: auto; background: var(--bg-raised);
  color: var(--ink); border: 1px solid var(--line-strong); border-radius: 8px;
  width: 40px; height: 38px; font-size: 1.1rem; cursor: pointer;
}

/* ---------- Section scaffolding ---------- */
.view { padding: 30px 0 70px; animation: rise 0.4s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.eyebrow {
  font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.26em;
  text-transform: uppercase; color: var(--copper); margin-bottom: 10px;
}
.view-title { font-size: clamp(1.8rem, 4vw, 2.6rem); line-height: 1.05; }
.view-intro { color: var(--ink-dim); max-width: 62ch; margin-top: 10px; }

/* ----- Hero banner (Make view) ----- */
.hero {
  position: relative; margin: 4px 0 26px;
  border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 18px 44px -22px rgba(0,0,0,0.7);
  background: var(--bg-sunk);
}
.hero-img {
  display: block; width: 100%; height: clamp(200px, 34vw, 340px);
  object-fit: cover; object-position: center 42%;
}
.hero-veil {
  position: absolute; inset: 0;
  background:
    linear-gradient(90deg, rgba(13,17,22,0.86) 0%, rgba(13,17,22,0.55) 42%, rgba(13,17,22,0.12) 100%),
    linear-gradient(0deg, rgba(13,17,22,0.7) 0%, rgba(13,17,22,0) 55%);
}
.hero-copy {
  position: absolute; left: 0; bottom: 0; padding: clamp(16px, 3vw, 28px);
  max-width: 60ch;
}
.hero-copy .eyebrow { margin-bottom: 8px; }
.hero-title {
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(1.7rem, 4vw, 2.6rem); line-height: 1.04; color: var(--ink);
  text-shadow: 0 2px 18px rgba(0,0,0,0.55);
}
.hero-intro {
  color: var(--ink); margin-top: 10px; max-width: 54ch;
  text-shadow: 0 1px 10px rgba(0,0,0,0.6);
}
@media (max-width: 560px) {
  .hero-img { height: 230px; object-position: center 40%; }
  .hero-veil { background:
    linear-gradient(0deg, rgba(13,17,22,0.9) 8%, rgba(13,17,22,0.25) 70%, rgba(13,17,22,0.1) 100%); }
}

.section-head {
  display: flex; align-items: baseline; gap: 12px;
  margin: 34px 0 16px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
}
.section-head h2 { font-size: 1.28rem; }
.section-head .count {
  font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted);
  margin-left: auto;
}

/* ---------- Cards / grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }

.card {
  position: relative; text-align: left; cursor: pointer;
  background: linear-gradient(180deg, var(--bg-raised), var(--bg-sunk));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 16px 14px; color: inherit; font: inherit;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  display: flex; flex-direction: column; gap: 8px;
}
.card:hover { transform: translateY(-3px); border-color: var(--line-strong); box-shadow: var(--shadow); }
.card:focus-visible { outline: 2px solid var(--copper-lit); outline-offset: 2px; }
.card.ready { border-color: rgba(102, 195, 160, 0.4); }
.card.ready::before {
  content: ""; position: absolute; inset: 0; border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px rgba(102, 195, 160, 0.25), 0 0 22px -8px var(--verdigris);
  pointer-events: none;
}
.card-base {
  font-family: var(--font-mono); font-size: 0.64rem; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--copper); padding-right: 46px;
}
.card-name { font-family: var(--font-display); font-size: 1.2rem; color: var(--ink); padding-right: 46px; }
.card-line { font-size: 0.86rem; color: var(--muted); }

/* drink illustration, top-right of each tile */
.card-thumb {
  position: absolute; top: 13px; right: 13px;
  width: 38px; height: 45px; overflow: visible; pointer-events: none;
}
.card-thumb .glass {
  fill: none; stroke: var(--copper-lit); stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round; opacity: 0.92;
}
.card-thumb .liquid { fill: var(--liq); opacity: 0.9; }
.card-thumb .bubble { fill: #fff; opacity: 0.5; }
.card.ready .card-thumb .glass { stroke: var(--verdigris); }
.card.ready .card-thumb { filter: drop-shadow(0 0 6px rgba(102, 195, 160, 0.35)); }
@media (prefers-reduced-motion: no-preference) {
  .card:hover .card-thumb { transform: translateY(-1px) rotate(-3deg); transition: transform 0.16s ease; }
}
.card-status {
  margin-top: auto; font-family: var(--font-mono); font-size: 0.68rem;
  letter-spacing: 0.04em; display: inline-flex; align-items: center; gap: 6px;
}
.card-status .dot { width: 7px; height: 7px; border-radius: 50%; }
.status-ready { color: var(--verdigris); }
.status-ready .dot { background: var(--verdigris); box-shadow: 0 0 8px var(--verdigris); }
.status-close { color: var(--copper-lit); }
.status-close .dot { background: var(--copper-lit); }
.status-need { color: var(--muted); }
.status-need .dot { background: var(--muted); }

/* ---------- Chips / filters ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 4px; }
.chip {
  font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.04em;
  color: var(--ink-dim); background: var(--bg-raised);
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 13px; cursor: pointer;
  transition: color 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}
.chip:hover { color: var(--ink); border-color: var(--line-strong); }
.chip.on { color: var(--bg); background: var(--copper-lit); border-color: var(--copper-lit); font-weight: 600; }

/* ---------- Buttons / inputs ---------- */
.btn {
  font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.04em;
  border-radius: 9px; padding: 10px 16px; cursor: pointer; border: 1px solid var(--line-strong);
  background: var(--bg-raised); color: var(--ink); transition: all 0.14s ease;
}
.btn:hover { border-color: var(--copper); color: var(--copper-lit); }
.btn-primary { background: var(--copper); border-color: var(--copper); color: #1a120b; font-weight: 600; }
.btn-primary:hover { background: var(--copper-lit); border-color: var(--copper-lit); color: #1a120b; }
.btn-ghost { background: transparent; }
.btn-danger:hover { border-color: #d97070; color: #ec9a9a; }
.btn:focus-visible { outline: 2px solid var(--copper-lit); outline-offset: 2px; }

.field {
  width: 100%; font-family: var(--font-body); font-size: 1rem;
  background: var(--bg-sunk); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 13px 15px;
}
.field:focus { outline: none; border-color: var(--copper); }
.field::placeholder { color: var(--muted); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.toolbar .grow { flex: 1 1 240px; }

/* ---------- My Bar ---------- */
.bar-group { margin-bottom: 24px; }
.bar-group-head {
  display: flex; align-items: baseline; gap: 10px;
  font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--copper); margin-bottom: 10px;
}
.bar-group-head .g-count { color: var(--muted); margin-left: auto; letter-spacing: 0; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 0.78rem;
  background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 8px 7px 14px; cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease;
}
.pill:hover { border-color: var(--line-strong); }
.pill.have { border-color: rgba(102, 195, 160, 0.45); background: var(--verdigris-d); color: var(--ink); }
.pill .x {
  display: inline-grid; place-items: center; width: 18px; height: 18px;
  border-radius: 50%; background: rgba(255,255,255,0.08); font-size: 0.7rem; color: var(--ink-dim);
}
.pill.have .add-mark { display: none; }
.pill .add-mark { color: var(--copper-lit); }
.pill.have .x-mark { display: inline-grid; }

.empty {
  border: 1px dashed var(--line-strong); border-radius: var(--radius);
  padding: 26px; text-align: center; color: var(--ink-dim);
}
.empty strong { color: var(--ink); font-family: var(--font-display); font-weight: 500; display: block; font-size: 1.15rem; margin-bottom: 6px; }

/* ---------- Recipe detail (modal) ---------- */
.modal-scrim {
  position: fixed; inset: 0; z-index: 60; background: rgba(4, 6, 9, 0.72);
  backdrop-filter: blur(4px); display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; animation: fade 0.2s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 560px; background: var(--bg-raised);
  border: 1px solid var(--line-strong); border-radius: 18px; box-shadow: var(--shadow);
  overflow: hidden; animation: rise 0.28s ease both;
}
.modal-head { padding: 22px 24px 18px; border-bottom: 1px solid var(--line); position: relative; }
.modal-close {
  position: absolute; top: 16px; right: 16px; width: 34px; height: 34px;
  border-radius: 8px; border: 1px solid var(--line-strong); background: var(--bg-sunk);
  color: var(--ink-dim); font-size: 1.1rem; cursor: pointer;
}
.modal-close:hover { color: var(--ink); border-color: var(--copper); }
.modal-base {
  font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--copper);
}
.modal-title { font-size: 1.7rem; margin: 6px 40px 6px 0; }
.modal-meta { font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); }
.modal-body { padding: 20px 24px 26px; }

.ing-list { list-style: none; margin: 0 0 22px; padding: 0; }
.ing-row {
  display: flex; align-items: baseline; gap: 12px; padding: 9px 0;
  border-bottom: 1px dashed var(--line);
}
.ing-row:last-child { border-bottom: none; }
.ing-amt {
  font-family: var(--font-mono); font-size: 0.82rem; color: var(--copper-lit);
  min-width: 74px; flex-shrink: 0;
}
.ing-name { flex: 1; }
.ing-name .opt { color: var(--muted); font-size: 0.82rem; }
.ing-flag { font-family: var(--font-mono); font-size: 0.64rem; letter-spacing: 0.04em; }
.ing-have { color: var(--verdigris); }
.ing-miss { color: var(--copper); }
.ing-row.missing .ing-name { color: var(--ink-dim); }

.method-label {
  font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--copper); margin-bottom: 8px;
}
.method { color: var(--ink-dim); line-height: 1.65; }
.garnish { margin-top: 16px; font-size: 0.9rem; color: var(--muted); }
.garnish b { color: var(--ink-dim); font-weight: 500; }

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 18px; }
.tag {
  font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.05em;
  color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px;
}

/* ---------- Prose (How to use / Changelog) ---------- */
.prose { max-width: 68ch; }
.prose h2 { font-size: 1.35rem; margin: 30px 0 10px; color: var(--ink); }
.prose h3 { font-size: 1.05rem; margin: 22px 0 8px; color: var(--copper-lit); font-family: var(--font-body); font-weight: 600; }
.prose p { color: var(--ink-dim); margin: 0 0 14px; }
.prose ol, .prose ul { color: var(--ink-dim); padding-left: 22px; margin: 0 0 16px; }
.prose li { margin-bottom: 7px; }
.prose code {
  font-family: var(--font-mono); font-size: 0.85em; background: var(--bg-sunk);
  border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; color: var(--copper-lit);
}
.callout {
  border-left: 3px solid var(--copper); background: var(--bg-raised);
  border-radius: 0 10px 10px 0; padding: 14px 18px; margin: 18px 0; color: var(--ink-dim);
}

/* changelog entries */
.release { border-left: 2px solid var(--line); padding: 0 0 4px 20px; margin: 0 0 6px; position: relative; }
.release::before {
  content: ""; position: absolute; left: -6px; top: 6px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--copper); box-shadow: 0 0 10px var(--copper-deep);
}
.release-ver { font-family: var(--font-mono); font-size: 1rem; color: var(--copper-lit); }
.release-date { font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); margin-left: 10px; }
.release ul { margin: 8px 0 26px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--bg-sunk); }
.footer-row {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 22px 0; color: var(--muted);
}
.footer-logo { width: 32px; height: 32px; border-radius: 50%; box-shadow: 0 0 0 1px var(--line); }
.footer-copy { font-size: 0.85rem; }
.footer-copy b { color: var(--ink-dim); font-weight: 500; font-family: var(--font-display); }
.footer-ver {
  margin-left: auto; font-family: var(--font-mono); font-size: 0.72rem;
  color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px;
}
.footer-ver a { color: var(--copper); }

/* ---------- Scanner ---------- */
.scan-stage {
  position: relative; border: 1px solid var(--line-strong); border-radius: var(--radius);
  overflow: hidden; background: #000; aspect-ratio: 4 / 3; max-width: 460px;
}
.scan-stage video { width: 100%; height: 100%; object-fit: cover; }
.scan-reticle {
  position: absolute; inset: 18% 12%; border: 2px solid var(--copper-lit);
  border-radius: 12px; box-shadow: 0 0 0 100vmax rgba(0,0,0,0.35);
}
.scan-msg { font-family: var(--font-mono); font-size: 0.82rem; color: var(--ink-dim); margin-top: 12px; min-height: 1.4em; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: var(--bg-raised); border: 1px solid var(--copper); color: var(--ink);
  font-family: var(--font-mono); font-size: 0.82rem; padding: 11px 18px; border-radius: 10px;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: all 0.25s ease; z-index: 80;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; gap: 2px; padding: 8px 20px 16px;
    background: rgba(13, 17, 22, 0.98); border-bottom: 1px solid var(--line);
  }
  .nav.open { display: flex; }
  .nav a { padding: 12px; }
  .nav-toggle { display: block; }
  .brand-sub { display: none; }
  .nav-install { width: 100%; text-align: center; margin-top: 8px; }
}

@media (max-width: 560px) {
  .fl-2 { grid-template-columns: 1fr; }
  .ing-edit-row { grid-template-columns: 74px 1fr auto auto; gap: 6px; }
  .ing-edit-row .field { padding: 11px 10px; }
  .opt-check { font-size: 0.6rem; }
  .view-head-row .btn { flex: 1 1 auto; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- v0.2: custom recipes, builder form, install ---------- */
.mine-tag {
  display: inline-block; font-family: var(--font-mono); font-size: 0.56rem;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--verdigris);
  border: 1px solid rgba(102, 195, 160, 0.4); border-radius: 999px; padding: 1px 6px;
  vertical-align: middle;
}
.view-head-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.view-head-row .view-title { margin: 0; }

/* recipe builder + forms in modals */
.modal-wide { max-width: 640px; }
.fl {
  display: block; margin-top: 15px; font-family: var(--font-mono);
  font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
}
.fl .field, .fl > input, .fl > select, .fl > textarea { margin-top: 7px; }
.fl-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fl-label {
  margin-top: 18px; margin-bottom: 8px; font-family: var(--font-mono);
  font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
}
.hint { text-transform: none; letter-spacing: 0; color: var(--muted); font-size: 0.62rem; }
.ing-edit-row {
  display: grid; grid-template-columns: 88px 1fr auto auto; gap: 8px;
  align-items: center; margin-bottom: 8px;
}
.ing-edit-row .amt { text-align: center; }
.opt-check {
  display: flex; align-items: center; gap: 5px; white-space: nowrap;
  font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted);
}
.opt-check input { accent-color: var(--copper); }
.row-x {
  background: transparent; border: 1px solid var(--line-strong); color: var(--muted);
  border-radius: 8px; width: 36px; height: 40px; cursor: pointer; font-size: 0.9rem;
}
.row-x:hover { border-color: #d97070; color: #ec9a9a; }
textarea.field { resize: vertical; min-height: 74px; font-family: var(--font-body); line-height: 1.5; }
select.field { cursor: pointer; }
.modal-actions {
  display: flex; gap: 10px; margin-top: 20px; padding-top: 16px;
  border-top: 1px solid var(--line);
}
.install-steps { margin: 14px 0 0; padding-left: 20px; color: var(--ink-dim); line-height: 1.7; }
.install-steps li { margin-bottom: 8px; }
