/* ── Reset & tokens ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #090806;
  --surface:      #131109;
  --border:       #252018;
  --text:         #ede8df;
  --muted:        #6e6358;
  --dim:          #35302a;
  --accent:       #c8955a;
  --accent-hi:    #dba870;
  --accent-dim:   rgba(200, 149, 90, 0.18);
  --spine-left:   108px;
  --transition:   220ms ease;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  font-weight: 300;
  line-height: 1.6;
  min-height: 100dvh;
}

/* Subtle film grain overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
  opacity: .028;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(9, 8, 6, 0.94);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  padding: 14px 40px;
  display: flex;
  align-items: center;
  gap: 24px;
}

h1 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.2rem;
  font-weight: 300;
  letter-spacing: .06em;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-name {
  font-style: italic;
  letter-spacing: .1em;
}
.header-divider {
  color: var(--dim);
  font-style: normal;
  font-weight: 300;
}
h1 span:last-child {
  color: var(--muted);
  font-style: normal;
  font-size: 1rem;
  letter-spacing: .14em;
  text-transform: uppercase;
}

/* ── Category pills ───────────────────────────────────────────────────────── */
#category-nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pill {
  background: none;
  border: 1px solid var(--border);
  border-radius: 0;
  color: var(--muted);
  cursor: pointer;
  font-family: 'DM Mono', monospace;
  font-size: .6rem;
  font-weight: 400;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 4px 14px;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition);
}
.pill:hover { border-color: var(--accent); color: var(--accent); }
.pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #09080a;
  font-weight: 400;
}

/* ── Sort toggle ──────────────────────────────────────────────────────────── */
.sort-btn {
  margin-left: auto;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  font-family: 'DM Mono', monospace;
  font-size: .6rem;
  font-weight: 300;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 2px 0;
  transition: border-color var(--transition), color var(--transition);
  white-space: nowrap;
}
.sort-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Timeline container ───────────────────────────────────────────────────── */
main {
  padding: 48px 0 120px;
}

/* Spine line running through the full gallery */
#gallery {
  position: relative;
  max-width: 900px;
  margin: 0 auto;
}
#gallery::before {
  content: '';
  position: absolute;
  left: calc(var(--spine-left) - 1px);
  top: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(
    to bottom,
    transparent 0,
    rgba(200, 149, 90, 0.15) 60px,
    rgba(200, 149, 90, 0.15) calc(100% - 60px),
    transparent 100%
  );
  pointer-events: none;
}

/* ── Month / Year marker ──────────────────────────────────────────────────── */
.timeline-month {
  display: grid;
  grid-template-columns: var(--spine-left) 1fr;
  padding: 36px 0 18px;
  position: relative;
}

/* Dot on the spine for month markers */
.timeline-month-dot {
  display: flex;
  justify-content: flex-end;
  padding-top: 10px;
}
.timeline-month-dot::after {
  content: '';
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--dim);
  margin-right: -2.5px;
  flex-shrink: 0;
}

.timeline-month-label {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-right: 40px;
}
.timeline-month-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--border), transparent);
}

.timeline-month-text {
  font-family: 'DM Mono', monospace;
  font-size: .85rem;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: .14em;
  text-transform: uppercase;
  white-space: nowrap;
}
.timeline-month-text strong {
  color: var(--accent);
  font-weight: 400;
}


/* ── Timeline entry ───────────────────────────────────────────────────────── */
.timeline-entry {
  display: grid;
  grid-template-columns: var(--spine-left) 1fr;
  margin-bottom: 64px;
  cursor: pointer;
  opacity: 0;
  animation: entryReveal 560ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: calc(min(var(--entry-idx, 0), 6) * 50ms);
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

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

/* Spine column — holds the dot and date labels */
.entry-spine {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding-top: 22px;
  padding-right: 0;
  gap: 4px;
  position: relative;
  z-index: 2;
}

.entry-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  margin-right: -4px; /* center on the 1px spine line */
  box-shadow: 0 0 10px rgba(200, 149, 90, 0.5);
  transition: box-shadow var(--transition), background var(--transition);
}
.timeline-entry:hover .entry-dot {
  box-shadow: 0 0 18px rgba(200, 149, 90, 0.75);
  background: var(--accent-hi);
}

.entry-date-month {
  font-family: 'DM Mono', monospace;
  font-size: .55rem;
  font-weight: 400;
  color: var(--accent);
  letter-spacing: .14em;
  text-transform: uppercase;
  text-align: right;
  line-height: 1;
  padding-right: 16px;
  margin-top: 6px;
}

.entry-date-day {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 2rem;
  font-weight: 300;
  color: var(--muted);
  line-height: 1;
  text-align: right;
  padding-right: 13px;
  transition: color var(--transition);
}
.timeline-entry:hover .entry-date-day { color: var(--text); }

/* ── Art gallery frame ────────────────────────────────────────────────────── */

/* Content column: stacks the frame and museum plaque */
.entry-content {
  display: flex;
  flex-direction: column;
  margin-right: 40px;
  position: relative;
  z-index: 1;
}

/* Gallery spotlight from above, revealed on hover */
.entry-content::before {
  content: '';
  position: absolute;
  top: -70px;
  left: 20%;
  width: 320px;
  height: 90px;
  background: radial-gradient(ellipse at center, rgba(200,149,90,0.09) 0%, transparent 70%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 600ms ease;
  z-index: 0;
}
.timeline-entry:hover .entry-content::before { opacity: 1; }

/* Picture frame — dark wood with subtle gradient sheen */
.entry-frame {
  position: relative;
  z-index: 1;
  padding: 14px;
  background: linear-gradient(150deg, #2c2016 0%, #1c160e 55%, #2a1e12 100%);
  border: 1px solid #3d2d18;
  box-shadow:
    inset 0 0 0 1px rgba(200,149,90,0.07),
    0 2px 6px rgba(0,0,0,0.45),
    0 12px 40px rgba(0,0,0,0.55),
    0 32px 80px rgba(0,0,0,0.35);
  transition: transform 500ms cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 500ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* Alternating subtle tilt — like pieces hanging slightly off-level */
.timeline-entry:nth-child(odd) .entry-frame  { transform: rotate(-0.6deg); }
.timeline-entry:nth-child(even) .entry-frame { transform: rotate(0.5deg); }

/* Straighten and lift on hover */
.timeline-entry:hover .entry-frame {
  transform: rotate(0deg);
  box-shadow:
    inset 0 0 0 1px rgba(200,149,90,0.12),
    0 4px 10px rgba(0,0,0,0.5),
    0 20px 60px rgba(0,0,0,0.65),
    0 44px 100px rgba(0,0,0,0.4);
}

/* Thin inner mat line — the cream-coloured mount behind the image */
.entry-frame::after {
  content: '';
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(200,149,90,0.1);
  pointer-events: none;
  z-index: 2;
}

/* Image container clips the zoom animation so it stays inside the mat */
.entry-img-container {
  position: relative;
  overflow: hidden;
  background: var(--surface);
}

.entry-image {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  opacity: 0;
  transition: opacity 700ms ease, transform 700ms cubic-bezier(0.22, 1, 0.36, 1);
  transform: scale(1.04);
  will-change: transform, opacity;
}
.entry-image.loaded {
  opacity: 1;
  transform: scale(1);
}
.timeline-entry:hover .entry-image { transform: scale(1.025); }

/* ── Museum plaque ────────────────────────────────────────────────────────── */
.entry-plaque {
  margin-top: 16px;
  padding: 0 2px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  opacity: 0.85;
  transition: opacity var(--transition);
}
.timeline-entry:hover .entry-plaque { opacity: 1; }

.plaque-category {
  font-family: 'DM Mono', monospace;
  font-size: .52rem;
  font-weight: 400;
  color: var(--accent);
  letter-spacing: .18em;
  text-transform: uppercase;
}

.plaque-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.75rem;
  font-weight: 300;
  font-style: italic;
  color: var(--text);
  line-height: 1.15;
  letter-spacing: .02em;
}

.plaque-date {
  font-family: 'DM Mono', monospace;
  font-size: .52rem;
  font-weight: 300;
  color: var(--muted);
  letter-spacing: .1em;
}

.plaque-series {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-family: 'DM Mono', monospace;
  font-size: .52rem;
  font-weight: 400;
  color: var(--accent);
  letter-spacing: .14em;
  text-transform: uppercase;
  border: 1px solid rgba(200, 149, 90, 0.3);
  padding: 3px 10px 3px 8px;
  width: fit-content;
}
.plaque-series::before {
  content: '';
  display: inline-block;
  width: 12px;
  height: 9px;
  border: 1px solid currentColor;
}
.plaque-series::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 9px;
  border: 1px solid currentColor;
  border-left: none;
  margin-left: -7px;
}

/* ── Empty / error ────────────────────────────────────────────────────────── */
.empty, .error {
  text-align: center;
  padding: 5rem 1rem;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: .65rem;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.error { color: #c04e3a; }

/* ── Lightbox ─────────────────────────────────────────────────────────────── */
#lightbox {
  border: none;
  background: #060504;
  padding: 0;
  max-width: 100vw;
  max-height: 100dvh;
  overflow: hidden;
}

/* Progress bar track — always visible when lightbox is open */
#lightbox[open]::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(200, 149, 90, 0.18);
  z-index: 19;
  pointer-events: none;
}

/* Progress bar fill — spans the top edge, fills left-to-right through the series */
#lb-progress {
  position: absolute;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: var(--accent);
  transition: width 300ms ease;
  z-index: 20;
  pointer-events: none;
  box-shadow: 0 0 10px rgba(200, 149, 90, 0.65);
}

#lightbox[open] {
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  margin: 0;
}

#lightbox::backdrop {
  background: rgba(4, 3, 2, 0.98);
}

/* Main image area */
#lb-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  min-height: 0;
}

#lb-img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  transition: opacity 180ms ease;
}

/* Footer — caption + film strip */
#lb-footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #060504;
  border-top: 1px solid var(--border);
}

#lb-caption {
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: .6rem;
  font-weight: 300;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 10px 60px;
  text-align: center;
  flex-shrink: 0;
}

/* Strip area — hidden by default, slides up when a progression is loaded */
#lb-strip-area {
  display: none;
}
#lb-strip-area.visible {
  display: block;
  animation: stripReveal 320ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes stripReveal {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Label row above the strip */
#lb-strip-header {
  padding: 8px 60px 4px;
  text-align: center;
}
#lb-strip-label {
  font-family: 'DM Mono', monospace;
  font-size: .52rem;
  font-weight: 400;
  color: var(--accent);
  letter-spacing: .18em;
  text-transform: uppercase;
  opacity: 0.8;
}

/* Strip row — scrollable strip only */
#lb-strip-row {
  padding: 0 10px;
}

/* Strip nav — overlaid on the main image, bottom-right corner */
#lb-strip-nav {
  position: absolute;
  bottom: 12px;
  right: 12px;
  display: none;
  gap: 4px;
  z-index: 10;
}
#lb-strip-nav.visible {
  display: flex;
}

/* Strip prev/next — compact overlay tap targets */
#lb-strip-prev, #lb-strip-next {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
  border-radius: 0;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition);
}
#lb-strip-prev:hover, #lb-strip-next:hover {
  background: var(--accent-dim);
  border-color: rgba(200, 149, 90, 0.4);
  color: var(--accent);
}
#lb-strip-prev:disabled, #lb-strip-next:disabled {
  opacity: 0.25;
  cursor: default;
  pointer-events: none;
}

/* Film strip */
#lb-strip {
  flex: 1;
  display: flex;
  flex-direction: row;
  gap: 3px;
  padding: 0 8px 14px;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--dim) transparent;
  justify-content: center;
  min-height: 0;
}

.strip-thumb {
  flex-shrink: 0;
  width: 76px;
  height: 56px;
  object-fit: cover;
  cursor: pointer;
  opacity: 0.35;
  border: 1px solid transparent;
  transition: opacity var(--transition), border-color var(--transition);
}
.strip-thumb:hover { opacity: 0.7; }
.strip-thumb.active {
  opacity: 1;
  border-color: var(--accent);
}

/* Lightbox controls */
#lb-close, #lb-prev, #lb-next {
  position: absolute;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  font-size: 1.6rem;
  line-height: 1;
  border-radius: 0;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition);
  z-index: 10;
}
#lb-close:hover, #lb-prev:hover, #lb-next:hover {
  background: var(--accent-dim);
  border-color: rgba(200, 149, 90, 0.3);
  color: rgba(255, 255, 255, 0.9);
}
#lb-close:disabled, #lb-prev:disabled, #lb-next:disabled {
  opacity: 0.2;
  cursor: default;
  pointer-events: none;
}

/* Close anchored to main dialog (covers full screen) */
#lb-close {
  position: fixed;
  top: 16px;
  right: 20px;
  padding: 6px 15px;
}

/* Prev/next anchored inside #lb-main */
#lb-prev { top: 50%; left: 16px; transform: translateY(-50%); padding: 16px 18px; }
#lb-next { top: 50%; right: 16px; transform: translateY(-50%); padding: 16px 18px; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --spine-left: 72px; }
  header { padding: 12px 24px; gap: 16px; }
  .entry-content { margin-right: 24px; }
  .plaque-title { font-size: 1.4rem; }
}

@media (max-width: 640px) {
  :root { --spine-left: 52px; }
  header { padding: 12px 16px; gap: 12px; flex-wrap: wrap; }
  h1 { font-size: .95rem; }
  .sort-btn { margin-left: 0; }
  main { padding: 32px 0 80px; }
  .entry-content { margin-right: 14px; max-width: 100%; }
  .entry-frame { padding: 10px; }
  .entry-frame::after { inset: 10px; }
  .entry-date-day { font-size: 1.5rem; padding-right: 10px; }
  .plaque-title { font-size: 1.25rem; }
  #lb-caption { padding: 8px 40px; }
  .strip-thumb { width: 60px; height: 44px; }
}

@media (max-width: 400px) {
  :root { --spine-left: 42px; }
  .entry-date-day { font-size: 1.2rem; padding-right: 8px; }
  .plaque-title { font-size: 1.1rem; }
}
