:root {
  color-scheme: light;
  --bg: #f1ebe1;
  --bg-2: #e9e1d3;
  --panel: #fffcf7;
  --ink: #2a2620;
  --muted: #6b6356;
  --line: #e0d5c2;
  --accent: #24453a;
  --accent-ink: #ffffff;
  --gold: #a9843f;
  --danger: #9a2b2b;
  --ok: #2f6b45;
  --radius: 14px;
  --serif: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 var(--sans);
  color: var(--ink);
  background: radial-gradient(120% 80% at 30% 0%, #f8f4ec 0%, var(--bg) 55%, var(--bg-2) 100%) fixed;
  background-color: var(--bg);
  min-height: 100vh;
}

.skip { position: absolute; left: -9999px; top: 8px; background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Masthead ---------- */
.masthead { max-width: 1360px; margin: 0 auto; padding: 36px 32px 4px; }
body:not(.is-editing) .masthead--maker { max-width: 1160px; }
.masthead--maker h1 { text-wrap: balance; }
.site-return { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; color: var(--accent); font-size: 0.875rem; font-weight: 600; text-underline-offset: 3px; }
.has-scene .site-return { color: var(--p-ink); }
.site-return:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
body.is-editing .masthead { padding-top: 12px; }
body.is-editing .masthead h1 { font-size: clamp(24px, 2.6vw, 32px); }
body.is-editing .masthead .eyebrow { display: none; }
.eyebrow { margin: 0 0 6px; font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--gold); font-weight: 600; }
h1 { margin: 0; font: 600 clamp(34px, 4.6vw, 54px)/1.05 var(--serif); letter-spacing: -.01em; }
.lede { margin: 10px 0 0; max-width: 60ch; color: var(--muted); font-size: 16px; }

/* ---------- Layout ---------- */
.layout {
  max-width: 1360px; margin: 0 auto; padding: 24px 32px 72px;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 420px); gap: 40px; align-items: start;
}
.viewer { position: sticky; top: 16px; min-width: 0; }

/* ---------- Screen 1: gallery ---------- */
.choose { max-width: 1160px; margin: 0 auto; padding: 16px 32px 80px; }
.choose[hidden], .layout[hidden] { display: none; }
.choose h2 { margin: 0; font: 600 clamp(26px, 3vw, 34px)/1.1 var(--serif); }
.choose-intro { display: flex; flex-wrap: wrap; align-items: start; gap: 16px 32px; margin-bottom: clamp(24px, 4vw, 40px); }
.choose-intro .lede { flex: 1 1 18rem; margin: 0; max-width: 48ch; }
.portrait-promo {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 18px;
  margin-inline-start: auto; padding: 12px 14px; border: 1px solid #cfbc96; border-radius: var(--radius);
  background: var(--panel);
}
.portrait-promo[hidden] { display: none; }
.portrait-promo__title { margin: 0; font: 600 23px/1.1 var(--serif); }
.portrait-promo__dates { margin: 3px 0 0; color: var(--muted); font-size: 14px; }
.portrait-promo .portrait-promo__action { min-height: 44px; border-radius: 999px; }
.gallery-controls {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px;
  padding-top: 16px; margin-bottom: 22px; border-top: 1px solid var(--line);
}
.gallery-filter { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.gallery-filter label { font-weight: 600; }
.gallery-filter select { font: inherit; color: var(--ink); background: var(--paper, #fffcf6); border: 1px solid #a89b86; border-radius: 5px; padding: 8px 12px; min-height: 44px; }
.gallery { display: grid; gap: clamp(32px, 5vw, 56px); }
.gallery h3 { margin: 0 0 16px; border-bottom: 1px solid #d7cebe; padding-bottom: 8px; font: 600 clamp(24px, 3vw, 30px)/1.15 var(--serif); }
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 26px 22px; }
.gallery-card { display: flex; flex-direction: column; gap: 8px; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; font: inherit; color: inherit; min-width: 0; }
.gallery-card .thumb { border-radius: 5px; box-shadow: 0 18px 30px -18px rgba(40, 30, 10, .55), 0 2px 6px rgba(40, 30, 10, .12); transition: transform .2s ease, box-shadow .2s ease; outline: 2px solid transparent; outline-offset: 3px; }
.gallery-card:hover .thumb { transform: translateY(-4px) rotate(-.6deg); box-shadow: 0 26px 36px -18px rgba(40, 30, 10, .6), 0 2px 6px rgba(40, 30, 10, .12); }
.gallery-card:focus-visible { outline: none; }
.gallery-card:focus-visible .thumb { outline: 3px solid var(--gold); }
.gallery-card.is-current .thumb { outline-color: var(--accent); }
.gallery-card .cover-name { font: 600 19px/1.2 var(--serif); }
.gallery-card[data-status="missing"] .thumb, .gallery-card[data-status="loading"] .thumb { background: repeating-linear-gradient(135deg, #e7dece 0 8px, #ddd2bf 8px 16px); }
.gallery-card[data-status="missing"] .thumb img, .gallery-card[data-status="loading"] .thumb img { visibility: hidden; }
@media (prefers-reduced-motion: reduce) { .gallery-card .thumb { transition: none; } .gallery-card:hover .thumb { transform: none; } }

/* ---------- Screen 2: edit bar ---------- */
.editbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.editbar .card-title { font: 600 22px/1.1 var(--serif); margin-right: auto; }
.btn.compact { min-height: 36px; padding: 6px 14px; font-size: 14px; }
.mode-hint { margin: 8px 0 0; color: var(--muted); font-size: 14px; min-height: 1.5em; }

/* ---------- Stage + card ---------- */
.stage {
  container: stage / inline-size;
  display: flex; justify-content: center; align-items: center;
  padding: 26px 0 30px;
  perspective: 2600px;
  overflow-x: clip;   /* the swinging cover never causes sideways scrolling; shadows below stay visible */
}
.card {
  --cw: min(100cqw - 8px, 440px);
  position: relative;
  width: var(--cw);
  aspect-ratio: 5 / 7;
  transform-style: preserve-3d;
  transition: transform 1s cubic-bezier(.25, .8, .25, 1);
  outline: none;
  border-radius: 4px;
}
.card.is-clickable { cursor: pointer; }
.stage.is-drop .card { box-shadow: 0 0 0 4px var(--bg), 0 0 0 8px var(--gold); }
.card:focus-visible { box-shadow: 0 0 0 4px var(--bg), 0 0 0 7px var(--gold); }
.page, .leaf { position: absolute; inset: 0; border-radius: 3px; }
.page canvas, .face canvas { display: block; width: 100%; height: 100%; border-radius: 3px; }

.inside-page {
  background: #fbf8f1;
  box-shadow: 0 30px 50px -28px rgba(60, 40, 10, .45), 0 2px 8px rgba(40, 30, 10, .1);
}
.inside-page::after { /* shadow cast by the cover as it lifts */
  content: ""; position: absolute; inset: 0; border-radius: 3px; pointer-events: none;
  background: linear-gradient(90deg, rgba(30, 20, 5, .35), rgba(30, 20, 5, 0) 60%);
  opacity: 1; transition: opacity .9s ease .15s;
}
.card[data-open="true"] .inside-page::after { opacity: 0; }

.leaf {
  z-index: 2;
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform 1.15s cubic-bezier(.45, .05, .2, 1), opacity .45s ease;
}
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 3px; overflow: hidden; }
.front { box-shadow: 0 30px 50px -28px rgba(30, 20, 5, .55), 0 2px 8px rgba(30, 20, 5, .14); background: #1d3a30; }
.back { transform: rotateY(180deg); background: #2b2722; }
.back::after { /* soft shading toward the fold */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(270deg, rgba(0, 0, 0, .28), rgba(0, 0, 0, 0) 16%);
}

/* On-card editing (Edit mode only): click targets over the parts of the card */
.hotspots { position: absolute; inset: 0; pointer-events: none; }
.spot {
  position: absolute; pointer-events: auto; padding: 0; background: transparent; cursor: pointer;
  border: 1.5px dashed transparent; border-radius: 6px; transition: border-color .15s, background .15s;
}
.spot:hover, .spot:focus-visible { border-color: var(--gold); background: rgba(169, 132, 63, .1); outline: none; }
.spot-photo { cursor: grab; touch-action: none; }
.spot-photo.dragging { cursor: grabbing; border-color: var(--gold); }
.resize-handle {
  position: absolute; right: -9px; bottom: -9px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 2px solid var(--accent); box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
  cursor: nwse-resize; touch-action: none; pointer-events: auto;
}
.resize-handle::after { content: ""; position: absolute; inset: -10px; }   /* larger touch target */
.resize-handle.dragging { background: var(--accent); }
.spot-greeting:hover, .spot-greeting:focus-visible { border-color: #fff; background: rgba(255, 255, 255, .12); }
.spot .tip {
  position: absolute; left: 50%; top: 0; transform: translate(-50%, -115%); white-space: nowrap;
  background: var(--accent); color: #fff; font: 600 12px/1 var(--sans); padding: 5px 9px; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
.spot:hover .tip, .spot:focus-visible .tip { opacity: 1; }
.spot-photo .tip { top: 50%; transform: translate(-50%, -50%); background: rgba(20, 30, 26, .82); }
@media (hover: none) { .spot { border-color: rgba(169, 132, 63, .5); } .spot-greeting { border-color: rgba(255, 255, 255, .55); } }
.pill {
  position: absolute; transform: translate(-50%, -50%); pointer-events: auto; white-space: nowrap; cursor: pointer;
  font: 600 13px/1 var(--sans); padding: 8px 14px; border-radius: 999px;
  color: var(--accent); background: rgba(255, 253, 247, .96); border: 1.5px dashed var(--gold);
  box-shadow: 0 4px 12px -4px rgba(40, 30, 10, .35); transition: background .15s, transform .15s;
}
.pill:hover, .pill:focus-visible { background: #fff; outline: none; border-style: solid; }
.pill-message { font-size: 15px; padding: 12px 20px; }
.card canvas { pointer-events: none; }
.leaf { transform: translateZ(1px); will-change: transform; }
.card[data-open="true"] .leaf { transform: translateZ(1px) rotateY(-180deg); }

.card.no-anim, .card.no-anim * , .card.no-anim .inside-page::after { transition: none !important; }

/* Center the open spread. On a narrow screen each panel takes half the stage. */
.card[data-open="true"] { transform: translateX(50%); }
.card[data-open="true"] .leaf { pointer-events: none; }
@container stage (max-width: 639.99px) {
  .card[data-open="true"] { --cw: 48cqw; }
}

/* Wide stage: a true two-panel spread, centered. */
@container stage (min-width: 640px) {
  .card { --cw: min(46cqw, 460px, (100svh - 240px) * 5 / 7); min-width: 240px; }
}

.art-wait {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 28px; text-align: center; color: #f3ead6; font: 500 19px/1.35 var(--serif);
  background: radial-gradient(circle at 50% 40%, #2c4a3f, #1a2d26);
}
.art-wait[hidden] { display: none; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 2px solid rgba(243, 234, 214, .3); border-top-color: #e2c98f; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Reduced motion: no swing, no slide — a direct, static switch between cover and inside. */
@media (prefers-reduced-motion: reduce) {
  .card, .leaf, .inside-page::after { transition: none !important; }
  .spinner { animation-duration: 3s; }
}

/* ---------- Viewer controls ---------- */
.viewer-controls { display: flex; flex-wrap: wrap; gap: 10px 12px; justify-content: center; align-items: center; }

.segmented { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span { display: block; padding: 7px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; color: var(--muted); transition: background .2s, color .2s; }
.segmented input:checked + span { background: var(--accent); color: var(--accent-ink); }
.segmented input:focus-visible + span { box-shadow: 0 0 0 3px var(--gold); }
.segmented.small span { padding: 5px 13px; font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 9px 18px; border-radius: 999px; border: 1px solid transparent;
  font: 600 15px/1.2 var(--sans); cursor: pointer; text-decoration: none; position: relative;
  transition: background .2s, border-color .2s, transform .1s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible, .link:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: #1a3a2f; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: rgba(255, 255, 255, .6); border-color: #cfc1a8; }
.btn.danger { color: var(--danger); }
.btn.wide { width: 100%; min-height: 50px; font-size: 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.btn.file:focus-within { outline: 3px solid var(--gold); outline-offset: 2px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font: 600 13px var(--sans); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

.notice { margin: 0 auto 4px; max-width: 760px; padding: 10px 16px; border-radius: 10px; font-size: 14px; border: 1px solid; }
.notice p { margin: 2px 0; }
.required-field-link {
  display: inline-block; min-width: 44px; min-height: 44px; padding: 0 5px;
  background: transparent; color: inherit; border: 0; font: inherit; font-weight: 700;
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.required-field-link:focus-visible { outline: 2px solid currentColor; outline-offset: -2px; border-radius: 4px; }
.notice.error { background: #fbeeeb; border-color: #e7b9b1; color: #7b2020; }
.notice.info { background: #f6f1e6; border-color: var(--line); color: var(--muted); }

/* ---------- Editor ---------- */
.editor { min-width: 0; }
.step { margin: 0 0 16px; padding: 18px 20px 20px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.step legend { float: left; width: 100%; padding: 0; margin: 0 0 14px; font: 600 23px/1.2 var(--serif); }
.step legend + * { clear: both; }
.num { display: inline-grid; place-items: center; width: 26px; height: 26px; margin-right: 6px; border-radius: 50%; border: 1px solid var(--gold); color: var(--gold); font: 600 14px/1 var(--sans); vertical-align: 3px; }
.opt { font: 500 12px var(--sans); color: var(--muted); letter-spacing: .04em; text-transform: uppercase; margin-left: 6px; vertical-align: 3px; }

.covers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 10px; margin-bottom: 16px; }
.cover-opt { position: relative; display: flex; flex-direction: column; gap: 6px; cursor: pointer; min-width: 0; }
.cover-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.thumb { display: block; aspect-ratio: 5 / 7; border-radius: 6px; overflow: hidden; background: #ddd3c1; box-shadow: 0 4px 10px -4px rgba(40, 30, 10, .35); outline: 2px solid transparent; outline-offset: 2px; transition: outline-color .15s, transform .15s; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-opt:hover .thumb { transform: translateY(-2px); }
.cover-opt input:checked ~ .thumb { outline-color: var(--accent); }
.cover-opt input:focus-visible ~ .thumb { outline: 3px solid var(--gold); }
.cover-opt[data-status="missing"] .thumb, .cover-opt[data-status="loading"] .thumb {
  background: repeating-linear-gradient(135deg, #e7dece 0 8px, #ddd2bf 8px 16px);
}
.cover-opt[data-status="missing"] .thumb img, .cover-opt[data-status="loading"] .thumb img { visibility: hidden; }
.cover-name { font-size: 12.5px; font-weight: 600; line-height: 1.25; }
.cover-opt input:checked ~ .cover-name { color: var(--accent); }
.tag { font-size: 11.5px; color: var(--muted); line-height: 1.2; }
.tag:empty { display: none; }

.field { margin: 0 0 14px; }
.field:last-child { margin-bottom: 0; }
.field > label, .label-row label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 5px; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
input[type="text"], textarea {
  width: 100%; font: 16px/1.45 var(--sans); color: var(--ink);
  background: #fff; border: 1px solid #d7cab3; border-radius: 9px; padding: 10px 12px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 150px; }
input[type="text"]:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(36, 69, 58, .18); }
[aria-invalid="true"] { border-color: var(--danger) !important; box-shadow: 0 0 0 3px rgba(154, 43, 43, .14) !important; }
.hint { margin: 5px 0 0; font-size: 13px; color: var(--muted); }
.counter { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.counter.over { color: var(--danger); font-weight: 700; }
.error { margin: 10px 0 0; font-size: 13.5px; color: var(--danger); }
.error[hidden] { display: none; }

.choices { display: grid; gap: 8px; }
.choice { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: #fff; }
.choice:has(input:checked) { border-color: var(--accent); background: #f3f6f2; }
.choice input { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; }
.choice small { color: var(--muted); font-size: 12.5px; margin-left: 4px; }
.custom-scripture { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.custom-scripture[hidden] { display: none; }
#customVerse { min-height: 92px; }

.substep { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.substep-title { margin: 0 0 10px; font: 600 19px/1.2 var(--serif); }
.dropzone.compact-dropzone { padding: 14px 14px; }
.dropzone.compact-dropzone .dz-title { font-size: 18px; margin-top: 0; }

.dropzone {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; cursor: pointer;
  padding: 22px 16px; border: 2px dashed #cdbd9f; border-radius: 12px; background: #fffaf0; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.is-drop { border-color: var(--accent); background: #f3f6f2; }
.dropzone:focus-within { outline: 3px solid var(--gold); outline-offset: 2px; }
.dropzone input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dz-plus { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 24px; line-height: 1; }
.dz-title { font: 600 21px/1.2 var(--serif); margin-top: 4px; }
.dz-sub { font-size: 13px; color: var(--muted); }
.hint.tight { margin: -6px 0 12px; }
.hint.lead { margin: 0 0 12px; font-size: 14px; }
.step.flash { animation: flash 1.1s ease; }
@keyframes flash { 0% { box-shadow: 0 0 0 0 rgba(169, 132, 63, .7); } 100% { box-shadow: 0 0 0 14px rgba(169, 132, 63, 0); } }
@media (prefers-reduced-motion: reduce) { .step.flash { animation: none; outline: 2px solid var(--gold); } }
.share-result { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.share-result label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 5px; }
.share-result[hidden], #shareOn[hidden], #shareOff[hidden], #sharePhotoNote[hidden] { display: none; }
a.btn { color: var(--ink); }
.share .status { min-height: 1.2em; margin: 10px 0 0; font-size: 14px; }
.step > .btn.ghost { margin-top: 2px; }

.photo-tools[hidden], .photo-empty[hidden] { display: none; }
.photo-name { margin: 0 0 12px; font-size: 13.5px; color: var(--muted); overflow-wrap: anywhere; }
.photo-tools .segmented { margin-bottom: 14px; }
.field.range { display: grid; grid-template-columns: 104px 1fr; align-items: center; gap: 10px; margin-bottom: 10px; }
.field.range label { margin: 0; font-weight: 500; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.row .btn { min-height: 38px; padding: 7px 14px; font-size: 14px; }

.download .status { min-height: 1.2em; margin: 10px 0 0; font-size: 14px; }
.status.ok { color: var(--ok); }
.status.bad { color: var(--danger); }
.explain { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13.5px; color: var(--muted); }
.explain p { margin: 0 0 8px; }
.explain p:last-child { margin: 0; }
.explain strong { color: var(--ink); }

/* ---------- Enlarge dialog ---------- */
.zoom { width: min(94vw, 980px); height: min(94vh, 1400px); padding: 0; border: 0; border-radius: 14px; background: #2b2722; color: #f4ede0; overflow: hidden; }
.zoom::backdrop { background: rgba(20, 16, 10, .72); }
.zoom[open] { display: flex; flex-direction: column; }
.zoom-bar { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px 10px 18px; font: 600 20px var(--serif); }
.zoom-bar .btn { color: #f4ede0; border-color: rgba(244, 237, 224, .3); }
.zoom-body { flex: 1; overflow: auto; padding: 0 16px 16px; -webkit-overflow-scrolling: touch; }
.zoom-body img, .zoom-body .enlarged-motion { display: block; width: max(100%, 760px); max-width: none; height: auto; margin: 0 auto; border-radius: 4px; }
@media (min-width: 800px) { .zoom-body img, .zoom-body .enlarged-motion { width: auto; max-width: 100%; max-height: calc(min(94vh, 1400px) - 80px); } }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 24px; padding: 12px 16px 56px; }
  .viewer { position: static; }
  .masthead { padding: 28px 16px 0; }
  .choose { padding: 12px 16px 56px; }
  .category-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 20px 14px; }
}
@media (max-width: 420px) {
  .step { padding: 16px 14px 18px; }
  .field.range { grid-template-columns: 1fr; gap: 2px; }
}
@media (max-width: 700px) {
  .portrait-promo { width: 100%; margin-inline-start: 0; }
}

/* ---------- Recipient page (card.html) ---------- */
.recipient .masthead { text-align: center; padding-top: 34px; }
.recipient .masthead .lede { margin: 8px auto 0; }
.recipient main { max-width: 1040px; margin: 0 auto; padding: 8px 16px 64px; text-align: center; }
.recipient .viewer { position: static; }
.recipient .viewer[hidden] { display: none; }
.recipient .notice { display: inline-block; margin-top: 18px; }
.recipient .notice[hidden] { display: none; }
.keep { margin-top: 26px; }
.keep #download { margin-top: 12px; }
#forwardSms[hidden], #forwardCard[hidden] { display: none; }
a#forwardSms { color: var(--p-accent-ink, var(--accent-ink)); }
#textShare, #forwardText { min-height: 44px; }
.keep .status { min-height: 1.2em; margin: 8px 0 0; font-size: 14px; }
.make-own { margin-top: 34px; font: 600 19px var(--serif); }
.make-own a { color: var(--accent); text-underline-offset: 4px; }
.keep-note { margin-top: 10px; padding: 9px 12px; border-radius: 9px; background: #f6f1e6; border: 1px solid var(--line); color: var(--ink); }
.recipient .keep-note { display: inline-block; max-width: 46ch; }

/* ---------- Video on the card ---------- */
.photo-tools[data-kind="video"] .photo-only, .photo-tools:not([data-kind="video"]) .video-only { display: none; }
.media { position: absolute; inset: 0; pointer-events: none; }
.media-box { position: absolute; display: grid; place-items: center; pointer-events: auto; overflow: hidden; }
.media-box.playing { background: #000; }
.media-box video, .media-box iframe { display: block; width: 100%; height: 100%; border: 0; object-fit: contain; background: #000; }
.face.back .media-box video { object-fit: cover; }
.play-btn {
  position: relative; width: clamp(40px, 24%, 84px); aspect-ratio: 1; border-radius: 50%; cursor: pointer;
  border: 2px solid #fff; background: rgba(20, 30, 26, .72); box-shadow: 0 6px 18px rgba(0, 0, 0, .4); transition: transform .15s, background .15s;
}
.play-btn::before { content: ""; position: absolute; left: 53%; top: 50%; transform: translate(-50%, -50%);
  border-style: solid; border-width: 0.62em 0 0.62em 1.05em; border-color: transparent transparent transparent #fff; font-size: clamp(11px, 2.2cqw, 18px); }
.play-btn:hover { background: rgba(20, 30, 26, .9); transform: scale(1.06); }
.play-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.media-note { font: 600 12px/1.3 var(--sans); color: #fff; background: rgba(20, 30, 26, .82); padding: 6px 10px; border-radius: 999px; text-align: center; max-width: 90%; }
.spot.is-video::after { content: "▶ Video"; position: absolute; left: 6px; bottom: 6px; font: 600 11px/1 var(--sans); color: #fff; background: rgba(20, 30, 26, .78); padding: 4px 7px; border-radius: 999px; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .play-btn { transition: none; } .play-btn:hover { transform: none; } }

/* ---------- Moving covers ---------- */
.cover-motion, .cover-text { position: absolute; inset: 0; width: 100%; height: 100%; display: block; border-radius: 3px; pointer-events: none; opacity: 0; transition: opacity .5s ease; }
.cover-motion { object-fit: cover; }
.front.has-motion .cover-motion, .front.has-motion .cover-text { opacity: 1; }
.front .hotspots, .front .art-wait { z-index: 2; }
.thumb { position: relative; }
.thumb video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.motion-badge { position: absolute; left: 8px; top: 8px; z-index: 1; font: 600 11px/1 var(--sans); letter-spacing: .04em; color: #fff; background: rgba(20, 30, 26, .72); padding: 5px 8px; border-radius: 999px; }
@media (prefers-reduced-motion: reduce) { .cover-motion, .cover-text { transition: none; } }

/* ---------- Record with the camera ---------- */
.record-btn { margin-top: 10px; min-height: 44px; font-size: 15px; }
.record-btn[hidden] { display: none; }
.media-picker { width: min(92vw, 23rem); max-height: 90dvh; overflow-y: auto; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink); }
.media-picker::backdrop { background: rgba(20, 16, 10, .65); }
.media-picker[open] { display: grid; gap: 10px; }
.media-picker h2 { margin: 0 0 4px; font: 600 26px/1.15 var(--serif); }
.media-picker .btn { min-height: 44px; }
.media-picker .hint { margin: 0; }

.recorder { width: min(94vw, 560px); padding: 0; border: 0; border-radius: 14px; background: #201d19; color: #f4ede0; overflow: hidden; }
.recorder::backdrop { background: rgba(20, 16, 10, .72); }
.rec-bar { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px 10px 18px; font: 600 20px var(--serif); }
.rec-bar .btn, .rec-actions .btn.ghost { color: #f4ede0; border-color: rgba(244, 237, 224, .3); }
.rec-view { position: relative; background: #000; aspect-ratio: 4 / 3; max-height: 62vh; margin: 0 auto; }
.rec-view video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: none; }
.recorder[data-stage="ready"] #recLive, .recorder[data-stage="recording"] #recLive, .recorder[data-stage="starting"] #recLive { display: block; transform: scaleX(-1); }   /* mirror, like a selfie preview */
.recorder[data-stage="review"] #recPlay { display: block; }
.rec-time { position: absolute; left: 10px; top: 10px; display: none; font: 600 13px/1 var(--sans); font-variant-numeric: tabular-nums; background: rgba(0, 0, 0, .6); padding: 6px 9px; border-radius: 999px; }
.recorder[data-stage="recording"] .rec-time { display: block; }
.recorder[data-stage="recording"] .rec-time::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: #e5484d; }
.rec-msg { margin: 0; padding: 12px 18px 0; font-size: 14px; color: #d9d0c0; min-height: 2.6em; }
.rec-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; padding: 12px 16px 18px; }
.rec-actions .btn { display: none; }
.recorder[data-stage="ready"] #recStart, .recorder[data-stage="recording"] #recStop, .recorder[data-stage="review"] #recAgain, .recorder[data-stage="review"] #recUse { display: inline-flex; }
.btn.rec-stop { background: #b3262b; }
.btn.rec-stop:hover { background: #981f24; }
/* the same dialog takes a still photo (data-mode="photo"): one "Take photo" button, and the shot is shown for review */
.rec-view img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: none; }
.recorder[data-mode="photo"][data-stage="review"] #recShot { display: block; }
.recorder[data-mode="photo"][data-stage="review"] #recPlay { display: none; }
.recorder[data-mode="photo"][data-stage="ready"] #recStart { display: none; }
.recorder[data-mode="photo"][data-stage="ready"] #recSnap { display: inline-flex; }

.field-label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
#motionField[hidden] { display: none; }

/* ---------- Cover picture: Motion | Still, at the top above the card ---------- */
.cover-style { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 12px 0 0; padding: 10px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.cover-style[hidden] { display: none; }
.cover-style .field-label { margin: 0; }
.cover-style-note { font-size: 13px; color: var(--muted); }

/* ---------- Snow on a cover (CardSnow) ---------- */
.cover-snow { position: absolute; inset: 0; width: 100%; height: 100%; display: block; border-radius: 3px; pointer-events: none; }
.cover-snow[hidden] { display: none; }


/* ---------- Share page, Sanctuary Choir: one flat midnight blue with gold music notes floating up around the card (card-scene.js, `solid`) ---------- */
body.has-scene.scene-solid { background: var(--p-top); }
.scene-dust .p-rise { position: absolute; display: block; width: var(--s); height: var(--s); opacity: 0; will-change: transform, opacity;
  animation: note-rise var(--d) linear var(--delay) infinite; }
.scene-dust .p-note { display: block; width: 100%; height: 100%; overflow: visible; fill: var(--p-dot); filter: drop-shadow(0 0 9px rgba(244, 200, 104, .38));
  animation: note-sway var(--w) ease-in-out var(--wd) infinite alternate; }
@keyframes note-rise {
  0% { opacity: 0; transform: translate3d(0, 0, 0); }
  9% { opacity: var(--o); }
  88% { opacity: var(--o); }
  100% { opacity: 0; transform: translate3d(0, var(--up), 0); }
}
@keyframes note-sway { from { transform: translateX(calc(var(--a) * -1)) rotate(-9deg); } to { transform: translateX(var(--a)) rotate(9deg); } }
/* the page's words and buttons: the page colour, soft-edged, over the notes */
.scene-shields { position: absolute; inset: 0; }
.scene-shield { position: absolute; display: block; border-radius: 8px; background: var(--p-top); box-shadow: 0 0 9px 6px var(--p-top); }
@media (prefers-reduced-motion: reduce) {
  .scene-dust .p-rise { animation: none; opacity: calc(var(--o) * .8); transform: translateY(calc(var(--up) * .45)); }
  .scene-dust .p-note { animation: none; transform: rotate(-5deg); }
}

/* ---------- Share page, Cathedral Snow Globe: deep winter blue, out-of-focus lights and falling snow (card-scene.js, `bokeh`) ---------- */
body.has-scene.scene-bokeh { background: linear-gradient(180deg, var(--p-top) 0, var(--p-mid) 26%, var(--p-mid) 46%, var(--p-bottom) 100%); }
.scene-lights { position: absolute; left: 0; top: 0; display: block; }
.scene-lights.breathe { animation: lights-breathe 7.5s ease-in-out infinite alternate; }
@keyframes lights-breathe { from { opacity: .7; } to { opacity: 1; } }
.scene-snowfall { position: fixed; left: 0; top: 0; width: 100%; height: 100%; display: block; }
.scene-dark.scene-bokeh .scene-vignette { background: radial-gradient(circle at var(--cx) var(--cy), transparent 0, transparent calc(var(--cr) * .7), rgba(1, 4, 18, .34) calc(var(--cr) * 1.9)); }
@media (prefers-reduced-motion: reduce) { .scene-lights.breathe { animation: none; } }

/* ---------- Share page: the card's picture continues around it (card-scene.js) ---------- */
body.has-scene { position: relative; overflow-x: hidden; color: var(--p-ink);
  background: linear-gradient(180deg, var(--p-top) 0%, var(--p-top) 30%, var(--p-bottom) 75%, var(--p-bottom) 100%); }
.scene { position: absolute; left: 0; top: 0; width: 100%; z-index: 0; overflow: hidden; pointer-events: none; opacity: 0; transition: opacity .9s ease; }
.scene.ready { opacity: 1; }
.has-scene .masthead, .has-scene main { position: relative; z-index: 1; }
.scene-far { position: absolute; inset: -140px; background-repeat: no-repeat; filter: blur(46px) saturate(1.08); opacity: .9; }
.scene-dark .scene-far { filter: blur(46px) saturate(1.08) brightness(.82); }
.scene-near { position: absolute; display: block;
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 25%, #000 75%, transparent 100%), linear-gradient(180deg, transparent 0%, #000 7%, #000 93%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(90deg, transparent 0%, #000 25%, #000 75%, transparent 100%), linear-gradient(180deg, transparent 0%, #000 7%, #000 93%, transparent 100%);
  mask-composite: intersect; }
.scene-dark .scene-near { filter: brightness(.78) saturate(.95); }
.scene-light .scene-near { filter: brightness(.98); }
.scene-vignette { position: absolute; inset: 0; }
.scene-dark .scene-vignette { background: radial-gradient(circle at var(--cx) var(--cy), transparent 0, transparent calc(var(--cr) * .55), rgba(0,0,0,.42) calc(var(--cr) * 1.6)); }
.scene-light .scene-vignette { background: radial-gradient(circle at var(--cx) var(--cy), transparent 0, transparent calc(var(--cr) * .55), rgba(120,96,56,.16) calc(var(--cr) * 1.6)); }

/* particles: snow falls, motes rise, stars twinkle in place, dust drifts down a beam */
.scene-dust { position: absolute; inset: 0; }
.scene-dust i { position: absolute; width: var(--s); height: var(--s); border-radius: 50%; background: var(--p-dot); opacity: 0;
  box-shadow: 0 0 calc(var(--s) * 2.5) var(--p-dot); animation: var(--a, twinkle) var(--d) linear var(--delay) infinite; }
.scene-dust .p-twinkle { --a: twinkle; animation-timing-function: ease-in-out; }
.scene-dust .p-snow { --a: snowfall; box-shadow: none; }
.scene-dust .p-motes { --a: motes; }
.scene-dust .p-dust { --a: dustfall; }
@keyframes twinkle { 0%, 100% { opacity: 0; transform: scale(.6); } 50% { opacity: var(--o); transform: scale(1); } }
@keyframes snowfall { 0% { opacity: 0; transform: translate(0, -40px); } 12% { opacity: var(--o); } 85% { opacity: var(--o); } 100% { opacity: 0; transform: translate(14px, 160px); } }
@keyframes motes { 0% { opacity: 0; transform: translate(0, 40px); } 20% { opacity: var(--o); } 80% { opacity: calc(var(--o) * .6); } 100% { opacity: 0; transform: translate(-8px, -130px); } }
@keyframes dustfall { 0% { opacity: 0; transform: translate(0, -30px); } 25% { opacity: calc(var(--o) * .7); } 100% { opacity: 0; transform: translate(0, 110px); } }
@media (prefers-reduced-motion: reduce) {
  .scene { transition: none; }
  .scene-dust i { animation: none; opacity: calc(var(--o) * .45); }
}

/* text and controls in the design's own colours */
.has-scene .masthead .eyebrow { color: var(--p-eyebrow, var(--p-accent)); }
.has-scene.scene-dark h1, .has-scene.scene-dark .lede { text-shadow: 0 2px 18px rgba(0,0,0,.55); }
.has-scene.scene-light h1, .has-scene.scene-light .lede { text-shadow: 0 1px 14px rgba(255,250,240,.9); }
.has-scene h1, .has-scene .lede, .has-scene .hint, .has-scene .status { color: var(--p-ink); }
.has-scene .lede, .has-scene .hint { opacity: .86; }
.has-scene .segmented, .has-scene .btn.ghost, .has-scene .keep-note, .has-scene .notice.info {
  background: var(--p-glass); border-color: var(--p-line); color: var(--p-ink);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.has-scene .segmented span { color: var(--p-ink); opacity: .82; }
.has-scene .segmented input:checked + span { background: var(--p-accent); color: var(--p-accent-ink); opacity: 1; }
.has-scene .btn.primary { background: var(--p-accent); color: var(--p-accent-ink); box-shadow: 0 6px 20px -8px rgba(0,0,0,.5); }
.has-scene .btn.primary:hover:not(:disabled) { background: var(--p-accent); filter: brightness(1.08); }
.has-scene .btn.ghost:hover { background: var(--p-glass); border-color: var(--p-accent); }
.has-scene .btn:focus-visible, .has-scene .segmented input:focus-visible + span, .has-scene .make-own a:focus-visible { outline: 3px solid var(--p-accent); outline-offset: 3px; box-shadow: none; }
.has-scene .card:focus-visible { box-shadow: 0 0 0 4px var(--p-top), 0 0 0 7px var(--p-accent); }
.has-scene .keep-note strong { color: inherit; }
.has-scene .make-own a { color: var(--p-ink); text-decoration-color: var(--p-accent); }
.has-scene .status.ok, .has-scene .status.bad { color: var(--p-ink); }
.has-scene .front, .has-scene .inside-page { box-shadow: 0 34px 60px -26px rgba(0,0,0,.65), 0 2px 10px rgba(0,0,0,.25); }

/* ---------- The church's name at the foot of the maker and share pages ---------- */
.church-foot { max-width: 1360px; margin: 0 auto; padding: 28px 32px 40px; text-align: center; font: 500 15px/1.5 var(--serif); letter-spacing: .04em; color: var(--muted); }
.church-foot strong { font-weight: 700; color: var(--accent); letter-spacing: .06em; }
.recipient .church-foot { padding-top: 10px; }
.has-scene .church-foot { position: relative; z-index: 1; color: var(--p-ink); opacity: .82; }
.has-scene .church-foot strong { color: var(--p-ink); }
@media (max-width: 640px) { .church-foot { padding: 22px 16px 32px; font-size: 14px; } }
.church-foot .credit { display: block; margin-top: 6px; font: 600 13px/1.4 var(--sans); letter-spacing: .03em; }

/* ---------- Share page: invitation to make a card, shown once the card is opened ---------- */
.invite { max-width: 560px; margin: 26px auto 4px; padding: 24px 28px 26px; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 14px 34px -22px rgba(40, 30, 15, .45); }
.invite.shown { animation: invite-in .7s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes invite-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.invite-eyebrow { margin: 0 0 4px; font: 600 12px/1.3 var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--gold); }
.invite h2 { margin: 0 0 8px; font: 600 clamp(24px, 3vw, 30px)/1.15 var(--serif); text-wrap: balance; }
.invite-text { margin: 0 auto 16px; max-width: 42ch; color: var(--muted); text-wrap: balance; }
.invited .make-own { display: none; }
.has-scene .invite { background: var(--p-glass); border-color: var(--p-line); color: var(--p-ink); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); box-shadow: 0 18px 40px -24px rgba(0, 0, 0, .6); }
.has-scene .invite-eyebrow { color: var(--p-eyebrow, var(--p-accent)); }
.has-scene .invite-text { color: var(--p-ink); opacity: .88; }
@media (prefers-reduced-motion: reduce) { .invite.shown { animation: none; } }
@media (max-width: 640px) { .invite { margin: 20px 0 4px; padding: 20px 18px 22px; } }

@font-face { font-family: Allura; src: url('../vendor/fonts/allura/Allura-Regular.ttf') format('truetype'); font-weight: 400; font-style: normal; font-display: swap; }
.thumb .tree-lettering { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.thumb .motion-badge { z-index: 2; }
@keyframes gallery-snowfall { to { background-position: 9px 38px, -6px 47px; } }
@media (prefers-reduced-motion: no-preference) {
  .thumb.with-snow::after { content: ''; position: absolute; inset: 0; pointer-events: none; background-image: radial-gradient(circle, #fff 1px, transparent 2px), radial-gradient(circle, #fffd 1px, transparent 1.5px); background-size: 37px 38px, 53px 47px; animation: gallery-snowfall 2s linear infinite; }
}

.zoom-body [hidden], .cover-play[hidden] { display: none; }
body:has(.card[data-open="true"]) .cover-play { display: none; }

.outside-back { visibility: hidden; background: var(--panel); }
.card[data-page="3"] .outside-back { visibility: visible; z-index: 4; }
.card[data-page="3"] .leaf, .card[data-page="3"] .inside-page { visibility: hidden; }
.book-nav, .detail-preview { display: none; }
@media (max-width: 720px), (pointer: coarse) and (max-height: 540px) {
  .stage { perspective: none; padding: 12px 0; }
  .stage .card, .stage .card[data-open="true"] {
    width: min(100% - 8px, 440px, 49svh); min-width: 0; transform: none; transition: none;
    transform-style: flat; overflow: hidden; touch-action: pan-y pinch-zoom;
    box-shadow: 0 4px 16px #0003;
  }
  .stage .card .leaf { display: contents; }
  .stage .card .face, .stage .card .page {
    visibility: hidden; transform: none; transition: none; backface-visibility: visible; pointer-events: none;
  }
  .stage .card[data-page="0"] .front, .stage .card[data-page="1"] .back,
  .stage .card[data-page="2"] .inside-page, .stage .card[data-page="3"] .outside-back {
    visibility: visible; pointer-events: auto;
  }
  .stage .back::after, .stage .inside-page::after { display: none; }
  .stage .card[data-page] :is(.turn-sheet, .turn-under) {
    visibility: visible; pointer-events: none;
  }
  .stage .card[data-page] .turn-sheet {
    z-index: 6; will-change: clip-path;
  }
  .stage .card[data-page] .turn-under { z-index: 5; }
  .paper-curl { position: absolute; inset: 0; z-index: 7; width: 100%; height: 100%; pointer-events: none; }
  dialog.book-zoom[open] {
    position: fixed; inset: 0; margin: auto; box-sizing: border-box;
    width: 100%; max-width: none; height: 100dvh; max-height: none; border-radius: 0;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    display: grid; grid-template-rows: 60px minmax(0,1fr) 60px; overflow: hidden;
  }
  .book-zoom .zoom-body { display: grid; place-items: center; overflow: hidden; padding: 0 8px; }
  .book-zoom .zoom-body > :is(img,.enlarged-motion), .book-zoom :is(#enlarge,.hotspots,.detail-preview) { display: none; }
  .book-zoom .stage { width: 100%; height: 100%; padding: 0; container-type: size; }
  .book-zoom .stage .card[data-page] { width: min(100cqw, 100cqh * 5 / 7); height: auto; }
  .book-zoom .viewer-controls { margin: 0; align-self: center; }
  .book-zoom .book-nav .btn { background: transparent; color: #fff; border-color: #fff8; }
  body:has(.book-zoom[open]) { overflow: hidden; }
  .viewer-controls > .segmented, .viewer-controls #toggleOpen { display: none; }
  .viewer-controls { gap: 8px; margin: 4px 0 12px; }
  .book-nav { display: inline-flex; align-items: center; gap: 6px; }
  .book-nav .btn { min-width: 44px; height: 44px; padding: 0 10px; }
  .book-nav output { min-width: 9em; text-align: center; font-size: 14px; }
  .book-nav button:disabled { opacity: .4; }
  .layout:not([hidden]) { display: block; }
  #editScreen > .viewer { display: contents; }
  #editScreen[data-mode="edit"] .stage {
    --preview-height: min(26dvh, calc(var(--edit-height, 100dvh) * .26), 180px);
    position: sticky; top: var(--keyboard-offset, 0px); z-index: 8;
    box-sizing: content-box; height: var(--preview-height);
    background: var(--bg); padding: 6px 0; box-shadow: 0 2px 8px #0002;
  }
  #editScreen[data-mode="edit"] .card { width: auto; height: 100%; }
  #editScreen[data-mode="edit"] .stage[data-detail] .detail-preview { display: block; width: 100%; object-fit: contain; height: 100%; }
  #editScreen[data-mode="edit"] .stage[data-detail] .card { position: absolute; opacity: 0; pointer-events: none; }
  #editor :is(input, textarea, select) { font-size: 16px; scroll-margin-block: min(34dvh, 230px) 28px; }
  #editor { margin-top: 16px; }
}
