/* Secret Santa: a warm, seasonal look with no external assets. */

:root {
  --pine: #1f4d3a;
  --pine-deep: #153829;
  --cranberry: #a8233a;
  --cranberry-deep: #861a2d;
  --gold: #c9962b;
  --gold-soft: #f6e7c1;

  --bg: #f7f2e8;
  --surface: #fffdf8;
  --surface-soft: #f1ebdd;
  --text: #1d2420;
  --text-muted: #56605a;
  --border: #ddd3bf;
  --input-border: #7d847f;
  --focus: #1d2420;

  --success-bg: #e3efe6;
  --success-text: #1b4a32;
  --error-bg: #fbe9ea;
  --error-text: #8a1c2e;
  --warn-bg: #fdf5e2;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgb(29 36 32 / 6%), 0 8px 24px rgb(29 36 32 / 6%);

  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --pine: #6fbf95;
    --pine-deep: #8fd3ad;
    --cranberry: #e0677a;
    --cranberry-deep: #ea8797;
    --gold: #e4b75a;
    --gold-soft: #3b3220;

    --bg: #121915;
    --surface: #1a231e;
    --surface-soft: #212c26;
    --text: #ece7dc;
    --text-muted: #a9b1ab;
    --border: #334039;
    --input-border: #7b857f;
    --focus: #f3d58c;

    --success-bg: #1d3327;
    --success-text: #a6dcbc;
    --error-bg: #3a1d23;
    --error-text: #f2a9b4;
    --warn-bg: #2c2618;

    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 25%);
  }
}

/* Base */

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

html {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

body { margin: 0; min-height: 100vh; background: var(--bg); }

h1, h2 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 2.1rem; line-height: 1.15; margin: 0 0 20px; }
h2 { font-size: 1.3rem; line-height: 1.3; margin: 0 0 14px; }
p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }

a { color: var(--cranberry); text-underline-offset: 3px; }
a:hover { color: var(--cranberry-deep); }

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

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

/* Frame */

.ribbon {
  height: 6px;
  background: repeating-linear-gradient(-45deg, var(--cranberry) 0 14px, var(--surface) 14px 28px, var(--pine) 28px 42px, var(--surface) 42px 56px);
}

.page { max-width: 1040px; margin: 0 auto; padding: 24px 24px 64px; }

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--pine);
  text-decoration: none;
}
.brand:hover { color: var(--pine-deep); }
.brand-mark { width: 26px; height: 26px; fill: var(--gold); }

.logout { margin: 0; }

/* Layout */

.grid { display: grid; gap: 24px; align-items: start; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.stack { display: grid; gap: 16px; }
.stack-lg { display: grid; gap: 24px; }
.narrow { max-width: 560px; margin: 0 auto; }

/* Cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  min-width: 0;
}
.card-narrow { max-width: 440px; margin: 0 auto; }
.card-soft { background: var(--surface-soft); box-shadow: none; }
.card-warn { border-top: 4px solid var(--cranberry); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.card-head h2 { margin-bottom: 8px; }

main > h1 + .card-narrow, main > .alert + .card-narrow { margin-top: 0; }
main:has(.card-narrow) > h1,
main:has(.narrow) > h1 { text-align: center; }
main:has(.narrow) > .alert { max-width: 560px; margin-left: auto; margin-right: auto; }

.lede { font-size: 1.1rem; }
.muted { color: var(--text-muted); }
.aside { margin-top: 20px; font-size: 0.95rem; color: var(--text-muted); }
.crumbs { margin: -8px 0 20px; }

/* Alerts */

.alert { border-radius: var(--radius-sm); padding: 14px 16px; margin: 0 0 24px; }
.alert h2 { font-family: var(--font-body); font-size: 1.05rem; margin: 0 0 6px; }
.alert ul { margin: 0; padding-left: 20px; }
.alert-success { background: var(--success-bg); color: var(--success-text); border-left: 4px solid var(--pine); }
.alert-error { background: var(--error-bg); color: var(--error-text); border-left: 4px solid var(--cranberry); }
.alert-error a { color: inherit; font-weight: 600; }

/* Forms */

.field { display: grid; gap: 6px; min-width: 0; }
label { font-weight: 600; }
.hint { font-size: 0.92rem; color: var(--text-muted); margin: 0; }
.field-error { font-weight: 600; color: var(--error-text); margin: 0; }
.field-invalid { border-left: 4px solid var(--cranberry); padding-left: 12px; }

input, select, button { font: inherit; max-width: 100%; }

input, select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}
input[aria-invalid="true"], select[aria-invalid="true"] { border: 2px solid var(--cranberry); }

.check { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
input.draw-confirm { width: 22px; height: 22px; min-height: 0; margin: 0; padding: 0; accent-color: var(--cranberry); }

button {
  min-height: 46px;
  padding: 10px 20px;
  border: 0;
  border-radius: 999px;
  background: var(--pine);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  justify-self: start;
}
button:hover { background: var(--pine-deep); }

.button-secondary { background: transparent; color: var(--pine); box-shadow: inset 0 0 0 2px var(--pine); }
.button-secondary:hover { background: var(--surface-soft); }
.button-danger { background: var(--cranberry); }
.button-danger:hover { background: var(--cranberry-deep); }
.button-quiet { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px var(--border); padding: 8px 16px; }
.button-quiet:hover { background: var(--surface-soft); }

@media (prefers-color-scheme: dark) {
  button, .button-danger { color: #121915; }
  .button-secondary, .button-quiet { color: var(--text); }
}

.year-switch { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.year-switch select { width: auto; }

/* Pills */

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--surface-soft);
  color: var(--text-muted);
  white-space: nowrap;
}
.pill-draft { background: var(--warn-bg); color: var(--text); box-shadow: inset 0 0 0 1px var(--gold); }
.pill-drawn { background: var(--pine); color: var(--surface); }
.pill-claimed { background: var(--success-bg); color: var(--success-text); }

/* Lists */

.year-list, .people { list-style: none; margin: 0; padding: 0; }
.year-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.year-list li:last-child { border-bottom: 0; }
.year-list a { font-family: var(--font-display); font-size: 1.2rem; font-weight: 700; }

.person {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
}
.person:last-child { border-bottom: 0; }
.person-name { font-weight: 600; flex: 1 1 auto; }
.person-edit { display: grid; gap: 8px; }
.inline-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; }

details.confirm { flex-basis: 100%; }
details.confirm summary { cursor: pointer; font-weight: 600; color: var(--cranberry); width: fit-content; }
details.confirm[open] { background: var(--error-bg); border-radius: var(--radius-sm); padding: 12px 14px; }
details.confirm[open] summary { margin-bottom: 8px; }
details.confirm p { color: var(--text); }

/* The reveal */

.reveal { text-align: center; }
.reveal .lede { font-size: 1.2rem; margin-bottom: 28px; }

.gift-tag {
  position: relative;
  max-width: 420px;
  margin: 0 auto 28px;
  padding: 44px 32px 32px;
  background: var(--gold-soft);
  color: var(--text);
  border: 2px dashed var(--gold);
  border-radius: 18px 18px 18px 18px / 18px;
  box-shadow: var(--shadow);
  animation: unwrap 900ms cubic-bezier(.2, .9, .3, 1.2) both;
}
.gift-tag::before {
  content: "";
  position: absolute;
  top: 14px;
  left: 50%;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: inset 0 0 0 2px var(--gold);
}
.gift-tag-label, .gift-tag-from {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.gift-tag-from { margin-top: 12px; letter-spacing: 0.06em; text-transform: none; font-weight: 600; }
.result-name {
  margin: 4px 0 0;
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 8vw, 3.4rem);
  font-weight: 700;
  line-height: 1.1;
  color: var(--cranberry);
  overflow-wrap: anywhere;
}

@keyframes unwrap {
  0% { opacity: 0; transform: translateY(16px) scale(.85) rotate(-4deg); }
  60% { opacity: 1; }
  100% { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .gift-tag { animation: none; }
}

/* Small screens */

@media (max-width: 639px) {
  .page { padding: 16px 16px 48px; }
  .header { margin-bottom: 24px; }
  h1 { font-size: 1.7rem; }
  .card { padding: 18px; }
  .grid-2, .grid-main { grid-template-columns: minmax(0, 1fr); }
  .stack > button, .card > form > button { width: 100%; }
  .gift-tag { padding: 40px 20px 24px; }
}
