/* Rapid Vinyl Font Preview — styles */
:root {
  --brand: #540c42;
  --brand-2: #6c3666;
  --brand-soft: #f3e9f1;
  --accent: #e4b43c;
  --ink: #1a1520;
  --muted: #6b6470;
  --line: #e6e2ea;
  --bg: #f6f5f7;
  --card: #ffffff;
  --radius: 10px;
  --panel-w: 340px;
  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Barlow Condensed", "Arial Narrow", Impact, sans-serif;
  --shadow: 0 1px 2px rgba(26, 21, 32, .06), 0 4px 16px rgba(26, 21, 32, .06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
}
button, input, select, textarea { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 8px 22px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand img { display: block; height: 74px; width: auto; }
.topbar-title { display: flex; flex-direction: column; line-height: 1.05; }
.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
.topbar h1 {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--brand);
}
.product-switch { margin-left: auto; }
.product-switch select {
  appearance: none;
  -webkit-appearance: none;
  padding: 9px 36px 9px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%236b6470' stroke-width='1.8'/%3E%3C/svg%3E") no-repeat right 13px center;
  font-weight: 500;
  cursor: pointer;
}
.product-switch select:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 1px; }

/* ---------- Product chooser (landing) ---------- */
.chooser { padding: 40px 22px 60px; }
.chooser-inner { max-width: 1100px; margin: 0 auto; }
.chooser h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(30px, 4vw, 44px);
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--brand);
  text-align: center;
}
.chooser-sub { margin: 0 auto 28px; max-width: 560px; text-align: center; color: var(--muted); }
.chooser-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 16px;
}
.choice {
  display: flex; flex-direction: column;
  text-align: left; padding: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.choice:hover, .choice:focus-visible { transform: translateY(-2px); border-color: var(--brand-2); box-shadow: 0 0 0 2px var(--brand-2), var(--shadow); outline: none; }
.choice-bar {
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
}
.choice-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: #fff;
  line-height: 1.1;
}
.choice-body { padding: 14px 18px 16px; }
.choice-blurb { margin: 0 0 12px; font-size: 13.5px; color: var(--muted); }
.choice-colors { display: flex; gap: 4px; flex-wrap: wrap; }
.choice-colors span { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); background: var(--c); }
.choice-go { margin-top: 12px; font-size: 13px; font-weight: 600; color: var(--brand); }

.site-footer {
  max-width: 1500px;
  margin: 24px auto 0;
  padding: 18px 22px 96px;
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}
.site-footer p { margin: 10px 0 0; }
.footer-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; }
.footer-nav a { color: var(--brand); text-decoration: none; font-weight: 500; }
.footer-nav a:hover { text-decoration: underline; }
.product-intro { margin: 0 0 16px; padding: 12px 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); font-size: 14px; color: var(--muted); }
.product-intro:empty { display: none; }
.choice { text-decoration: none; color: inherit; }
.site-footer sup { font-size: .6em; vertical-align: super; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: var(--panel-w) minmax(0, 1fr);
  gap: 22px;
  padding: 22px;
  max-width: 1500px;
  margin: 0 auto;
}
.panel {
  position: sticky;
  top: 113px;
  align-self: start;
  max-height: calc(100vh - 135px);
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 18px 14px;
  box-shadow: var(--shadow);
}
.control { padding: 14px 0; border-bottom: 1px solid var(--line); }
.control:last-of-type { border-bottom: 0; }
.control-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.control-head label, .control-head .label {
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: .01em;
}
.hint { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.count { font-size: 12px; color: var(--muted); }

textarea#text-input {
  width: 100%;
  resize: vertical;
  min-height: 84px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfafc;
  font-size: 17px;
  line-height: 1.35;
}
textarea#text-input:focus-visible, input:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 1px; border-color: transparent; }
input[type="search"] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfafc;
}

.align-group, .finish-group { display: inline-flex; gap: 2px; padding: 2px; background: var(--bg); border-radius: 8px; }
.icon-btn {
  width: 32px; height: 28px;
  display: inline-grid; place-items: center;
  border: 0; border-radius: 6px; background: transparent; cursor: pointer; color: var(--muted);
}
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; }
.icon-btn:hover { color: var(--ink); }
.icon-btn[aria-pressed="true"] { background: var(--card); color: var(--brand); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.chip {
  padding: 4px 12px; border: 0; border-radius: 6px; background: transparent;
  font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--card); color: var(--brand); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* ---------- Swatches ---------- */
.swatches { display: flex; flex-wrap: wrap; gap: 7px; }
.swatch {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,.14);
  padding: 0; cursor: pointer;
  position: relative;
  background-color: var(--c);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.35);
  transition: transform .12s ease;
}
.swatch:hover { transform: scale(1.08); }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--brand); }
.swatch.metallic { background-image: linear-gradient(135deg, rgba(255,255,255,.45) 0%, rgba(255,255,255,0) 45%, rgba(0,0,0,.18) 100%); }
.swatch.chrome { background-image: linear-gradient(160deg, rgba(255,255,255,.75) 0%, rgba(255,255,255,.05) 40%, rgba(0,0,0,.28) 60%, rgba(255,255,255,.35) 100%); }
.swatches-small .swatch { width: 28px; height: 28px; border-radius: 8px; }
.swatch-custom {
  width: 28px; height: 28px; border-radius: 8px; border: 1px dashed var(--muted);
  background: conic-gradient(#e4303c, #e4b43c, #309054, #4860a8, #601854, #e4303c);
  padding: 0; cursor: pointer; position: relative; overflow: hidden;
}
.swatch-custom input { position: absolute; inset: -6px; width: 200%; height: 200%; opacity: 0; cursor: pointer; }
.selected-name { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.selected-name span { color: var(--ink); font-weight: 500; }

input[type="range"] { width: 100%; accent-color: var(--brand); }
output { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); }

.panel-note { margin: 12px 0 0; padding: 10px 12px; font-size: 12.5px; color: var(--muted); background: var(--brand-soft); border-radius: 8px; }
.panel-note strong { color: var(--brand); }

/* ---------- Preview grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr));
  gap: 14px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: box-shadow .15s ease, border-color .15s ease;
}
.card:hover { border-color: #cdbfd0; }
.card.selected { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand), var(--shadow); }
.card-head {
  display: flex; align-items: baseline; gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}
.card-num { font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.card-name { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-body {
  min-height: calc(var(--size, 48px) * 1.15 + 36px);
  padding: 18px 16px;
  display: grid;
  align-items: center;
  background: var(--surface, #fff);
  overflow: hidden;
}
.card-text {
  white-space: pre;
  line-height: 1.15;
  color: var(--vinyl, #000);
  text-align: var(--align, center);
  font-family: var(--family);
  font-size: calc(var(--size, 48px) * var(--scale, 1) * var(--fit, 1));
  visibility: hidden;
  width: 100%;
}
.card.loaded .card-text { visibility: visible; }
.card.failed .card-text { visibility: visible; font-family: var(--font-ui); }
.card.failed .card-name::after { content: " · preview unavailable"; color: #b3261e; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

/* ---------- Lightbox (enlarged preview) ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center;
  padding: 24px;
  background: rgba(26, 21, 32, .72);
  cursor: zoom-out;
  animation: lb-in .15s ease;
}
@keyframes lb-in { from { opacity: 0; } to { opacity: 1; } }
.lightbox-card {
  width: min(1200px, 100%);
  background: var(--card);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,.45);
}
.lightbox-head {
  display: flex; align-items: baseline; gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.lightbox-head .card-num { font-size: 16px; }
.lightbox-hint { margin-left: auto; font-size: 12px; color: var(--muted); }
.lightbox-body {
  display: grid; align-items: center;
  min-height: min(60vh, 520px);
  padding: 40px 32px;
  background: var(--surface, #fff);
  overflow: hidden;
}
.lightbox-body .card-text {
  visibility: visible;
  font-size: calc(var(--lb-size, 150px) * var(--scale, 1) * var(--fit, 1));
}
.card { cursor: zoom-in; }
@media (max-width: 900px) {
  .lightbox { padding: 12px; }
  .lightbox-body { padding: 24px 16px; min-height: 40vh; }
  .lightbox-hint { display: none; }
}

/* ---------- Selection bar ---------- */
.selection-bar {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 16px;
  max-width: min(920px, calc(100% - 28px));
  padding: 10px 12px 10px 18px;
  background: var(--ink); color: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(26,21,32,.35);
  z-index: 30;
}
.selection-text { display: flex; flex-direction: column; min-width: 0; }
.selection-text strong { font-size: 15px; }
.selection-text span { font-size: 12.5px; color: rgba(255,255,255,.72); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selection-actions { display: flex; gap: 8px; margin-left: auto; }
.btn {
  padding: 8px 14px; border-radius: 8px; border: 1px solid rgba(255,255,255,.25);
  background: transparent; color: #fff; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: rgba(255,255,255,.1); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.btn-primary:hover { background: #f0c453; }
.btn-ghost { border-color: transparent; padding: 8px 10px; }

.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(10px);
  padding: 8px 14px; border-radius: 8px; background: var(--brand); color: #fff; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: opacity .15s ease, transform .15s ease; z-index: 31;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 14px; gap: 14px; }
  .panel { position: static; max-height: none; }
  .topbar { padding: 8px 14px; gap: 12px; }
  .brand img { height: 58px; }
  .topbar h1 { font-size: 20px; }
  .eyebrow { font-size: 10px; }
  .selection-bar { flex-direction: column; align-items: stretch; gap: 10px; bottom: 10px; }
  .selection-actions { margin-left: 0; }
  .selection-actions .btn { flex: 1; }
}
@media (max-width: 480px) {
  .topbar-title { display: none; }
  .grid { grid-template-columns: 1fr; }
}
