/* Yrjölöiden Secret Santa: shared design system (site + organizer page).
   "Korvatunturin posti": cream paper on a Lapland night, ink type, handwriting for what people write. */

:root {
  color-scheme: dark;

  /* night (outside the paper) */
  --night-0: #02050f;
  --night-1: #060f2b;
  --night-2: #0b1d4a;
  --night-3: #15306a;
  --on-night: #f4ecdc;
  --on-night-dim: rgba(244, 236, 220, 0.72);

  /* paper and ink */
  --paper: #f5eddc;
  --paper-2: #ece1c9;
  --paper-3: #dccdae;
  --ink: #2a2019;
  --ink-soft: #66543f;
  --ink-faint: #998771;
  --ink-red: #b02a1f;
  --ink-red-dark: #7a1a12;
  --ink-green: #21543a;
  --ink-blue: #1c3d73;
  --highlight: rgba(255, 220, 90, 0.42);

  /* legacy names, kept so older markup still resolves */
  --gold: #e8b730;
  --gold-light: var(--on-night);
  --gold-deep: #9a7414;
  --red: var(--ink-red);
  --red-deep: var(--ink-red-dark);
  --spruce: var(--ink-green);
  --spruce-light: #2f7350;
  --snow: var(--on-night);
  --text: var(--on-night);
  --text-dim: var(--on-night-dim);
  --text-faint: rgba(244, 236, 220, 0.5);
  --field-bg: transparent;
  --field-border: var(--ink-soft);
  --glass-border: rgba(42, 32, 25, 0.18);

  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .33 0 0 0 0 .25 0 0 0 0 .15 0 0 0 .11 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");

  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-body: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-hand: "Caveat", "Bradley Hand", "Segoe Print", cursive;
  --font-type: "Courier Prime", "Courier New", ui-monospace, monospace;
  /* effects still use these */
  --font-script: "Great Vibes", cursive;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --paper-shadow: 0 1px 1px rgba(0, 0, 0, 0.3), 0 16px 36px -10px rgba(0, 0, 0, 0.7);
}

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

html {
  -webkit-text-size-adjust: 100%;
  background: var(--night-0);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--night-0);
  color: var(--text);
  font: 17px/1.55 var(--font-body);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px dashed currentColor;
  outline-offset: 3px;
}

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

/* ---------- Layout ---------- */

.page {
  position: relative;
  z-index: 10;
  width: min(660px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px calc(120px + env(safe-area-inset-bottom));
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.row.center {
  justify-content: center;
}

.row.between {
  justify-content: space-between;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 420px) {
  .grid2 {
    grid-template-columns: 1fr;
  }
}

/* ---------- Typography ---------- */

/* Masthead: big serif, with "Secret Santa" written over it by hand. */
.title {
  margin: 0;
  line-height: 0.9;
  color: var(--on-night);
}

.title .t1 {
  display: block;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(46px, 12vw, 86px);
  letter-spacing: -0.035em;
  font-variation-settings: "opsz" 144;
}

.title .t2 {
  display: inline-block;
  margin: -0.12em 0 0 0.9em;
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: clamp(38px, 9.5vw, 64px);
  line-height: 1;
  color: #ff8a72;
  transform: rotate(-4deg);
}

h2,
.h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 750;
  font-size: clamp(23px, 5.4vw, 29px);
  line-height: 1.15;
  letter-spacing: -0.015em;
  font-variation-settings: "opsz" 72;
  color: var(--text);
}

h3,
.h3 {
  margin: 0;
  font-family: var(--font-type);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.kicker,
.label {
  font-family: var(--font-type);
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hand {
  font-family: var(--font-hand);
}

.script {
  font-family: var(--font-hand);
}

.muted {
  color: var(--text-dim);
}

.faint {
  color: var(--text-faint);
  font-size: 15px;
}

.center {
  text-align: center;
}

p {
  margin: 0;
}

/* ---------- Paper ---------- */

.card {
  --text: var(--ink);
  --text-dim: var(--ink-soft);
  --text-faint: var(--ink-faint);
  --gold-light: var(--ink-red);
  --snow: var(--ink);
  position: relative;
  padding: 26px 24px 24px;
  border-radius: 3px;
  background: var(--grain), linear-gradient(176deg, var(--paper) 0%, var(--paper-2) 100%);
  color: var(--text);
  box-shadow: var(--paper-shadow);
}

.card.strong {
  background: var(--grain), linear-gradient(176deg, #fbf6ea, var(--paper));
}

/* A strip of tape holding the paper up. */
.card.taped::before {
  content: "";
  position: absolute;
  top: -13px;
  left: calc(50% - 58px);
  width: 116px;
  height: 28px;
  background: rgba(236, 226, 196, 0.62);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transform: rotate(-2.5deg);
  backdrop-filter: blur(0.5px);
}

@media (max-width: 420px) {
  .card {
    padding: 22px 16px 20px;
  }
}

.divider {
  height: 0;
  border: 0;
  border-top: 1.5px dashed rgba(42, 32, 25, 0.28);
  margin: 6px 0;
}

/* ---------- Buttons: flat ink with a hard printed shadow ---------- */

.btn {
  --bg: var(--ink-red);
  --fg: #fff6e8;
  --edge: var(--ink);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 22px;
  border: 1.5px solid var(--edge);
  border-radius: 5px;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-type);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--edge);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--edge);
}

.btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--edge);
}

.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: 3px 3px 0 var(--edge);
}

.btn.gold {
  --bg: var(--ink-red);
}

.btn.green {
  --bg: var(--ink-green);
}

.btn.ghost {
  --bg: transparent;
  --fg: var(--ink);
}

/* Buttons sitting directly on the night sky */
.on-night .btn.ghost,
.btn.ghost.on-night {
  --fg: var(--on-night);
  --edge: var(--on-night);
}

.btn.small {
  min-height: 38px;
  padding: 7px 14px;
  font-size: 13px;
}

.btn.block {
  width: 100%;
}

.linkbtn {
  border: 0;
  background: none;
  padding: 6px 2px;
  color: inherit;
  font-family: var(--font-type);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
}

/* ---------- Forms: write on the paper ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field > span,
.field > label,
.field > small,
fieldset.field > legend {
  font-family: var(--font-type);
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.field .hint {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 14px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-faint);
}

.input,
.select {
  width: 100%;
  min-height: 46px;
  padding: 4px 2px 2px;
  border: 0;
  border-bottom: 1.5px solid var(--field-border);
  border-radius: 0;
  background: transparent;
  color: var(--ink-blue);
  font-family: var(--font-hand);
  font-weight: 500;
  font-size: 27px;
  line-height: 1.2;
  transition: background-color 0.2s, border-color 0.2s;
}

.textarea {
  width: 100%;
  min-height: 136px;
  padding: 1px 4px 0 32px;
  border: 0;
  border-radius: 0;
  resize: vertical;
  color: var(--ink-blue);
  font-family: var(--font-hand);
  font-weight: 500;
  font-size: 25px;
  line-height: 34px;
  /* margin line + ruled lines, scrolling with the text */
  background:
    linear-gradient(90deg, transparent 22px, rgba(176, 42, 31, 0.4) 22px 23.5px, transparent 23.5px),
    repeating-linear-gradient(transparent 0 33px, rgba(28, 61, 115, 0.2) 33px 34px);
  background-attachment: local;
}

.select {
  appearance: none;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%), linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position: calc(100% - 16px) 22px, calc(100% - 10px) 22px;
  background-size: 6px 6px;
  background-repeat: no-repeat;
}

.select option {
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--ink);
  background: var(--paper);
}

.input::placeholder,
.textarea::placeholder {
  color: rgba(42, 32, 25, 0.32);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  background-color: var(--highlight);
  border-color: var(--ink);
}

.error {
  font-family: var(--font-type);
  font-weight: 700;
  font-size: 14px;
  color: var(--ink-red);
}

.error:empty {
  display: none;
}

/* 4-digit PIN: little stamped squares */
.pin {
  display: flex;
  gap: 10px;
  justify-content: flex-start;
}

.pin input {
  width: 52px;
  height: 60px;
  border: 1.5px solid var(--ink);
  border-radius: 4px;
  background: #fffaf0;
  text-align: center;
  font-family: var(--font-type);
  font-weight: 700;
  font-size: 28px;
  color: var(--ink);
  caret-color: var(--ink-red);
  box-shadow: 2px 2px 0 rgba(42, 32, 25, 0.85);
}

.pin input:focus {
  outline: none;
  background: #fff3c4;
}

.pin.shake {
  animation: shake 0.45s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(9px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}

/* ---------- Tags, badges, tables ---------- */

/* Name tag: a paper tag with a punched hole. */
.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 1px 14px 0 26px;
  min-height: 38px;
  background: #fffaf0;
  color: var(--ink);
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: 23px;
  line-height: 1.1;
  clip-path: polygon(12px 0, 100% 0, 100% 100%, 12px 100%, 0 50%);
  filter: drop-shadow(0 1px 0 rgba(42, 32, 25, 0.35));
}

.chip::before {
  content: "";
  position: absolute;
  left: 9px;
  top: calc(50% - 4px);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--paper-3);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.35);
}

button.chip {
  border: 0;
  cursor: pointer;
  transition: transform 0.15s var(--ease-spring), background 0.15s;
}

button.chip:hover {
  transform: rotate(-2deg) translateY(-1px);
}

button.chip[aria-pressed="true"] {
  background: #fff1b8;
  color: var(--ink-red-dark);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 3px;
  background: var(--ink-red);
  color: #fff6e8;
  font-family: var(--font-type);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.badge.ok {
  background: var(--ink-green);
}

.badge.dim {
  background: rgba(42, 32, 25, 0.16);
  color: var(--ink);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
}

.table th,
.table td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px dashed rgba(42, 32, 25, 0.25);
  vertical-align: middle;
}

.table th {
  font-family: var(--font-type);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-bottom: 1.5px solid var(--ink);
}

/* ---------- Toast: a paper slip ---------- */

.toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: min(92vw, 440px);
}

.toast {
  padding: 11px 16px;
  border-radius: 2px;
  background: var(--grain), var(--paper);
  color: var(--ink);
  border-left: 5px solid var(--ink-green);
  box-shadow: var(--paper-shadow);
  font-family: var(--font-type);
  font-weight: 700;
  font-size: 15px;
  text-align: left;
  transform: rotate(-0.6deg);
  animation: toast-in 0.35s var(--ease-spring);
}

.toast.err {
  border-left-color: var(--ink-red);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(14px) rotate(-3deg); }
  to { opacity: 1; transform: rotate(-0.6deg); }
}

/* ---------- Entrance ---------- */

.rise {
  animation: rise 0.6s var(--ease-out) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
