/* =============================================================
   SAGE PHARMACY — COMPONENT LIBRARY
   Depends on tokens.css. Plain CSS, framework-agnostic.
   ============================================================= */

/* ---------- RESET / BASE ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: none; box-shadow: var(--sh-focus); border-radius: var(--r-xs); }

/* ---------- TYPOGRAPHY ---------- */
.display { font-family: var(--font-display); font-size: var(--fs-display); line-height: var(--lh-tight); font-weight: 600; letter-spacing: -0.018em; }
h1, .h1 { font-family: var(--font-display); font-size: var(--fs-h1); line-height: var(--lh-tight); font-weight: 600; letter-spacing: -0.015em; }
h2, .h2 { font-family: var(--font-display); font-size: var(--fs-h2); line-height: var(--lh-snug); font-weight: 600; letter-spacing: -0.012em; }
h3, .h3 { font-family: var(--font-display); font-size: var(--fs-h3); line-height: var(--lh-snug); font-weight: 600; }
h4, .h4 { font-family: var(--font-sans); font-size: var(--fs-h4); line-height: 1.35; font-weight: 700; letter-spacing: -0.005em; }
.lead { font-size: var(--fs-lg); line-height: 1.55; color: var(--text-secondary); }
.serif { font-family: var(--font-display); }
.serif-italic { font-family: var(--font-display); font-style: italic; }
.muted { color: var(--text-muted); }
.small { font-size: var(--fs-sm); }
.tiny { font-size: var(--fs-xs); }
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--green-700);
}
.label {
  font-size: var(--fs-xs); font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted);
}
.mono { font-family: var(--font-mono); }

/* ---------- LAYOUT HELPERS ---------- */
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--s-6); }
.container-wide { max-width: var(--container-wide); }
.container-narrow { max-width: var(--container-narrow); }
.section { padding-block: var(--s-20); }
.section-sm { padding-block: var(--s-12); }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; }
.between { justify-content: space-between; }
.center { justify-content: center; }
.grid { display: grid; }
.gap-1 { gap: var(--s-1); } .gap-2 { gap: var(--s-2); } .gap-3 { gap: var(--s-3); }
.gap-4 { gap: var(--s-4); } .gap-5 { gap: var(--s-5); } .gap-6 { gap: var(--s-6); }
.gap-8 { gap: var(--s-8); } .gap-10 { gap: var(--s-10); } .gap-12 { gap: var(--s-12); }

/* ---------- BUTTONS ---------- */
.btn {
  --btn-bg: var(--green-600); --btn-fg: var(--on-brand); --btn-bd: transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  font-family: var(--font-sans); font-weight: 700; font-size: var(--fs-body);
  line-height: 1; letter-spacing: -0.005em;
  padding: 0.95rem 1.6rem; border-radius: var(--r-full);
  background: var(--btn-bg); color: var(--btn-fg);
  border: 1.5px solid var(--btn-bd); cursor: pointer;
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease), background 0.18s var(--ease), filter 0.18s var(--ease);
  white-space: nowrap; user-select: none;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.04); }
.btn:active { transform: translateY(0); filter: brightness(0.97); }
.btn-primary { --btn-bg: var(--green-600); --btn-fg: var(--on-brand); box-shadow: var(--sh-brand); }
.btn-primary:hover { box-shadow: 0 14px 32px oklch(0.52 0.108 162 / 0.30); }
.btn-dark { --btn-bg: var(--green-900); --btn-fg: var(--on-brand); }
.btn-accent { --btn-bg: var(--apricot-600); --btn-fg: oklch(0.99 0.01 60); }
.btn-secondary { --btn-bg: var(--surface); --btn-fg: var(--green-800); --btn-bd: var(--line); box-shadow: var(--sh-xs); }
.btn-secondary:hover { --btn-bd: var(--green-300); background: var(--green-50); }
.btn-ghost { --btn-bg: transparent; --btn-fg: var(--green-800); box-shadow: none; }
.btn-ghost:hover { background: var(--green-50); }
.btn-lg { padding: 1.15rem 2rem; font-size: var(--fs-lg); }
.btn-sm { padding: 0.6rem 1.1rem; font-size: var(--fs-sm); }
.btn-block { width: 100%; }
.btn-icon { padding: 0.8rem; border-radius: var(--r-full); }
.btn[disabled], .btn.is-disabled { opacity: 0.5; pointer-events: none; }

/* ---------- LINKS ---------- */
.link { color: var(--green-700); font-weight: 600; text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px; text-decoration-color: var(--green-300); transition: color .15s, text-decoration-color .15s; }
.link:hover { color: var(--green-800); text-decoration-color: var(--green-600); }
.link-quiet { color: var(--text-secondary); text-decoration: none; }
.link-quiet:hover { color: var(--green-700); }

/* ---------- BADGES / CHIPS / PILLS ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 0.4em;
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.01em;
  padding: 0.32em 0.7em; border-radius: var(--r-full);
  background: var(--sand); color: var(--text-secondary);
}
.badge-green { background: var(--green-100); color: var(--green-800); }
.badge-mint { background: var(--green-50); color: var(--green-700); }
.badge-apricot { background: var(--apricot-100); color: var(--apricot-700); }
.badge-save { background: var(--green-700); color: var(--on-brand); }
.badge-rx { background: var(--info-bg); color: var(--info); }
.badge-otc { background: var(--sand); color: var(--stone-700); }
.badge-outline { background: transparent; border: 1.5px solid var(--line); color: var(--text-secondary); }
.dot { width: 7px; height: 7px; border-radius: var(--r-full); background: currentColor; }

.chip {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: 0.55rem 1rem; border-radius: var(--r-full);
  background: var(--surface); border: 1.5px solid var(--line);
  font-size: var(--fs-sm); font-weight: 600; color: var(--text-secondary);
  cursor: pointer; transition: all .15s var(--ease);
}
.chip:hover { border-color: var(--green-300); color: var(--green-800); }
.chip.is-active { background: var(--green-600); border-color: var(--green-600); color: var(--on-brand); }

/* ---------- CARDS ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-sm);
}
.card-pad { padding: var(--s-6); }
.card-pad-lg { padding: var(--s-8); }
.card-hover { transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease); }
.card-hover:hover { transform: translateY(-3px); box-shadow: var(--sh-lg); border-color: var(--green-200); }
.card-flat { box-shadow: none; }
.card-sunk { background: var(--surface-sunk); border-color: var(--line-soft); box-shadow: none; }

/* ---------- INPUTS / FORMS ---------- */
.field { display: flex; flex-direction: column; gap: var(--s-2); }
.field-label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-secondary); }
.field-label .req { color: var(--danger); }
.field-hint { font-size: var(--fs-xs); color: var(--text-muted); }
.input, .select, .textarea {
  width: 100%; font-size: var(--fs-body); color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--line);
  border-radius: var(--r-md); padding: 0.9rem 1rem;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s;
}
.input::placeholder, .textarea::placeholder { color: var(--stone-400); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--green-300); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--green-500); box-shadow: var(--sh-focus); }
.input.is-valid { border-color: var(--green-500); }
.input.is-error { border-color: var(--danger); }
.input-lg { padding: 1.1rem 1.25rem; font-size: var(--fs-lg); }
.textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%235a6b5f' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.9rem center; padding-right: 2.6rem; cursor: pointer; }
.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-left: 2.9rem; }
.input-group .ig-icon { position: absolute; left: 1rem; color: var(--stone-400); pointer-events: none; }

/* search field (rounded, prominent) */
.search {
  display: flex; align-items: center; gap: var(--s-3);
  background: var(--surface); border: 1.5px solid var(--line);
  border-radius: var(--r-full); padding: 0.55rem 0.6rem 0.55rem 1.3rem;
  box-shadow: var(--sh-sm); transition: border-color .15s, box-shadow .15s;
}
.search:focus-within { border-color: var(--green-400); box-shadow: var(--sh-focus); }
.search input { flex: 1; border: none; background: transparent; font-size: var(--fs-body); }
.search input:focus { outline: none; }

/* checkbox / radio */
.check { display: inline-flex; align-items: flex-start; gap: var(--s-3); cursor: pointer; font-size: var(--fs-sm); }
.check input { appearance: none; width: 22px; height: 22px; flex: none; border: 1.5px solid var(--line); border-radius: 7px; background: var(--surface); display: grid; place-content: center; cursor: pointer; transition: all .15s; margin-top: 1px; }
.check input[type=radio] { border-radius: var(--r-full); }
.check input:checked { background: var(--green-600); border-color: var(--green-600); }
.check input:checked::after { content: ""; width: 11px; height: 11px; }
.check input[type=checkbox]:checked::after { width: 7px; height: 11px; border: solid white; border-width: 0 2.5px 2.5px 0; transform: rotate(42deg) translateY(-1px); }
.check input[type=radio]:checked::after { border-radius: 50%; background: white; }
.check input:focus-visible { box-shadow: var(--sh-focus); }

/* toggle */
.toggle { position: relative; width: 48px; height: 28px; flex: none; }
.toggle input { appearance: none; position: absolute; inset: 0; width: 100%; height: 100%; background: var(--sand-deep); border-radius: var(--r-full); cursor: pointer; transition: background .2s; }
.toggle input:checked { background: var(--green-600); }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; background: #fff; border-radius: 50%; box-shadow: var(--sh-sm); transition: transform .2s var(--ease); }
.toggle input:checked::after { transform: translateX(20px); }

/* segmented control */
.segmented { display: inline-flex; background: var(--sand); border-radius: var(--r-full); padding: 4px; gap: 2px; }
.segmented button { border: none; background: transparent; padding: 0.55rem 1.1rem; border-radius: var(--r-full); font-weight: 600; font-size: var(--fs-sm); color: var(--text-muted); cursor: pointer; transition: all .15s; }
.segmented button.is-active { background: var(--surface); color: var(--green-800); box-shadow: var(--sh-xs); }

/* ---------- PRICE / SAVINGS ---------- */
.price { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
.price-lg { font-size: 2rem; line-height: 1; }
.price-xl { font-size: 2.6rem; line-height: 1; }
.price-was { font-size: var(--fs-sm); color: var(--stone-400); text-decoration: line-through; font-family: var(--font-sans); font-weight: 500; }
.price-unit { font-size: var(--fs-sm); color: var(--text-muted); font-family: var(--font-sans); font-weight: 500; }
.save-pill { display: inline-flex; align-items: center; gap: 0.35em; background: var(--green-50); color: var(--green-700); font-weight: 700; font-size: var(--fs-sm); padding: 0.3em 0.7em; border-radius: var(--r-full); }

/* ---------- TRUST ROW ---------- */
.trust-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-5); }
.trust-item { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); font-weight: 600; color: var(--text-secondary); }
.trust-item .ico { color: var(--green-600); flex: none; }

/* ---------- ALERTS / NOTES ---------- */
.note { display: flex; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-radius: var(--r-md); font-size: var(--fs-sm); line-height: 1.5; }
.note .ico { flex: none; margin-top: 1px; }
.note-info { background: var(--info-bg); color: oklch(0.40 0.07 230); }
.note-success { background: var(--success-bg); color: var(--green-800); }
.note-warning { background: var(--warning-bg); color: oklch(0.46 0.10 70); }
.note-rx { background: var(--green-50); color: var(--green-800); border: 1px solid var(--green-200); }

/* ---------- STEPPER / PROGRESS (checkout) ---------- */
.stepper { display: flex; align-items: center; gap: var(--s-2); }
.step { display: inline-flex; align-items: center; gap: var(--s-3); }
.step-dot { width: 32px; height: 32px; flex: none; border-radius: var(--r-full); display: grid; place-content: center; font-weight: 700; font-size: var(--fs-sm); background: var(--sand); color: var(--text-muted); border: 1.5px solid transparent; transition: all .2s; }
.step.is-active .step-dot { background: var(--green-600); color: var(--on-brand); box-shadow: var(--sh-brand); }
.step.is-done .step-dot { background: var(--green-100); color: var(--green-700); border-color: var(--green-200); }
.step-label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); }
.step.is-active .step-label, .step.is-done .step-label { color: var(--ink); }
.step-bar { flex: 1; height: 2px; background: var(--line); min-width: 24px; }
.step.is-done + .step-bar, .step-bar.is-done { background: var(--green-300); }

/* quantity stepper */
.qty { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: var(--r-full); overflow: hidden; background: var(--surface); }
.qty button { width: 42px; height: 42px; border: none; background: transparent; cursor: pointer; font-size: 1.2rem; color: var(--green-700); display: grid; place-content: center; transition: background .15s; }
.qty button:hover { background: var(--green-50); }
.qty span { min-width: 40px; text-align: center; font-weight: 700; }

/* ---------- AVATAR / ICON CIRCLE ---------- */
.icon-circle { width: 48px; height: 48px; border-radius: var(--r-full); display: grid; place-content: center; flex: none; background: var(--green-50); color: var(--green-700); }
.icon-circle.apricot { background: var(--apricot-100); color: var(--apricot-700); }
.icon-circle.sand { background: var(--sand); color: var(--stone-700); }
.icon-circle-lg { width: 64px; height: 64px; }

/* ---------- IMAGE PLACEHOLDER ---------- */
.ph {
  position: relative; background:
    repeating-linear-gradient(135deg, oklch(0.945 0.016 85) 0 10px, oklch(0.965 0.013 86) 10px 20px);
  border: 1px solid var(--line-soft); border-radius: var(--r-md);
  display: grid; place-content: center; color: var(--stone-400);
  font-family: var(--font-mono); font-size: var(--fs-xs); text-align: center; overflow: hidden;
}
.ph::after { content: attr(data-label); padding: 0.3em 0.6em; }
.ph-pill { background:
    repeating-linear-gradient(135deg, var(--green-100) 0 10px, var(--green-50) 10px 20px); color: var(--green-700); }

/* ---------- DIVIDER ---------- */
.divider { height: 1px; background: var(--line); border: none; }
.divider-soft { height: 1px; background: var(--line-soft); border: none; }
.dot-sep { width: 4px; height: 4px; border-radius: 50%; background: var(--stone-400); display: inline-block; }

/* ---------- HEADER / NAV ---------- */
.site-header { position: sticky; top: 0; z-index: 50; background: oklch(0.988 0.008 92 / 0.86); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: var(--s-3); font-family: var(--font-display); font-weight: 700; font-size: 1.4rem; letter-spacing: -0.01em; color: var(--green-900); }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; background: var(--green-600); color: var(--on-brand); display: grid; place-content: center; box-shadow: var(--sh-brand); flex: none; }
.nav-link { font-size: var(--fs-sm); font-weight: 600; color: var(--text-secondary); padding: 0.5rem 0.2rem; transition: color .15s; }
.nav-link:hover { color: var(--green-800); }
.topbar { background: var(--green-900); color: oklch(0.92 0.02 160); font-size: var(--fs-xs); }
.topbar a { color: oklch(0.86 0.05 160); font-weight: 600; }

/* ---------- FOOTER ---------- */
.site-footer { background: var(--green-900); color: oklch(0.86 0.018 150); }
.site-footer a { color: oklch(0.86 0.018 150); font-size: var(--fs-sm); transition: color .15s; }
.site-footer a:hover { color: #fff; }
.footer-head { color: oklch(0.97 0.01 150); font-weight: 700; font-size: var(--fs-sm); letter-spacing: 0.02em; }

/* ---------- UTIL ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.full-bleed { width: 100vw; margin-left: 50%; transform: translateX(-50%); }
.rounded-img { border-radius: var(--r-lg); overflow: hidden; }
.shadow-lg { box-shadow: var(--sh-lg); }
.text-brand { color: var(--green-700); }
.text-apricot { color: var(--apricot-700); }
.bg-cream { background: var(--cream); }
.bg-sand { background: var(--sand); }
.bg-green-50 { background: var(--green-50); }
.bg-dark { background: var(--green-900); color: oklch(0.92 0.015 150); }
.maxw-prose { max-width: 62ch; }
@media (max-width: 760px) {
  .container { padding-inline: var(--s-5); }
  .section { padding-block: var(--s-12); }
  .hide-mobile { display: none !important; }
}
