/* Layout: photo-led screens. A full-bleed abbey photo opens each view, content sits on
   warm stone below it, the passport itself is drawn as a paper page with inked stamps. */
:root {
  --ink: #6d1a28;          /* abbey burgundy: buttons, header */
  --gold: #c49a45;         /* gilt accents, milestones */
  --text: #241a15;         /* iron-gall ink */
  --muted: #6b5646;
  --paper: #f3ede3;        /* stone wall */
  --card: #fffaf1;
  --page: #fbf5e8;         /* passport page */
  --line: #e1d3bb;
  --ok: #3d5a4a;           /* visited: cloister green */
  --warn: #8a5a00;
  --surface: #ffffff; --on-ink: #ffffff; --link: #6d1a28; --stamp-bg: #fbf5e8;
  --banner-bg: #fff3d6; --banner-line: #ecd49a; --scrim: rgba(36,26,21,.62); --camera: #000000;
  --photo-shade: rgba(28,18,14,.82);
  --map-sea: #d9e3dc; --map-wave: #b9cbc0; --map-land: #f1e4c8; --map-line: #b99f78; --map-state: #cdb894; --map-label: #241a15;
  --display: 'Cormorant Garamond', 'Iowan Old Style', Georgia, 'Times New Roman', serif;
  --sans: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  --serif: var(--display);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --ink: #8e2a3a; --text: #f1e6d6; --muted: #c2ad96; --paper: #16110e; --card: #221a16; --page: #2a211b; --line: #43352b;
  --surface: #2b221c; --link: #f0a3ad; --stamp-bg: #efe3cc; --banner-bg: #3a2c12; --banner-line: #6b5420; --warn: #f0c870;
  --ok: #7fae95; --scrim: rgba(0,0,0,.72);
  --map-sea: #1d2a28; --map-wave: #2b3c39; --map-land: #3a2f25; --map-line: #6e5c47; --map-state: #5a4a3a; --map-label: #f1e6d6; color-scheme: dark; } }
:root[data-theme="dark"] {
  --ink: #8e2a3a; --text: #f1e6d6; --muted: #c2ad96; --paper: #16110e; --card: #221a16; --page: #2a211b; --line: #43352b;
  --surface: #2b221c; --link: #f0a3ad; --stamp-bg: #efe3cc; --banner-bg: #3a2c12; --banner-line: #6b5420; --warn: #f0c870;
  --ok: #7fae95; --scrim: rgba(0,0,0,.72);
  --map-sea: #1d2a28; --map-wave: #2b3c39; --map-land: #3a2f25; --map-line: #6e5c47; --map-state: #5a4a3a; --map-label: #f1e6d6; color-scheme: dark; }

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--text); font: 17px/1.55 var(--sans); -webkit-text-size-adjust: 100%; }
a { color: var(--link); }
button, input, select { font: inherit; }
img { max-width: 100%; }
.app { max-width: 600px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; padding-bottom: calc(84px + env(safe-area-inset-bottom)); background: var(--paper); }
.gutter { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

/* Top bar */
header.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 6; display: flex; align-items: center; gap: 10px;
  padding-block: calc(8px + env(safe-area-inset-top)) 8px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: var(--ink); color: var(--on-ink); }
header.top .mark { width: 30px; height: 30px; flex: none; }
header.top .t1 { font: 700 20px/1 var(--display); letter-spacing: .01em; }
header.top .t2 { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; opacity: .8; }
header.top a { color: var(--on-ink); text-decoration: none; display: flex; gap: 10px; align-items: center; }
main { padding-block: 0 16px; }
main:focus { outline: none; }

/* Type */
h1, h2, h3 { font-family: var(--display); line-height: 1.1; text-wrap: balance; margin: 0; }
h1 { font-size: 40px; font-weight: 700; }
h2 { font-size: 28px; font-weight: 700; }
h3 { font-size: 22px; font-weight: 700; }
.eyebrow { font: 600 12px/1.3 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
.muted { color: var(--muted); } .small { font-size: 14px; }
.section { display: grid; gap: 12px; margin-top: 28px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.section-head a { font-size: 15px; font-weight: 600; text-decoration: none; }

/* Photos: real photo on top of a painted stand-in, so something good always shows */
.ph { position: relative; overflow: hidden; background: var(--text); }
.ph > svg, .ph > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.ph::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0) 35%, var(--photo-shade) 100%); }

/* Hero */
.hero { position: relative; min-height: 360px; display: flex; flex-direction: column; justify-content: flex-end; color: #fff; }
.hero .ph { position: absolute; inset: 0; }
.hero .inner { position: relative; z-index: 1; display: grid; gap: 8px; padding-block: 24px 64px; }
.hero h1 { color: #fff; font-size: 46px; }
.hero .eyebrow { color: #f6d993; }
.hero .lede { color: rgba(255,255,255,.9); font-size: 16px; max-width: 34ch; margin: 0; }
.ph .credit { position: absolute; right: 10px; top: 8px; z-index: 2; font-size: 11px; color: rgba(255,255,255,.8); text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.ph.nophoto .credit, .rail-card .credit, .sheet-photo .credit, .place-card .credit { display: none; }
.detail-hero .credit { top: auto; bottom: 8px; }
.tally { display: flex; align-items: baseline; gap: 10px; margin-top: 6px; }
.tally b { font: 700 54px/1 var(--display); color: #fff; font-variant-numeric: tabular-nums; }
.tally span { font-size: 15px; color: rgba(255,255,255,.85); }
.progress { height: 6px; background: rgba(255,255,255,.25); border-radius: 3px; overflow: hidden; max-width: 320px; }
.progress > span { display: block; height: 100%; background: #f6d993; border-radius: 3px; transition: width .6s; }
.hero-cta { position: relative; z-index: 2; margin-top: -30px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 50px; padding: 10px 20px; border-radius: 999px;
  border: 2px solid var(--ink); background: var(--ink); color: var(--on-ink); font-weight: 600; text-decoration: none; cursor: pointer; }
.btn svg { width: 22px; height: 22px; flex: none; }
.btn.secondary { background: transparent; color: var(--link); border-color: var(--link); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #241a15; box-shadow: 0 10px 24px rgba(36,26,21,.25); }
.btn.block { width: 100%; }
.btn.small { min-height: 42px; padding: 6px 14px; font-size: 15px; }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .btn { flex: 1 1 140px; }

/* "On your way" carousel */
.rail { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; margin: 0 calc(-1 * max(16px, env(safe-area-inset-right, 0px))) 0 0; }
.rail-card { flex: none; width: 220px; scroll-snap-align: start; text-decoration: none; color: inherit; display: grid; gap: 6px; }
.rail-card .ph { aspect-ratio: 4 / 3; border-radius: 14px; max-width: 100%; }
.rail-card b { font: 700 19px/1.15 var(--display); }
.rail-card span { font-size: 13px; color: var(--muted); }

/* Passport page */
.passport-page { background: var(--page); border: 1px solid var(--line); border-radius: 6px 18px 18px 6px; padding: 20px 16px 24px;
  box-shadow: inset 14px 0 18px -14px rgba(36,26,21,.35), 0 2px 0 var(--line), 0 4px 0 var(--card);
  background-image: repeating-linear-gradient(0deg, transparent 0 31px, rgba(109,26,40,.06) 31px 32px); }
.passport-page .grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 4px; }
.slot { display: grid; justify-items: center; gap: 2px; text-decoration: none; color: var(--text); text-align: center; min-width: 0; }
.slot svg { width: 100%; max-width: 120px; height: auto; display: block; }
.slot .n { font: 600 13px/1.2 var(--sans); overflow-wrap: anywhere; }
.slot .d { font-size: 11px; color: var(--muted); }
.slot.empty .ring { width: 100%; max-width: 104px; aspect-ratio: 1; border: 2px dashed var(--line); border-radius: 50%; display: grid; place-items: center; color: var(--muted); font-size: 12px; margin: 8px; }
.page-foot { margin: 16px 0 0; font: italic 16px/1.4 var(--display); color: var(--muted); text-align: center; }

/* Milestones */
.badges { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 4px; }
.badge { flex: none; width: 72px; text-align: center; font-size: 12px; color: var(--muted); display: grid; justify-items: center; gap: 4px; }
.badge .b { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; font: 700 24px var(--display); border: 2px dashed var(--line); color: var(--muted); }
.badge.on .b { border: 3px double #fff4d4; background: radial-gradient(circle at 35% 30%, #e8c77a, var(--gold) 60%, #9a7430); color: #3a2a10; box-shadow: 0 3px 8px rgba(36,26,21,.25); }
.badge.on { color: var(--text); font-weight: 600; }

/* Cards and places */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: grid; gap: 8px; }
.card p { margin: 0; }
ol.how { padding-left: 22px; margin: 0; display: grid; gap: 4px; }
.place-card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; display: grid; }
.place-card .ph { aspect-ratio: 16 / 10; max-width: 100%; }
.place-card .over { position: absolute; left: 16px; right: 96px; bottom: 12px; z-index: 1; color: #fff; }
.place-card .over h3 { color: #fff; font-size: 26px; }
.place-card .over span { font-size: 14px; opacity: .9; }
.place-card .mini { position: absolute; right: 10px; bottom: 10px; z-index: 1; width: 78px; height: 78px; border-radius: 50%; background: var(--stamp-bg); box-shadow: 0 4px 12px rgba(0,0,0,.35); }
.place-card .mini svg { width: 100%; height: 100%; }
.place-card .body { padding: 14px 16px 16px; display: grid; gap: 10px; }
.place-card .body p { margin: 0; }
a.place-link { color: inherit; text-decoration: none; display: block; position: relative; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 999px; background: var(--line); color: var(--text); }
.tag.ok { background: var(--ok); color: var(--on-ink); }
.list { display: grid; gap: 16px; }
input[type=text], input[type=search], select { width: 100%; min-height: 50px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); }
label { display: block; font-weight: 600; }
.filters { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 420px) { .filters { grid-template-columns: 2fr 1fr; } }
.page-head { display: grid; gap: 6px; padding-block: 24px 4px; }
.page-head p { margin: 0; }

/* Place detail */
.detail-hero { position: relative; min-height: 320px; display: flex; align-items: flex-end; color: #fff; }
.detail-hero .ph { position: absolute; inset: 0; }
.detail-hero .inner { position: relative; z-index: 1; padding-block: 20px; display: grid; gap: 4px; }
.detail-hero h1 { color: #fff; }
.back { position: absolute; top: 12px; left: max(12px, env(safe-area-inset-left, 0px)); z-index: 2; background: rgba(0,0,0,.45); color: #fff; border-radius: 999px; padding: 6px 14px; text-decoration: none; font-size: 15px; }
.quote { font: italic 20px/1.35 var(--display); color: var(--muted); border-left: 3px solid var(--gold); padding-left: 12px; margin: 0; }

/* Scanner */
.scanbox { position: relative; background: var(--camera); border-radius: 20px; overflow: hidden; aspect-ratio: 1; max-width: 100%; }
.scanbox video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanbox .idle { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; text-align: center; padding: 24px; }

/* Bottom tabs */
nav.tabs { position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--line); display: flex; justify-content: center;
  padding-bottom: env(safe-area-inset-bottom); padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); z-index: 5; }
nav.tabs a { flex: 1; max-width: 140px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 10px; color: var(--muted); text-decoration: none; font-size: 13px; min-height: 60px; }
nav.tabs a svg { width: 26px; height: 26px; }
nav.tabs a[aria-current=page] { color: var(--link); font-weight: 700; }

/* Overlay */
.overlay { position: fixed; inset: 0; background: var(--scrim); display: grid; place-items: center; padding: 16px; z-index: 20; animation: fade .2s; }
.overlay .sheet { background: var(--paper); border-radius: 22px; width: 100%; max-width: 420px; text-align: center; max-height: 92vh; overflow: auto; }
.overlay .sheet-body { padding: 0 20px 20px; display: grid; gap: 10px; }
.overlay .sheet-body p { margin: 0; }
.overlay .sheet-photo { height: 150px; }
.overlay .big { margin-top: -90px; position: relative; z-index: 1; }
.overlay .big svg { width: 200px; height: 200px; background: var(--stamp-bg); border-radius: 50%; box-shadow: 0 8px 22px rgba(0,0,0,.3); animation: thunk .5s cubic-bezier(.2,1.6,.4,1); }
.overlay .plain { padding: 24px 20px 20px; }
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--paper); padding: 10px 16px; border-radius: 10px; z-index: 30; max-width: 90vw; text-align: center; }
.banner { background: var(--banner-bg); border: 1px solid var(--banner-line); color: var(--warn); padding: 10px 12px; border-radius: 12px; font-size: 14px; margin: 0; }
.stamp-big { text-align: center; } .stamp-big svg { width: min(300px, 80vw); height: auto; background: var(--stamp-bg); border-radius: 50%; }
footer.foot { font-size: 13px; color: var(--muted); text-align: center; padding-block: 8px 24px; }

/* Certificate */
.cert { background: #fffdf6; color: #241a15; border: 8px double #6d1a28; padding: 28px 20px; text-align: center; font-family: var(--display); display: grid; gap: 8px; }
.cert h1 { font-size: 34px; color: #6d1a28; }
.cert .muted { color: #6b5646; }
.cert .name { font-size: 34px; font-style: italic; border-bottom: 1px solid #6b5646; justify-self: center; padding: 0 16px 4px; min-width: 60%; }
.cert p { font-size: 19px; margin: 0; }
.cert ul { list-style: none; padding: 0; margin: 0; font: 14px/1.5 var(--sans); text-align: left; }
.cert li { break-inside: avoid; margin: 2px 0; }
@media (min-width: 480px), print { .cert ul { columns: 2; } }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@keyframes thunk { 0% { transform: scale(2.2) rotate(-12deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media print {
  header.top, nav.tabs, footer.foot, .noprint { display: none !important; }
  html, body { background: #fff; } .app { padding: 0; max-width: none; } main { padding: 0; }
  .cert { border-width: 10px; min-height: 90vh; }
}
.sheet-photo .ph { height: 100%; }
.hero .ph::after, .detail-hero .ph::after { background: linear-gradient(180deg, rgba(20,12,9,.15) 0%, rgba(20,12,9,.5) 45%, var(--photo-shade) 100%); }

/* Pilgrimage map */
.map-wrap { display: grid; gap: 8px; }
.map-frame { position: relative; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; background: var(--map-sea); aspect-ratio: 4 / 3; max-width: 100%; box-shadow: inset 0 0 0 6px var(--page), inset 0 0 0 7px var(--map-line); }
.map-wrap.tall .map-frame { aspect-ratio: 1 / 1; }
@media (min-width: 520px) { .map-wrap.tall .map-frame { aspect-ratio: 4 / 3; } }
.map-svg { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.map-svg:active { cursor: grabbing; }
.map-sea { fill: var(--map-sea); } .map-wave { stroke: var(--map-wave); }
.map-land { fill: var(--map-land); stroke: var(--map-line); stroke-linejoin: round; }
.map-state { fill: none; stroke: var(--map-state); }
.map-border { fill: none; stroke: var(--map-line); }
.map-route { fill: none; stroke: var(--link); stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.map-label { fill: var(--map-label); font-family: var(--display); font-weight: 700; paint-order: stroke; stroke: var(--map-land); stroke-width: .08px; }
.pin:focus-visible circle:nth-child(2) { stroke: var(--gold); }
.map-tools { position: absolute; right: 12px; top: 12px; display: grid; gap: 6px; }
.map-tools button { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 20px; line-height: 1; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.map-legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.map-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; }
.lg-v { background: var(--ink); border: 2px solid var(--gold); }
.lg-n { background: var(--page); border: 3px solid var(--ink); }
.lg-r { width: 22px !important; height: 0 !important; border-radius: 0 !important; border-top: 3px dashed var(--link); }

.hero-rule { margin: 2px 0 6px; font: italic 600 21px/1.3 var(--display); color: #fff6df; max-width: 30ch; text-shadow: 0 1px 8px rgba(0,0,0,.45); }
.hero-rule span, .quote .cite { display: block; font: 600 11px/1.6 var(--sans); letter-spacing: .12em; text-transform: uppercase; font-style: normal; opacity: .85; margin-top: 4px; }
.hero-rule span { color: #f6d993; }
.quote .cite { color: var(--gold); }
