/* ————————————————————————————————————————————————
   ADVENTURE LOG · travel scrapbook design system
   Warm paper ground. Photos live in white polaroid frames held down
   with washi tape. Titles set in Fraunces like a hand-bound journal;
   annotations in Caveat, like someone wrote in the margins.
   One accent: postal vermilion, reserved for the primary action.
   ———————————————————————————————————————————————— */

:root {
  --paper: #f3ecdf;          /* page ground */
  --paper-deep: #e9dcc6;     /* ground vignette edges */
  --card: #fbf7ee;           /* paper cards */
  --white: #fffdf8;          /* polaroid frames */
  --ink: #372c20;            /* text — 11:1 on card */
  --ink-soft: #5d4f3e;       /* secondary — 6.5:1 on card */
  --ink-faint: #8a7a64;      /* decorative annotations only */
  --edge: rgba(120, 95, 60, 0.16);
  --accent: #b23a2c;         /* postal vermilion — primary action ONLY */
  --accent-down: #9a3023;
  --teal: rgba(110, 160, 150, 0.42);   /* second washi tape */
  --kraft: rgba(226, 186, 138, 0.5);   /* first washi tape */
  --ok: #2e7d4f;
  --warn: #a5691b;
  --radius: 12px;
  --pad: clamp(16px, 4vw, 28px);
  --shadow-soft: 0 1px 2px rgba(64, 48, 26, 0.08), 0 8px 24px rgba(64, 48, 26, 0.12);
  --shadow-lift: 0 2px 4px rgba(64, 48, 26, 0.1), 0 16px 36px rgba(64, 48, 26, 0.17);
  --hand-font: 'Caveat', cursive;
  font-size: 20px;           /* base body size — non-negotiable for these users */
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Atkinson Hyperlegible', system-ui, sans-serif;
  line-height: 1.55;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* Warm paper ground with a soft vignette, like an old album page —
   a faint compass rose and surveyor's contours drawn into the paper. */
.paper-bg {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 220 220' fill='none' stroke='%238a7a64' stroke-opacity='0.3' stroke-width='1.1'%3E%3Ccircle cx='110' cy='110' r='86'/%3E%3Ccircle cx='110' cy='110' r='64'/%3E%3Ccircle cx='110' cy='110' r='5'/%3E%3Cpath d='M110 16 L118 96 L110 110 L102 96 Z'/%3E%3Cpath d='M110 204 L118 124 L110 110 L102 124 Z'/%3E%3Cpath d='M16 110 L96 102 L110 110 L96 118 Z'/%3E%3Cpath d='M204 110 L124 102 L110 110 L124 118 Z'/%3E%3Cline x1='45' y1='45' x2='85' y2='85'/%3E%3Cline x1='175' y1='45' x2='135' y2='85'/%3E%3Cline x1='45' y1='175' x2='85' y2='135'/%3E%3Cline x1='175' y1='175' x2='135' y2='135'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 300' fill='none' stroke='%238a7a64' stroke-opacity='0.22' stroke-width='1.1'%3E%3Cpath d='M40 160 C60 90 150 60 220 80 C300 100 340 150 330 200 C315 255 220 270 150 250 C80 232 25 220 40 160 Z'/%3E%3Cpath d='M70 160 C90 110 160 90 215 105 C280 122 305 158 296 195 C283 235 210 246 155 230 C100 215 55 205 70 160 Z'/%3E%3Cpath d='M105 160 C120 128 170 115 210 126 C255 138 270 162 262 185 C252 212 200 220 162 208 C122 196 92 192 105 160 Z'/%3E%3C/svg%3E"),
    radial-gradient(140% 110% at 50% -10%, #f9f3e8 0%, var(--paper) 48%, var(--paper-deep) 100%);
  background-repeat: no-repeat, no-repeat, no-repeat;
  background-position: calc(100% + 120px) calc(100% + 120px), -90px -70px, center;
  background-size: 460px 460px, 560px 420px, cover;
}
@media (max-width: 719px) {
  .paper-bg { background-size: 300px 300px, 420px 315px, cover; background-position: calc(100% + 80px) calc(100% + 80px), -110px -60px, center; }
}

/* Paper grain over everything except the dark photo rooms. */
body::after {
  content: ''; position: fixed; inset: 0; z-index: 2000; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='280' height='280'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='2'/%3E%3C/filter%3E%3Crect width='280' height='280' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.045; mix-blend-mode: multiply;
}
body.show-mode::after, body.lightbox::after { display: none; }

.wrap { max-width: 640px; margin: 0 auto; padding: var(--pad); }
.wrap-wide { max-width: 1080px; margin: 0 auto; padding: var(--pad); }
.site-head { padding-top: 1.6rem; }

/* Masthead: title block with a corner of loose ephemera. */
.masthead { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; }
.mast-main { min-width: 240px; }
.site-stats { margin: 0.5rem 0 0; font-size: 1.35rem; color: var(--ink-faint); }
.mast-ephemera { position: relative; width: 150px; height: 120px; flex: none; }
.mast-ephemera .stamp { position: absolute; right: 66px; top: 34px; transform: rotate(-8deg); }
.postmark.pm-loose { position: absolute; right: -6px; top: 0; transform: rotate(7deg); }
@media (max-width: 719px) { .mast-ephemera { display: none; } }

.btn-back { width: auto; display: inline-flex; min-height: 56px; padding: 0.5rem 1.2rem; margin: 0.9rem 0 0; }

/* ————— Typography ————— */

.eyebrow {
  font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--ink-faint); margin: 0 0 0.5rem;
}

h1.trip-title {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 620; font-variation-settings: 'opsz' 90;
  font-size: clamp(2.1rem, 7vw, 3.5rem);
  line-height: 1.04; letter-spacing: -0.012em;
  margin: 0 0 0.4rem; text-wrap: balance;
}

.hand {
  font-family: var(--hand-font);
  font-weight: 500; font-size: 1.45rem; line-height: 1.25;
  color: #6d5b44;
}
.jh-sub { margin: 0.3rem 0 0; }
.site-tagline { margin: 0.4rem 0 0; font-size: 1.65rem; }
.hand-note { font-size: 1.6rem; margin: 0.6rem 0 1rem; }

p { font-size: 1rem; }
.muted { color: var(--ink-soft); }
.small { font-size: 0.9rem; }

/* ————— Paper cards & washi tape ————— */

.paper-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  padding: calc(var(--pad) * 1.1);
  margin: 2rem 0 1.5rem;
}
.center-card { text-align: center; max-width: 620px; margin-left: auto; margin-right: auto; transform: rotate(-0.35deg); }

.tape {
  position: absolute; top: -15px; left: 50%;
  width: 132px; height: 34px;
  transform: translateX(-50%) rotate(-2.5deg);
  background: var(--kraft);
  box-shadow: 0 1px 2px rgba(64, 48, 26, 0.14);
  clip-path: polygon(1.5% 0%, 98% 3%, 100% 34%, 98.5% 100%, 2% 97%, 0% 62%);
  pointer-events: none;
}
.tape-teal { background: var(--teal); transform: translateX(-50%) rotate(2deg); }

/* ————— Polaroid & postmark ————— */

.journal-head {
  display: flex; gap: clamp(1.2rem, 4vw, 2.5rem); align-items: flex-start; flex-wrap: wrap;
  margin: 2.2rem 0 1.2rem;
}
.jh-main { flex: 1; min-width: 240px; }

.polaroid {
  position: relative; margin: 0.5rem 0 0;
  background: var(--white);
  padding: 10px 10px 6px;
  box-shadow: var(--shadow-lift);
  transform: rotate(2.2deg);
  width: clamp(150px, 32vw, 230px);
}
.polaroid img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.polaroid figcaption { text-align: center; font-size: 1.35rem; padding: 0.35rem 0 0.5rem; }
.polaroid .tape { top: -16px; }

.postmark {
  position: absolute; right: -26px; top: -22px;
  width: 96px; height: 96px; border-radius: 50%;
  border: 2.5px solid rgba(140, 70, 55, 0.55);
  color: rgba(140, 70, 55, 0.8);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.1rem;
  transform: rotate(9deg);
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='0.8' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.9 0'/%3E%3C/filter%3E%3Crect width='120' height='120' fill='white' filter='url(%23n)'/%3E%3C/svg%3E");
  mask-size: 120px 120px;
}
.postmark b { font-size: 0.6rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.postmark i { font-family: var(--hand-font); font-style: normal; font-size: 0.95rem; }

/* ————— Rubber stamps ————— */

.stamp {
  display: inline-block; padding: 0.35rem 0.9rem; margin-bottom: 0.7rem;
  font-weight: 700; font-size: 0.78rem;
  letter-spacing: 0.22em; text-transform: uppercase;
  border: 2.5px solid currentColor; border-radius: 5px;
  transform: rotate(-4.5deg);
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='44'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='0.85' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.88 0'/%3E%3C/filter%3E%3Crect width='140' height='44' fill='white' filter='url(%23n)'/%3E%3C/svg%3E");
  mask-size: 140px 44px;
}
.stamp-red { color: #b23a2c; }
.stamp-faded { color: var(--ink-faint); }

/* ————— Buttons: 60px minimum, words that say what happens ————— */

.btn {
  display: flex; align-items: center; justify-content: center; gap: 0.6rem;
  width: 100%; min-height: 64px;
  padding: 0.8rem 1.4rem; margin: 0.55rem 0;
  font-family: 'Atkinson Hyperlegible', sans-serif;
  font-size: 1.1rem; font-weight: 700;
  border-radius: var(--radius); border: 2px solid transparent;
  cursor: pointer; text-decoration: none; text-align: center;
  transition: transform 90ms ease, background-color 130ms ease, box-shadow 130ms ease;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.985); }

.btn-primary {
  background: var(--accent); color: #fff8f3;
  box-shadow: 0 2px 6px rgba(140, 45, 30, 0.28), 0 10px 24px rgba(140, 45, 30, 0.18);
}
.btn-primary:hover { background: var(--accent-down); }

.btn-quiet { background: var(--white); color: var(--ink); border-color: #d9cbae; box-shadow: var(--shadow-soft); }
.btn-quiet:hover { background: var(--card); }

.btn-danger { background: transparent; color: #a1352a; border-color: rgba(161, 53, 42, 0.45); }

.btn-row { display: flex; gap: 0.75rem; }
.btn-row .btn { flex: 1; }

:where(a, button, input, [tabindex]):focus-visible {
  outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px;
}

/* ————— Forms ————— */

label.field-label { display: block; font-weight: 700; margin: 1rem 0 0.4rem; }
input[type='text'], input[type='password'] {
  width: 100%; min-height: 60px;
  font-family: inherit; font-size: 1.15rem;
  color: var(--ink); background: var(--white);
  border: 2px solid #d9cbae; border-radius: 10px;
  padding: 0.6rem 1rem;
}
input:focus { border-color: #b09a72; outline: none; }
.check-row {
  display: flex; align-items: center; gap: 0.8rem;
  min-height: 60px; padding: 0.4rem 0; cursor: pointer;
}
.check-row input[type='checkbox'] { width: 28px; height: 28px; accent-color: var(--accent); flex: none; }

/* ————— Status line: persistent, honest, never a toast ————— */

.status-line {
  display: none;
  background: var(--white); border: 1px solid var(--edge);
  border-left: 6px solid var(--ink-faint);
  border-radius: 8px; box-shadow: var(--shadow-soft);
  padding: 1rem 1.2rem; margin: 1.2rem 0;
  font-size: 1.05rem;
}
.status-line.show { display: block; }
.status-line.ok { border-left-color: var(--ok); }
.status-line.warn { border-left-color: var(--warn); }
.status-line .bar { height: 8px; background: #e8ddc8; border-radius: 4px; margin-top: 0.7rem; overflow: hidden; }
.status-line .bar > div { height: 100%; width: 0%; background: var(--accent); border-radius: 4px; transition: width 300ms ease; }

/* ————— Photo grid: little white-framed prints ————— */

.photo-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 14px; margin: 1.8rem 0; padding: 0; list-style: none;
}
@media (min-width: 700px) { .photo-grid { grid-template-columns: repeat(4, 1fr); gap: 18px; } }
@media (min-width: 1000px) { .photo-grid { grid-template-columns: repeat(5, 1fr); } }

.photo-grid a {
  display: block; background: var(--white); padding: 6px;
  border-radius: 3px; box-shadow: var(--shadow-soft);
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.photo-grid img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 1px; }
.photo-grid li:nth-child(4n + 1) a { transform: rotate(0.7deg); }
.photo-grid li:nth-child(4n + 2) a { transform: rotate(-0.5deg); }
.photo-grid li:nth-child(4n + 3) a { transform: rotate(0.4deg); }
.photo-grid li:nth-child(4n) a { transform: rotate(-0.8deg); }
.photo-grid a:hover, .photo-grid a:focus-visible { transform: rotate(0deg) translateY(-3px); box-shadow: var(--shadow-lift); }

.photo-grid .is-cover { position: relative; }
.photo-grid .is-cover::after {
  content: 'COVER'; position: absolute; left: 12px; top: 12px;
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.16em;
  color: var(--accent); background: rgba(255, 253, 248, 0.92);
  border: 1.5px solid var(--accent); border-radius: 3px;
  padding: 0.12rem 0.42rem; transform: rotate(-3deg);
}

/* ————— Home: postcards on the album page ————— */

.tile-grid { display: grid; grid-template-columns: 1fr; gap: 2rem 1.6rem; margin: 2.2rem 0 1.5rem; padding: 0 0.4rem; list-style: none; }
@media (min-width: 640px) { .tile-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .tile-grid { grid-template-columns: repeat(3, 1fr); } }

.trip-tile {
  display: block; position: relative; text-decoration: none; color: inherit;
  background: var(--white); padding: 10px 10px 14px;
  border-radius: 4px; border: 2px solid transparent;
  box-shadow: var(--shadow-soft);
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.tile-grid li:nth-child(odd) .trip-tile { transform: rotate(-0.6deg); }
.tile-grid li:nth-child(even) .trip-tile { transform: rotate(0.55deg); }
.trip-tile:hover, .trip-tile:focus-visible {
  transform: rotate(0deg) translateY(-4px);
  box-shadow: var(--shadow-lift); outline: none;
}
.trip-tile:focus-visible { border-color: var(--accent); }
.trip-tile .tile-img { position: relative; aspect-ratio: 3 / 2; overflow: hidden; border-radius: 2px; background: #efe6d4; display: flex; align-items: center; justify-content: center; }
.trip-tile .tile-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* photo-mount corners, like the little paper triangles in an old album */
.trip-tile .tile-img::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(135deg, rgba(251, 247, 238, 0.95) 11px, transparent 11.5px) top left,
    linear-gradient(225deg, rgba(251, 247, 238, 0.95) 11px, transparent 11.5px) top right,
    linear-gradient(45deg, rgba(251, 247, 238, 0.95) 11px, transparent 11.5px) bottom left,
    linear-gradient(315deg, rgba(251, 247, 238, 0.95) 11px, transparent 11.5px) bottom right;
  background-size: 28px 28px; background-repeat: no-repeat;
}
.ghost-tile { background: transparent; border: 2px solid var(--edge); box-shadow: none; }
.ghost-tile .tile-img { background: transparent; }
.ghost-tile .tile-img::after { display: none; }
.ghost-tile .hand { color: var(--ink-faint); font-size: 1.4rem; }
.tile-blank { color: var(--ink-faint); font-size: 1.4rem; }
.trip-tile .tile-body { padding: 0.75rem 0.35rem 0; }
.trip-tile .tile-title {
  font-family: 'Fraunces', Georgia, serif; font-weight: 620;
  font-size: 1.45rem; line-height: 1.12; margin: 0;
}
.trip-tile .tile-sub { font-size: 1.25rem; margin: 0.15rem 0 0; }

/* ————— Banners ————— */

.banner {
  background: var(--card); border: 1px solid var(--edge);
  border-radius: 8px; box-shadow: var(--shadow-soft);
  padding: 1rem 1.2rem; margin: 1.4rem 0;
  display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; justify-content: space-between;
}
.banner p { margin: 0; }
.banner .btn { width: auto; margin: 0; min-height: 56px; }

/* ————— Lightbox page (a dark room for one photo) ————— */

body.lightbox { background: #171310; color: #f2ebdf; }
.lb-stage { min-height: 100dvh; display: grid; grid-template-rows: 1fr auto; }
.lb-img-wrap { display: flex; align-items: center; justify-content: center; min-height: 0; }
.lb-img-wrap img { max-width: 100vw; max-height: calc(100dvh - 140px); object-fit: contain; }
.lb-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0.75rem var(--pad) calc(0.75rem + env(safe-area-inset-bottom));
}
.lb-nav {
  display: flex; align-items: center; justify-content: center;
  min-width: 64px; min-height: 64px; border-radius: var(--radius);
  color: #f2ebdf; text-decoration: none; border: 2px solid rgba(242, 235, 223, 0.28);
  font-size: 1.6rem; background: rgba(35, 28, 22, 0.6);
}
.lb-nav[aria-disabled='true'] { opacity: 0.3; pointer-events: none; }
.lb-caption { color: #c9bca8; font-size: 0.9rem; text-align: center; flex: 1; }

/* Immersive: tap the photo, everything else gets out of the way. */
.lb-img-wrap { cursor: zoom-in; }
body.immersive { background: #000; }
body.immersive .lb-img-wrap { cursor: zoom-out; }
body.immersive .lb-bar, body.immersive .lb-tools { display: none; }
body.immersive .lb-img-wrap img { max-height: 100dvh; max-width: 100vw; }
body.lightbox .btn-quiet { background: transparent; color: #f2ebdf; border-color: rgba(242, 235, 223, 0.35); box-shadow: none; }
body.lightbox .btn-danger { color: #ff9d8d; border-color: rgba(255, 157, 141, 0.45); }

/* ————— Slideshow ————— */

body.show-mode { background: #000; overflow: hidden; cursor: none; }
.show-stage { position: fixed; inset: 0; }
.show-stage img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; opacity: 0; transition: opacity 900ms ease;
}
.show-stage img.on { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .show-stage img { transition: none; } }
.show-hud {
  position: fixed; left: 0; right: 0; bottom: 0; padding: 1.2rem var(--pad) calc(1.2rem + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
  display: flex; justify-content: space-between; align-items: end; gap: 1rem;
  opacity: 0; transition: opacity 300ms ease; pointer-events: none;
}
body.show-mode.hud .show-hud { opacity: 1; pointer-events: auto; }
body.show-mode.hud { cursor: default; }
.show-hud .show-title { font-family: 'Fraunces', Georgia, serif; font-weight: 620; font-size: 1.7rem; margin: 0; color: #f2ebdf; }
.show-hud .show-count { color: #c9bca8; }

/* ————— Globe transition overlay ————— */

.globe-overlay {
  position: fixed; inset: 0; z-index: 50; overflow: hidden;
  background: radial-gradient(130% 100% at 50% 0%, #f9f3e8, var(--paper) 55%, var(--paper-deep));
  opacity: 1; transition: opacity 650ms ease, transform 650ms ease;
}
.globe-overlay.out { opacity: 0; transform: scale(1.35); pointer-events: none; }
/* Full-bleed: the planet fills the screen and spills past its edges. */
.globe-overlay canvas {
  position: absolute; left: 50%; top: 46%;
  transform: translate(-50%, -50%); display: block;
}
.globe-label { position: absolute; left: 0; right: 0; bottom: max(9vh, 64px); padding: 0 1.4rem; text-align: center; pointer-events: none; }
.globe-label .globe-place { text-wrap: balance; }
.globe-label .globe-place {
  font-family: 'Fraunces', Georgia, serif; font-weight: 620;
  font-size: clamp(1.7rem, 6vw, 2.8rem); margin: 0.2rem 0 0; line-height: 1.05;
  color: var(--ink);
}
.globe-skip {
  position: absolute; top: max(3vh, 18px); right: max(3vw, 18px);
  color: var(--ink-faint); font-size: 0.8rem; letter-spacing: 0.14em; text-transform: uppercase;
}
@media (prefers-reduced-motion: reduce) { .globe-overlay { display: none; } }

/* ————— Empty states & footer ————— */

.center-card .trip-title { margin-top: 0.4rem; }

footer.site-foot {
  margin-top: 3.5rem; padding-top: 1.3rem; border-top: 1px solid var(--edge);
  color: var(--ink-faint); font-size: 0.85rem;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
}
footer.site-foot a { color: var(--ink-soft); }

/* ————— Admin table ————— */

table.admin { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.admin th, table.admin td { text-align: left; padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--edge); }
table.admin th { color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.7rem; }
table.admin code { color: var(--ink-soft); font-family: ui-monospace, monospace; font-size: 0.82rem; }

.hidden { display: none !important; }

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