:root {
  --pine: #173A2E;
  --cranberry: #B3263E;
  --cranberry-dark: #961F34;
  --squash: #E0A43A;
  --wool: #F3EEE4;
  --cocoa: #3B2418;
  --sage: #8FA98A;
  --field: #FFFDF8;

  --display: "Caprasimo", "Cooper Black", Georgia, serif;
  --body: "Atkinson Hyperlegible", Verdana, system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }
body {
  background: var(--pine);
  color: var(--wool);
  font-family: var(--body);
  font-size: 1.0625rem;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2 {
  font-family: var(--display);
  font-weight: 400;
  line-height: 1.08;
  margin: 0;
}

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

.knit { display: block; width: 100%; }

/* ---------- Buttons and fields ---------- */

.btn {
  appearance: none;
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--cranberry);
  color: var(--wool);
  font: inherit;
  font-weight: 700;
  min-height: 48px;
  padding: 0.7em 1.4em;
  cursor: pointer;
}
.btn:hover { background: var(--cranberry-dark); }
.btn:disabled { opacity: 0.6; cursor: progress; }

.btn--quiet {
  background: transparent;
  border-color: currentColor;
  color: var(--cocoa);
}
.btn--quiet:hover { background: rgb(59 36 24 / 0.08); }

.btn--small {
  min-height: 40px;
  padding: 0.35em 0.95em;
  font-size: 0.95rem;
}

.field {
  width: 100%;
  font: inherit;
  color: var(--cocoa);
  background: var(--field);
  border: 2px solid rgb(59 36 24 / 0.35);
  border-radius: 10px;
  padding: 0.65em 0.8em;
}
.field:focus { border-color: var(--cocoa); }
textarea.field { resize: vertical; min-height: 6.5em; }

.error {
  margin: 0;
  min-height: 1.4em;
  color: var(--cranberry);
  font-weight: 700;
}

/* ---------- Note patch ---------- */

figure { margin: 0; }

.patch {
  position: relative;
  background: var(--wool);
  color: var(--cocoa);
  border-radius: 16px;
  padding: 1.1em 1.25em 1em;
  transform: rotate(var(--tilt, 0deg));
}
/* The dashed line looks like stitching around a sewn-on patch. */
.patch::after {
  content: "";
  position: absolute;
  inset: 7px;
  border: 2px dashed rgb(59 36 24 / 0.4);
  border-radius: 10px;
  pointer-events: none;
}
.patch--sage { background: var(--sage); }
.patch--sage::after { border-color: rgb(59 36 24 / 0.5); }

.patch blockquote { margin: 0; overflow-wrap: anywhere; }
.patch figcaption { margin-top: 0.6em; font-weight: 700; }
.patch figcaption::before { content: "— "; }

/* ---------- Guest page (phone) ---------- */

.guest {
  max-width: 34rem;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3rem;
}
.guest h1 {
  font-size: clamp(2.1rem, 10vw, 3.2rem);
  margin-bottom: 0.35em;
}
.lede { margin: 0 0 1.5rem; max-width: 32ch; }

.note-form {
  display: grid;
  gap: 0.35rem;
  padding: 1.5rem 1.4rem 1.3rem;
}
.note-form label { font-weight: 700; margin-top: 0.5rem; }
.note-form label:first-child { margin-top: 0; }
.optional { font-weight: 400; }
.count, .hint { margin: 0; font-size: 0.92rem; color: rgb(59 36 24 / 0.8); }
.count { text-align: right; }
.count.is-low { color: var(--cranberry); font-weight: 700; }
.note-form .btn { justify-self: start; margin-top: 1rem; }
.note-form .error { margin-top: 0.4rem; }

.done { padding: 1.75rem 1.4rem 1.5rem; }
.done h2 { font-size: 2rem; margin-bottom: 0.5rem; }
.done p { margin: 0 0 1.2rem; }

/* ---------- TV page ---------- */

.page-tv {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.tv-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2vw;
  padding: 1.6vh 3.5vw 0;
}
.tv-head h1 { font-size: clamp(2rem, 4.2vw, 5.5rem); }

.tv-qr {
  display: flex;
  align-items: center;
  gap: 0.9vw;
  flex-shrink: 0;
  background: var(--wool);
  color: var(--cocoa);
  border-radius: 14px;
  padding: 0.6vw 1.1vw 0.6vw 0.6vw;
}
.tv-qr img { display: block; width: clamp(90px, 8vw, 180px); height: auto; border-radius: 6px; }
.tv-qr p { margin: 0; max-width: 7em; font-weight: 700; font-size: clamp(0.95rem, 1.2vw, 1.6rem); line-height: 1.2; }

/* The snow globe: notes fall behind, one note sits in the spotlight in front. */
.globe {
  position: relative;
  overflow: hidden;
}
/* Soft fade where notes come in at the top and leave at the bottom. */
.globe::before, .globe::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 9%;
  z-index: 2;
  pointer-events: none;
}
.globe::before { top: 0; background: linear-gradient(var(--pine), transparent); }
.globe::after { bottom: 0; background: linear-gradient(transparent, var(--pine)); }

.snow, .flurry {
  position: absolute;
  inset: 0;
  transition: opacity 900ms ease;
}
.globe.is-spot .snow { opacity: 0.4; }

.flake {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;
}

.flurry i {
  position: absolute;
  top: -2vh;
  border-radius: 50%;
  background: var(--wool);
  animation: flurry linear infinite;
}
@keyframes flurry {
  to { transform: translate3d(var(--drift, 0), 110vh, 0); }
}

.spotlight {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 3vh 4vw;
  pointer-events: none;
}
.spotlight > * { grid-area: 1 / 1; }
.spotlight .patch {
  box-shadow: 0 1.5vw 4vw rgb(0 0 0 / 0.4);
  width: fit-content;
  max-width: min(60rem, 75vw);
  padding: 2.6vw 3.2vw 2.2vw;
  border-radius: 26px;
}
.spotlight .patch::after { inset: 12px; border-width: 3px; border-radius: 16px; }
.spotlight blockquote {
  font-family: var(--display);
  font-size: clamp(1.8rem, 3.5vw, 4.6rem);
  line-height: 1.12;
}
.spotlight figcaption { font-size: clamp(1.1rem, 1.6vw, 2.1rem); margin-top: 0.8em; }

.spotlight .tag {
  position: absolute;
  z-index: 1;
  top: -0.95em;
  left: 1.6em;
  background: var(--cranberry);
  color: var(--wool);
  font-weight: 700;
  font-size: clamp(0.95rem, 1.15vw, 1.4rem);
  padding: 0.3em 0.9em;
  border-radius: 999px;
}

.spotlight .empty {
  margin: 0;
  max-width: 22ch;
  text-align: center;
  font-family: var(--display);
  font-size: clamp(1.5rem, 2.6vw, 3.2rem);
}

/* The one motion moment: a new note drops in like a patch pressed onto a sweater. */
.patch.is-arriving { animation: arrive 900ms cubic-bezier(0.2, 1.4, 0.4, 1) both; }

@keyframes arrive {
  from { opacity: 0; transform: translateY(-7vh) rotate(calc(var(--tilt, 0deg) - 7deg)) scale(0.9); }
  to   { opacity: 1; transform: rotate(var(--tilt, 0deg)) scale(1); }
}
.status {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  margin: 0;
  background: var(--squash);
  color: var(--cocoa);
  font-weight: 700;
  padding: 0.4em 1.1em;
  border-radius: 999px;
}

/* ---------- Admin page ---------- */

.page-admin { background: var(--wool); color: var(--cocoa); }

.admin {
  max-width: 46rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}
.admin a { color: var(--pine); font-weight: 700; }

.admin-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 1.25rem;
}
.admin-head h1 { font-size: 2rem; color: var(--pine); }
.admin-links { display: flex; align-items: center; gap: 1rem; }

.login { display: grid; gap: 0.5rem; max-width: 22rem; }
.login label { font-weight: 700; }
.login .btn { justify-self: start; margin-top: 0.5rem; }

.admin-count { margin: 0 0 0.25rem; font-weight: 700; }

.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem 1rem;
  padding: 0.9rem 0;
  border-bottom: 2px dashed rgb(59 36 24 / 0.25);
}
.row-text { margin: 0; overflow-wrap: anywhere; }
.row-meta { margin: 0.15rem 0 0; font-size: 0.9rem; color: rgb(59 36 24 / 0.75); }
.row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 0.5rem; }
.row-confirm { font-weight: 700; }

.row-edit { grid-column: 1 / -1; display: grid; gap: 0.4rem; }
.row-edit label { font-weight: 700; font-size: 0.95rem; }
.row-edit .row-actions { justify-content: flex-start; margin-top: 0.4rem; }

@media (max-width: 30rem) {
  .row { grid-template-columns: 1fr; }
  .row-actions { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  .patch.is-arriving { animation: none; }
  .flurry { display: none; }
}
