/* ===========================================================================
   Presently
   ---------------------------------------------------------------------------
   Palette is taken straight off the logo: deep teal for structure, the coral
   spark and amber dashes for the one thing this app is really about — the
   stuff the recipient isn't allowed to see.

   The signature element is .veil: every band of content hidden from the person
   whose list you're looking at sits inside a coral-ruled, faintly hatched
   block labelled with exactly who can't see it. Everything else stays quiet so
   that band reads at a glance on a phone in a shop.

   Type: system sans for the interface, a warm serif for names, and monospace
   for money and states so the buying ledger reads like a ledger.
=========================================================================== */

:root {
  color-scheme: light;

  --shell: #f1f5f6;
  --card: #ffffff;
  --card-sunk: #f7fafa;
  --ink: #0f2429;
  --muted: #566d73;
  --rule: #d5e2e5;

  --brand: #0c7c8b;
  --brand-ink: #085c68;
  --brand-contrast: #ffffff;

  --secret: #b9563a;
  --secret-rule: #e08a6b;
  --secret-tint: #fdf2ed;
  --secret-hatch: rgba(237, 130, 101, 0.13);

  --amber: #96650f;
  --good: #1c6f55;
  --good-tint: #e8f3ef;
  --alert: #a3352f;
  --alert-tint: #f9ecea;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --radius: 10px;
  --tap: 44px;
}

[data-theme="dark"] {
  color-scheme: dark;

  --shell: #0c1316;
  --card: #141f23;
  --card-sunk: #101a1e;
  --ink: #e4eef0;
  --muted: #92a7ad;
  --rule: #253840;

  --brand: #3bb5c0;
  --brand-ink: #6fd3db;
  --brand-contrast: #06181c;

  --secret: #f0a184;
  --secret-rule: #b96a4d;
  --secret-tint: #211815;
  --secret-hatch: rgba(240, 145, 112, 0.055);

  --amber: #e0aa5c;
  --good: #55c39a;
  --good-tint: #12241e;
  --alert: #e58079;
  --alert-tint: #251616;
}

@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    color-scheme: dark;

    --shell: #0c1316;
    --card: #141f23;
    --card-sunk: #101a1e;
    --ink: #e4eef0;
    --muted: #92a7ad;
    --rule: #253840;

    --brand: #3bb5c0;
    --brand-ink: #6fd3db;
    --brand-contrast: #06181c;

    --secret: #f0a184;
    --secret-rule: #b96a4d;
    --secret-tint: #211815;
    --secret-hatch: rgba(240, 145, 112, 0.055);

    --amber: #e0aa5c;
    --good: #55c39a;
    --good-tint: #12241e;
    --alert: #e58079;
    --alert-tint: #251616;
  }
}

/* --- base ---------------------------------------------------------------- */

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--shell);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  overflow-wrap: break-word;
}

main {
  max-width: 62rem;
  margin: 0 auto;
  padding: 1rem 1rem calc(3rem + env(safe-area-inset-bottom));
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; margin: 0 0 0.25rem; }
h2 { font-size: 1.2rem; margin: 1.75rem 0 0.7rem; }
h3 { font-size: 1.05rem; margin: 0; }

a { color: var(--brand-ink); }
a:hover { color: var(--brand); }

:where(a, button, input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--secret-rule);
  outline-offset: 2px;
  border-radius: 3px;
}

img { max-width: 100%; }

/* --- masthead ------------------------------------------------------------ */

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--rule);
  padding: 0.55rem 0.9rem 0;
  padding-top: calc(0.55rem + env(safe-area-inset-top));
  position: sticky;
  top: 0;
  z-index: 20;
}

.wrap { max-width: 62rem; margin: 0 auto; }

.masthead { display: flex; align-items: center; gap: 0.75rem; }

.brand { display: block; line-height: 0; margin-right: auto; }
.brand img { height: 30px; width: auto; }
.logo-dark { display: none; }
[data-theme="dark"] .logo-light { display: none; }
[data-theme="dark"] .logo-dark { display: block; }
@media (prefers-color-scheme: dark) {
  html[data-theme="system"] .logo-light { display: none; }
  html[data-theme="system"] .logo-dark { display: block; }
}

/* On a phone the links scroll sideways rather than wrapping onto three rows.
   No JS, no hamburger, and every destination stays one tap away. */
.mainnav {
  display: flex;
  gap: 0.3rem;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.mainnav::-webkit-scrollbar { display: none; }

.mainnav a, .mainnav button {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 0.7rem;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 400;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.mainnav a:hover, .mainnav button:hover { color: var(--ink); }
.mainnav a.here { color: var(--brand-ink); border-bottom-color: var(--brand); }

@media (min-width: 54rem) {
  .topbar .wrap { display: flex; align-items: center; gap: 1.25rem; }
  .masthead { flex: 0 0 auto; }
  .brand { margin-right: 0; }
  .brand img { height: 34px; }
  .mainnav { margin-left: auto; }
}

/* Compact person rows, so a household of four doesn't fill a phone screen. */
.people { border-top: 1px solid var(--rule); }
.people a.person {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: var(--tap);
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
  text-decoration: none;
  font-family: var(--serif);
  font-size: 1.05rem;
}
.people a.person:last-child { border-bottom: 0; }
.people a.person:hover { color: var(--brand-ink); }
.people a.person > span:first-child { flex: 1 1 auto; }
.people a.person .meta { flex: 0 0 auto; font-family: var(--sans); }
.people a.person .chev { flex: 0 0 auto; color: var(--muted); font-family: var(--sans); }

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

.card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.9rem;
  margin-bottom: 0.7rem;
}

.card-head { display: flex; gap: 0.4rem 0.7rem; align-items: baseline; flex-wrap: wrap; }

.grid { display: grid; gap: 0.7rem; grid-template-columns: 1fr; }
@media (min-width: 34rem) { .grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 58rem) { .grid { grid-template-columns: 1fr 1fr 1fr; } }

.household { margin: 1.6rem 0 0.6rem; }
.household h2 { margin: 0; }

.meta { color: var(--muted); font-size: 0.875rem; }
.money { font-family: var(--mono); font-size: 0.95rem; font-variant-numeric: tabular-nums; }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.pill {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
  white-space: nowrap;
}
.pill-bought { border-color: var(--good); color: var(--good); }
.pill-locked { border-color: var(--alert); color: var(--alert); }

/* --- the veil: everything the recipient cannot see ----------------------- */

.veil {
  margin-top: 0.85rem;
  padding: 0.7rem 0.8rem 0.85rem;
  border-top: 1px solid var(--secret-rule);
  border-bottom: 1px solid var(--secret-rule);
  background-color: var(--secret-tint);
  background-image: repeating-linear-gradient(
    -45deg,
    var(--secret-hatch) 0 6px,
    transparent 6px 12px
  );
}
.veil > .eyebrow { color: var(--secret); display: block; margin-bottom: 0.45rem; }
.veil ul { margin: 0 0 0.6rem; padding-left: 1.1rem; }
.veil li { margin-bottom: 0.25rem; }
.veil .card { background: var(--card-sunk); }
.veil-item { border-color: var(--secret-rule); }

/* --- forms --------------------------------------------------------------- */

label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.2rem; }

input, select, textarea {
  font: inherit;
  font-size: 1rem; /* never below 16px, or iOS zooms the page on focus */
  width: 100%;
  min-height: var(--tap);
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
}
textarea { min-height: 4.5rem; }
input[type="checkbox"] { width: auto; min-height: 0; accent-color: var(--brand); }

.field { margin-bottom: 0.6rem; }
.fields { display: grid; gap: 0.6rem; grid-template-columns: 1fr; }
@media (min-width: 40rem) { .fields { grid-template-columns: 1fr 1fr; } }

button, .button {
  font: inherit;
  font-weight: 500;
  min-height: var(--tap);
  padding: 0.5rem 1rem;
  border: 1px solid var(--brand);
  border-radius: 6px;
  background: var(--brand);
  color: var(--brand-contrast);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
button.secondary, .button.secondary { background: var(--card); color: var(--brand-ink); }
button.danger, .button.danger { background: var(--card); color: var(--alert); border-color: var(--alert); }
button.small, .button.small {
  min-height: 2.2rem;
  padding: 0.2rem 0.7rem;
  font-size: 0.85rem;
}

.row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: flex-end; }
.row > * { flex: 1 1 9rem; }
.row > button { flex: 0 0 auto; }

.inline { display: inline-block; }
.linkish {
  background: none; border: 0; padding: 0; min-height: 0;
  color: var(--brand-ink); font: inherit; font-size: 0.9rem;
  text-decoration: underline; cursor: pointer;
}

details > summary {
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--brand-ink);
  min-height: var(--tap);
  display: flex;
  align-items: center;
}
details[open] > summary { margin-bottom: 0.5rem; }

/* --- flashes ------------------------------------------------------------- */

.flash {
  padding: 0.65rem 0.85rem;
  border-radius: 6px;
  font-size: 0.92rem;
  margin: 0 0 0.8rem;
}
.flash-ok { background: var(--good-tint); border: 1px solid var(--good); color: var(--good); }
.flash-err { background: var(--alert-tint); border: 1px solid var(--alert); color: var(--alert); }

/* --- tables: rows become cards on a phone -------------------------------- */

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
th {
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 400;
}

@media (max-width: 39.99rem) {
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack thead { display: none; }
  table.stack tr {
    background: var(--card);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 0.55rem 0.7rem;
    margin-bottom: 0.6rem;
  }
  table.stack td { border: 0; padding: 0.15rem 0; }
  table.stack td::before {
    content: attr(data-label);
    font-family: var(--mono);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted);
    display: block;
  }
}

/* --- scraped product data ------------------------------------------------ */

.thumb {
  display: block;
  max-width: 7rem;
  max-height: 7rem;
  width: auto;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: #fff;
  margin: 0.5rem 0;
}
.drop { color: var(--good); font-weight: 600; }

.empty { color: var(--muted); font-style: italic; }

/* --- theme picker -------------------------------------------------------- */

.themes { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.themes button { flex: 1 1 7rem; }
.themes button[aria-pressed="true"] {
  background: var(--brand);
  color: var(--brand-contrast);
  border-color: var(--brand);
}
.themes button[aria-pressed="false"] {
  background: var(--card);
  color: var(--ink);
  border-color: var(--rule);
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
