/* Secret Santa, "Latvian knit" design.
   One stylesheet for every page. Colours and sizes live in the variables below,
   so changing the look means editing one place. Mobile first: the base rules are
   for phones, and @media (min-width: ...) blocks add the wider layouts. */

:root {
  --snow: #F3F5F2;        /* page background */
  --red: #B0282E;
  --pine: #1E4D3A;
  --ink: #1C2420;         /* text and outlines */
  --mute: #5E6B64;        /* secondary text */

  /* Quiet tints of ink for borders and fills, so we stay inside the palette */
  --line: rgba(28, 36, 32, .16);
  --wash: rgba(30, 77, 58, .07);

  --radius: 14px;
  --font: 'Bricolage Grotesque', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

/* Anything with the "hidden" attribute stays hidden, even if a rule below gives it a display */
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--snow);
  color: var(--ink);
  font: 400 17px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  color: var(--pine);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 0 0 .5em;
}
h1 { font-size: clamp(2.1rem, 7vw, 3.6rem); }
h2 { font-size: 1.4rem; line-height: 1.2; }
p { margin: 0 0 1em; }
a { color: var(--pine); font-weight: 700; text-underline-offset: 3px; }
a:hover { color: var(--red); }
small, .muted { color: var(--mute); }
strong { font-weight: 700; }

/* Keyboard users always see where they are */
:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
  border-radius: 6px;
}

/* Hidden on screen but still read out by screen readers */
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- The knitted bands ---------- */
.knit-band {
  display: block;
  width: 100%;
  color: var(--red);         /* the stitches use currentColor */
  flex: none;
}
.knit-band-top { height: 49px; }
.knit-band-bottom { height: 14px; }

/* ---------- Footer ---------- */
.site-footer .inner {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 20px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 24px;
  color: var(--mute);
  font-size: .9rem;
}
.site-footer p { margin: 0; }
.footer-name { font-weight: 700; color: var(--pine); }
.footer-name span { font-weight: 400; color: var(--mute); }
.footer-links { display: flex; gap: 18px; }
.footer-links a { color: var(--mute); font-weight: 400; }
.footer-links a:hover { color: var(--red); }
.shoutout { width: 100%; font-style: italic; }

/* ---------- Header ---------- */
.site-header .inner,
main {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding-left: 20px;
  padding-right: 20px;
}
.site-header .inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 18px;
  padding-bottom: 18px;
}
.logo { display: inline-flex; line-height: 0; }
.logo img { height: 30px; width: auto; }
.user-menu { display: flex; align-items: center; gap: 14px; font-size: .95rem; color: var(--mute); }
.user-menu form { margin: 0; }
.user-email { display: none; }      /* shown from tablet width up */

main { flex: 1; padding-top: 20px; padding-bottom: 24px; }
.narrow { max-width: 640px; }
main.auth { max-width: 520px; }

/* ---------- Buttons ---------- */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;                /* easy to tap */
  padding: 12px 24px;
  border: 2px solid var(--red);
  border-radius: var(--radius);
  background: var(--red);
  color: var(--snow);
  font: 700 1rem/1.2 var(--font);
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
}
button:hover, .btn:hover { background: #93202A; border-color: #93202A; color: var(--snow); }
button:disabled { opacity: .55; cursor: default; }

.btn-secondary, button.btn-secondary {
  background: transparent;
  border-color: var(--ink);
  color: var(--ink);
}
.btn-secondary:hover, button.btn-secondary:hover { background: var(--ink); border-color: var(--ink); color: var(--snow); }

.btn-pine, button.btn-pine { background: var(--pine); border-color: var(--pine); }
.btn-pine:hover, button.btn-pine:hover { background: #163A2B; border-color: #163A2B; }

/* Small text-style button, e.g. "Log out" */
.btn-text, button.btn-text {
  min-height: 0;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn-text:hover, button.btn-text:hover { background: none; color: var(--red); }

/* Cautious action: quiet outline, never shouts */
.btn-caution, button.btn-caution {
  background: transparent;
  border: 2px dashed var(--mute);
  color: var(--mute);
}
.btn-caution:hover, button.btn-caution:hover { background: transparent; border-color: var(--red); color: var(--red); }

.btn-block { width: 100%; }

/* ---------- Chips: small facts like budget, date, number of people ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 24px; padding: 0; list-style: none; }
.chip {
  display: inline-block;
  border: 2px solid var(--pine);
  border-radius: 999px;
  padding: 5px 16px;
  color: var(--pine);
  font-weight: 700;
  font-size: .95rem;
  white-space: nowrap;
}

/* ---------- Panels and lists ---------- */
.panel {
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
}
.panel > :last-child { margin-bottom: 0; }
.section { margin-top: 40px; }

.eyebrow { color: var(--mute); font-size: 1rem; margin-bottom: .4em; }

.draw-message {
  border-left: 3px solid var(--pine);
  padding-left: 14px;
  color: var(--mute);
  margin-bottom: 24px;
}
.draw-message p:last-child { margin-bottom: 0; }

.draw-list { list-style: none; padding: 0; margin: 0; }
.draw-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-top: 2px solid var(--line);
}
.draw-list li:first-child { border-top: 0; padding-top: 0; }
.draw-list li:last-child { padding-bottom: 0; }
.draw-list a { text-decoration: none; font-size: 1.05rem; }
.draw-list a:hover { text-decoration: underline; }

/* ---------- Flash messages ---------- */
.messages { list-style: none; padding: 0; margin: 0 0 24px; }
.messages li {
  border: 2px solid var(--pine);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 8px;
  color: var(--pine);
  font-weight: 700;
}
.messages li.error { border-color: var(--red); color: var(--red); }

/* ---------- Forms ---------- */
label { display: block; font-weight: 700; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], textarea, select {
  width: 100%;
  min-height: 50px;
  font: 400 1rem/1.4 var(--font);
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  transition: border-color .15s;
}
input:hover, textarea:hover { border-color: rgba(28, 36, 32, .35); }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--pine);
  box-shadow: 0 0 0 3px rgba(30, 77, 58, .2);
}
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--pine); vertical-align: middle; margin: 0 8px 0 0; }

.field { margin-bottom: 22px; }
.field textarea { resize: none; overflow: hidden; }   /* grows with its text (see create_draw.html) */
legend.label { display: block; font-weight: 700; margin-bottom: 8px; padding: 0; }

/* Budget: a three-way switch, then currency and amount boxes side by side */
.segmented { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.segment { margin: 0; cursor: pointer; font-weight: 400; }
.segment input { position: absolute; opacity: 0; pointer-events: none; }
.segment span {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 18px;
  border: 2px solid var(--pine);
  border-radius: 999px;
  color: var(--pine);
  font-weight: 700;
}
.segment:hover span { background: var(--wash); }
.segment input:checked + span { background: var(--pine); color: var(--snow); }
.segment input:focus-visible + span { outline: 3px solid var(--ink); outline-offset: 3px; }
.budget-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.budget-currency { flex: 0 0 120px; }
.budget-amount { flex: 1 1 110px; }
.budget-row label { font-weight: 400; color: var(--mute); font-size: .9rem; }
select {
  appearance: none;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%231C2420' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 14px center / 12px;
  padding-right: 36px;
}
.field small, .helptext { display: block; margin-top: 6px; color: var(--mute); font-size: .9rem; }

/* Errors: red, clear, impossible to miss */
.errorlist {
  list-style: none;
  padding: 0;
  margin: 6px 0;
  color: var(--red);
  font-weight: 700;
  font-size: .95rem;
}
.errorlist li::before { content: '! '; }
.errorlist.nonfield, .errorlist.nonform {
  border: 2px solid var(--red);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 20px;
}
[aria-invalid="true"], .field-error input, .field-error textarea { border-color: var(--red); }
.error-text { color: var(--red); font-weight: 700; }

/* allauth's pages wrap each field in a <p>; give them the same spacing and help text style */
main.auth form p { margin-bottom: 18px; }
main.auth form p > span { display: block; color: var(--mute); font-size: .9rem; margin-top: 6px; }
main.auth form p:has(input[type=checkbox]) label { display: inline-block; font-weight: 400; }
/* allauth's headings, buttons and labels come in Title Case ("Sign In", "Remember Me").
   Show them in sentence case like the rest of the site: all lowercase, then a capital first letter. */
main.auth h1, main.auth h2, main.auth label, .sentence { text-transform: lowercase; }
main.auth h1::first-letter, main.auth h2::first-letter,
main.auth label::first-letter, .sentence::first-letter { text-transform: uppercase; }
.sentence { display: inline-block; }
main.auth form button[type=submit] { width: 100%; }
main.auth ul { padding-left: 0; list-style: none; }
main.auth hr { border: 0; border-top: 2px solid var(--line); margin: 24px 0; }

/* ---------- Home: two clear choices ---------- */
.intro { max-width: 640px; margin-bottom: 32px; }
.intro p { color: var(--mute); font-size: 1.15rem; }

.choices { display: grid; gap: 20px; }
.choice {
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
}
.choice p { color: var(--mute); }
.choice .push { margin-top: auto; }
.join-row { display: flex; gap: 10px; flex-wrap: wrap; }
.join-row .code-input { flex: 1 1 160px; }
.code-input {
  text-transform: uppercase;
  letter-spacing: .25em;
  font-size: 1.3rem;
  font-weight: 700;
  text-align: center;
}
.code-input::placeholder { letter-spacing: .25em; color: rgba(94, 107, 100, .5); }

.lists { display: grid; gap: 20px; margin-top: 40px; }

/* ---------- Organizer page ---------- */
.share-code {
  display: inline-block;
  font-weight: 800;
  font-size: 2.2rem;
  letter-spacing: .2em;
  color: var(--pine);
  border: 2px solid var(--pine);
  border-radius: var(--radius);
  padding: 4px 6px 4px 18px;      /* letter-spacing adds space on the right only */
  margin-bottom: 16px;
}
.invite-link { display: flex; gap: 8px; margin-bottom: 14px; }
.invite-link input { flex: 1; min-width: 0; font-size: .95rem; color: var(--mute); }
.invite-link button { flex: none; }
.share-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.progress {
  height: 10px;
  border: 2px solid var(--pine);
  border-radius: 999px;
  overflow: hidden;
  margin: 4px 0 18px;
}
.progress > span { display: block; height: 100%; background: var(--pine); }

/* Participants with a clear status marker each */
.people { list-style: none; padding: 0; margin: 0; }
.people li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 2px solid var(--line);
}
.people li:first-child { border-top: 0; }
.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: .9rem;
  font-weight: 700;
  white-space: nowrap;
}
.status::before {
  content: '';
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid currentColor;
  flex: none;
}
.status-done { color: var(--pine); }
.status-done::before { background: currentColor; }
.status-joined { color: var(--pine); }
.status-waiting { color: var(--mute); }
.status-waiting::before { border-style: dashed; }

.caution { border-style: dashed; }
.caution h2 { color: var(--ink); }

/* ---------- Join: names as large tappable options ---------- */
.name-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}
.name-option { margin: 0; cursor: pointer; }
.name-option input { position: absolute; opacity: 0; pointer-events: none; }
.name-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60px;
  padding: 10px 12px;
  text-align: center;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  transition: background-color .12s, color .12s;
}
.name-option:hover span { background: var(--wash); }
.name-option input:checked + span { background: var(--pine); border-color: var(--pine); color: var(--snow); }
.name-option input:focus-visible + span { outline: 3px solid var(--ink); outline-offset: 3px; }

.note {
  border-left: 3px solid var(--pine);
  padding: 2px 0 2px 14px;
  color: var(--mute);
  font-size: .95rem;
}

/* ---------- Spin page ---------- */
/* Phones: wheel first, then the details. Wider screens: details left, wheel right. */
.spin-layout { display: grid; gap: 28px; align-items: center; }
.spin-wheel { order: 0; }
.spin-details { order: 1; }

.wheel-wrap {
  position: relative;
  width: 100%;
  max-width: 540px;
  margin: 14px auto 0;
}
.wheel-wrap canvas { display: block; width: 100%; height: auto; }
/* A solid ink triangle at the top, pointing into the wheel */
.pointer {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 17px solid transparent;
  border-right: 17px solid transparent;
  border-top: 34px solid var(--ink);
  z-index: 1;
  transform-origin: 50% 0;
}
.pointer.tick { animation: pointer-tick .14s ease-out; }
@keyframes pointer-tick {
  0%   { transform: translateX(-50%) rotate(0); }
  40%  { transform: translateX(-50%) rotate(-12deg); }
  100% { transform: translateX(-50%) rotate(0); }
}

.spin-action { margin-top: 8px; }
.spin-action button { min-width: 220px; font-size: 1.1rem; }

.result-card {
  display: inline-block;
  min-width: min(100%, 320px);
  max-width: 100%;
  background: var(--red);
  color: var(--snow);
  border-radius: var(--radius);
  padding: 22px 30px 24px;
  margin: 0;
}
.result-card .label { display: block; font-size: 1.05rem; }
.result-card .name {
  display: block;
  font-weight: 800;
  font-size: clamp(2.4rem, 8vw, 3.4rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}
/* One short reveal when the result appears after a spin */
.result-card.reveal { animation: result-reveal .55s cubic-bezier(.2, .9, .3, 1); }
@keyframes result-reveal {
  from { clip-path: inset(0 100% 0 0 round var(--radius)); transform: translateY(6px); }
  to   { clip-path: inset(0 0 0 0 round var(--radius)); transform: translateY(0); }
}

/* ---------- Reveal page ---------- */
.notice {
  border: 2px solid var(--red);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--red);
  font-weight: 700;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 8px; border-bottom: 2px solid var(--line); }
th { font-size: .85rem; color: var(--mute); font-weight: 700; }
td.arrow { color: var(--red); width: 1%; font-weight: 800; }

/* ---------- "Continue with Google" button ---------- */
.or-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--mute);
  font-size: .9rem;
  margin: 24px 0 16px;
}
.or-divider::before, .or-divider::after { content: ''; flex: 1; border-top: 2px solid var(--line); }
.provider-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 50px;
  padding: 11px 16px;
  background: #fff;
  color: #1f1f1f;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  font-weight: 700;
  text-decoration: none;
}
.provider-btn:hover { color: #1f1f1f; background: var(--wash); }
.provider-icon { width: 20px; height: 20px; flex: none; }

/* ---------- Calendar (flatpickr), themed to match ---------- */
input.date-picker {
  cursor: pointer;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231E4D3A' stroke-width='2' stroke-linecap='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='3'/%3E%3Cpath d='M3 10h18M8 3v4M16 3v4'/%3E%3C/svg%3E") no-repeat right 14px center / 20px;
  padding-right: 44px;
}
.date-clear { margin-top: 6px; }
.flatpickr-calendar {
  font-family: var(--font);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 12px 30px rgba(28, 36, 32, .18);
  padding: 6px;
  width: auto;
}
.flatpickr-calendar::before, .flatpickr-calendar::after { display: none; }
.flatpickr-months .flatpickr-month { height: 44px; color: var(--pine); }
.flatpickr-current-month { font-size: 1.1rem; font-weight: 800; padding-top: 8px; }
.flatpickr-current-month .flatpickr-monthDropdown-months { font-weight: 800; }
.flatpickr-months .flatpickr-prev-month, .flatpickr-months .flatpickr-next-month { padding: 14px; }
.flatpickr-months .flatpickr-prev-month:hover svg,
.flatpickr-months .flatpickr-next-month:hover svg { fill: var(--red); }
span.flatpickr-weekday { color: var(--mute); font-weight: 700; font-size: .75rem; }
.flatpickr-day { border-radius: 10px; color: var(--ink); }
.flatpickr-day:hover, .flatpickr-day:focus { background: var(--wash); border-color: transparent; }
.flatpickr-day.today { border-color: var(--pine); }
.flatpickr-day.today:hover { background: var(--wash); border-color: var(--pine); color: var(--ink); }
.flatpickr-day.selected, .flatpickr-day.selected:hover, .flatpickr-day.selected:focus {
  background: var(--red); border-color: var(--red); color: var(--snow);
}
.flatpickr-day.flatpickr-disabled, .flatpickr-day.prevMonthDay, .flatpickr-day.nextMonthDay {
  color: rgba(28, 36, 32, .28);
}
.flatpickr-day.festive { position: relative; }
.flatpickr-day.festive::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  width: 5px;
  height: 5px;
  margin-left: -2.5px;
  border-radius: 50%;
  background: var(--red);
}

/* ---------- The running Santa (after a spin) ---------- */
.santa-run {
  position: fixed;
  bottom: 8vh;
  left: 0;
  width: 110px;
  z-index: 50;
  pointer-events: none;     /* never blocks clicks */
  animation: santa-across 2.6s linear forwards;
}
.santa-run .bob { animation: santa-bob .3s ease-in-out infinite alternate; }
.santa-run .leg { transform-box: fill-box; transform-origin: top center; }
.santa-run .leg-a { animation: santa-step .3s ease-in-out infinite alternate; }
.santa-run .leg-b { animation: santa-step .3s ease-in-out infinite alternate-reverse; }
@keyframes santa-across {
  from { transform: translateX(-140px); }
  to   { transform: translateX(calc(100vw + 20px)); }
}
@keyframes santa-bob { from { transform: translateY(0); } to { transform: translateY(-6px); } }
@keyframes santa-step { from { transform: rotate(-30deg); } to { transform: rotate(30deg); } }

/* People who've asked their system for less motion get no animations */
@media (prefers-reduced-motion: reduce) {
  .santa-run { display: none; }
  .result-card.reveal, .pointer.tick { animation: none; }
  * { transition: none !important; }
}

/* ---------- Wider screens ---------- */
@media (min-width: 640px) {
  .knit-band-top { height: 77px; }
  .knit-band-bottom { height: 21px; }
  .site-footer .inner { padding: 56px 40px 24px; }
  .logo img { height: 36px; }
  .site-header .inner, main { padding-left: 40px; padding-right: 40px; }
  .site-header .inner { padding-top: 26px; padding-bottom: 26px; }
  .user-email { display: inline; }
  main { padding-top: 32px; }
  .choices, .lists { grid-template-columns: 1fr 1fr; }
  .panel { padding: 28px; }
}

@media (min-width: 900px) {
  .spin-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 56px; }
  .spin-details { order: 0; }
  .spin-wheel { order: 1; }
  .wheel-wrap { margin-top: 0; }
}

/* ---------- Small helpers ---------- */
.mt { margin-top: 16px; margin-bottom: 0; }
.tight { margin-bottom: 4px; }
fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.plain legend { padding: 0; }

/* Budget line in the red result card, and the "we emailed you" note under it */
.result-card .budget { display: block; margin-top: 8px; font-size: 1.05rem; font-weight: 700; }
.email-note { margin-top: 14px; max-width: 420px; color: var(--mute); font-size: .95rem; }

/* ---------- Long text pages (privacy policy, terms) ---------- */
.prose h2 { margin-top: 1.8em; }
.prose ul { padding-left: 1.2em; margin: 0 0 1em; }
.prose li { margin-bottom: .5em; }
.prose a { font-weight: 400; }
fieldset.plain.budget { margin-bottom: 22px; }
