:root {
  color-scheme: dark;
  --background: #0a0c0f;
  --surface: #12151a;
  --surface-high: #191d23;
  --surface-highest: #222730;
  --primary: #d7e0ff;
  --on-primary: #17213a;
  --secondary: #b4b8bf;
  --text: #f3f4f6;
  --muted: #9da5b0;
  --outline: rgba(255, 255, 255, 0.1);
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.4);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --radius: 6px;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  background: var(--background);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  background: var(--background);
  color: var(--text);
  font-family: var(--sans);
  font-feature-settings: "kern" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(255, 255, 255, 0.2); }

a { color: inherit; }

button,
a { -webkit-tap-highlight-color: transparent; }

button { font: inherit; }

.view[hidden] { display: none; }

.location-index,
.location-detail,
.error-view { min-height: 100vh; }

.view-enter { animation: view-in 520ms var(--ease-out) both; }

.index-hero,
.detail-hero,
.error-view,
.location-list,
#album-list {
  width: min(100% - clamp(32px, 6vw, 96px), 1440px);
  margin-inline: auto;
}

.index-hero {
  padding: clamp(88px, 14vh, 156px) 0 clamp(48px, 7vh, 80px);
}

.detail-hero {
  padding: clamp(44px, 7vh, 76px) 0 clamp(44px, 7vh, 84px);
}

.error-view { padding-top: clamp(88px, 14vh, 156px); }

.overline {
  margin: 0 0 18px;
  color: var(--secondary);
  font-size: 0.7rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.2em;
}

h1 {
  max-width: 1100px;
  margin: 0;
  font-size: clamp(3.5rem, 9vw, 7.5rem);
  font-weight: 500;
  line-height: 0.95;
  letter-spacing: -0.04em;
}

.detail-hero h1 {
  font-size: clamp(3rem, 7vw, 6rem);
}

.hero-copy {
  max-width: 620px;
  margin: 30px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.5vw, 1.25rem);
  line-height: 1.6;
}

.hero-meta {
  margin-top: 18px;
  font-size: 0.95rem;
}

.back-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: clamp(40px, 7vh, 72px);
  margin-left: -4px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 160ms ease;
}

.back-button:hover { color: var(--text); }

.location-list {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: clamp(16px, 2vw, 28px);
  padding-bottom: clamp(88px, 12vh, 144px);
}

.location-card {
  position: relative;
  grid-column: span 6;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  isolation: isolate;
}

.location-card:only-child {
  grid-column: 1 / -1;
  aspect-ratio: 21 / 9;
}

.location-card::after {
  position: absolute;
  inset: 0;
  z-index: 1;
  content: "";
  pointer-events: none;
  background: linear-gradient(180deg, transparent 55%, rgba(0, 0, 0, 0.7) 100%);
}

.location-card img {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition:
    opacity 700ms ease,
    transform 900ms var(--ease-out);
}

.location-card.is-loaded img { opacity: 1; }

.location-card:hover img { transform: scale(1.03); }

.location-card-copy {
  position: absolute;
  right: clamp(20px, 2.5vw, 32px);
  bottom: clamp(18px, 2.2vw, 28px);
  left: clamp(20px, 2.5vw, 32px);
  z-index: 2;
}

.location-card h2 {
  margin: 0;
  font-size: clamp(1.6rem, 2.6vw, 2.4rem);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.location-meta {
  margin: 6px 0 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.8rem;
}

#album-list { padding-bottom: clamp(88px, 12vh, 144px); }

.album { margin-top: clamp(42px, 6vw, 84px); }

.album:first-child { margin-top: 0; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-rows: clamp(170px, 17vw, 330px);
  grid-auto-flow: dense;
  gap: clamp(8px, 1vw, 14px);
}

.photo {
  position: relative;
  grid-column: span 4;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius);
  background:
    linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.04) 45%, transparent 60%),
    var(--surface-high);
  background-size: 250% 100%;
  cursor: zoom-in;
  animation: placeholder-shimmer 1.8s linear infinite;
}

/* Tile sizes are assigned by tileLayout() in app.js so rows always fill */
.tile-large { grid-column: span 8; grid-row: span 2; }
.tile-large.tile-right { grid-column: 5 / span 8; }
.tile-half { grid-column: span 6; grid-row: span 2; }
.tile-full { grid-column: 1 / -1; grid-row: span 2; }

.photo img {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: var(--ratio, 4 / 3);
  object-fit: cover;
  opacity: 0;
  transition:
    opacity 600ms ease,
    filter 250ms ease;
}

.photo.is-loaded {
  background: var(--surface-high);
  animation: none;
}

.photo.is-loaded img { opacity: 1; }

.photo:hover img { filter: brightness(0.9); }

.photo-label {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
  padding: 68px 18px 17px;
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.76rem;
  font-weight: 520;
  line-height: 1.4;
  text-align: left;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
  opacity: 0;
  transform: translateY(5px);
  transition: opacity 200ms ease, transform 250ms var(--ease-out);
}

.photo:hover .photo-label,
.photo:focus-visible .photo-label {
  opacity: 1;
  transform: translateY(0);
}

.reveal {
  opacity: 0;
  transform: translateY(18px);
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 700ms var(--ease-out) var(--reveal-delay, 0ms),
    transform 700ms var(--ease-out) var(--reveal-delay, 0ms);
}

.status {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.9rem;
}

footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  padding: 42px clamp(20px, 4vw, 64px);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  color: var(--muted);
  font-size: 0.75rem;
}

footer a {
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  transition: color 160ms ease;
}

footer a:hover { color: white; }

.location-card:focus-visible,
.photo:focus-visible,
.icon-button:focus-visible,
.lightbox-arrow:focus-visible,
.back-button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 4px;
}

.lightbox {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  padding: 0;
  border: 0;
  background: rgba(7, 9, 12, 0.96);
  color: white;
  opacity: 0;
}

.lightbox[open] {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 72px;
  opacity: 1;
  animation: lightbox-in 260ms ease both;
}

.lightbox::backdrop {
  background: rgba(3, 4, 6, 0.8);
  backdrop-filter: blur(18px);
}

.lightbox figure {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-width: 0;
  margin: 0;
}

.lightbox-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 58px 20px 14px;
  touch-action: pan-y;
}

.lightbox-stage img {
  position: relative;
  z-index: 1;
  max-width: 100%;
  max-height: calc(100dvh - 140px);
  border-radius: 2px;
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.42);
  object-fit: contain;
  opacity: 1;
  transform: scale(1);
  transition: opacity 220ms ease, transform 350ms var(--ease-out);
}

.lightbox.is-loading .lightbox-stage img {
  opacity: 0;
  transform: scale(0.992);
}

.lightbox-loading {
  position: absolute;
  color: rgba(255, 255, 255, 0.48);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  opacity: 0;
  transition: opacity 180ms ease;
}

.lightbox.is-loading .lightbox-loading { opacity: 1; }

.lightbox figcaption {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  min-height: 74px;
  padding: 18px 20px 24px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.82rem;
}

.lightbox-caption:empty { display: none; }

.lightbox-context {
  margin-left: auto;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.7rem;
  letter-spacing: 0.025em;
}

.icon-button,
.lightbox-arrow {
  position: relative;
  z-index: 2;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.58);
  cursor: pointer;
  font-size: 1.25rem;
  transition: color 160ms ease, background 160ms ease, transform 180ms var(--ease-out);
}

.lightbox-arrow:hover {
  color: white;
  transform: scale(1.08);
}

.lightbox-close {
  position: fixed;
  z-index: 20;
  top: 16px;
  right: 18px;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 50%;
  background: rgba(25, 29, 35, 0.82);
  color: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(16px);
}

.lightbox-close:hover {
  background: rgba(40, 45, 54, 0.96);
  color: white;

}

@keyframes placeholder-shimmer {
  from { background-position: 100% 0; }
  to { background-position: -150% 0; }
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@media (max-width: 900px) {
  .location-card { grid-column: 1 / -1; }
  .photo { grid-column: span 6; }
  .tile-large,
  .tile-large.tile-right,
  .tile-row-end { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  .index-hero,
  .detail-hero,
  .error-view,
  .location-list,
  #album-list { width: min(100% - 28px, 1440px); }

  .index-hero { padding-top: 76px; }
  h1 { font-size: clamp(3rem, 17vw, 4.5rem); }
  .detail-hero h1 { font-size: clamp(2.5rem, 13vw, 3.75rem); }

  .location-card,
  .location-card:only-child { aspect-ratio: 4 / 5; }

  /* One photo per row at its natural shape */
  .photo-grid { grid-auto-rows: auto; }

  .photo,
  .photo[class*="tile-"] {
    grid-column: 1 / -1;
    grid-row: auto;
  }

  .photo img { height: auto; }

  .lightbox[open] { grid-template-columns: 44px minmax(0, 1fr) 44px; }
  .lightbox-stage { padding-inline: 0; }
  .lightbox figcaption { flex-direction: column; gap: 6px; padding-inline: 8px; }
  .lightbox-context { margin-left: 0; }
  .lightbox-close { top: 10px; right: 10px; }
  footer { padding-inline: 14px; }
}

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

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .reveal { opacity: 1; transform: none; }
}
