/* Ben & Killy — album site
   Zigzag timeline: oldest at the bottom, newest at the top. */

:root {
  --ink: #0c0e13;
  --ink-2: #12161d;
  --ink-3: #1a2029;
  --paper: #f4efe7;
  --muted: #98a2b3;
  --line: rgba(244, 239, 231, 0.14);
  --accent: #e8b06a;
  --accent-2: #c98bb0;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --rail-x: 50%;
  --rail-w: 2px;
  --gut: clamp(16px, 4vw, 48px);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 700px at 78% -10%, rgba(232, 176, 106, 0.14), transparent 60%),
    radial-gradient(900px 600px at 8% 12%, rgba(201, 139, 176, 0.10), transparent 62%),
    var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}

img, video { display: block; max-width: 100%; }
a { color: inherit; }

/* ---------- top bar ---------- */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px var(--gut);
  backdrop-filter: blur(14px);
  background: linear-gradient(to bottom, rgba(12, 14, 19, 0.86), rgba(12, 14, 19, 0.35));
  border-bottom: 1px solid var(--line);
}

.brand {
  font-family: var(--serif);
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
}
.brand i { color: var(--accent); font-style: normal; }

.topbar-right { display: flex; align-items: center; gap: 10px; }

.hint {
  font-size: 0.78rem;
  color: var(--muted);
  transition: opacity 0.6s ease;
}
.hint.gone { opacity: 0; }

.year-chip {
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  color: var(--ink);
  background: var(--accent);
  border-radius: 999px;
  padding: 3px 11px;
  font-weight: 600;
}

.ghost-btn {
  font: inherit;
  font-size: 0.78rem;
  color: var(--paper);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
}
.ghost-btn:hover { background: rgba(244, 239, 231, 0.08); border-color: rgba(244, 239, 231, 0.3); }

/* ---------- cover (the "now" end of the timeline) ---------- */

.cover {
  min-height: 74vh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 120px var(--gut) 40px;
}

.kicker {
  margin: 0 0 10px;
  font-size: 0.76rem;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--accent);
}

.cover-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.6rem, 8vw, 5.4rem);
  line-height: 1.02;
  letter-spacing: -0.01em;
}

.cover-line {
  max-width: 46ch;
  margin: 20px auto 0;
  color: var(--muted);
  font-size: clamp(0.95rem, 1.4vw, 1.08rem);
}

.cover-count { margin: 18px 0 0; font-size: 0.85rem; letter-spacing: 0.18em; color: var(--paper); opacity: 0.7; }
.cover-scroll { margin-top: 34px; font-size: 0.8rem; color: var(--muted); animation: float 2.6s ease-in-out infinite; }

@keyframes float {
  0%, 100% { transform: translateY(0); opacity: 0.55; }
  50% { transform: translateY(-7px); opacity: 1; }
}

/* ---------- timeline ---------- */

.timeline {
  list-style: none;
  position: relative;
  margin: 0 auto;
  padding: 4vh var(--gut) 12vh;
  max-width: 1280px;
}

.rail {
  position: absolute;
  left: var(--rail-x);
  top: 0;
  bottom: 0;
  width: var(--rail-w);
  transform: translateX(-50%);
  background: var(--line);
}

.rail-fill {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  transform-origin: bottom center;
  transform: scaleY(0);
  background: linear-gradient(to top, var(--accent), var(--accent-2));
  box-shadow: 0 0 18px rgba(232, 176, 106, 0.35);
  transition: transform 0.25s linear;
}

.entry {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px minmax(0, 1fr);
  align-items: center;
  column-gap: 0;
  margin: 7vh 0;
}

.entry .thumb {
  position: relative;
  display: block;
  border-radius: 20px;
  overflow: hidden;
  background: var(--ink-2);
  box-shadow: 0 26px 60px -28px rgba(0, 0, 0, 0.9), 0 2px 0 rgba(244, 239, 231, 0.05) inset;
  text-decoration: none;
  opacity: 0;
  transform: translate3d(var(--dx, 0), 30px, 0);
  transition: opacity 0.85s ease, transform 1.05s cubic-bezier(0.16, 0.84, 0.24, 1), box-shadow 0.5s ease;
}

.entry .thumb img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  transform: scale(1.07);
  transition: transform 1.6s cubic-bezier(0.16, 0.84, 0.24, 1), filter 0.6s ease;
}

.entry .thumb::after {
  content: "open album →";
  position: absolute;
  left: 16px;
  bottom: 14px;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--paper);
  background: rgba(12, 14, 19, 0.62);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  backdrop-filter: blur(6px);
}

.entry .thumb:hover { box-shadow: 0 34px 70px -26px rgba(0, 0, 0, 0.95); }
.entry .thumb:hover::after { opacity: 1; transform: none; }
.entry .thumb:hover img { transform: scale(1.045); }

.entry.side-right { --dx: 46px; }
.entry.side-left { --dx: -46px; }

.entry.side-right .thumb { grid-column: 3; }
.entry.side-right .meta { grid-column: 1; text-align: right; align-items: flex-end; }
.entry.side-left .thumb { grid-column: 1; }
.entry.side-left .meta { grid-column: 3; text-align: left; align-items: flex-start; }

.entry .meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 clamp(14px, 1.6vw, 26px);
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.9s ease 0.1s, transform 0.9s cubic-bezier(0.16, 0.84, 0.24, 1) 0.1s;
}

.entry.in .thumb,
.entry.in .meta { opacity: 1; transform: none; }
.entry.in .thumb img { transform: scale(1); }

.entry .date {
  font-size: 0.76rem;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--accent);
}

.entry .name {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.7rem, 3.2vw, 2.7rem);
  line-height: 1.06;
}
.entry .name a { text-decoration: none; }
.entry .name a:hover { color: var(--accent); }

.entry .caption { margin: 2px 0 0; color: var(--muted); font-size: 0.95rem; max-width: 34ch; }

.entry .counts {
  margin-top: 8px;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  color: var(--paper);
  opacity: 0.65;
}

.entry .pin {
  margin-top: 4px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.node {
  position: absolute;
  left: var(--rail-x);
  top: 50%;
  transform: translate(-50%, -50%) scale(0.4);
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--accent);
  transition: transform 0.7s cubic-bezier(0.16, 0.84, 0.24, 1), box-shadow 0.4s ease, background 0.4s ease;
}
.entry.in .node { transform: translate(-50%, -50%) scale(1); }
.entry:hover .node { background: var(--accent); box-shadow: 0 0 0 7px rgba(232, 176, 106, 0.16); }

.year-row {
  position: relative;
  display: flex;
  justify-content: center;
  margin: 5vh 0 1vh;
}
.year-row .chip {
  position: relative;
  z-index: 1;
  font-family: var(--serif);
  font-size: 1.05rem;
  letter-spacing: 0.2em;
  color: var(--paper);
  background: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 20px;
}

.endcard {
  text-align: center;
  padding: 6vh var(--gut) 14vh;
  border-top: 1px solid var(--line);
}
.end-title { font-family: var(--serif); font-size: 1.6rem; margin: 0; }
.end-date { color: var(--accent); letter-spacing: 0.2em; text-transform: uppercase; font-size: 0.78rem; margin: 8px 0 22px; }
.end-link { color: var(--muted); font-size: 0.85rem; text-decoration: none; border-bottom: 1px solid var(--line); padding-bottom: 2px; }
.end-link:hover { color: var(--paper); }

/* ---------- album page ---------- */

.album-head { padding: 96px var(--gut) 26px; max-width: 1180px; margin: 0 auto; }
.back { font-size: 0.8rem; color: var(--muted); text-decoration: none; letter-spacing: 0.14em; text-transform: uppercase; }
.back:hover { color: var(--paper); }
.album-head-inner { margin-top: 26px; }
.album-head h1 {
  margin: 6px 0 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.2rem, 6vw, 4rem);
  line-height: 1.04;
}
.album-sub { color: var(--muted); font-size: 0.86rem; letter-spacing: 0.06em; margin: 12px 0 0; }
.album-sub .dot { opacity: 0.5; margin: 0 8px; }
.album-sub a { color: var(--accent); text-decoration: none; }
.album-caption { color: var(--paper); opacity: 0.8; max-width: 60ch; margin: 14px 0 0; }

.album-main { max-width: 1320px; margin: 0 auto; padding: 20px var(--gut) 14vh; }

/* flexible mosaic: every photo keeps its own aspect ratio and the pieces pack
   tight like tetris (row spans are computed per tile in album.js) */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  grid-auto-rows: 8px;
  grid-auto-flow: dense;
  gap: 12px;
}

.tile {
  position: relative;
  display: block;
  grid-row-end: span var(--span, 14);
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  background: var(--ink-2);
  border-radius: 14px;
  overflow: hidden;
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.16, 0.84, 0.24, 1);
}
.tile.in { opacity: 1; transform: none; }
.tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.7s ease, filter 0.5s ease;
}
.tile:hover img { transform: scale(1.05); }
.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.45), transparent 55%);
  opacity: 0;
  transition: opacity 0.35s ease;
}
.tile:hover::after { opacity: 1; }

.tile .badge {
  position: absolute;
  right: 10px;
  bottom: 10px;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--paper);
  background: rgba(12, 14, 19, 0.72);
  border-radius: 999px;
  padding: 3px 9px;
  backdrop-filter: blur(4px);
}

.tile.is-video .play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.tile.is-video .play span {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 1px solid rgba(244, 239, 231, 0.7);
  background: rgba(12, 14, 19, 0.45);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  padding-left: 4px;
  transition: transform 0.35s ease, background 0.35s ease;
}
.tile.is-video:hover .play span { transform: scale(1.08); background: rgba(232, 176, 106, 0.85); }

.empty { color: var(--muted); text-align: center; padding: 8vh 0; }

/* ---------- grid ↔ viewer zoom ----------
   The tapped tile and the full-screen image share one view-transition-name, so
   the browser itself grows the thumbnail into the viewer (same-document View
   Transitions). The tile is excluded from the root snapshot while it morphs. */

::view-transition-group(bkk-photo) {
  animation-duration: 0.45s;
  animation-timing-function: cubic-bezier(0.22, 0.61, 0.36, 1);
}
::view-transition-old(bkk-photo),
::view-transition-new(bkk-photo) {
  animation-duration: 0.45s;
  animation-timing-function: cubic-bezier(0.22, 0.61, 0.36, 1);
}
::view-transition-group(root) { animation-duration: 0.35s; }

.tile img { contain: layout; }

/* lazy-load trigger at the end of the grid; invisible, full width */
.grid-sentinel {
  grid-column: 1 / -1;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ---------- lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(6, 7, 10, 0.94);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4vh 4vw;
}

/* the [hidden] attribute must win over display:flex, otherwise the lightbox
   sits open on top of the grid from the moment the page loads */
.lightbox[hidden] { display: none; }

.lb-stage { display: grid; place-items: center; max-height: 84vh; max-width: 100%; }
.lb-stage img, .lb-stage video {
  max-height: 82vh;
  max-width: 92vw;
  border-radius: 10px;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 1);
}
.lb-stage img { opacity: 0; transition: opacity 0.35s ease; }
.lb-stage img.ready { opacity: 1; }

.lb-bar { margin-top: 14px; font-size: 0.78rem; color: var(--muted); letter-spacing: 0.1em; display: flex; gap: 14px; }
.lb-name { opacity: 0.6; }

.lb-close, .lb-nav {
  position: absolute;
  font: inherit;
  color: var(--paper);
  background: rgba(244, 239, 231, 0.06);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.25s ease, transform 0.25s ease;
}
.lb-close { top: 18px; right: 18px; width: 42px; height: 42px; font-size: 1.4rem; line-height: 1; }
.lb-nav { top: 50%; width: 46px; height: 46px; font-size: 1.6rem; line-height: 1; transform: translateY(-50%); }
.lb-prev { left: 18px; }
.lb-next { right: 18px; }
.lb-close:hover, .lb-nav:hover { background: rgba(232, 176, 106, 0.85); color: #1a1206; }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  :root { --rail-x: 22px; }
  .entry {
    grid-template-columns: 44px minmax(0, 1fr);
    margin: 8vh 0;
  }
  .entry.side-right .thumb, .entry.side-left .thumb { grid-column: 2; grid-row: 1; }
  .entry.side-right .meta, .entry.side-left .meta {
    grid-column: 2;
    grid-row: 2;
    text-align: left;
    align-items: flex-start;
    padding: 16px 0 0;
  }
  .entry.side-left { --dx: 24px; }
  .entry.side-right { --dx: 24px; }
  .hint { display: none; }
  .cover { min-height: 66vh; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .tile { border-radius: 10px; }
  .lb-prev { left: 6px; }
  .lb-next { right: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .entry .thumb, .entry .meta, .tile { transition: opacity 0.3s ease; transform: none !important; }
  .entry .thumb img { transform: none; }
  .cover-scroll { animation: none; }
  .rail-fill { transition: none; }
}
