/*
 * Alpenglow Cycle Works — the stage is part of the product.
 * Light-only by intent: paint finishes must read true.
 */

:root {
  --ink: #1d1d1f;
  --ink-soft: #6e6e73;
  --ink-faint: #a1a1a6;
  --paper: #faf9f7;
  --card: #ffffff;
  --hairline: rgba(29, 29, 31, 0.1);
  --stage: radial-gradient(120% 90% at 50% 30%, #ffffff 0%, #f2eee8 58%, #e5e0d6 100%);
  --focus: #0a5dc2;
  --good: #2e7d43;

  /* live paint, set from the catalog by app.js */
  --paint: #bfd6e0;
  --paint-hi: #eaf2f6;
  --paint-deep: #8faebf;
  --decal: #35505e;
  --accent: #232326;
  --accent-deep: #161619;

  font-size: 100%;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 7.5rem; /* room for the build bar */
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- masthead ---------- */

.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 1.4rem 2.2rem 1.1rem;
  border-bottom: 1px solid var(--hairline);
}

.wordmark {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.wordmark span {
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin-left: 0.45em;
}

.masthead-note {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}

/* ---------- layout ---------- */

.configurator {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(21rem, 27rem);
  gap: 0;
  max-width: 90rem;
  margin: 0 auto;
}

/* ---------- stage ---------- */

.stage {
  position: sticky;
  top: 0;
  align-self: start;
  padding: 3.2rem 1.6rem 2rem 2.2rem;
}

.stage-inner, #bike {
  width: 100%;
  height: auto;
  display: block;
}

.stage::before {
  content: "";
  position: absolute;
  inset: 2.2rem 1rem 1rem 1.6rem;
  background: var(--stage);
  border-radius: 22px;
  z-index: -1;
}

.stage-caption {
  display: flex;
  justify-content: center;
  gap: 0.6em;
  align-items: baseline;
  margin: 0.4rem 0 0;
  font-size: 0.92rem;
  color: var(--ink-soft);
}

.stage-model {
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.01em;
}

.stage-finish::before { content: "· "; color: var(--ink-faint); }

/* paint transitions on the SVG */
#frame path, #bar-tape, #saddle, #decal {
  transition: stroke 340ms ease, fill 340ms ease;
}

.wheel-rim {
  transition: stroke-width 420ms cubic-bezier(0.3, 0.9, 0.4, 1), r 420ms cubic-bezier(0.3, 0.9, 0.4, 1);
}

@media (prefers-reduced-motion: reduce) {
  #frame path, #bar-tape, #saddle, #decal, .wheel-rim { transition: none; }
}

/* ---------- rail ---------- */

.rail {
  padding: 3rem 2.2rem 2rem 1.6rem;
  border-left: 1px solid var(--hairline);
  background: var(--card);
}

.rail h1 {
  margin: 0 0 0.4rem;
  font-size: clamp(1.7rem, 2.6vw, 2.1rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.lede {
  margin: 0 0 2rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
  max-width: 34ch;
}

.option-group {
  padding: 1.4rem 0;
  border-top: 1px solid var(--hairline);
}

.group-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.9rem;
}

.group-head h2 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink);
}

.group-value {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

/* finish swatches */

.swatches {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.swatch {
  --sw: #ccc;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  background: var(--sw);
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.65), 0 1px 3px rgba(29, 29, 31, 0.18);
  transition: transform 160ms ease, box-shadow 160ms ease;
  position: relative;
}

.swatch:hover { transform: scale(1.08); }
.swatch:active { transform: scale(0.94); transition-duration: 80ms; }

.swatch[aria-checked="true"] {
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.65), 0 0 0 2px var(--paper), 0 0 0 4px var(--ink);
}

@media (prefers-reduced-motion: reduce) {
  .swatch, .swatch:hover, .swatch:active { transition: none; transform: none; }
}

/* option cards */

.cards {
  display: grid;
  gap: 0.6rem;
}

.option-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.2rem 0.8rem;
  text-align: left;
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: var(--card);
  transition: border-color 160ms ease, background 160ms ease, transform 120ms ease;
}

.option-card:active { transform: scale(0.99); }

.option-card[aria-checked="true"] {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.option-card .card-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.option-card .card-detail {
  grid-column: 1;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.option-card .card-price {
  grid-row: 1 / span 2;
  grid-column: 2;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  align-self: center;
}

.option-card .rim-glyph {
  grid-row: 1 / span 2;
  grid-column: 3;
  width: 34px;
  height: 34px;
}

/* chips + segments */

.chips, .segments {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.chip, .segment {
  padding: 0.5rem 0.95rem;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  font-size: 0.9rem;
  transition: border-color 140ms ease, background 140ms ease, transform 100ms ease;
}

.chip:active, .segment:active { transform: scale(0.96); }

.chip[aria-checked="true"], .segment[aria-checked="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.chip .chip-dot {
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  border-radius: 50%;
  margin-right: 0.45em;
  vertical-align: -0.08em;
}

/* constraint notice */

.notice {
  margin-top: 1.2rem;
  padding: 1rem 1.1rem;
  border-radius: 12px;
  background: #fbf4e8;
  border: 1px solid #ecd9b8;
}

.notice-text {
  margin: 0 0 0.7rem;
  font-size: 0.9rem;
}

.notice-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.notice-actions .btn { font-size: 0.85rem; }

/* ---------- buttons ---------- */

.btn {
  padding: 0.62rem 1.15rem;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 600;
  transition: transform 110ms ease, background 140ms ease, border-color 140ms ease;
}

.btn:active { transform: scale(0.97); }

.btn.solid {
  background: var(--ink);
  color: var(--paper);
}

.btn.solid:hover { background: #000; }

.btn.ghost {
  border: 1px solid var(--hairline);
  background: var(--card);
}

.btn.ghost:hover { border-color: var(--ink-soft); }

@media (prefers-reduced-motion: reduce) {
  .btn, .btn:active, .chip:active, .segment:active, .option-card:active { transition: none; transform: none; }
}

/* ---------- build bar ---------- */

.buildbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 2.2rem;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border-top: 1px solid rgba(29, 29, 31, 0.08);
  z-index: 30;
}

@media (prefers-reduced-transparency: reduce) {
  .buildbar { background: #ffffff; backdrop-filter: none; -webkit-backdrop-filter: none; }
}

.totals .price {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 0.7em;
}

.price-label {
  font-size: 0.82rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.price-value {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
}

/* rolling digits */
.digit-slot {
  display: inline-block;
  position: relative;
  height: 1.15em;
  overflow: hidden;
}

.digit-strip {
  display: block;
  will-change: transform;
}

.digit-strip span {
  display: block;
  height: 1.15em;
  line-height: 1.15em;
}

.weight {
  margin: 0.1rem 0 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.buildbar-actions {
  display: flex;
  gap: 0.6rem;
}

/* ---------- sheet ---------- */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(29, 29, 31, 0.32);
  opacity: 0;
  transition: opacity 260ms ease;
  z-index: 40;
}

.scrim.visible { opacity: 1; }

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 105%);
  width: min(34rem, calc(100vw - 2rem));
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-radius: 18px 18px 0 0;
  padding: 0.7rem 1.6rem 1.4rem;
  box-shadow: 0 -12px 44px rgba(29, 29, 31, 0.18);
  z-index: 50;
  will-change: transform;
  touch-action: none;
}

@media (prefers-reduced-transparency: reduce) {
  .sheet { background: #ffffff; backdrop-filter: none; -webkit-backdrop-filter: none; }
}

.sheet-handle {
  width: 42px;
  height: 5px;
  border-radius: 3px;
  background: rgba(29, 29, 31, 0.2);
  margin: 0.2rem auto 0.9rem;
  cursor: grab;
}

.sheet h2 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.sheet-rows {
  margin: 0;
  display: grid;
  gap: 0.55rem;
}

.sheet-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.sheet-row dt { margin: 0; font-size: 0.92rem; }
.sheet-row dt small { display: block; color: var(--ink-soft); font-size: 0.8rem; }
.sheet-row dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
  color: var(--ink-soft);
}

.sheet-total {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--hairline);
  margin-top: 1rem;
  padding-top: 0.9rem;
  font-weight: 700;
  font-size: 1.05rem;
}

.sheet-total dt, .sheet-total dd { margin: 0; }
.sheet-total dd { font-variant-numeric: tabular-nums; }

.sheet-note {
  color: var(--ink-soft);
  font-size: 0.82rem;
  margin: 0.6rem 0 1rem;
}

.sheet-close { width: 100%; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  bottom: 7.6rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  font-size: 0.88rem;
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  box-shadow: 0 6px 22px rgba(29, 29, 31, 0.28);
  z-index: 60;
}

/* ---------- colophon ---------- */

.colophon {
  max-width: 46rem;
  margin: 3rem auto 1.5rem;
  padding: 0 2rem;
  text-align: center;
}

.colophon p {
  font-size: 0.8rem;
  color: var(--ink-faint);
  line-height: 1.6;
}

/* ---------- narrow screens ---------- */

@media (max-width: 56rem) {
  .configurator { grid-template-columns: 1fr; }
  .stage { position: static; padding: 2rem 1.2rem 1rem; }
  .rail { border-left: none; padding: 1.6rem 1.4rem; }
  .buildbar { padding: 0.8rem 1.2rem; flex-wrap: wrap; }
}
