/* Giver web, Direction A "Editorial gallery": warm paper and ink, one fern accent, system font only.
   Sizes in rem/em so the page follows the reader's text size (older relatives are core givers).
   On iOS the root is the system body style, so 1rem IS the reader's Dynamic Type size (17px by
   default, ~53px at the largest accessibility size). Headings add a fixed step to 1rem rather than
   multiplying it, the way iOS's own title styles grow less than body text. */
:root {
  --canvas: #FAF8F5;
  --surface: #FFFFFF;
  --sunken: #F3F0EA;
  --ink: #1A1714;
  --ink-2: #6B655C;
  --ink-on-sunken: #4D4842;
  --accent: #2F5D46;
  --accent-soft: #E3ECE5;
  --on-ink: #FAF8F5;
  --border: #E7E2D9;
  --border-strong: #D5CEC2;
  --radius-card: 6px;
  --radius-field: 12px;
  --radius-sheet: 28px;
  --gutter: 20px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #0F0D0B;
    --surface: #1A1714;
    --sunken: #2A2622;
    --ink: #FAF8F5;
    --ink-2: #A8A196;
    --ink-on-sunken: #A8A196;
    --accent: #8FB39E;
    --accent-soft: #1C3328;
    --on-ink: #0F0D0B;
    --border: #2A2622;
    --border-strong: #6B655C;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* iOS only (desktop Safari's body style is smaller than the web default). */
@supports (font: -apple-system-body) and (-webkit-touch-callout: none) {
  html { font: -apple-system-body; }
}
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 1rem/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
main { max-width: 760px; margin: 0 auto; padding: 0 var(--gutter) 64px; }
a { color: inherit; }
button { font: inherit; color: inherit; }
.loading { padding: 48px var(--gutter); color: var(--ink-2); text-align: center; }

/* App banner (small, dismissible) */
.banner { display: flex; align-items: center; gap: 12px; margin: 12px 0 0; padding: 10px 12px; background: var(--sunken); border-radius: var(--radius-field); font-size: 0.875rem; color: var(--ink-on-sunken); }
.banner a { font-weight: 600; color: var(--ink); text-decoration: none; }
.banner .x { margin-left: auto; background: none; border: 0; padding: 4px 6px; cursor: pointer; color: var(--ink-2); font-size: 1rem; }

/* Header */
.head { padding: 28px 0 18px; }
.eyebrow { margin: 0 0 4px; font-size: 0.9375rem; color: var(--ink-2); }
h1 { margin: 0; font-size: calc(1rem + 15px); line-height: 1.1; letter-spacing: -0.02em; font-weight: 700; }
.occasion { margin: 8px 0 0; color: var(--accent); font-weight: 600; font-size: 0.9375rem; }
.lede { margin: 12px 0 0; color: var(--ink-2); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0.75em 1.25em; border-radius: 1.5em; /* a pill on one line, a rounded rectangle when large text wraps */ border: 1px solid transparent; font-weight: 600; font-size: 1rem; text-decoration: none; cursor: pointer; width: 100%; text-align: center; }
.btn-primary { background: var(--ink); color: var(--on-ink); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border-strong); }
.btn-text { background: none; border: 0; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; min-height: 44px; }
.btn-link { background: none; border: 0; padding: 0.5em 0; margin: 0; font: inherit; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; white-space: nowrap; }
.btn[disabled] { opacity: 0.5; cursor: default; }
.stack { display: grid; gap: 10px; }

/* Filter */
.filter { display: inline-flex; flex-wrap: wrap; max-width: 100%; padding: 3px; background: var(--sunken); border-radius: 1.5em; margin: 4px 0 16px; }
.filter button { border: 0; background: none; padding: 0.5em 1em; border-radius: 1.3em; font-weight: 600; font-size: 0.9375rem; color: var(--ink-on-sunken); cursor: pointer; }
.filter button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }

/* Grid of items */
/* Two columns at normal sizes; one column once the reader's text is large enough that titles would crush. */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 9rem), 1fr)); gap: 13px; }
.card { position: relative; display: flex; flex-direction: column; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; color: inherit; }
.tile { position: relative; aspect-ratio: 4 / 5; border-radius: var(--radius-card); overflow: hidden; background: var(--sunken); display: flex; align-items: center; justify-content: center; }
.tile img { width: 100%; height: 100%; object-fit: cover; }
.tile-logo .logo { width: 56%; height: auto; max-height: 28%; object-fit: contain; }
@media (prefers-color-scheme: dark) { .tile-logo { background: #F3F0EA; } }
.mini .tile-logo .logo { width: 72%; }
.tile .store { font-weight: 700; font-size: 1rem; color: var(--ink-on-sunken); padding: 12px; text-align: center; }
.card .t { margin: 8px 0 2px; font-weight: 600; font-size: 0.9375rem; line-height: 1.3; }
.card .m { margin: 0; font-size: 0.8125rem; color: var(--ink-2); }
.star { color: var(--accent); font-weight: 600; }

/* Claimed state: plain words, never colour alone, large-text readable (constraint 8). */
.card.is-claimed .tile::after { content: ""; position: absolute; inset: 0; background: var(--canvas); opacity: 0.58; }
.status { position: absolute; left: 8px; top: 8px; z-index: 1; display: inline-flex; align-items: center; gap: 0.35em; padding: 0.3em 0.65em; border-radius: 999px; font-weight: 700; font-size: 0.875rem; background: var(--ink); color: var(--on-ink); max-width: calc(100% - 16px); }
.status.yours { background: var(--accent); color: var(--on-ink); }
.status::before { content: "✓"; }
.avail { margin: 2px 0 0; font-size: 0.8125rem; font-weight: 600; color: var(--ink); }

/* Item detail */
.back { display: inline-flex; align-items: center; gap: 6px; margin: 16px 0 0; padding: 8px 0; background: none; border: 0; cursor: pointer; color: var(--ink-2); font-weight: 600; }
.detail .tile { aspect-ratio: 1 / 1; margin: 12px 0 18px; }
.detail h2 { margin: 0 0 6px; font-size: calc(1rem + 7px); line-height: 1.2; letter-spacing: -0.01em; }
.retailer { margin: 0 0 10px; color: var(--ink-2); font-weight: 600; }
.price { margin: 0 0 4px; font-size: 1.125rem; font-weight: 700; }
.price small { font-weight: 400; color: var(--ink-2); font-size: 0.875rem; }
.attrib { margin: 0 0 12px; font-size: 0.8125rem; color: var(--ink-2); }
.facts { margin: 12px 0 18px; padding: 0; list-style: none; display: grid; gap: 4px; color: var(--ink-on-sunken); }
.note { margin: 0 0 18px; padding: 14px 16px; background: var(--sunken); border-radius: var(--radius-field); }
.note b { display: block; font-size: 0.8125rem; color: var(--ink-2); margin-bottom: 4px; }
.claimed-banner { margin: 0 0 16px; padding: 14px 16px; border-radius: var(--radius-field); background: var(--sunken); font-weight: 700; font-size: 1.0625rem; }
.claimed-banner.yours { background: var(--accent-soft); }

/* Boxed disclosure next to buy links (constraint 6) */
.disclosure { margin: 16px 0 0; padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-field); font-size: 0.875rem; color: var(--ink-on-sunken); }

/* Confirmation / message pages */
.hero { padding: 40px 0 8px; }
.hero h1 { font-size: calc(1rem + 11px); }
.hero p { color: var(--ink-2); }
.mini { display: flex; gap: 12px; align-items: center; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-field); margin: 18px 0; }
.mini .tile { width: 4rem; height: 4rem; aspect-ratio: auto; flex: none; }
.mini .tile .store { font-size: 0.75rem; padding: 4px; }
.mini p { margin: 0; font-weight: 600; }

/* Sheet (identity G4) */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.36); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet { width: 100%; max-width: 520px; background: var(--surface); border-radius: var(--radius-sheet) var(--radius-sheet) 0 0; padding: 24px var(--gutter) calc(24px + env(safe-area-inset-bottom)); max-height: 92vh; overflow: auto; }
@media (min-width: 640px) { .scrim { align-items: center; } .sheet { border-radius: var(--radius-sheet); } }
.sheet h2 { margin: 0 0 6px; font-size: calc(1rem + 5px); }
.sheet p { margin: 0 0 16px; color: var(--ink-2); }
label { display: block; font-weight: 600; font-size: 0.9375rem; margin: 0 0 6px; }
input[type="text"], input[type="email"] { width: 100%; min-height: 48px; padding: 12px 14px; border-radius: var(--radius-field); border: 1px solid var(--border-strong); background: var(--canvas); color: var(--ink); font: inherit; margin: 0 0 14px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 2px 0 18px; }
.check input { width: 1.3em; height: 1.3em; margin: 1px 0 0; accent-color: var(--accent); }
.error { color: #B3261E; font-weight: 600; margin: 0 0 12px; }
@media (prefers-color-scheme: dark) { .error { color: #F2B8B5; } }
.trust { margin: -6px 0 16px; padding: 10px 12px; background: var(--sunken); border-radius: var(--radius-field); color: var(--ink-on-sunken) !important; font-size: 0.875rem; }
.hero .trust { margin: 0 0 18px; }
.or { text-align: center; color: var(--ink-2); margin: 14px 0; font-size: 0.875rem; }
.apple { background: #000; color: #fff; }
@media (prefers-color-scheme: dark) { .apple { background: #fff; color: #000; } }

footer.attributions { margin: 28px 0 0; font-size: 0.8125rem; color: var(--ink-2); }

@media (prefers-reduced-motion: no-preference) {
  .sheet { animation: rise 220ms cubic-bezier(.2,.8,.2,1); }
  @keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
}

/* Legal and support pages (privacy.html, terms.html, support.html): same paper, ink and type as the giver page. */
.legal { max-width: 680px; }
.legal .draft { margin: 20px 0 0; padding: 10px 12px; border: 1px dashed var(--border-strong); border-radius: var(--radius-field); font-size: 0.875rem; font-weight: 600; color: var(--ink-on-sunken); }
.legal .head { padding-bottom: 8px; }
.legal h2 { margin: 36px 0 8px; font-size: calc(1rem + 5px); line-height: 1.25; letter-spacing: -0.01em; }
.legal h3 { margin: 22px 0 6px; font-size: 1rem; }
.legal p, .legal li { color: var(--ink); }
.legal ul { padding-left: 1.2em; margin: 8px 0 12px; }
.legal li { margin: 4px 0; }
.legal .muted { color: var(--ink-2); }
.legal table { width: 100%; border-collapse: collapse; margin: 10px 0 16px; font-size: 0.9375rem; }
.legal th, .legal td { text-align: left; vertical-align: top; padding: 8px 10px 8px 0; border-bottom: 1px solid var(--border); }
.legal th { font-weight: 600; color: var(--ink-2); font-size: 0.8125rem; }
.legal .confirm { font-size: 0.8125rem; font-weight: 600; color: var(--accent); white-space: nowrap; }
.legal nav.pages { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 40px 0 0; padding: 16px 0 0; border-top: 1px solid var(--border); font-size: 0.9375rem; }
.legal nav.pages a { color: var(--ink-2); text-underline-offset: 3px; }
.fine { margin: -4px 0 16px !important; font-size: 0.8125rem; color: var(--ink-2) !important; }
.fine a { color: var(--ink-2); text-underline-offset: 2px; }
/* Spacing utilities (the CSP's style-src 'self' blocks inline style attributes). */
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-18 { margin-bottom: 18px; }
