/*
  base.css — tokens and components shared by the organiser app and gift page.
  Palette: an Australian summer Christmas. Eucalypt and gum leaf greens,
  Christmas bush crimson, Christmas beetle gold. The gift tag is the one
  signature shape; everything else stays quiet.
*/

@font-face {
  font-family: 'Alegreya';
  src: url('../fonts/alegreya-latin-wght-normal.woff2') format('woff2');
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --eucalypt: #1e3a34;
  --gum: #5e8c7f;
  --gum-mist: #dde8e3;
  --paper: #f4f7f3;
  --card: #ffffff;
  --bush: #b3263e;
  --bush-press: #951d32;
  --beetle: #c99a2e;
  --ink: #17231f;
  --ink-soft: #4a5a54;
  --line: #cfdbd5;
  --warn-bg: #fbeff1;
  --warn-ink: #8a1d31;
  --ok-ink: #2f6b58;
  --on-bush: #ffffff;

  --tag-bg: var(--eucalypt);
  --tag-ink: #f3f1e6;
  --tag-soft: #b9cfc6;

  --font-display: 'Alegreya', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --font-ui: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 20px;
  --shadow: 0 1px 2px rgba(23, 35, 31, 0.08), 0 6px 18px rgba(23, 35, 31, 0.06);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --eucalypt: #b7d3c9;
    --gum: #8db6a8;
    --gum-mist: #22403a;
    --paper: #0f1e1b;
    --card: #172a26;
    --bush: #e0566c;
    --bush-press: #ec7285;
    --beetle: #e2b64e;
    --ink: #e6eeea;
    --ink-soft: #a9bab3;
    --line: #2d4943;
    --warn-bg: #3a1c24;
    --warn-ink: #ffb3bf;
    --ok-ink: #8fd1b8;
    --on-bush: #1d0a0f;
    --tag-bg: #213f38;
    --tag-ink: #f3f1e6;
    --tag-soft: #a9c4ba;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
  margin: 0;
  color: var(--ink);
  text-wrap: balance;
  font-variant-numeric: lining-nums;
  font-feature-settings: 'lnum' 1;
}
h1 { font-size: clamp(1.9rem, 6vw, 2.5rem); letter-spacing: -0.01em; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
p { margin: 0; }

a { color: var(--bush); text-underline-offset: 3px; }

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

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap;
}

.muted { color: var(--ink-soft); }
.small { font-size: 0.9rem; }
.stack > * + * { margin-top: 12px; }
.stack-lg > * + * { margin-top: 24px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }

/* ---------- Gift tag: the signature shape ---------- */
.tag {
  --notch: 26px;
  position: relative;
  background: var(--tag-bg);
  color: var(--tag-ink);
  border-radius: 6px 22px 22px 6px;
  padding: 24px 22px 24px 58px;
  clip-path: polygon(var(--notch) 0, 100% 0, 100% 100%, var(--notch) 100%, 0 calc(100% - var(--notch)), 0 var(--notch));
}
.tag::before {
  content: '';
  position: absolute;
  left: 22px;
  top: 50%;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: inset 0 0 0 3px var(--beetle);
}
.tag h1, .tag h2, .tag h3 { color: var(--tag-ink); }
.tag .muted { color: var(--tag-soft); }
.tag a { color: var(--tag-ink); }

.tag-title {
  font-variant-numeric: lining-nums;
  font-feature-settings: 'lnum' 1;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 5.5vw, 2.2rem);
  font-weight: 700;
  line-height: 1.1;
}

/* ---------- Countdown ---------- */
.countdown {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin: 18px 0 16px;
}
.countdown-unit { min-width: 3.2ch; }
.countdown-value {
  display: block;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.3rem, 10vw, 3.6rem);
  line-height: 1;
  font-variant-numeric: lining-nums tabular-nums;
  font-feature-settings: 'lnum' 1, 'tnum' 1;
}
.countdown-unit[data-unit='seconds'] .countdown-value { color: var(--beetle); }
.countdown-label { display: block; font-size: 0.85rem; color: var(--tag-soft); margin-top: 2px; }
.countdown-message {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 6vw, 2.2rem);
  font-weight: 700;
  margin: 16px 0;
}

.event-facts { display: grid; gap: 6px; }
.event-facts p { display: flex; gap: 10px; align-items: baseline; }
.event-facts .fact-label { color: var(--ink-soft); min-width: 4.5em; font-size: 0.9rem; flex: none; }
.tag .event-facts .fact-label { color: var(--tag-soft); }

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 18px;
  border-radius: var(--r-md);
  border: 0;
  background: var(--bush);
  color: var(--on-bush);
  font: 600 1rem/1.2 var(--font-ui);
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}
@media (hover: hover) and (pointer: fine) { .btn:hover { background: var(--bush-press); } }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.secondary { background: var(--gum-mist); color: var(--ink); }
@media (hover: hover) and (pointer: fine) { .btn.secondary:hover { background: var(--line); } }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
@media (hover: hover) and (pointer: fine) { .btn.ghost:hover { background: var(--gum-mist); } }
.btn.danger { background: transparent; color: var(--warn-ink); box-shadow: inset 0 0 0 1.5px currentColor; }
.btn.small { min-height: 38px; padding: 6px 12px; font-size: 0.92rem; }
.btn.block { width: 100%; }
.tag .btn.secondary { background: rgba(243, 241, 230, 0.14); color: var(--tag-ink); }
@media (hover: hover) and (pointer: fine) { .tag .btn.secondary:hover { background: rgba(243, 241, 230, 0.24); } }

.link-btn {
  appearance: none; background: none; border: 0; padding: 0;
  color: var(--bush); font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}

/* ---------- Fields ---------- */
.field { display: grid; gap: 6px; }
.field > span { font-weight: 600; font-size: 0.95rem; }
.field .hint { display: block; font-weight: 400; color: var(--ink-soft); font-size: 0.88rem; }
.input, select.input, textarea.input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: 1rem/1.4 var(--font-ui);
}
textarea.input { min-height: 96px; resize: vertical; }
.input[aria-invalid] { border-color: var(--warn-ink); }
.input:focus { border-color: var(--gum); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--beetle) 45%, transparent); }
.fields-2 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
@media (max-width: 420px) { .fields-2 { grid-template-columns: 1fr; } }
.check { display: flex; gap: 12px; align-items: center; min-height: 48px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--bush); flex: none; }

/* ---------- Surfaces ---------- */
.card {
  background: var(--card);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--shadow);
}
.notice {
  border-radius: var(--r-md);
  padding: 12px 14px;
  background: var(--gum-mist);
  color: var(--ink);
}
.notice.warn { background: var(--warn-bg); color: var(--warn-ink); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.85rem;
  background: var(--gum-mist);
  color: var(--ink);
  white-space: nowrap;
}
.chip.warn { background: var(--warn-bg); color: var(--warn-ink); }
.chip.gold { background: color-mix(in srgb, var(--beetle) 22%, transparent); }

/* ---------- Wishlist display ---------- */
.wish-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.wish-list li {
  background: var(--card);
  border-radius: var(--r-md);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.wish-list li.no { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); }
.wish-link { font-size: 0.9rem; }

/* ---------- Wishlist editor (organiser app and gift page) ---------- */
.wish-rows { display: grid; gap: 10px; }
.wish-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  background: var(--card);
  border-radius: var(--r-md);
  padding: 10px;
  box-shadow: var(--shadow);
}
.wish-row .input { min-height: 44px; }
.wish-row .icon-btn { align-self: start; }
.wish-row .wish-fields { display: grid; gap: 8px; }


/* ---------- Wrapping-paper blur ---------- */
.wrapped {
  display: inline-block;
  width: 7.5ch;
  height: 1.05em;
  vertical-align: -0.12em;
  border-radius: 4px;
  background: repeating-linear-gradient(135deg,
    var(--bush) 0 5px, color-mix(in srgb, var(--bush) 30%, var(--card)) 5px 9px, var(--beetle) 9px 11px, color-mix(in srgb, var(--bush) 30%, var(--card)) 11px 15px);
  opacity: 0.8;
}

/* ---------- Dialog sheet ---------- */
dialog.sheet {
  border: 0;
  padding: 0;
  width: min(560px, 100%);
  max-width: 100%;
  max-height: min(92dvh, 900px);
  border-radius: var(--r-lg);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
dialog.sheet::backdrop { background: rgba(10, 20, 18, 0.5); }
.sheet-inner { display: flex; flex-direction: column; max-height: inherit; }
.sheet-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
}
.sheet-head h2 { flex: 1; font-size: 1.35rem; }
.sheet-body { padding: 16px 18px; overflow: auto; }
.sheet-foot {
  display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap;
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.icon-btn {
  appearance: none; border: 0; background: transparent; color: var(--ink);
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
}
@media (hover: hover) and (pointer: fine) { .icon-btn:hover { background: var(--gum-mist); } }
.icon-btn svg, .icon svg { width: 22px; height: 22px; }

@media (max-width: 640px) {
  dialog.sheet {
    margin: auto 0 0;
    width: 100%;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
  }
  dialog.sheet[open] { animation: sheet-up 220ms cubic-bezier(0.2, 0.8, 0.2, 1); }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  z-index: 50;
  width: min(92vw, 460px);
  pointer-events: none;
}
.toast {
  background: var(--ink);
  color: var(--paper);
  padding: 12px 16px;
  border-radius: var(--r-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.toast.warn { background: var(--warn-ink); color: var(--paper); }

.loading {
  min-height: 60vh;
  display: grid;
  place-items: center;
  color: var(--ink-soft);
}

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

.about { white-space: pre-line; }
