/* ============================================================
   FIRST LIGHT — components
   Every component reads its colours from the context it sits in:
   .on-dark (pre-dawn) or .on-light (paper). Default is light.
   ============================================================ */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  background: var(--cream-100);
  color: var(--ink-700);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg, canvas { display: block; max-width: 100%; }

.on-light {
  --fg: var(--ink-900);
  --fg-body: var(--ink-700);
  --fg-muted: var(--ink-700);
  --surface: var(--paper-50);
  --surface-2: var(--cream-200);
  --line: rgba(26, 17, 13, .16);
  --ring: var(--ink-900);
  --shadow: var(--shadow-light);
  --field-bg: var(--paper-50);
  --on-fg: var(--paper-50);
  --cut: var(--ember-600);
  --err: var(--ember-600);
  color: var(--fg-body);
}

.on-dark {
  --fg: var(--cream-200);
  --fg-body: var(--cream-200);
  --fg-muted: var(--muted-on-dark);
  --surface: var(--roast-700);
  --surface-2: var(--night-800);
  --line: rgba(243, 230, 207, .18);
  --ring: var(--sun-500);
  --shadow: var(--shadow-dark);
  --field-bg: rgba(243, 230, 207, .06);
  --on-fg: var(--night-900);
  --cut: var(--sun-500);
  --err: #FF9A78;
  color: var(--fg-body);
}

/* ---------- Type ---------- */

.display, .h-hero, .h2, .h3 {
  font-family: var(--font-display);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: var(--track-display);
  line-height: var(--lh-display);
  color: var(--fg, var(--ink-900));
  margin: 0;
  text-wrap: balance;
}
.h-hero { font-size: var(--fs-hero); }
.h2     { font-size: var(--fs-h2); }
.h3     { font-size: var(--fs-h3); font-weight: 800; line-height: 1; }

.inline-cut {
  font-family: var(--font-inline);
  font-weight: 900;
  color: var(--cut, var(--sun-500));
}

.lead {
  font-size: var(--fs-lead);
  line-height: 1.5;
  color: var(--fg-body, var(--ink-700));
  max-width: 34ch;
  margin: 0;
}

.small { font-size: var(--fs-small); }

.label, .eyebrow {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--fs-label);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--fg-muted, var(--ink-700));
}

.section-head { display: grid; gap: var(--s-4); }
.section-head .eyebrow { display: flex; align-items: center; gap: var(--s-3); }
.section-head .eyebrow::after {
  content: "";
  height: 1px;
  width: 48px;
  background: currentColor;
  opacity: .5;
}

/* ---------- Buttons ---------- */

.btn {
  --btn-bg: transparent;
  --btn-fg: var(--fg, var(--ink-900));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  min-height: 56px;
  padding: 0 var(--s-6);
  border-radius: var(--r-pill);
  border: 1.5px solid transparent;
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition:
    transform var(--dur-1) var(--ease),
    background-color var(--dur-1) var(--ease),
    box-shadow var(--dur-1) var(--ease),
    color var(--dur-1) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn svg { width: 18px; height: 18px; flex: none; transition: transform var(--dur-1) var(--ease); }
.btn:hover svg { transform: translateX(3px); }
.btn:focus-visible {
  outline: 3px solid var(--ring, var(--ink-900));
  outline-offset: 3px;
}

.btn--primary {
  --btn-bg: var(--ember-600);
  --btn-fg: #FFFFFF;
  box-shadow: 0 10px 24px -10px rgba(200, 64, 28, .65);
}
.btn--primary:hover {
  --btn-bg: var(--ember-700);
  transform: translateY(-2px);
  box-shadow: 0 16px 30px -12px rgba(200, 64, 28, .7);
}
.btn--primary:active { transform: translateY(0); }

.btn--ghost { border-color: currentColor; }
.btn--ghost:hover { background: color-mix(in srgb, currentColor 8%, transparent); transform: translateY(-2px); }

.btn--sm { min-height: 44px; padding: 0 var(--s-5); font-size: .9375rem; }

/* ---------- Badges & stamps ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 7px 14px;
  border-radius: var(--r-pill);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: var(--fs-label);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  line-height: 1.2;
  white-space: nowrap;
}
.badge--sun { background: var(--sun-500); color: var(--ink-900); }
.badge--outline { border: 1.5px solid currentColor; color: var(--fg, var(--ink-900)); }
.badge--ember { background: var(--ember-600); color: #fff; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.stamp {
  --size: 132px;
  position: relative;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  border: 1.5px solid currentColor;
  display: grid;
  place-items: center;
  color: var(--fg, var(--ink-900));
  flex: none;
}
.stamp svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.stamp text {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 9.5px;
  letter-spacing: .22em;
  fill: currentColor;
}
.stamp .stamp-core {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 2.6rem;
  line-height: .8;
  text-align: center;
}
.stamp .stamp-core small {
  display: block;
  font-family: var(--font-mono);
  font-size: .6rem;
  letter-spacing: .2em;
  font-weight: 600;
  margin-top: 6px;
}
.stamp--spin svg { animation: spin 28s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Form ---------- */

.field { display: grid; gap: var(--s-2); }
.field > .label { color: var(--fg-muted); }

.input, .select, .textarea {
  width: 100%;
  min-height: 56px;
  padding: 0 var(--s-4);
  border-radius: var(--r-input);
  border: 1px solid var(--line);
  background: var(--field-bg);
  color: var(--fg);
  font: 500 1rem/1.4 var(--font-body);
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
  appearance: none;
}
.textarea { padding: var(--s-4); min-height: 112px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--fg-muted); opacity: .75; }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 35%, transparent);
}
.field.is-invalid .input,
.field.is-invalid .textarea { border-color: var(--ember-600); }
.field .error {
  font-size: var(--fs-small);
  color: var(--err, var(--ember-600));
  min-height: 0;
}

.stepper {
  display: inline-flex;
  align-items: center;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--field-bg);
  height: 56px;
  padding: 4px;
}
.stepper button {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--fg);
  font: 600 1.4rem/1 var(--font-body);
  cursor: pointer;
  transition: background-color var(--dur-1) var(--ease);
}
.stepper button:hover { background: color-mix(in srgb, currentColor 10%, transparent); }
.stepper button:focus-visible { outline: 3px solid var(--ring); outline-offset: -3px; }
.stepper output {
  min-width: 3ch;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.9rem;
  color: var(--fg);
}

/* Segmented choice (pack size, pickup day) */
.choices { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 48px;
  padding: 0 var(--s-5);
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--field-bg);
  color: var(--fg);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--dur-1) var(--ease);
}
.choice span:hover { border-color: var(--fg); }
.choice input:checked + span {
  background: var(--fg);
  color: var(--on-fg, var(--night-900));
  border-color: var(--fg);
}
.choice input:focus-visible + span { outline: 3px solid var(--ring); outline-offset: 2px; }

/* Sunrise day chip */
.day-chip span {
  flex-direction: column;
  min-height: 0;
  padding: var(--s-3) var(--s-4) var(--s-2);
  border-radius: var(--r-card);
  gap: 2px;
  line-height: 1.1;
}
.day-chip .sunrise {
  width: 40px; height: 20px;
  margin-bottom: 4px;
}
.day-chip .sunrise .sun { fill: var(--sun-500); transform: translateY(6px); transition: transform var(--dur-2) var(--ease); }
.day-chip .sunrise .hz { stroke: currentColor; }
.day-chip input:checked + span .sun { transform: translateY(0); }
.day-chip b { font-family: var(--font-display); font-weight: 900; font-size: 1.4rem; text-transform: uppercase; }
.day-chip small { font-family: var(--font-mono); font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; opacity: .8; }

/* ---------- Cards & panels ---------- */

.card {
  background: var(--surface);
  border-radius: var(--r-card);
  padding: var(--s-6);
  box-shadow: var(--shadow);
  color: var(--fg-body);
}

.panel {
  position: relative;
  background: var(--sun-500);
  color: var(--ink-900);
  border-radius: var(--r-panel);
  padding: var(--s-8) var(--s-7);
  overflow: hidden;
  isolation: isolate;
  --fg: var(--ink-900);
  --fg-body: var(--ink-900);
  --fg-muted: var(--ink-700);
}
.panel--bleed-right { border-top-right-radius: 0; border-bottom-right-radius: 0; margin-right: calc(var(--gutter) * -1); }
.panel--bleed-left  { border-top-left-radius: 0;  border-bottom-left-radius: 0;  margin-left:  calc(var(--gutter) * -1); }
.panel::before {
  /* faint bean shapes, 6% */
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: .05;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'><g fill='none' stroke='%231A110D' stroke-width='5' stroke-linecap='round'><g transform='translate(48 52) rotate(-28)'><ellipse rx='26' ry='38'/><path d='M0-36c-12 18 12 54 0 72'/></g><g transform='translate(132 128) rotate(34)'><ellipse rx='22' ry='32'/><path d='M0-30c-10 15 10 45 0 60'/></g></g></svg>");
  background-size: 180px;
}

/* ---------- Sticky CTA ---------- */

.sticky-cta {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: 8px 8px 8px var(--s-5);
  border-radius: var(--r-pill);
  background: rgba(18, 12, 9, .92);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: var(--cream-200);
  box-shadow: var(--shadow-dark);
  max-width: 560px;
}
.sticky-cta .sticky-copy { display: grid; line-height: 1.25; min-width: 0; }
.sticky-cta .sticky-copy b { font-weight: 600; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sticky-cta .sticky-copy span { font-family: var(--font-mono); font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted-on-dark); }
.sticky-cta .btn { margin-left: auto; min-height: 48px; }

/* ---------- Grain ---------- */

.grain::after {
  content: "";
  position: fixed;
  inset: -50%;
  pointer-events: none;
  z-index: 9999;
  background-image: var(--grain);
  opacity: .05;
}

/* ---------- Utilities ---------- */

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

:focus-visible { outline-color: var(--ring, var(--ink-900)); }
