/* ==========================================================================
   Secret Santa: tokens
   ========================================================================== */

:root {
  --bg: #f5f6f4;
  --surface: #ffffff;
  --surface-muted: #fafbfa;
  --border: #e4e8e5;
  --border-strong: #d3d9d5;
  --text: #1b2420;
  --muted: #5d6a64;
  --subtle: #8a958f;

  --accent: #1f5c45;
  --accent-hover: #174a37;
  --accent-soft: #e9f2ed;
  --festive: #b3262e;
  --danger: #b3262e;
  --danger-hover: #931e25;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 28, 22, 0.04), 0 2px 8px rgba(16, 28, 22, 0.03);
  --focus: 0 0 0 3px rgba(31, 92, 69, 0.18);

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

  color-scheme: light;
}

/* ==========================================================================
   Base
   ========================================================================== */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h3 { font-size: 16px; font-weight: 600; }
h4 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
}
p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0 20px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }

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

.icon { width: 18px; height: 18px; flex-shrink: 0; }
.icon-sm { width: 15px; height: 15px; }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }

/* ==========================================================================
   Layout
   ========================================================================== */

.container { max-width: 1160px; margin: 0 auto; padding: 0 24px; }
main.container { padding-top: 32px; padding-bottom: 64px; }

.grid { display: grid; gap: 24px; align-items: start; }
.grid-main { grid-template-columns: minmax(0, 1fr) 340px; }
.grid-side { grid-template-columns: minmax(0, 1fr) 340px; }
.grid-half { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.stack { display: grid; gap: 24px; }
.sticky { position: sticky; top: 88px; }
.narrow { max-width: 600px; margin: 0 auto; }

.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 28px; font-weight: 650; letter-spacing: -0.02em; }
.page-header p { color: var(--muted); margin-top: 4px; }

/* ==========================================================================
   Header
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
/* A thin candy-cane stripe: the one overtly festive touch. */
.site-header::before {
  content: "";
  display: block;
  height: 3px;
  background: repeating-linear-gradient(135deg, var(--festive) 0 10px, #fff 10px 14px, var(--accent) 14px 24px, #fff 24px 28px);
}

.header-inner { display: flex; align-items: center; gap: 28px; height: 60px; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.brand:hover { color: var(--text); }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
}
.brand-mark .icon { width: 17px; height: 17px; }

.nav { display: flex; gap: 4px; }
.nav-link {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
}
.nav-link:hover { background: #f0f2f0; color: var(--text); }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.account { display: flex; align-items: center; gap: 10px; margin: 0 0 0 auto; }
.account-name { font-weight: 550; font-size: 14px; }

/* ==========================================================================
   Panels
   ========================================================================== */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}
.panel-body { padding: 24px; }
.panel-body-tight { padding-bottom: 12px; }
.panel h3 { margin-bottom: 4px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.section-head h3 { margin: 0; }
.count { font-size: 13px; color: var(--subtle); white-space: nowrap; }

/* ==========================================================================
   Home
   ========================================================================== */

.match { overflow: hidden; }
.match-hero {
  padding: 28px 28px 24px;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(179, 38, 46, 0.06), transparent 55%),
    linear-gradient(180deg, #f2f7f4 0%, #ffffff 100%);
  border-bottom: 1px solid var(--border);
}
.eyebrow {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}
.match-name { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.match-name h2 { font-family: var(--font-display); font-size: 42px; font-weight: 600; letter-spacing: -0.01em; }
.match-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  margin: 0;
}

.match-pending .match-hero { text-align: center; padding: 48px 28px; border-bottom: 0; }
.match-pending h2 { font-family: var(--font-display); font-size: 30px; font-weight: 600; margin-bottom: 8px; }
.match-pending .match-hint { display: block; max-width: 420px; margin: 0 auto 20px; }
.match-pending .match-hint:last-child { margin-bottom: 0; }
.hero-icon {
  display: inline-grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 16px;
}
.hero-icon .icon { width: 24px; height: 24px; }

.wish-list { list-style: none; margin: 0; padding: 0; }
.wish {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.wish:first-child { padding-top: 4px; }
.wish:last-child { border-bottom: 0; padding-bottom: 0; }
.wish-main { min-width: 0; }
.wish-title { display: block; font-weight: 550; overflow-wrap: anywhere; }
.wish-notes { display: block; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }

.empty {
  padding: 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

.mini-list { list-style: none; margin: 0 0 16px; padding: 0; font-size: 14px; }
.mini-list li { padding: 8px 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.mini-list li:first-child { padding-top: 0; }
.panel-body > .muted + .btn { margin-top: 4px; }

.status-line { display: flex; align-items: center; gap: 8px; font-weight: 550; margin: 8px 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #c3cbc6; }
.dot-on { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: 550 14px/1.2 var(--font);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: #f4f6f4; color: var(--text); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #eef1ef; color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); color: #fff; }
.btn-danger-text { color: var(--danger); }
.btn-danger-text:hover { background: #fbeeee; color: var(--danger-hover); }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-block { width: 100%; }

/* ==========================================================================
   Forms
   ========================================================================== */

.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 14px; font-weight: 550; }
.optional { margin-left: 6px; font-size: 12px; font-weight: 400; color: var(--subtle); }

input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: 15px/1.4 var(--font);
  transition: border-color 0.12s, box-shadow 0.12s;
}
input::placeholder, textarea::placeholder { color: var(--subtle); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
textarea { resize: vertical; min-height: 80px; }
input.pin { font-size: 20px; letter-spacing: 0.5em; text-align: center; padding-left: 0.5em; }

.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--danger); }

.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

/* ==========================================================================
   Alerts & badges
   ========================================================================== */

.alert { padding: 12px 16px; border: 1px solid; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 20px; }
.alert-error { background: #fdf1f1; border-color: #f2cdcf; color: #8d1d24; }
.alert-success { background: #edf6f1; border-color: #c7e2d3; color: var(--accent); }
.form > .alert, .panel-body > .alert { margin-bottom: 16px; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  background: #eef0ee;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-on { background: var(--accent-soft); color: var(--accent); }
.badge-warn { background: #fdf3e2; color: #8a5800; }

.tag {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  vertical-align: 1px;
}

/* ==========================================================================
   Avatars
   ========================================================================== */

.avatar {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 650;
  flex-shrink: 0;
}
.avatar.sm { width: 26px; height: 26px; font-size: 12px; }
.avatar.lg { width: 52px; height: 52px; font-size: 22px; }
.tone-0 { background: #e3efe8; color: #1f5c45; }
.tone-1 { background: #f6e4e3; color: #9b2a2f; }
.tone-2 { background: #e5eaf6; color: #2e4a8b; }
.tone-3 { background: #f5edd9; color: #835f12; }
.tone-4 { background: #ede5f4; color: #64398a; }
.tone-5 { background: #e1eff1; color: #1d6570; }
.tone-6 { background: #f4e7dc; color: #8a4a1d; }

/* ==========================================================================
   Tables
   ========================================================================== */

.table-panel { overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  padding: 10px 16px;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
  white-space: nowrap;
}
td { padding: 13px 16px; vertical-align: top; overflow-wrap: break-word; }

.wishlists td { border-bottom: 1px solid #eff2f0; }
.wishlists tbody tr:last-child td { border-bottom: 0; }
.wishlists tbody + tbody { border-top: 1px solid var(--border); }
.wishlists th.person {
  width: 190px;
  padding: 13px 16px;
  border-right: 1px solid var(--border);
  text-align: left;
  font-weight: normal;
  vertical-align: top;
}
.wishlists tbody.mine th.person { background: #f6faf8; box-shadow: inset 3px 0 0 var(--accent); }
.wishlists tbody.mine td { background: #fcfdfc; }

.person-inner { display: flex; align-items: center; gap: 10px; }
.person-name { font-weight: 600; white-space: nowrap; }
.person-count { font-size: 12px; color: var(--subtle); }

.col-wish { font-weight: 550; width: 34%; }
.col-notes { color: var(--muted); width: 34%; }
.col-link, .col-actions { width: 1%; white-space: nowrap; }
.col-actions { text-align: right; padding-top: 8px; padding-bottom: 8px; }
.col-actions form { display: inline; margin: 0; }
td.col-link { padding-top: 13px; }
.empty-cell { color: var(--subtle); font-style: italic; }

.link-out { display: inline-flex; align-items: center; gap: 4px; font-weight: 550; text-decoration: none; }
.link-out:hover { text-decoration: underline; }

.plain td { border-top: 1px solid var(--border); vertical-align: middle; }
.plain .col-actions { padding-top: 6px; padding-bottom: 6px; }

.rules { margin: 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
.rules li { margin: 3px 0; }

/* ==========================================================================
   Sign in
   ========================================================================== */

.bare main.container { display: grid; justify-items: center; padding-top: 9vh; }
.auth { width: 100%; max-width: 400px; }
.auth-panel { padding: 32px; }
.auth-head { margin-bottom: 24px; }
.auth-head h1 { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; margin-bottom: 6px; }
.auth-head p { color: var(--muted); font-size: 14px; }
.auth-foot { margin: 20px 0 0; text-align: center; font-size: 14px; color: var(--muted); }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 960px) {
  .grid-main, .grid-side, .grid-half { grid-template-columns: minmax(0, 1fr); }
  .sticky { position: static; }
}

@media (max-width: 640px) {
  body { font-size: 15px; }
  .container { padding: 0 16px; }
  main.container { padding-top: 20px; padding-bottom: 40px; }
  .grid, .stack { gap: 16px; }

  .header-inner { flex-wrap: wrap; height: auto; gap: 4px 12px; padding: 10px 16px 0; }
  .account { margin-left: auto; }
  .account-name { display: none; }
  .nav { order: 3; width: calc(100% + 32px); margin: 0 -16px; padding: 4px 12px 8px; overflow-x: auto; }

  .page-header { margin-bottom: 16px; }
  .page-header h1 { font-size: 23px; }
  .panel-body { padding: 18px; }
  .match-hero { padding: 22px 18px 18px; }
  .match-name h2 { font-size: 32px; }
  .match-pending .match-hero { padding: 32px 18px; }
  .wish { flex-wrap: wrap; }
  .auth-panel { padding: 24px; }

  /* Wishlist table becomes a stacked list. */
  .wishlists thead { display: none; }
  .wishlists, .wishlists tbody, .wishlists tr, .wishlists th, .wishlists td { display: block; width: auto; }
  .wishlists th.person { width: auto; border-right: 0; padding: 14px 16px 6px; }
  .wishlists tbody.mine { background: #f6faf8; border-left: 3px solid var(--accent); }
  .wishlists tbody.mine th.person, .wishlists tbody.mine td { background: transparent; box-shadow: none; }
  .wishlists td { border-bottom: 0; padding: 2px 16px; }
  .wishlists tr { padding: 6px 0; }
  .wishlists tbody tr + tr { border-top: 1px solid #eff2f0; margin: 0 16px; }
  .wishlists tbody tr + tr td { padding-left: 0; padding-right: 0; }
  .wishlists tbody tr:last-child { padding-bottom: 12px; }
  .wishlists td:empty { display: none; }
  .wishlists .col-actions { text-align: left; padding-top: 4px; margin-left: -10px; }
  .wishlists .col-notes { font-size: 14px; }
  .wishlists td.empty-cell { padding-bottom: 6px; }
}
