:root {
  --bg: #ebe6df;
  --bg-deep: #e0d9d0;
  --ink: #1c1a17;
  --ink-soft: #5a554e;
  --line: rgba(28, 26, 23, 0.12);
  --accent: #2f5d50;
  --surface: rgba(28, 26, 23, 0.04);
  --surface-strong: rgba(28, 26, 23, 0.06);
  --elevated: rgba(235, 230, 223, 0.92);
  --elevated-hover: #f4f0ea;
  --error: #8a2f2f;
  --radius: 2px;
  /* Same value for side padding and space under the hero */
  --gap: clamp(0.5rem, 1.2vw, 0.85rem);
  --page-pad: clamp(0.75rem, 2vw, 1.5rem);
  --font-display: "Fraunces", "Times New Roman", serif;
  --font-body: "Manrope", "Segoe UI", sans-serif;
  --glow-warm: rgba(255, 255, 255, 0.55);
  --glow-accent: rgba(47, 93, 80, 0.08);
  --main-glow: rgba(47, 93, 80, 0.06);
  --main-shadow: rgba(20, 18, 16, 0.18);
  --grain-opacity: 0.22;
}

/* Synced from main site via localStorage pref-theme — no local toggle */
html[data-theme="dark"] {
  --bg: #1c1a17;
  --bg-deep: #121110;
  --ink: #ebe6df;
  --ink-soft: #a39e96;
  --line: rgba(235, 230, 223, 0.14);
  --accent: #7aaf9d;
  --surface: rgba(235, 230, 223, 0.05);
  --surface-strong: rgba(235, 230, 223, 0.08);
  --elevated: rgba(28, 26, 23, 0.88);
  --elevated-hover: #2a2723;
  --error: #e08a8a;
  --glow-warm: rgba(235, 230, 223, 0.06);
  --glow-accent: rgba(122, 175, 157, 0.1);
  --main-glow: rgba(122, 175, 157, 0.08);
  --main-shadow: rgba(0, 0, 0, 0.45);
  --grain-opacity: 0.14;
}

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

html {
  background-color: var(--bg-deep);
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 700px at 12% -10%, var(--glow-warm), transparent 55%),
    radial-gradient(900px 600px at 90% 0%, var(--glow-accent), transparent 50%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  line-height: 1.5;
  overscroll-behavior-y: none;
}

.skip-link {
  position: absolute;
  left: 0.75rem;
  top: 0.75rem;
  z-index: 100;
  padding: 0.55rem 0.85rem;
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  border-radius: var(--radius);
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: translateY(0);
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.45'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

.hero,
main,
.site-footer {
  position: relative;
}

.hero {
  z-index: 1;
  background: #1c1a17;
  animation: hero-in 1.1s ease both;
  /* Always reserve viewport height so async album load does not cause CLS */
  min-height: min(100svh, 760px);
}

.hero[hidden] {
  /* Fatal-error path only: collapse intentionally */
  display: none;
}

.hero-media {
  position: relative;
  z-index: 0;
  height: min(100svh, 760px);
  overflow: hidden;
  background: #1c1a17;
}

.hero-shot {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  appearance: none;
  -webkit-appearance: none;
}

.hero-shot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transform: scale(1.04);
  opacity: 0;
  transition: opacity 0.45s ease;
  animation: none;
}

.hero-shot img.is-ready {
  opacity: 1;
  animation: hero-ken 18s ease-out both;
}

@media (prefers-reduced-motion: reduce) {
  .hero-shot img.is-ready {
    animation: none;
    transform: none;
  }
}

.hero-shot:focus-visible {
  outline: 2px solid #ebe6df;
  outline-offset: -6px;
}

.hero-scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(20, 18, 16, 0.28) 35%,
    rgba(20, 18, 16, 0.72) 100%
  );
}

.hero-copy {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  align-content: end;
  justify-items: center;
  width: 100%;
  height: 100%;
  padding: clamp(4rem, 14vh, 7rem) clamp(1.25rem, 4vw, 3rem) clamp(2rem, 5vh, 3rem);
  text-align: center;
  color: #f4f0ea;
  pointer-events: none;
  animation: rise 1s ease 0.15s both;
}

.hero-spacer {
  display: none;
}

.hero .brand {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 8vw, 5.2rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.02;
  color: #e4d2a8;
  text-shadow: 0 2px 28px rgba(0, 0, 0, 0.35);
}

.hero .tagline {
  margin: 0.85rem auto 0;
  max-width: 34rem;
  color: rgba(244, 240, 234, 0.88);
  font-size: clamp(0.95rem, 2.2vw, 1.1rem);
  font-weight: 500;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.35);
}

.hero-cta {
  display: inline-block;
  margin-top: 1.35rem;
  padding: 0 0 0.15rem;
  border: 0;
  border-bottom: 1px solid rgba(244, 240, 234, 0.55);
  background: transparent;
  color: #f4f0ea;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  pointer-events: auto;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.3s ease, opacity 0.3s ease;
}

.hero-cta:hover,
.hero-cta:focus-visible {
  border-bottom-color: #f4f0ea;
  outline: none;
}

.hero-cta:focus-visible {
  outline: 2px solid #ebe6df;
  outline-offset: 4px;
}

main {
  z-index: 2;
  padding: var(--page-pad);
  padding-bottom: 3rem;
  background:
    radial-gradient(900px 500px at 85% 0%, var(--main-glow), transparent 55%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  box-shadow: 0 -24px 48px var(--main-shadow);
}

.site-footer {
  z-index: 2;
  background: var(--bg-deep);
}

@media (prefers-reduced-motion: reduce) {
  .hero-copy { animation: none; }
}

.status {
  margin: 0 auto;
  max-width: 40rem;
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.95rem;
  /* Avoid a jump when "Loading…" is cleared */
  min-height: 1.5rem;
}

.status:not([hidden]) {
  margin-bottom: var(--page-pad);
}

.status[hidden],
.tagline[hidden],
.back-to-top[hidden] {
  display: none;
}

.status.is-error {
  color: var(--error);
}

.status.is-fatal:not([hidden]) {
  margin: clamp(3rem, 12vh, 6rem) auto;
  max-width: 32rem;
  color: var(--ink);
}

.status-panel {
  padding: 1.75rem 1.25rem;
  text-align: left;
  background:
    linear-gradient(180deg, var(--glow-warm), transparent 60%),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
}

.status-kicker {
  margin: 0 0 0.4rem;
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-title {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 4vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--ink);
}

.status-body {
  margin: 0 0 1rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.status-hints {
  margin: 0 0 1.35rem;
  padding-left: 1.15rem;
  color: var(--ink-soft);
  font-size: 0.88rem;
  line-height: 1.55;
}

.status-hints li + li {
  margin-top: 0.35rem;
}

.status-hints code {
  font-size: 0.84em;
  color: var(--ink);
}

.status-retry {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.4rem;
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--bg);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: opacity 0.2s ease;
}

.status-retry:hover,
.status-retry:focus-visible {
  opacity: 0.88;
  outline: none;
}

.status-retry:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.gallery {
  max-width: 1440px;
  margin: 0 auto;
  min-height: 40vh;
  scroll-margin-top: var(--page-pad);
}

.gallery-item {
  display: block;
  position: relative;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 6px;
  background: var(--surface-strong);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: zoom-in;
  appearance: none;
  -webkit-appearance: none;
  /* Do not use fill-mode "both" — dynamically inserted masonry items can
     get stuck at opacity: 0 if the animation never starts (hover "fixes" it). */
  opacity: 1;
  animation: fade-in 0.7s ease;
}

.gallery-item:focus {
  outline: none;
}

.gallery-item img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  transition: transform 0.7s cubic-bezier(0.22, 1, 0.36, 1), filter 0.5s ease;
  background: var(--surface-strong);
}

.gallery-item:hover img,
.gallery-item:focus-visible img {
  transform: scale(1.03);
  filter: contrast(1.03) saturate(1.05);
}

.gallery-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.gallery-item .meta {
  position: absolute;
  inset: auto 0 0;
  padding: 1.1rem 0.75rem 0.65rem;
  background: linear-gradient(transparent, rgba(20, 18, 16, 0.78));
  color: #f4f0ea;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}

.gallery-item:hover .meta,
.gallery-item:focus-visible .meta {
  opacity: 1;
  transform: translateY(0);
}

@media (hover: none) {
  .gallery-item .meta {
    opacity: 1;
    transform: none;
    background: linear-gradient(transparent, rgba(20, 18, 16, 0.55));
  }
}

.meta-primary {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.meta-detail {
  margin: 0.2rem 0 0;
  font-size: 0.64rem;
  line-height: 1.35;
  opacity: 0.88;
  font-weight: 500;
}

/* Compact hover metadata on smaller laptop/desktop viewports. */
@media (max-width: 1366px), (max-height: 820px) {
  .gallery-item .meta {
    padding: 0.9rem 0.65rem 0.55rem;
  }

  .meta-primary {
    font-size: 0.76rem;
  }

  .meta-detail {
    font-size: 0.61rem;
    line-height: 1.3;
  }
}

/* Touch / small screens: keep place + date only (hide camera EXIF clutter). */
@media (max-width: 560px), (hover: none) {
  .gallery-item .meta-exif {
    display: none;
  }

  .gallery-item .meta .meta-date {
    margin-top: 0;
    font-family: var(--font-display);
    font-size: 0.92rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    opacity: 1;
  }

  .gallery-item .meta .meta-place + .meta-date {
    margin-top: 0.2rem;
    font-family: var(--font-body);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: normal;
    opacity: 0.88;
  }
}

/* Masonry: column widths leave room for JS gutter === --gap */
.gallery.is-masonry {
  margin: 0 auto;
}

/* Sizer is width-only — no margin (margin was adding phantom top space) */
.gallery.is-masonry .gallery-sizer {
  width: calc((100% - 2 * var(--gap)) / 3);
  margin: 0;
  padding: 0;
  border: 0;
}

.gallery.is-masonry .gallery-item {
  width: calc((100% - 2 * var(--gap)) / 3);
  margin-bottom: var(--gap);
}

@media (max-width: 900px) {
  .gallery.is-masonry .gallery-sizer,
  .gallery.is-masonry .gallery-item {
    width: calc((100% - var(--gap)) / 2);
  }
}

@media (max-width: 560px) {
  .gallery.is-masonry .gallery-sizer,
  .gallery.is-masonry .gallery-item {
    width: 100%;
  }
}

/* Justified Gallery */
.gallery.is-justified .gallery-item {
  margin: 0;
}

.site-footer {
  padding: 2rem var(--page-pad) 2.75rem;
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.site-footer p {
  margin: 0;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.site-footer .footer-sep {
  width: 1px;
  height: 0.85em;
  background: var(--line);
}

.site-footer a {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.2rem;
  color: inherit;
  text-decoration: none;
  letter-spacing: 0.04em;
  text-transform: none;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s ease;
}

.site-footer .footer-github-icon {
  flex-shrink: 0;
  opacity: 0.85;
}

.site-footer a:hover,
.site-footer a:focus-visible {
  color: var(--ink);
  outline: none;
}

.back-to-top {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 40;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.65rem;
  height: 2.65rem;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--elevated);
  color: var(--ink);
  box-shadow: 0 8px 24px rgba(28, 26, 23, 0.12);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  backdrop-filter: blur(8px);
  transition: opacity 0.25s ease, transform 0.25s ease, background-color 0.2s ease;
}

.back-to-top:hover,
.back-to-top:focus-visible {
  background: var(--elevated-hover);
  outline: none;
}

.back-to-top:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .back-to-top {
    transition: none;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes hero-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes hero-ken {
  from {
    transform: scale(1.08);
  }
  to {
    transform: scale(1.02);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.pswp__custom-caption {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(90vw, 40rem);
  padding: 0.5rem 0.9rem;
  color: #f4f0ea;
  font: 500 0.85rem var(--font-body);
  text-align: center;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 4px;
}

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