/*
 * Christmas Raffle – public page, "Soft pine" direction.
 *
 * WCAG 2.2 AA contrast (computed with the WCAG relative-luminance formula):
 *   cream #f4efe6 on pine #123d30 ............ 10.56:1
 *   cream #f4efe6 on pine-deep #0c2a21 ....... 13.40:1
 *   pine #123d30 on cream #f4efe6 ............ 10.56:1
 *   pine-deep #0c2a21 on coral #ff7a59 ........ 5.98:1  (picked tiles, chips)
 *   muted #a9bdb3 on pine #123d30 ............. 6.12:1
 *   taken text #9fb4aa on #1d4a3c ............. 4.57:1
 *   coral-ink #b8401d on cream #f4efe6 ........ 4.84:1  (links in the sheet)
 *   grey #5d6b64 on cream #f4efe6 ............. 4.89:1  (secondary sheet text)
 * White text on the brand coral is only 2.57:1, so coral surfaces always
 * carry dark (pine-deep) text.
 *
 * Fonts are self-hosted (public/fonts, SIL OFL) — no requests to Google.
 */

@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("/fonts/bricolage-grotesque-latin-800-normal.woff2") format("woff2");
}
@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/dm-sans-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/dm-sans-latin-500-normal.woff2") format("woff2");
}
@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/dm-sans-latin-700-normal.woff2") format("woff2");
}

:root {
  --pine: #123d30;
  --pine-deep: #0c2a21;
  --pine-soft: #1d4a3c;
  --cream: #f4efe6;
  --cream-line: #ddd5c6;
  --coral: #ff7a59;
  --coral-ink: #b8401d;
  --ink: #0c2a21;
  --muted: #a9bdb3;
  --taken-ink: #9fb4aa;
  --grey: #5d6b64;
  --focus: #ffd24c;
  --radius: 14px;
  --radius-lg: 24px;
  --font-display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --font-body: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --shadow: 0 10px 30px rgba(4, 18, 13, 0.35);
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--cream);
  background:
    radial-gradient(120% 50% at 50% 0%, rgba(255, 255, 255, 0.07) 0%, transparent 60%),
    linear-gradient(180deg, var(--pine) 0%, var(--pine-deep) 100%) fixed;
  background-color: var(--pine-deep);
}

body.scroll-locked {
  overflow: hidden;
}

a {
  color: inherit;
  text-underline-offset: 3px;
}

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

/* Panels focused by script (so screen readers announce them) need no ring. */
[tabindex="-1"]:focus {
  outline: none;
}

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

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

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 16px calc(120px + env(safe-area-inset-bottom));
}

/* ---- Hero ---- */

.hero {
  text-align: center;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.5rem, 9vw, 4rem);
  line-height: 1;
  letter-spacing: -0.03em;
}

.lede {
  max-width: 34ch;
  margin: 14px auto 18px;
  font-size: 1.0625rem;
  color: var(--muted);
}

.logo-pill {
  margin-top: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--cream);
  color: var(--pine);
}

.logo-pill img {
  display: block;
  max-height: 56px;
  width: auto;
}

.logo-pill[hidden] {
  display: none;
}

/* ---- Steps ---- */

.steps {
  list-style: none;
  margin: 0 0 12px;
  padding: 14px;
  display: grid;
  gap: 10px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.steps li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
}

.step-num {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--coral);
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 700;
}

@media (min-width: 640px) {
  .steps {
    grid-template-columns: repeat(3, 1fr);
  }
}

.rule {
  margin: 0 0 20px;
  text-align: center;
  font-size: 0.9375rem;
  color: var(--muted);
}

.page-error {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--cream);
  color: var(--coral-ink);
  font-weight: 700;
}

.grid-loading {
  text-align: center;
  color: var(--muted);
}

/* ---- Grid ---- */

.grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

@media (min-width: 480px) {
  .grid {
    grid-template-columns: repeat(8, 1fr);
  }
}

@media (min-width: 900px) {
  .grid {
    grid-template-columns: repeat(10, 1fr);
    gap: 10px;
  }
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--cream);
  color: var(--pine);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1rem, 4.2vw, 1.25rem);
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
}

.tile:active {
  transform: translateY(0);
}

.tile .tick {
  display: none;
  position: absolute;
  top: 3px;
  right: 6px;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 700;
}

.tile--picked {
  background: var(--coral);
  color: var(--ink);
}

.tile--picked .tick {
  display: block;
}

.tile--taken {
  cursor: not-allowed;
  background: var(--pine-soft);
  color: var(--taken-ink);
  box-shadow: none;
}

.tile--taken:hover {
  transform: none;
  box-shadow: none;
}

.tile--taken .tile-num {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

.tile .taken-label {
  font-family: var(--font-body);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
  margin-top: 2px;
}

/* ---- Legend ---- */

.legend {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px;
  margin: 18px 0 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
}

.swatch--free { background: var(--cream); }
.swatch--picked { background: var(--coral); }
.swatch--taken { background: var(--pine-soft); outline: 1px solid rgba(255, 255, 255, 0.2); }

/* ---- Closed ---- */

.closed-card {
  padding: 32px 24px;
  border-radius: var(--radius-lg);
  background: var(--cream);
  color: var(--ink);
  text-align: center;
  box-shadow: var(--shadow);
}

.closed-card h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
}

.closed-card p {
  margin: 0;
  color: var(--grey);
}

/* ---- Footer ---- */

.footer {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 36px;
  font-size: 0.875rem;
  color: var(--muted);
}

/* ---- Floating pill ---- */

.pick-pill {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-height: 52px;
  max-width: calc(100% - 32px);
  padding: 8px 8px 8px 20px;
  border: 0;
  border-radius: 999px;
  background: var(--cream);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.pick-pill[hidden] {
  display: none;
}

.pick-pill-cta {
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--pine);
  color: var(--cream);
}

/* ---- Buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  padding: 12px 18px;
  border: 0;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.btn--primary {
  background: var(--pine);
  color: var(--cream);
}

.btn--primary:hover {
  background: var(--pine-deep);
}

.btn--primary:disabled,
.btn--primary[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--ghost {
  margin-top: 8px;
  background: transparent;
  color: var(--coral-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn--small {
  width: auto;
  min-height: 44px;
  padding: 8px 14px;
  background: var(--pine);
  color: var(--cream);
  font-size: 0.875rem;
}

/* ---- Sheet / dialog ---- */

.sheet {
  width: 100%;
  max-width: 100%;
  max-height: 90dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--cream);
  color: var(--ink);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.sheet::backdrop {
  background: rgba(4, 18, 13, 0.6);
}

.sheet[open] {
  animation: sheet-up 0.25s ease-out;
}

@keyframes sheet-up {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@media (min-width: 640px) {
  .sheet {
    width: min(440px, calc(100% - 32px));
    margin: auto;
    border-radius: var(--radius-lg);
  }

  .sheet[open] {
    animation-name: card-in;
  }

  @keyframes card-in {
    from { transform: scale(0.96); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
  }
}

.sheet-inner {
  position: relative;
  max-height: 90dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px 20px calc(20px + env(safe-area-inset-bottom));
}

.sheet-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(12, 42, 33, 0.08);
  color: var(--ink);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.sheet-title {
  margin: 0 48px 12px 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.625rem;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

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

.chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 44px;
  padding: 0 0 0 14px;
  border-radius: 999px;
  background: var(--coral);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.125rem;
}

.chip-remove {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.chip-remove:hover {
  background: rgba(12, 42, 33, 0.12);
}

.sheet-total {
  margin: 0 0 16px;
  color: var(--grey);
}

.sheet-total strong {
  color: var(--ink);
  font-size: 1.125rem;
}

.sheet-notice {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(18, 61, 48, 0.08);
  font-size: 0.9375rem;
}

.field {
  margin-bottom: 12px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
  font-size: 0.9375rem;
}

.field input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--cream-line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 1rem; /* 16px stops iOS zooming on focus */
}

.field input:focus-visible {
  outline: 3px solid var(--pine);
  outline-offset: 1px;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 4px 0 14px;
  font-size: 0.9375rem;
}

.checkbox-row input {
  flex: none;
  width: 24px;
  height: 24px;
  margin: 0;
  accent-color: var(--pine);
}

.checkbox-row a {
  color: var(--coral-ink);
  font-weight: 700;
}

.sheet :focus-visible {
  outline-color: var(--pine);
}

.turnstile-container:not(:empty) {
  margin-bottom: 12px;
}

.dev-note,
.wait-note {
  margin: 0 0 12px;
  font-size: 0.875rem;
  color: var(--grey);
}

.form-error {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-left: 4px solid var(--coral-ink);
  border-radius: 8px;
  background: #fff;
  color: var(--coral-ink);
  font-weight: 700;
}

/* ---- Donate step ---- */

.donate-lede {
  margin: 0 0 12px;
}

.donate-lede strong {
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.caption-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 10px 10px 10px 16px;
  border: 2px dashed var(--cream-line);
  border-radius: var(--radius);
  background: #fff;
}

.caption-box code {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.25rem;
  word-break: break-word;
}

.hold-note {
  margin: 14px 0 0;
  font-size: 0.9375rem;
  color: var(--grey);
}

/* ---- Privacy / terms pages ---- */

.legal-page {
  background: var(--cream);
  color: var(--ink);
}

.legal-page header,
.legal-page main {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
}

.legal-page header {
  padding-top: 40px;
}

.legal-page main {
  padding-bottom: 48px;
}

.legal-page h1 {
  margin: 0 0 16px;
  font-size: clamp(2rem, 7vw, 2.75rem);
  color: var(--pine);
}

.legal-page h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.375rem;
  color: var(--pine);
}

.legal-page section {
  margin-bottom: 24px;
}

.legal-page a {
  color: var(--coral-ink);
  font-weight: 700;
}

.legal-page :focus-visible {
  outline-color: var(--pine);
}

/* #664d03 on #fff3cd = 7.21:1 */
.legal-page .placeholder-flag {
  padding: 14px 16px;
  border: 1px solid #ffda6a;
  border-radius: 10px;
  background: #fff3cd;
  color: #664d03;
  font-weight: 700;
}

/* ---- Motion ---- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .tile:hover {
    transform: none;
  }
}
