/* JULLOTTNING — a warm, snowy Christmas evening. */

/* Caveat, a handwritten font for wish lists (SIL Open Font License, see
   fonts/CAVEAT-OFL.txt). Served from this site, so no font service is
   contacted. */
@font-face {
  font-family: "Caveat";
  src: url("fonts/caveat-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  --bg: #fbf6ee;
  --bg-glow: #f3e6d3;
  --surface: #fffdf9;
  --ink: #2b1d14;
  --ink-soft: #6d5a4b;
  --line: #e6d7c3;
  --red: #b3262e;
  --red-deep: #8c1b22;
  --green: #1f5e3b;
  --gold: #c8962e;
  --snow: rgba(255, 255, 255, 0.9);
  --shadow: 0 10px 30px rgba(73, 38, 14, 0.12);
  --radius: 18px;
  color-scheme: light dark;

  /* Wish lists are handwritten on a little lined note, light in both
     themes like real paper. */
  --hand: "Caveat", "Segoe Script", "Bradley Hand", cursive;
  --paper: #fffdf6;
  --paper-rule: #cfe0ee;
  --paper-margin: #e8a4a4;
  --ink-pen: #23406e;
  --line-height-hand: 2rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1b16;
    --bg-glow: #183427;
    --surface: #13261e;
    --ink: #f6efe4;
    --ink-soft: #b9c7bd;
    --line: #26453a;
    --red: #e0484f;
    --red-deep: #b3262e;
    --green: #5fbf86;
    --gold: #e9bd5b;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  background: radial-gradient(ellipse at top, var(--bg-glow), var(--bg) 60%) fixed;
  background-color: var(--bg);
  color: var(--ink);
  font: 17px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

h1, .brand, .assignment__name {
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  letter-spacing: 0.01em;
}

a { color: var(--red); }

/* --- Falling snow ------------------------------------------------------- */

.snow {
  position: fixed;
  inset: -100vh 0 0 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(3px 3px at 20px 30px, var(--snow), transparent 60%),
    radial-gradient(2px 2px at 120px 80px, var(--snow), transparent 60%),
    radial-gradient(4px 4px at 200px 150px, var(--snow), transparent 60%),
    radial-gradient(2px 2px at 290px 40px, var(--snow), transparent 60%),
    radial-gradient(3px 3px at 340px 200px, var(--snow), transparent 60%);
  background-size: 360px 240px;
  opacity: 0.55;
  animation: snowfall 22s linear infinite;
}

@media (prefers-color-scheme: light) {
  .snow { --snow: rgba(179, 38, 46, 0.25); opacity: 0.6; }
}

@keyframes snowfall {
  to { transform: translateY(100vh); }
}

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

/* --- Page frame --------------------------------------------------------- */

.site-header, .site-main, .site-footer {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px;
}

.site-header {
  padding-top: 20px;
  padding-bottom: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: baseline;
  justify-content: space-between;
}

.language-switch {
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.language-switch a {
  color: var(--ink-soft);
  text-decoration: none;
}

.language-switch a:hover { color: var(--red); }

.language-switch a[aria-current] {
  color: var(--ink);
  font-weight: 600;
}

.brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
}

.site-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-top: 12px;
  padding-bottom: 32px;
}

.site-footer {
  color: var(--ink-soft);
  font-size: 0.9rem;
  text-align: center;
  padding-bottom: 24px;
}

/* --- Building blocks ---------------------------------------------------- */

.hero {
  text-align: center;
  padding: 28px 0 8px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.4rem, 9vw, 3.6rem);
  color: var(--red);
  text-shadow: 0 2px 0 var(--bg-glow);
}

.hero__tagline {
  margin: 8px auto 0;
  max-width: 32ch;
  color: var(--ink-soft);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card h1 {
  margin: 4px 0 0;
  font-size: 1.6rem;
}

.card p { margin: 0; }

label {
  font-weight: 600;
}

label small {
  font-weight: 400;
  color: var(--ink-soft);
}

input[type="text"], input[type="number"], textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}

input:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

textarea { resize: vertical; }

.button {
  align-self: flex-start;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 18px;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.2s ease;
}

.button:hover { background: var(--bg-glow); }
.button:active { transform: translateY(1px); }

.button--primary {
  color: #fff;
  background: var(--red);
  border-color: var(--red-deep);
}

.button--primary:hover { background: var(--red-deep); }

.notice {
  color: var(--ink-soft);
}

.rules {
  color: var(--green);
  font-weight: 500;
}

.saved {
  color: var(--green);
  font-weight: 600;
}

/* --- Wish lists, handwritten ------------------------------------------ */

/* A sheet of lined paper with a red margin line. */
.wish-list,
#wish-list {
  font-family: var(--hand);
  font-size: 1.45rem;
  line-height: var(--line-height-hand);
  color: var(--ink-pen);
  background-color: var(--paper);
  background-image:
    linear-gradient(90deg, transparent 30px, var(--paper-margin) 30px,
      var(--paper-margin) 31px, transparent 31px),
    repeating-linear-gradient(transparent 0,
      transparent calc(var(--line-height-hand) - 1px),
      var(--paper-rule) calc(var(--line-height-hand) - 1px),
      var(--paper-rule) var(--line-height-hand));
  border: 1px solid #e6dccb;
  border-radius: 6px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}

/* The list your santa sees: a little note, slightly askew. */
.assignment__wishes {
  width: 100%;
  max-width: 36ch;
}

.assignment__wishes p { margin: 0 0 8px; }

.wish-list {
  list-style: none;
  margin: 0;
  padding: 0 14px 0 42px;
  text-align: left;
  transform: rotate(-1deg);
}

.wish-list li {
  position: relative;
}

.wish-list li::before {
  content: "–";
  position: absolute;
  left: -22px;
}

/* Your own list: write straight onto the same paper. */
#wish-list {
  padding: 0 12px 0 42px;
  min-height: calc(var(--line-height-hand) * 4);
  background-attachment: local;
}

#wish-list::placeholder {
  color: #8a9bb5;
}

/* --- Host tools ----------------------------------------------------------- */

/* One card, one titled group per tool, with room between them. */
.host-tools summary {
  cursor: pointer;
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: 1.25rem;
  font-weight: 700;
}

.host-tools[open] summary {
  margin-bottom: 8px;
}

.host-tool {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.host-tool h2 {
  margin: 0;
  font-size: 1.05rem;
}

/* Guest links: a table of name, link and copy button. */
.guest-links {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.guest-links th,
.guest-links td {
  padding: 6px 4px;
  text-align: left;
  vertical-align: middle;
}

.guest-links thead th {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
}

.guest-links__name { width: 28%; }

.guest-links__copy { width: 8.75rem; }

.guest-links tbody th {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guest-links tbody tr + tr th,
.guest-links tbody tr + tr td {
  border-top: 1px solid var(--line);
}

.guest-links td:last-child {
  text-align: right;
}

.guest-links .share__link {
  width: 100%;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  color: var(--ink-soft);
  padding: 6px 10px;
  border-radius: 8px;
}

.guest-links .button {
  font-size: 0.8rem;
  padding: 6px 12px;
  white-space: nowrap;
}

/* --- Your events on the front page ------------------------------------- */

.my-events h2 {
  margin: 0;
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: 1.25rem;
}

.my-events__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.my-events__list a {
  color: var(--red);
  font-weight: 600;
  text-decoration: none;
}

.my-events__list a:hover { text-decoration: underline; }

.my-events__who {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

/* --- Share link --------------------------------------------------------- */

.share__row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.share__row .share__link {
  flex: 1 1 auto;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  color: var(--ink-soft);
  padding: 6px 10px;
  border-radius: 8px;
}

.share__row .button {
  flex: none;
  font-size: 0.8rem;
  padding: 6px 12px;
}

/* --- Guest list --------------------------------------------------------- */

.roster {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* The guest list sits inside the event card, so the names are flat. */
.roster__member {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.95rem;
}

.roster__member::before {
  content: "⭐ ";
}

/* --- The big reveal ----------------------------------------------------- */

/* Once the names are drawn, the reveal gets a frame: candy cane down the
   sides and along the bottom, snow lying along the top, and a sprig of holly
   on every corner with its berries right on the corner. */
.assignment {
  --cane: 14px;
  /* holly.svg is 4:3 and its berries sit at 50% across, 44% down. */
  --holly: 104px;
  --holly-height: calc(var(--holly) * 0.75);
  --berry-x: calc(var(--holly) * 0.5);
  --berry-y: calc(var(--holly-height) * 0.44);

  position: relative;
  text-align: center;
  align-items: center;
  margin: 40px 18px 40px;
  padding: 34px 22px 28px;
  border-style: solid;
  border-color: transparent;
  border-width: 0 var(--cane) var(--cane);
  border-image: repeating-linear-gradient(
    45deg, #d42a33 0 12px, #fbf6ee 12px 24px
  ) 0 14 14;
  border-radius: 0;
}

.snowcap {
  position: absolute;
  top: -22px;
  left: calc(-1 * var(--cane));
  right: calc(-1 * var(--cane));
  height: 36px;
  /* Whole tiles only, so the snow ends the same way on the right as it
     starts on the left: sloping down under the holly, not cut off. */
  background: url("snowcap.svg") left top / 120px 36px;
  background-repeat: round no-repeat;
  /* A soft shadow keeps white snow visible on the light, creamy page. */
  filter: drop-shadow(0 1px 2px rgba(60, 90, 120, 0.35));
  pointer-events: none;
  z-index: 1;
}

/* The holly: berries centred on the corners, where the middle of each cane
   meets the snow at the top or the other cane at the bottom. */
.assignment::before,
.assignment::after {
  content: "";
  position: absolute;
  left: calc(-0.5 * var(--cane) - var(--berry-x));
  right: calc(-0.5 * var(--cane) - var(--berry-x));
  height: var(--holly-height);
  pointer-events: none;
  z-index: 2;
  background:
    url("holly.svg") left top / var(--holly) var(--holly-height) no-repeat,
    url("holly.svg") right top / var(--holly) var(--holly-height) no-repeat;
}

/* The top sprigs sit in the snow, so they have a little on them too. */
.assignment::before {
  top: calc(-1 * var(--berry-y));
  background-image: url("holly-snowy.svg"), url("holly-snowy.svg");
  /* The same soft shadow as the snow along the top. */
  filter: drop-shadow(0 1px 2px rgba(60, 90, 120, 0.35));
}

.assignment::after {
  bottom: calc(-0.5 * var(--cane) - var(--berry-y));
  transform: scaleY(-1);
}

/* Smaller sprigs on narrow phones, so they stay on screen. */
@media (max-width: 420px) {
  .assignment { --holly: 76px; }
}

.assignment__name {
  font-size: 2rem;
  font-weight: 700;
  color: var(--red);
}

.assignment__wishes {
  max-width: 40ch;
  white-space: pre-line;
}

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