/* ==========================================================================
   Nebo storefront
   Light theme by default, dark via prefers-color-scheme. All colors go
   through the custom properties below so there is one place to rebrand.
   ========================================================================== */

:root {
  --ink: #0d1b26;
  --ink-soft: #4a5c68;
  --ink-faint: #7b8c98;
  --surface: #ffffff;
  --surface-2: #f6f9fb;
  --surface-3: #eaf1f5;
  --line: #dbe5ec;
  --accent: #0f6d92;
  --accent-hot: #0b5878;
  --accent-wash: #e4f1f7;
  --good: #0f7a52;
  --bad: #b3261e;
  --warn-bg: #fff4d6;
  --warn-ink: #6b4c00;
  --warn-line: #e8cf8f;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-1: 0 1px 2px rgba(13, 27, 38, 0.06), 0 2px 8px rgba(13, 27, 38, 0.05);
  --shadow-2: 0 12px 32px rgba(13, 27, 38, 0.14);

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --wrap: 1140px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8f0f5;
    --ink-soft: #a6b8c4;
    --ink-faint: #7d919e;
    --surface: #0f2131;
    --surface-2: #0b1926;
    --surface-3: #16303f;
    --line: #23404f;
    --accent: #4bb8dd;
    --accent-hot: #6fcbea;
    --accent-wash: #12303f;
    --good: #4dd39d;
    --bad: #ff8f84;
    --warn-bg: #3a2f10;
    --warn-ink: #f4dc9b;
    --warn-line: #6a5722;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-2: 0 12px 32px rgba(0, 0, 0, 0.5);
  }
}

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

/* The `hidden` attribute must always win.
   Browsers apply `[hidden] { display: none }` from the user-agent stylesheet,
   which ANY author `display` rule outranks — so `.cart-drawer { display: flex }`
   silently defeated `hidden` and left the cart permanently open. Everything
   toggled via the `hidden` property in app.js depends on this rule. */
[hidden] {
  display: none !important;
}

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

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--surface-2);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0;
  font-weight: 650;
}

p {
  margin: 0;
}

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

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

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

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: 20px;
}

.wrap-narrow {
  max-width: 760px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-2);
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 12px;
}

/* --- Test-mode banner ---------------------------------------------------- */

.test-banner {
  background: var(--warn-bg);
  color: var(--warn-ink);
  border-bottom: 1px solid var(--warn-line);
  text-align: center;
  padding: 9px 16px;
  font-size: 0.85rem;
  font-weight: 550;
}

.test-banner code {
  background: rgba(0, 0, 0, 0.09);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.95em;
}

/* --- Header -------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 68px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  /* Smaller than a bare wordmark would be: the 52px seal carries the weight,
     and "Nebo Elementary School" is long enough to crowd the nav otherwise. */
  font-size: 1.05rem;
  line-height: 1.15;
  letter-spacing: -0.015em;
  max-width: 15ch;
}

/* The school seal. `contain` so the circular logo is never cropped, and a fixed
   box so a swapped-in file of any dimensions cannot shift the header height. */
.brand-logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
  flex: none;
}

/* Stand-in shown only while assets/nebo-logo.png is missing. */
.brand-logo-fallback {
  display: none;
  width: 52px;
  height: 52px;
  flex: none;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand.is-missing-logo .brand-logo {
  display: none;
}

.brand.is-missing-logo .brand-logo-fallback {
  display: grid;
}

@media (max-width: 620px) {
  .brand-logo,
  .brand-logo-fallback {
    width: 42px;
    height: 42px;
  }

  .brand-word {
    font-size: 0.98rem;
    line-height: 1.2;
  }
}

.cart-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  /* Pushed to the right edge; there is no nav between it and the logo. */
  margin-inline-start: auto;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 560;
  color: var(--ink);
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.cart-button:hover {
  background: var(--accent-wash);
  border-color: var(--accent);
}

.cart-button svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.cart-count {
  min-width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  padding-inline: 5px;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

@media (prefers-color-scheme: dark) {
  .cart-count {
    color: #06202c;
  }
}

@media (max-width: 620px) {
  .cart-button span:not(.cart-count):not(.sr-only) {
    /* Drop the word "Cart" on narrow screens; the icon and badge carry it. */
    display: none;
  }
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 600;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.08s ease, border-color 0.15s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

@media (prefers-color-scheme: dark) {
  .btn-primary {
    color: #05202b;
  }
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hot);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

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

.btn-block {
  width: 100%;
}

.icon-button {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  cursor: pointer;
  padding: 7px;
  display: inline-grid;
  place-items: center;
}

.icon-button:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.icon-button svg {
  width: 20px;
  height: 20px;
}

/* --- Sections ------------------------------------------------------------ */

.section {
  padding-block: clamp(52px, 7vw, 86px);
  background: var(--surface-2);
}

.section-alt {
  background: var(--surface);
  border-block: 1px solid var(--line);
}

.section-head {
  margin-bottom: 34px;
  max-width: 60ch;
}

.section-head h1,
.section-head h2 {
  font-size: clamp(1.6rem, 3.2vw, 2.15rem);
  margin-bottom: 10px;
}

.section-head p {
  color: var(--ink-soft);
}

.section-head-center {
  margin-inline: auto;
  text-align: center;
}

/* Extra breathing room above the single product, since there is no hero. */
.section-shop {
  padding-block: clamp(40px, 6vw, 68px) clamp(52px, 7vw, 86px);
}

/* --- Product grid -------------------------------------------------------- */

/* `auto-fit` with a max track width keeps one product from stretching into a
   1140px-wide card, while still tiling neatly if more products are added. */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 360px));
  justify-content: center;
  gap: 22px;
}

.grid-status {
  grid-column: 1 / -1;
  color: var(--ink-faint);
  padding-block: 40px;
  text-align: center;
}

.grid-status.is-error {
  color: var(--bad);
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-1);
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}

.card:hover {
  box-shadow: var(--shadow-2);
  transform: translateY(-2px);
}

/* Portrait, to match the bottle photos (800×1036). `contain` rather than
   `cover` so no bottle ever gets its lid or base cropped off, and a white
   backdrop in both themes because the photos are shot on white. */
.card-media {
  position: relative;
  aspect-ratio: 3 / 4;
  background: #fff;
  overflow: hidden;
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  /* Cross-fade when switching color, so the swap does not read as a flicker. */
  transition: opacity 0.15s ease;
}

.cart-thumb,
.card-media img {
  background: #fff;
}

/* Shown when the product photo is missing, so an empty slot still looks
   deliberate instead of broken. */
.card-media.is-missing img {
  display: none;
}

.card-media .media-fallback {
  display: none;
  position: absolute;
  inset: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--ink-faint);
  font-size: 0.78rem;
  text-align: center;
  padding: 16px;
}

.card-media.is-missing .media-fallback {
  display: flex;
}

.media-fallback svg {
  width: 34px;
  height: 34px;
  opacity: 0.55;
}

.media-fallback code {
  font-size: 0.72rem;
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 5px;
  border-radius: 4px;
  word-break: break-all;
}

@media (prefers-color-scheme: dark) {
  .media-fallback code {
    background: rgba(255, 255, 255, 0.08);
  }
}

.badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: var(--ink);
  color: var(--surface);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 999px;
}

.card-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.card-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.card-title-row h3 {
  font-size: 1.06rem;
}

.price {
  font-weight: 700;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.price s {
  color: var(--ink-faint);
  font-weight: 500;
  margin-inline-end: 6px;
  text-decoration-thickness: 1px;
}

.card-tagline {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.spec-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.spec {
  font-size: 0.75rem;
  color: var(--ink-soft);
  background: var(--surface-3);
  border-radius: 999px;
  padding: 3px 10px;
}

.card-details {
  font-size: 0.86rem;
  color: var(--ink-soft);
}

.card-details summary {
  cursor: pointer;
  font-weight: 550;
  color: var(--ink);
  font-size: 0.86rem;
  padding-block: 3px;
}

.card-details ul {
  margin: 8px 0 0;
  padding-inline-start: 18px;
  display: grid;
  gap: 4px;
}

.card-controls {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

/* Color and Design sit side by side, then stack when the card gets narrow. */
.option-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.field {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.field label {
  font-size: 0.76rem;
  font-weight: 620;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
}

select {
  font: inherit;
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  width: 100%;
  cursor: pointer;
}

/* --- FAQ ----------------------------------------------------------------- */

.faq {
  display: grid;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.faq details {
  border-bottom: 1px solid var(--line);
}

.faq details:last-child {
  border-bottom: 0;
}

.faq summary {
  cursor: pointer;
  padding: 16px 20px;
  font-weight: 570;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary::after {
  content: "+";
  color: var(--accent);
  font-size: 1.3rem;
  font-weight: 400;
  line-height: 1;
  flex: none;
}

.faq details[open] summary::after {
  content: "\2013";
}

.faq details p {
  padding: 0 20px 18px;
  color: var(--ink-soft);
  font-size: 0.93rem;
  max-width: 62ch;
}

/* --- Footer -------------------------------------------------------------- */

.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-block: 42px;
}

.footer-inner {
  display: grid;
  gap: 7px;
}

.footer-brand {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.footer-note,
.footer-legal {
  color: var(--ink-faint);
  font-size: 0.86rem;
}

/* --- Cart drawer --------------------------------------------------------- */

.cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 18, 26, 0.5);
  z-index: 50;
  animation: fade-in 0.18s ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.cart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 51;
  width: min(420px, 100vw);
  height: 100dvh;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-2);
  display: flex;
  flex-direction: column;
  animation: slide-in 0.22s cubic-bezier(0.32, 0.72, 0.35, 1);
}

@keyframes slide-in {
  from {
    transform: translateX(100%);
  }
}

.cart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.cart-head h2 {
  font-size: 1.1rem;
}

.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 8px 20px;
}

.cart-empty {
  color: var(--ink-faint);
  text-align: center;
  padding-block: 52px;
  font-size: 0.93rem;
}

.cart-item {
  display: grid;
  grid-template-columns: 62px 1fr auto;
  gap: 13px;
  align-items: start;
  padding-block: 16px;
  border-bottom: 1px solid var(--line);
}

.cart-item:last-child {
  border-bottom: 0;
}

.cart-thumb {
  width: 62px;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  /* `contain` for the same reason as the card: the bottle is portrait and
     must not be cropped into a square. */
  object-fit: contain;
  flex: none;
}

.cart-item-name {
  font-weight: 580;
  font-size: 0.92rem;
  line-height: 1.35;
}

.cart-item-color {
  color: var(--ink-faint);
  font-size: 0.8rem;
  margin-top: 2px;
}

.qty {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-top: 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px;
}

.qty button {
  width: 26px;
  height: 26px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1;
  border-radius: 999px;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.qty button:hover:not(:disabled) {
  background: var(--surface-3);
}

.qty button:disabled {
  color: var(--ink-faint);
  cursor: not-allowed;
}

.qty output {
  min-width: 24px;
  text-align: center;
  font-size: 0.88rem;
  font-weight: 620;
  font-variant-numeric: tabular-nums;
}

.cart-item-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.cart-item-price {
  font-weight: 650;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}

.remove-link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 0.78rem;
  color: var(--ink-faint);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.remove-link:hover {
  color: var(--bad);
}

.cart-foot {
  border-top: 1px solid var(--line);
  padding: 18px 20px calc(18px + env(safe-area-inset-bottom));
  display: grid;
  gap: 11px;
  background: var(--surface);
}

.cart-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 1.02rem;
}

.cart-line strong {
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
}

.cart-fineprint {
  font-size: 0.78rem;
  color: var(--ink-faint);
  margin-top: -4px;
}

.cart-error {
  font-size: 0.85rem;
  color: var(--bad);
  background: color-mix(in srgb, var(--bad) 10%, transparent);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  display: grid;
  gap: 6px;
}

/* Stripe's own explanation of a setup problem. Deliberately quiet and
   monospaced — it is a diagnostic, not a message for shoppers. */
.cart-error-detail {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.74rem;
  line-height: 1.45;
  opacity: 0.85;
  word-break: break-word;
}

.cart-secure {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--ink-faint);
}

.cart-secure svg {
  width: 14px;
  height: 14px;
  flex: none;
}

/* Locks the page behind the open drawer. */
body.cart-open {
  overflow: hidden;
}

/* --- Toast --------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 60;
  background: var(--ink);
  color: var(--surface);
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 550;
  box-shadow: var(--shadow-2);
  animation: toast-in 0.2s ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
}

/* --- Receipt (success page) ---------------------------------------------- */

.receipt-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 40px 20px;
  background: var(--surface-2);
}

.receipt {
  width: 100%;
  max-width: 540px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: clamp(26px, 5vw, 40px);
  text-align: center;
}

.receipt-icon {
  width: 54px;
  height: 54px;
  margin: 0 auto 18px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--good) 14%, transparent);
  color: var(--good);
}

.receipt-icon svg {
  width: 28px;
  height: 28px;
}

.receipt h1 {
  font-size: 1.6rem;
  margin-bottom: 10px;
}

.receipt-sub {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.receipt-lines {
  margin-top: 26px;
  text-align: left;
  border-top: 1px solid var(--line);
}

.receipt-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding-block: 11px;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}

.receipt-row span:first-child {
  color: var(--ink-soft);
}

.receipt-row.is-total {
  font-weight: 700;
  font-size: 1.05rem;
  border-bottom: 0;
}

.receipt-row .qty-badge {
  color: var(--ink-faint);
}

.receipt-actions {
  margin-top: 26px;
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.receipt-status {
  color: var(--ink-faint);
  padding-block: 20px;
}

.receipt-status.is-error {
  color: var(--bad);
}
