/* Landing (the QR target): dedication, pack-code field, progress. iPhone-first: 100dvh, safe areas, no hover states. */
.page-landing {
  min-height: 100dvh;
  background:
    radial-gradient(90% 55% at 50% 0%, rgba(201, 162, 74, 0.16), transparent 70%),
    radial-gradient(70% 45% at 50% 100%, rgba(139, 30, 30, 0.16), transparent 75%),
    var(--obsidian);
  display: flex; flex-direction: column;
  overflow-x: clip;
}
.page-landing footer.site { position: relative; z-index: 1; padding-bottom: max(40px, calc(env(safe-area-inset-bottom) + 24px)); }

/* drifting embers: transform/opacity only */
.embers { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.embers i {
  position: absolute; left: var(--x); bottom: -12px; width: 3px; height: 3px; border-radius: 50%;
  background: radial-gradient(circle, #ffd88a 0%, rgba(255, 150, 60, 0.6) 45%, transparent 70%);
  scale: var(--s); opacity: 0;
  animation: ember var(--d) linear var(--t) infinite;
}
@keyframes ember {
  0% { transform: translate3d(0, 0, 0); opacity: 0; }
  12% { opacity: 0.9; }
  70% { opacity: 0.5; }
  100% { transform: translate3d(28px, -105vh, 0); opacity: 0; }
}

.landing {
  position: relative; z-index: 1; flex: 1;
  width: 100%; max-width: 480px; margin: 0 auto;
  padding: max(34px, calc(env(safe-area-inset-top) + 18px)) max(20px, env(safe-area-inset-right)) 28px max(20px, env(safe-area-inset-left));
  display: flex; flex-direction: column; align-items: stretch; gap: 22px;
}

/* returning visitor (she already holds cards): the code field comes before the letter */
.landing.is-returning .dedication { order: 5; }

/* crest */
.crest { text-align: center; }
.crest__sigil { width: 70px; height: 70px; margin: 0 auto 12px; color: var(--gold); filter: drop-shadow(0 0 14px rgba(201, 162, 74, 0.45)); animation: crest-glow 5s ease-in-out infinite; }
@keyframes crest-glow { 50% { filter: drop-shadow(0 0 24px rgba(243, 220, 148, 0.65)); } }
.crest__eyebrow { margin: 0; font-family: var(--display); font-size: 0.72rem; letter-spacing: 0.36em; text-transform: uppercase; color: var(--muted); }
.crest h1 { margin: 6px 0 0; font-size: clamp(2.1rem, 10.5vw, 3rem); letter-spacing: 0.05em; }
.crest__sub { margin: 8px auto 0; max-width: 34ch; text-wrap: balance; font-style: italic; color: var(--parchment-2); font-size: 1.02rem; line-height: 1.4; }

/* dedication: a letter, sealed in gold */
.dedication {
  position: relative; margin: 0; padding: 22px 22px 18px;
  border-radius: var(--radius);
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(201, 162, 74, 0.12), transparent 60%),
    linear-gradient(170deg, #1a1510, #100d0b);
  box-shadow: inset 0 0 0 1px rgba(201, 162, 74, 0.38), inset 0 0 0 5px rgba(11, 10, 13, 0.7), inset 0 0 0 6px rgba(201, 162, 74, 0.14), 0 18px 40px rgba(0, 0, 0, 0.45);
  color: var(--parchment);
}
.dedication::before { /* top ornament */
  content: '✦'; position: absolute; top: -11px; left: 50%; translate: -50% 0;
  width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%;
  background: var(--obsidian); color: var(--gold); font-size: 12px; box-shadow: 0 0 0 1px rgba(201, 162, 74, 0.5);
}
.dedication p { margin: 0; }
.dedication__to { font-family: var(--display); font-size: 0.82rem; letter-spacing: 0.26em; text-transform: uppercase; color: var(--gold-hi); text-align: center; margin-bottom: 10px !important; }
.dedication__msg { font-style: italic; font-size: 1.08rem; line-height: 1.5; text-wrap: pretty; }
.dedication__signoff { margin-top: 12px !important; text-align: right; font-family: var(--display); font-size: 0.8rem; letter-spacing: 0.12em; color: var(--gold); }

/* the code field: four gilded cells over one real input */
.redeem { display: flex; flex-direction: column; align-items: stretch; gap: 12px; margin: 4px 0 0; }
.redeem__label { text-align: center; font-family: var(--display); font-size: 0.86rem; letter-spacing: 0.24em; text-transform: uppercase; color: var(--gold-hi); }
.redeem__field { position: relative; align-self: center; width: min(100%, 300px); height: 74px; }
.redeem__field input {
  position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%;
  margin: 0; padding: 0; border: 0; border-radius: 12px; outline: none;
  background: transparent; color: transparent; caret-color: transparent;
  font-size: 16px; /* ≥16px: iOS never zooms */ letter-spacing: 3em; text-indent: -999px;
  -webkit-appearance: none; appearance: none;
}
.redeem__field input::selection { background: transparent; }
.redeem__cells { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; pointer-events: none; }
.redeem__cells span {
  display: grid; place-items: center; border-radius: 12px;
  font-family: var(--display); font-weight: 600; font-size: 2rem; color: var(--gold-hi);
  background: linear-gradient(180deg, #1d1813, #0f0c0a);
  box-shadow: inset 0 0 0 1px rgba(201, 162, 74, 0.45), inset 0 -10px 18px rgba(0, 0, 0, 0.45), 0 6px 16px rgba(0, 0, 0, 0.4);
  transition: box-shadow 0.25s, transform 0.25s;
}
.redeem__cells span.is-filled { text-shadow: 0 0 14px rgba(243, 220, 148, 0.55); }
.redeem__field:focus-within .redeem__cells span.is-cursor {
  box-shadow: inset 0 0 0 1.5px var(--gold-hi), inset 0 -10px 18px rgba(0, 0, 0, 0.45), 0 0 18px rgba(243, 220, 148, 0.35);
}
.redeem__field:focus-within .redeem__cells span.is-cursor::after {
  content: ''; width: 2px; height: 28px; background: var(--gold-hi); border-radius: 1px; animation: caret 1.05s steps(1) infinite;
}
.redeem__cells span.is-filled.is-cursor::after { display: none; }
@keyframes caret { 50% { opacity: 0; } }
.redeem.is-error .redeem__field { animation: shake 0.42s cubic-bezier(.36, .07, .19, .97); }
.redeem.is-error .redeem__cells span { box-shadow: inset 0 0 0 1.5px #c8574f, inset 0 -10px 18px rgba(0, 0, 0, 0.45); }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }

.redeem__go {
  position: relative; overflow: hidden; align-self: center; width: min(100%, 300px); min-height: 54px;
  border: 0; border-radius: 999px; cursor: pointer;
  font-family: var(--display); font-weight: 700; font-size: 0.95rem; letter-spacing: 0.2em; text-transform: uppercase; color: #1b1308;
  background: linear-gradient(180deg, #f8e6a8, #d6ad52 55%, #a9802c);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 10px 26px rgba(201, 162, 74, 0.28);
  transition: transform 0.15s, filter 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.redeem__go:active { transform: scale(0.97); }
.redeem__go::after { /* foil glint */
  content: ''; position: absolute; inset: 0; translate: -120% 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.55) 50%, transparent 70%);
  animation: glint 4.5s ease-in-out 1.2s infinite;
}
@keyframes glint { 0%, 70% { translate: -120% 0; } 100% { translate: 120% 0; } }
.redeem__go[aria-busy='true'] { filter: saturate(0.6) brightness(0.9); }
.redeem__go[aria-busy='true']::after { animation-duration: 0.9s; animation-delay: 0s; }
.redeem__hint { margin: 0; text-align: center; color: var(--muted); font-size: 0.92rem; font-style: italic; }
.redeem__error:empty { display: none; }
.redeem__error {
  margin: 0; padding: 10px 14px; border-radius: 12px; text-align: center; font-size: 1rem; line-height: 1.4;
  color: #f6d5cf; background: rgba(139, 30, 30, 0.22); box-shadow: inset 0 0 0 1px rgba(200, 87, 79, 0.45);
}

/* progress */
.progress { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 4px; }
.progress p { margin: 0; color: var(--parchment-2); font-size: 1.02rem; }
.progress b { font-family: var(--display); font-weight: 600; color: var(--gold-hi); letter-spacing: 0.08em; }
.progress__ring { width: 40px; height: 40px; rotate: -90deg; flex: none; }
.progress__ring circle { fill: none; stroke: rgba(201, 162, 74, 0.2); stroke-width: 3; }
.progress[data-empty] .progress__arc { opacity: 0; }
.progress__ring .progress__arc { stroke: var(--gold-hi); stroke-linecap: round; stroke-dasharray: var(--p, 0) 100; transition: stroke-dasharray 0.9s cubic-bezier(.2, .8, .2, 1); filter: drop-shadow(0 0 3px rgba(243, 220, 148, 0.6)); }

.to-codex {
  align-self: center; display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 24px;
  border-radius: 999px; text-decoration: none;
  font-family: var(--display); font-size: 0.82rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--gold-hi);
  box-shadow: inset 0 0 0 1px rgba(201, 162, 74, 0.5);
}
.to-codex:active { background: rgba(201, 162, 74, 0.1); }

/* Add to Home Screen hint (iOS Safari, not installed) */
.a2hs {
  display: flex; align-items: center; gap: 10px; margin-top: 4px; padding: 12px 12px 12px 16px; border-radius: 14px;
  background: rgba(29, 26, 34, 0.85); box-shadow: inset 0 0 0 1px var(--line); color: var(--parchment-2); font-size: 0.95rem; line-height: 1.4;
}
.a2hs[hidden] { display: none; }
.a2hs p { margin: 0; flex: 1; }
.a2hs b { color: var(--gold-hi); font-weight: 600; }
.a2hs__icon svg { display: inline-block; width: 18px; height: 18px; vertical-align: -3px; color: #7fb0ff; }
.a2hs__close { flex: none; width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 1.4rem; line-height: 1; cursor: pointer; }

html.pack-open, html.pack-open body { overflow: hidden; overscroll-behavior: none; }

@media (prefers-reduced-motion: reduce) {
  .embers { display: none; }
  .crest__sigil, .redeem__go::after { animation: none; }
  .redeem.is-error .redeem__field { animation: none; }
}
