/* ==========================================================================
   Handcrafted by Haze — order form
   Mobile-first. One breakpoint at 640px, which only centers and caps width.

   Colors follow the Moss palette (COLORS.md). Two layers: the raw ramps,
   then semantic aliases. Everything below the :root block uses the semantic
   layer only — to retheme, edit Layer 2 and nothing else.

   The one rule to remember: --moss-500 (#84B067) is 2.5:1 on white. It is a
   fill, never text, and never carries white text. Green text uses --moss-700.
   ========================================================================== */

/* Playpen Sans, self-hosted so there's no third-party request and no
   dependency on Google's CDN staying up. Latin subset, variable 400-700.
   To update it, replace the .woff2 in assets/fonts/ — nothing else changes. */
@font-face {
  font-family: "Playpen Sans";
  src: url("assets/fonts/playpen-sans-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* ============================================
     LAYER 1 — Raw ramps
     ============================================ */

  /* Primary — Moss (hue 96) */
  --moss-50:  #F5FAF2;
  --moss-100: #E7F3E0;
  --moss-200: #D1E7C2;
  --moss-300: #B6D6A0;
  --moss-400: #9BC380;
  --moss-500: #84B067; /* base */
  --moss-600: #6C994F;
  --moss-700: #577C3E;
  --moss-800: #415E2E;
  --moss-900: #2C401F;
  --moss-950: #1B2713;

  /* Neutrals — hue-matched, 6-20% saturation */
  --grey-0:   #FFFFFF;
  --grey-50:  #F8FAF7;
  --grey-100: #F1F3EF;
  --grey-200: #E1E5DF;
  --grey-300: #CACFC7;
  --grey-400: #A6ADA1;
  --grey-500: #848D7F;
  --grey-600: #687162;
  --grey-700: #525A4C;
  --grey-800: #383F34;
  --grey-900: #242921;
  --grey-950: #151813;

  /* Accent — Clay (hue 24) */
  --clay-100: #F4E3D7;
  --clay-500: #CF8859;
  --clay-600: #BA6B36;
  --clay-700: #92542A;

  /* Feedback */
  --red-50:  #FAEEED;
  --red-600: #B63D2B;
  --red-700: #973121;

  /* ============================================
     LAYER 2 — Semantic aliases (use these)
     ============================================ */

  /* Surfaces */
  --surface:            var(--grey-0);
  --surface-subtle:     var(--grey-50);
  --surface-brand:      var(--moss-50);   /* page background */
  --surface-brand-soft: var(--moss-100);
  --surface-accent:     var(--clay-100);

  /* Text */
  --text:           var(--grey-800); /* 10.89:1 on white */
  --text-secondary: var(--grey-700); /*  7.18:1 */
  --text-muted:     var(--grey-600); /*  5.09:1 */
  --text-brand:     var(--moss-700); /*  4.82:1 */
  --text-inverse:   var(--grey-0);

  /* Button labels. moss-500 + moss-950 computes at 6.23:1, but two tones of
     one hue read far flatter than that number suggests — WCAG 2.x luminance
     math is generous with same-hue pairs. Using the palette's other verified
     pairing instead: dark fill, white label. */
  --text-on-action:          var(--grey-0);   /* 4.82:1 on moss-700 */
  --text-on-action-disabled: var(--moss-950); /* 9.7:1  on moss-300 */

  /* Borders — grey-300 for decorative rules; control boundaries need 3:1.
     Note: COLORS.md calls grey-400 the lightest token that clears 3:1, but
     its own table puts it at 2.30 on white. grey-500 (3.44) is the real
     floor, so that's what outlines inputs and other controls here. */
  --border:        var(--grey-300);
  --border-field:  var(--grey-500);
  --border-brand:  var(--moss-600);
  --border-selected: var(--moss-700); /* 4.2:1 on the moss-100 selected fill */

  /* Interactive */
  --action:          var(--moss-700); /* 4.82:1 with white */
  --action-hover:    var(--moss-800); /* 7.33:1 with white */
  --action-disabled: var(--moss-300);
  --focus-ring:      var(--moss-600);

  /* Feedback */
  --danger:    var(--red-700);
  --danger-bg: var(--red-50);
  --notice:    var(--clay-700); /* 5.96:1 on white — scarcity notes, not alarm */

  /* Shape and type */
  --radius:     18px;
  --radius-sm:  12px;
  --shadow:     0 1px 2px rgba(36, 41, 33, .05), 0 8px 20px rgba(36, 41, 33, .06);
  --shadow-lg:  0 2px 4px rgba(36, 41, 33, .06), 0 14px 34px rgba(36, 41, 33, .10);

  /* Headings and other display type. The fallback is a rounded system face,
     not a serif — if Playpen Sans fails to load, the page should still feel
     handmade rather than switch character entirely. */
  --display: "Playpen Sans", "Chalkboard SE", "Comic Sans MS", "Segoe UI", sans-serif;
  --sans:    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --bar-h: 76px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--surface-brand);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

/* Playpen Sans is wide, tall-ascendered, and already loosely spaced — it needs
   more leading and no negative tracking, unlike the serif this replaced. */
h1, h2 {
  font-family: var(--display);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0;
  margin: 0 0 12px;
}
h1 { font-size: 1.5rem; }
h2 { font-size: 1.375rem; }

.eyebrow {
  margin: 0 0 6px;
  font-size: .8125rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-brand);
  font-weight: 600;
}

.lede { margin: 0 0 20px; color: var(--text-muted); }
.lede--sm { font-size: .9375rem; margin-bottom: 18px; }
.note { margin: 0 0 4px; font-size: .875rem; color: var(--text-muted); }
.hint { margin: 6px 0 0; font-size: .8125rem; color: var(--text-muted); }
.optional { color: var(--text-muted); font-weight: 400; }

/* Focus is always visible, and always clears 3:1 against its surroundings. */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* --- Layout --------------------------------------------------------------- */

main {
  padding: 20px 20px 8px;
  /* Steps swap in and out; without this Chrome "helpfully" preserves the old
     scroll position and lands the new step mid-page. */
  overflow-anchor: none;
}

.step { animation: rise .28s ease both; }
.step[hidden] { display: none; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.step--welcome { padding-top: 24px; text-align: left; }

.footer {
  padding: 28px 20px calc(20px + env(safe-area-inset-bottom));
  text-align: center;
  font-size: .8125rem;
  color: var(--text-muted);
}
.footer p { margin: 0; }
body.has-bar .footer { padding-bottom: calc(var(--bar-h) + 24px + env(safe-area-inset-bottom)); }

/* --- Top bar + progress --------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(245, 250, 242, .92); /* --moss-50, translucent */
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar[hidden] { display: none; }

.topbar__back {
  flex: none;
  width: 44px; height: 44px;
  margin-left: -10px;
  border: 0;
  background: none;
  color: var(--text);
  font-size: 1.375rem;
  line-height: 1;
  border-radius: 50%;
  cursor: pointer;
}
.topbar__back:active { background: var(--surface-brand-soft); }

.progress {
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: var(--grey-200);
  overflow: hidden;
}
.progress__fill {
  height: 100%;
  width: 25%;
  border-radius: 999px;
  /* moss-700, not the base green: the fill has to read against its track. */
  background: var(--moss-700);
  transition: width .3s ease;
}

.topbar__label {
  flex: none;
  font-size: .75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* --- Welcome -------------------------------------------------------------- */

.chips { list-style: none; margin: 24px 0; padding: 0; display: grid; gap: 8px; }
.chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .9375rem;
  box-shadow: var(--shadow);
}

.stack-actions { display: grid; gap: 10px; margin-top: 22px; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform .12s ease, background-color .12s ease;
}

/* moss-700 fill + white label = 4.82:1. Never white on moss-500 (2.5:1). */
.btn--primary {
  background: var(--action);
  color: var(--text-on-action);
  box-shadow: var(--shadow);
}
.btn--primary:active { transform: scale(.985); background: var(--action-hover); }
.btn--primary[disabled] {
  background: var(--action-disabled);
  color: var(--text-on-action-disabled);
  cursor: not-allowed;
  box-shadow: none;
}
/* A moss ring would sit on a moss button; go dark instead. */
.btn--primary:focus-visible { outline-color: var(--moss-950); }

.btn--ghost {
  background: transparent;
  color: var(--text-brand);
  border: 1px solid var(--border-field);
}
.btn--ghost:active { background: var(--surface-brand-soft); }

.btn--sm { min-height: 40px; padding: 0 16px; font-size: .875rem; }

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

.products { display: grid; gap: 14px; }

/* Stands in for the whole grid when every piece is hidden, so it carries the
   vertical space a card would have — an empty shop shouldn't read as a bug. */
.products__empty {
  margin: 0;
  padding: 28px 12px;
  text-align: center;
  color: var(--text-muted);
}

.product {
  display: grid;
  /* 112px is the widest photo that still leaves every product name room to fit
     on two lines at 375px; past it the longest names take a third and the card
     grows taller than the photo can balance. */
  grid-template-columns: 112px 1fr;
  gap: 14px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.product.is-added { border-color: var(--border-brand); box-shadow: var(--shadow-lg); }
.product.is-out { opacity: .6; }

/* Out of flow on purpose: it rides on the photo's corner without adding a row
   or a pixel of height. It's anchored to .product__media rather than the card
   because the photo floats — it centres against a taller body, so any offset
   from the card's own corner would drift. Moss rather than the clay --notice,
   so "New" and "Only N left" stay two distinct signals on a piece that happens
   to be both. */
.product__new {
  position: absolute;
  top: 6px; left: 6px;
  z-index: 1;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--action);
  color: var(--text-on-action);
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .02em;
  line-height: 1.45;
  box-shadow: var(--shadow);
}

/* Square, always — whatever the photo's own proportions. Centred, so whatever
   height the text has over it splits evenly above and below and reads as
   padding rather than as a gap under the photo. */
.product__media { position: relative; align-self: center; }
.product__img {
  display: block;   /* no inline descender gap under the photo */
  width: 112px; height: 112px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--surface-brand-soft);
}
/* One 4px rhythm for the whole body instead of a margin per child; the price
   row takes a little more air below the text it's separated from. */
.product__body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-width: 0;
}
/* h3 has no reset above, so zero the UA margin here — the body is a flex
   column, where margins don't collapse, so the default 1em would show twice. */
.product__name { margin: 0; line-height: 1.25; font-family: var(--display); font-size: 1.0625rem; font-weight: 600; }
/* Two lines is the card's budget: a long description from the sheet truncates
   rather than pushing the price row past the photo's height. */
.product__desc {
  margin: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: .8125rem;
  color: var(--text-muted);
}
/* Reserve the tallest control's height (the 44px add button) so the card keeps
   the same height once it's swapped for the 40px stepper — or for "Sold out". */
.product__row { margin-top: 4px; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; }
/* Price and scarcity are one thought, so they share a line. Wrapping rather
   than overflowing is the fallback if the pair ever outgrows the column. */
.product__meta { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; min-width: 0; }
.product__price { font-weight: 600; font-variant-numeric: tabular-nums; }
.product__soldout { font-size: .8125rem; color: var(--text-muted); font-style: italic; }

/* Scarcity, said quietly — next to the price, where the decision is made. It
   steps aside once the piece is in the order: the stepper is three times the
   width of the add button it replaces, and there isn't room for both. By then
   the note has done its job, and a disabled + says the same thing. */
.product__stock {
  margin: 0;
  font-size: .75rem;
  font-weight: 600;
  color: var(--notice);
}
.product__stock::before { content: "·"; margin-right: 6px; color: var(--text-muted); }
.product.is-added .product__stock { display: none; }

.stepper { display: flex; align-items: center; gap: 4px; }
.stepper__btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 1px solid var(--border-field);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-brand);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}
.stepper__btn:active { background: var(--surface-brand-soft); }
.stepper__btn[disabled] { opacity: .35; cursor: not-allowed; }
.stepper__btn--add {
  background: var(--action);
  border-color: var(--action);
  color: var(--text-on-action);
  width: 44px; height: 44px;
}
.stepper__btn--add:focus-visible { outline-color: var(--moss-950); }
.stepper__qty {
  min-width: 30px;
  text-align: center;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* --- Fields --------------------------------------------------------------- */

.field { margin-bottom: 20px; border: 0; padding: 0; }
.field > label, .field legend, .label-like {
  display: block;
  margin-bottom: 8px;
  font-size: .875rem;
  font-weight: 600;
}
.field legend { padding: 0; }

input[type="text"], textarea {
  width: 100%;
  min-height: 52px;
  padding: 14px 16px;
  border: 1px solid var(--border-field);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
}
textarea { min-height: auto; resize: vertical; line-height: 1.5; }
::placeholder { color: var(--grey-500); opacity: 1; }

input[type="text"]:focus, textarea:focus, .upload:focus-within {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
  border-color: var(--border-brand);
}
input.is-invalid, textarea.is-invalid { border-color: var(--danger); }

.input-prefix {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border-field);
  border-radius: var(--radius-sm);
  padding-left: 16px;
}
.input-prefix span { color: var(--text-muted); font-weight: 600; }
.input-prefix input {
  border: 0;
  background: none;
  padding-left: 4px;
}
.input-prefix input:focus { outline: none; }
.input-prefix:focus-within {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
  border-color: var(--border-brand);
}
.input-prefix.is-invalid { border-color: var(--danger); }

.err {
  margin: 6px 0 0;
  font-size: .8125rem;
  color: var(--danger);
  min-height: 0;
}
.err:empty { display: none; }

/* --- Radio options -------------------------------------------------------- */

.option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  background: var(--surface);
  border: 1px solid var(--border-field);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.option:has(input:checked) { border-color: var(--border-selected); background: var(--surface-brand-soft); }
.option input {
  flex: none;
  width: 22px; height: 22px;
  accent-color: var(--border-brand); /* moss-600 — moss-500 is under 3:1 */
  margin: 0;
}
.option__body { display: flex; flex-direction: column; }
.option__title { font-weight: 600; }
.option__sub { font-size: .8125rem; color: var(--text-muted); }

/* --- Cards, callouts, summaries ------------------------------------------- */

.card {
  padding: 16px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card__label {
  margin: 0 0 6px;
  font-size: .75rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}
.card--total { background: var(--surface-brand-soft); border-color: var(--moss-200); }

.callout {
  padding: 14px 16px;
  margin-bottom: 20px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px dashed var(--border); /* decorative panel, not a control */
  font-size: .875rem;
  color: var(--text-muted);
}
/* Clay accent — the one warm note, used where money needs attention. */
.callout--warm {
  background: var(--surface-accent);
  border-color: var(--clay-500);
  color: var(--text);
}

.summary { display: grid; gap: 10px; font-size: .9375rem; }
.summary__row { display: flex; justify-content: space-between; gap: 14px; }
/* Keeps the price column on one line — but never the free-text values,
   which have to wrap (long addresses, notes). */
.summary__row > span:last-child:not(.summary__val) {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.summary__row--total {
  padding-top: 10px;
  border-top: 1px solid var(--moss-200);
  font-weight: 700;
  font-size: 1.0625rem;
}
.summary__key { color: var(--text-muted); }
.summary__val { text-align: right; white-space: pre-line; overflow-wrap: anywhere; }
.summary__row--stack { display: grid; gap: 2px; }
.summary__row--stack .summary__val { text-align: left; }

/* --- GCash block ---------------------------------------------------------- */

.gcash__name { margin: 0; font-family: var(--display); font-size: 1.25rem; font-weight: 600; }
.gcash__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
}
.gcash__number {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
}
.gcash__qr {
  width: 270px;
  height: auto;
  margin: 16px auto 0;
  /* border-radius: var(--radius-sm); */
  /* border: 1px solid var(--border); */
}

/* --- Upload --------------------------------------------------------------- */

.upload {
  display: block;
  position: relative;
  padding: 24px 16px;
  border: 1.5px dashed var(--border-field);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
  cursor: pointer;
}
.upload input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  opacity: 0;
  cursor: pointer;
}
.upload.is-invalid { border-color: var(--danger); }
.upload.has-file { border-style: solid; border-color: var(--border-brand); padding: 12px; text-align: left; }

.upload__inner { display: block; }
.upload__icon { font-size: 1.5rem; display: block; margin-bottom: 6px; }
.upload__text { display: block; font-weight: 600; font-size: .9375rem; }
.upload__sub { display: block; font-size: .8125rem; color: var(--text-muted); }

.preview { display: flex; align-items: center; gap: 12px; }
.preview img {
  width: 64px; height: 64px;
  border-radius: 10px;
  object-fit: cover;
  flex: none;
  background: var(--surface-brand-soft);
}
.preview__meta { min-width: 0; }
.preview__name {
  font-weight: 600;
  font-size: .875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preview__sub { font-size: .8125rem; color: var(--text-muted); }

/* --- Sticky action bar ---------------------------------------------------- */

.actionbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  background: rgba(245, 250, 242, .94); /* --moss-50, translucent */
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
}
.actionbar[hidden] { display: none; }
.actionbar__inner {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 480px;
  margin: 0 auto;
}
.actionbar__total { display: flex; flex-direction: column; line-height: 1.25; }
.actionbar__total[hidden] { display: none; }
.actionbar__count { font-size: .75rem; color: var(--text-muted); }
.actionbar__amount { font-size: 1.125rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.actionbar .btn { flex: 1; }

/* --- Confirmation --------------------------------------------------------- */

.step--done { padding-top: 24px; }
.done__mark {
  width: 60px; height: 60px;
  margin-bottom: 18px;
  border-radius: 50%;
  /* moss-700 + white = 4.82:1. The base green would fail behind the glyph. */
  background: var(--action);
  color: var(--text-inverse);
  display: grid;
  place-items: center;
  font-size: 1.75rem;
  animation: pop .35s ease both;
}
@keyframes pop {
  0%   { transform: scale(.6); opacity: 0; }
  70%  { transform: scale(1.06); }
  100% { transform: scale(1); opacity: 1; }
}

.recap { list-style: none; margin: 20px 0 0; padding: 0; display: grid; gap: 12px; }
.recap li {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .9375rem;
}

.inline-plus {
  display: inline-grid;
  place-items: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--action);
  color: var(--text-on-action);
  font-size: .75rem;
  line-height: 1;
  /* `middle` puts the circle's centre on the text's x-height centre, which is
     where the eye expects it. The old -3px nudge sat it 2.45px too low and
     wouldn't have survived a change to the surrounding font size. */
  vertical-align: middle;
}

/* --- Wider screens: just center the column -------------------------------- */

@media (min-width: 640px) {
  main { max-width: 480px; margin: 0 auto; padding-top: 32px; }
  .topbar { max-width: 480px; margin: 0 auto; border-radius: 0 0 var(--radius) var(--radius); }
  h1 { font-size: 1.75rem; }
}

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