/* Midcentury Christmas design system: a 1960s Wish Book with modern usability. */
:root {
  --cream: #f7ebd5;
  --warm-white: #fff9ee;
  --evergreen: #285344;
  --evergreen-soft: #3b6b58;
  --red: #b64036;
  --red-pressed: #9c342b;
  --gold: #d7a44a;
  --pink: #e8b5a3;
  --sage: #a7b9a4;
  --cocoa: #765d4a;
  --ink: #292b26;

  /* Lighter tints keep evergreen text at WCAG AA on colored cards. */
  --pink-tint: #f3d3c7;
  --sage-tint: #ccd8c9;
  --gold-tint: #efd49c;

  --border: #e3d3b6;
  --shadow: 0 1px 2px rgb(41 43 38 / 6%), 0 4px 14px rgb(41 43 38 / 6%);

  --font-display: 'Fraunces', 'DM Serif Display', Georgia, serif;
  --font-ui: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --gutter: 20px;
  --radius-card: 18px;
  --radius-button: 14px;
  --radius-input: 12px;
  --radius-tag: 8px;
  --nav-height: 68px;

  color-scheme: light;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--cream);
  /* Barely-there printed paper grain. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .46 0 0 0 0 .36 0 0 0 0 .29 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  color: var(--evergreen);
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.5;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) var(--gutter) calc(40px + env(safe-area-inset-bottom));
}
body.has-nav main { padding-bottom: calc(var(--nav-height) + 40px + env(safe-area-inset-bottom)); }

/* ---------- type ---------- */

h1, h2, h3, p { margin: 0; }
.display { font-family: var(--font-display); font-weight: 700; color: var(--evergreen); letter-spacing: -0.01em; line-height: 1.15; font-variation-settings: 'SOFT' 50, 'WONK' 1; }
h1.display { font-size: 1.75rem; }
h1.hero { font-size: 2.125rem; }
.small-display { font-size: 1.25rem; }
.section-title { font-family: var(--font-display); font-weight: 700; font-size: 1.375rem; color: var(--evergreen); }
.micro {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--red);
}
.muted { color: var(--cocoa); }
.small { font-size: 0.875rem; }

a { color: var(--red); }

/* ---------- layout ---------- */

.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 28px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grow { flex: 1; }
.title-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.title-row .art { flex-shrink: 0; }
.center-screen { min-height: 70vh; display: grid; place-content: center; justify-items: center; gap: 16px; }

.page-header { position: relative; display: flex; flex-direction: column; gap: 8px; }
.page-header.home { padding-top: 8px; }
.page-header .display, .welcome .display { max-width: 80%; }
.star-field { position: absolute; top: -6px; right: -8px; width: 120px; height: 60px; pointer-events: none; }

.welcome { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding-top: 12px; }
.welcome .display { max-width: 100%; }
.welcome .star-field { top: 0; right: 0; }

/* ---------- surfaces ---------- */

.card {
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 20px;
}

.surface-pink { background: var(--pink-tint); }
.surface-sage { background: var(--sage-tint); }
.surface-gold { background: var(--gold-tint); }
.surface-white { background: var(--warm-white); }

.note-card {
  background: var(--warm-white);
  border-left: 4px solid var(--gold);
  border-radius: 4px var(--radius-card) var(--radius-card) 4px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--ink);
}
.note-card .micro { color: var(--cocoa); display: flex; align-items: center; gap: 4px; }

.privacy-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--evergreen);
  background: var(--sage-tint);
  border-radius: var(--radius-input);
  padding: 10px 12px;
}
.privacy-note .icon { flex-shrink: 0; margin-top: 2px; }

/* ---------- buttons ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 20px;
  border-radius: var(--radius-button);
  border: 1.5px solid transparent;
  font: 600 1rem/1.2 var(--font-ui);
  text-decoration: none;
  cursor: pointer;
  transition: transform 150ms ease, background-color 150ms ease;
  -webkit-tap-highlight-color: transparent;
}
.button:active { transform: scale(0.98); }
.button:disabled { opacity: 0.55; cursor: default; transform: none; }
.button.primary { background: var(--red); color: var(--warm-white); box-shadow: 0 2px 0 var(--red-pressed); }
.button.primary:active { background: var(--red-pressed); box-shadow: none; }
.button.secondary { background: var(--warm-white); color: var(--evergreen); border-color: var(--evergreen); }
.button.secondary:active { background: var(--cream); }
.button.danger { color: var(--red); border-color: var(--red); }
.button.compact { min-height: 44px; padding: 8px 16px; }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.text-button {
  align-self: flex-start;
  min-height: 44px;
  padding: 0;
  background: none;
  border: 0;
  color: var(--red);
  font: 600 0.9375rem var(--font-ui);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.icon-button.danger { color: var(--red); }

.back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  align-self: flex-start;
  min-height: 44px;
  margin-left: -6px;
  color: var(--evergreen);
  font-weight: 600;
  font-size: 0.9375rem;
  text-decoration: none;
}

:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------- badges & status ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  padding: 3px 8px;
  border-radius: var(--radius-tag);
  background: var(--warm-white);
  border: 1px solid var(--border);
  color: var(--evergreen);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge.priority-high { background: #f6dcd6; border-color: #e7b8ae; color: #8f2f27; }
.badge.priority-medium { background: var(--gold-tint); border-color: #e2c27c; color: #5c4630; }
.badge.priority-low { background: var(--sage-tint); border-color: #b4c5b0; color: var(--evergreen); }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 0.875rem; font-weight: 600; }
.status.mine { color: var(--evergreen); }
.status.taken { color: var(--cocoa); }

/* ---------- family ---------- */

.crew-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.crew-card {
  position: relative;
  width: 100%;
  min-height: 132px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 16px;
  border: 1px solid rgb(40 83 68 / 12%);
  border-radius: var(--radius-card);
  color: var(--evergreen);
  text-decoration: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 150ms ease;
}
.crew-card:active { transform: scale(0.98); }
.crew-card .avatar { margin-bottom: 6px; }
.crew-card .badge { position: absolute; top: 14px; right: 14px; }
.crew-name { font-family: var(--font-display); font-weight: 700; font-size: 1.1875rem; line-height: 1.2; overflow-wrap: anywhere; }
.crew-meta { font-size: 0.875rem; color: var(--evergreen); }

.avatar {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--evergreen);
  background: var(--warm-white);
  color: var(--evergreen);
  font: 700 1.25rem/1 var(--font-display);
}
.crew-card .avatar { background: var(--warm-white); }
.avatar.sm { width: 36px; height: 36px; font-size: 1rem; }
.avatar.lg { width: 56px; height: 56px; font-size: 1.5rem; }

/* ---------- welcome: choosing who you are ---------- */

.identity-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.identity-row {
  width: 100%;
  min-height: 60px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: var(--warm-white);
  color: var(--evergreen);
  font: 600 1.0625rem var(--font-ui);
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease;
}
.identity-row .badge { margin-left: 8px; vertical-align: 2px; }
.identity-row.selected { border-color: var(--evergreen); background: var(--sage-tint); }
.radio-dot {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border: 2px solid var(--evergreen);
  border-radius: 50%;
  color: var(--warm-white);
}
.identity-row.selected .radio-dot { background: var(--evergreen); }
.center { text-align: center; }

/* ---------- home ---------- */

.countdown {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  padding: 6px 14px 6px 10px;
  border-radius: 999px;
  background: var(--evergreen);
  color: var(--warm-white);
  font-weight: 600;
  font-size: 0.875rem;
}

.feature-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--radius-card);
  background: var(--evergreen);
  color: var(--warm-white);
  text-decoration: none;
  box-shadow: var(--shadow);
}
.feature-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--red); flex-shrink: 0; }
.feature-text { flex: 1; display: flex; flex-direction: column; font-size: 0.875rem; }
.feature-text strong { font-family: var(--font-display); font-size: 1.125rem; }

.recent { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.recent-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 14px;
  background: var(--warm-white);
  border: 1px solid var(--border);
  color: var(--evergreen);
  text-decoration: none;
}
.recent-text { display: flex; flex-direction: column; min-width: 0; }
.recent-text strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- gifts ---------- */

.gift-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.gift-card {
  display: flex;
  gap: 14px;
  padding: 14px;
  border-radius: var(--radius-card);
  background: var(--warm-white);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  color: var(--evergreen);
  text-decoration: none;
  transition: transform 150ms ease;
}
.gift-card:active { transform: scale(0.99); }
.gift-card.is-taken { background: #f9f1e3; box-shadow: none; }
.gift-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.gift-name { font-family: var(--font-display); font-weight: 700; font-size: 1.125rem; line-height: 1.25; overflow-wrap: anywhere; }
.gift-meta { font-size: 0.875rem; color: var(--cocoa); }
.gift-note {
  font-size: 0.875rem;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.gift-body .status { margin-top: 4px; }

.thumb {
  width: 84px;
  height: 84px;
  flex-shrink: 0;
  border-radius: 12px;
  object-fit: cover;
  background: #fff;
  border: 1px solid var(--border);
}
.thumb.small { width: 52px; height: 52px; border-radius: 10px; }
.placeholder { display: grid; place-items: center; }

.hero-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 360px;
  object-fit: contain;
  border-radius: 22px;
  background: #fff;
  border: 1px solid var(--border);
}
.hero-image.placeholder { aspect-ratio: 16 / 10; }

.detail-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.price { font-size: 1.375rem; font-weight: 700; color: var(--ink); }

.claim-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  border-radius: var(--radius-card);
  background: var(--gold-tint);
  color: var(--ink);
}
.claim-panel.mine { background: var(--sage-tint); }
.claim-panel.taken { background: var(--warm-white); border: 1px dashed var(--border); }

.check-row { display: flex; align-items: center; gap: 12px; min-height: 44px; font-weight: 500; color: var(--ink); }
.check-row input, .bag-check input { width: 22px; height: 22px; accent-color: var(--evergreen); }

.bag-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px 6px 6px;
  border-radius: 14px;
  background: var(--warm-white);
  border: 1px solid var(--border);
}
.bag-check { display: grid; place-items: center; width: 44px; height: 44px; flex-shrink: 0; }
.bag-text { flex: 1; display: flex; flex-direction: column; padding: 6px 0; color: var(--evergreen); text-decoration: none; min-width: 0; }
.bag-row.done .bag-text strong { text-decoration: line-through; color: var(--cocoa); }

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

label, legend { font-weight: 600; font-size: 0.9375rem; color: var(--evergreen); }
label .icon { vertical-align: -3px; margin-right: 6px; }
.field { display: flex; flex-direction: column; gap: 6px; }

input:not([type='checkbox']):not([type='radio']), textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1.5px solid #d9c6a5;
  border-radius: var(--radius-input);
  background: #fffdf8;
  color: var(--ink);
  font: 400 1rem var(--font-ui); /* 16px prevents iOS zoom on focus */
}
input:focus, textarea:focus { border-color: var(--evergreen); outline: none; box-shadow: 0 0 0 3px rgb(215 164 74 / 45%); }
input::placeholder, textarea::placeholder { color: #9a8573; }
textarea { resize: vertical; }

.link-card { background: var(--warm-white); border: 1.5px dashed var(--gold); }
.image-field { display: flex; align-items: flex-end; gap: 12px; }
.image-field .field { flex: 1; }
.image-preview:empty { display: none; }
.image-preview .thumb { width: 48px; height: 48px; }

.priority-picker { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.priority-picker legend { margin-bottom: 8px; padding: 0; }
.priority-option { position: relative; }
.priority-option input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.priority-option span {
  display: grid;
  place-items: center;
  min-height: 48px;
  padding: 8px 6px;
  border-radius: var(--radius-input);
  border: 1.5px solid #d9c6a5;
  background: #fffdf8;
  font-size: 0.875rem;
  font-weight: 600;
  text-align: center;
  color: var(--evergreen);
  cursor: pointer;
}
.priority-option input:checked + span { background: var(--evergreen); border-color: var(--evergreen); color: var(--warm-white); }
.priority-option input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------- settings ---------- */

.you-card { display: flex; align-items: center; gap: 14px; }
.you-text { flex: 1; min-width: 0; }
.you-text .micro { color: var(--cocoa); }

.settings-list { list-style: none; margin: 0; padding: 0; border-radius: var(--radius-card); background: var(--warm-white); border: 1px solid var(--border); }
.settings-list li { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 8px 8px 14px; color: var(--evergreen); }
.settings-list li + li { border-top: 1px solid var(--border); }
.settings-list .badge { margin-left: 8px; vertical-align: 2px; }

/* ---------- empty states ---------- */

.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 24px 12px; text-align: center; }
.empty h2 { font-size: 1.5rem; }
.empty p { max-width: 30ch; }
.empty .button { margin-top: 8px; }

/* ---------- navigation ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: var(--warm-white);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgb(41 43 38 / 6%);
}
.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 52px;
  border-radius: 14px;
  color: var(--cocoa);
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
}
.tabbar a.active { color: var(--evergreen); }
.tabbar a.active .icon { background: var(--gold-tint); border-radius: 999px; padding: 3px 14px; width: 52px; height: 28px; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 20;
  width: min(520px, calc(100% - 32px));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 6px 16px;
  border-radius: 16px;
  background: var(--evergreen);
  color: var(--warm-white);
  font-weight: 600;
  box-shadow: 0 8px 24px rgb(41 43 38 / 25%);
  animation: toast-in 220ms ease-out;
}
body.has-nav .toast { bottom: calc(var(--nav-height) + 16px + env(safe-area-inset-bottom)); }
.toast span { flex: 1; }
.toast.error { background: #8f2f27; }

/* ---------- motion ---------- */

main.enter > section > *, main.enter .gift-list > li, main.enter .crew-grid > li {
  animation: rise 240ms ease-out both;
}
main.enter .gift-list > li, main.enter .crew-grid > li { animation-delay: calc(var(--i, 0) * 40ms); }
.art.pop { animation: pop 420ms cubic-bezier(.2, 1.4, .4, 1) both; }
.art.sway { transform-origin: 50% 100%; animation: sway 3.5s ease-in-out 2; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(0.3) rotate(-30deg); } to { opacity: 1; transform: none; } }
@keyframes sway { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(2.5deg); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

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

@media (max-width: 350px) {
  .crew-grid, .two-col, .button-row { grid-template-columns: 1fr; }
  h1.hero { font-size: 1.875rem; }
}
