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

/* ─── Custom font ────────────────────────────────── */
@font-face {
  font-family: 'Century Schoolbook Monospace';
  src: url('fonts/CenturySchoolbookMonospace.woff2') format('woff2'),
       url('fonts/CenturySchoolbookMonospace.woff') format('woff');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ─── Tokens ─────────────────────────────────────── */
:root {
  --bg-left:     #e1e2e6;
  --bg-right:    #1c1d21;
  --text:        #3b3d44;
  --font:        'Century Schoolbook Monospace', 'Courier New', Courier, monospace;
  --left-w:      500px;
  --strip-w:     48px;
  --strip-pad:   8px;
  --center-pad:  48px;
}

/* ─── Base ───────────────────────────────────────── */
html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-right);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Three-column layout ────────────────────────── */
.layout {
  display: flex;
  height: 100vh;
  width: 100%;
  overflow: hidden;
  position: relative;
}

/* ─── Left: Bio panel ────────────────────────────── */
.bio-panel {
  width: var(--left-w);
  min-width: var(--left-w);
  background: var(--bg-left);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  position: relative;
  transition: width 500ms cubic-bezier(0.69, 0.01, 0.53, 1.01), min-width 500ms cubic-bezier(0.69, 0.01, 0.53, 1.01);
}
.bio-panel::-webkit-scrollbar { width: 0; }

/* Inner wrapper carries the padding and slides independently */
.bio-inner {
  width: var(--left-w);
  padding: 48px;
  display: flex;
  flex-direction: column;
  gap: 40px;
  transition: transform 500ms cubic-bezier(0.69, 0.01, 0.53, 1.01);
}

.bio-text {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 1.5em;
}

.bio-panel ::selection {
  background: #3b3d44;
  color: #e1e2e6;
}

.bio-text a {
  color: inherit;
  text-decoration: underline;
  text-decoration-skip-ink: auto;
  text-decoration-color: #9da1ae;
  text-underline-position: from-font;
}
.bio-text a:hover {
  opacity: 0.6;
}

.link-nepal,
.link-kyrgyzstan,
.link-manor,
.link-bass,
.link-morbier,
.link-newzealand {
  cursor: text;
}

.contact,
.site-credits {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
}

.contact a,
.site-credits a {
  color: inherit;
  text-decoration: underline;
  text-decoration-skip-ink: auto;
  text-decoration-color: #9da1ae;
  text-underline-position: from-font;
}

.contact a:hover,
.site-credits a:hover {
  opacity: 0.6;
}

.bio-divider {
  display: block;
  flex-shrink: 0;
  width: 25px;
}

/* ─── Collapse divider + knob ────────────────────── */

/* Zero-width flex item — sits exactly on the boundary between panels */
.col-divider {
  width: 0;
  flex-shrink: 0;
  position: relative;
  overflow: visible;
  z-index: 10;
  cursor: w-resize;
}

/* Invisible hover hit zone centred on the boundary */
.col-divider::before {
  content: '';
  position: absolute;
  left: -8px;
  width: 16px;
  top: 0;
  bottom: 0;
}

/* Knob: white card with beige pill inside — from Figma */
.col-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 40px;
  background: #ffffff;
  border: 1px solid rgba(130, 130, 130, 0.1);
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.15);
  border-radius: 12px;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  opacity: 1;
  pointer-events: none;
}

/* Inner beige pill */
.col-knob::after {
  content: '';
  width: 4px;
  height: 32px;
  background: #e6e5e1;
  border-radius: 12px;
  flex-shrink: 0;
}

/* Scale images up when left panel is collapsed */
.work-section > div {
  transition: transform 500ms cubic-bezier(0.69, 0.01, 0.53, 1.01);
}
.layout.collapsed .work-section > div {
  transform: scale(1.2);
}

/* Collapsed: shrink layout width (main panel expands) + slide inner content left */
.layout.collapsed .bio-panel {
  width: 100px;
  min-width: 100px;
  overflow-y: hidden;
  pointer-events: none;
}

.layout.collapsed .bio-inner {
  transform: translateX(calc(-1 * (var(--left-w) - 100px)));
}

.layout.collapsed .col-divider { cursor: e-resize; }

/* ─── Center: Main panel ─────────────────────────── */
.main-panel {
  flex: 1 0 0;
  min-width: 0;
  background: var(--bg-right);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 var(--center-pad);
  display: flex;
  flex-direction: column;
  gap: 0;
  align-items: center;
  scrollbar-width: none;
  scroll-snap-type: y mandatory;
}
.main-panel::-webkit-scrollbar { width: 0; }

.work-section {
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: center;
  scroll-snap-align: start;
  justify-content: center;
  flex-shrink: 0;
}

.img-frame {
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
}
.img-frame img,
.img-frame video {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.portrait-frame {
  width: min(482px, 100%);
  aspect-ratio: 482 / 642;
}

.figma-ads-frame {
  width: min(880px, 100%);
  aspect-ratio: 880 / 600;
}

/* ─── Right: Thumbnail filmstrip ─────────────────── */
.thumb-strip {
  width: var(--strip-w);
  min-width: var(--strip-w);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: var(--strip-pad);
  display: flex;
  flex-direction: column;
  gap: var(--strip-pad);
  scrollbar-width: none;
}

@media (min-width: 769px) {
  .thumb-strip {
    background: var(--bg-right);
  }
}
.thumb-strip::-webkit-scrollbar { width: 0; }

/* Push thumbs to vertical centre; collapses to 0 when content overflows so scrolling still works */
.thumb-strip::before,
.thumb-strip::after {
  content: '';
  flex: 1;
}

.thumb {
  width: 100%;
  flex-shrink: 0;
  overflow: hidden;
  cursor: pointer;
  transition: opacity 0.2s ease;
  background: #2d2e33;
  position: relative;
}
.thumb img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb.faded { opacity: 0.4; }
.thumb.active { opacity: 1; }
.thumb.faded:hover { opacity: 0.75; }

.thumb.empty { background: #2d2e33; }

/* DIIV section: dark background, overflow hidden, centred poster */
.img-diiv {
  background: #1c1d21;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
}
.img-diiv-inner {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  overflow: hidden;
}

/* Disable bio links while an overlay is open (tablet/mobile) */
.bio-panel.overlay-open a {
  pointer-events: none;
}

/* ─── Bio link hover overlays (centred in bio panel) */
.hover-overlay {
  display: none;
  position: fixed;
  transform: translate(-50%, -50%);
  height: auto;
  width: auto;
  max-height: 75vh;
  max-width: min(460px, calc(100vw - 32px));
  z-index: 1000;
  pointer-events: none;
}

/* Disable image/video drag and callout */
img, video {
  -webkit-user-drag: none;
  user-drag: none;
  -webkit-touch-callout: none;
}

/* Portrait hover swap — instant, no transition */
.portrait-swap .portrait-blink { display: none; }
.portrait-swap:hover .portrait-blink { display: block; }
.portrait-swap:hover .portrait-default { display: none; }

/* Empty placeholder sections */
.img-empty { background: #2d2e33; }

/* Overflow/crop image containers */
.img-overflow-wrap { overflow: hidden; }
.img-overflow {
  position: absolute;
  max-width: none;
  pointer-events: none;
}

/* Overflow thumbs */
.thumb-overflow { overflow: hidden; }

/* ─── Responsive: Tablet (≤ 1100px) ─────────────── */
@media (max-width: 1100px) {
  :root {
    --left-w: 500px;
    --center-pad: 32px;
  }

  /* Bio panel becomes an overlay drawer — pulled out of flex flow */
  .bio-panel {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 20;
    width: var(--left-w);
    min-width: var(--left-w);
    overflow-y: auto;
    pointer-events: auto;
    transform: translateX(0);
    transition: transform 500ms cubic-bezier(0.69, 0.01, 0.53, 1.01);
  }

  /* Collapsed: slide left so only the 100px background strip peeks */
  .layout.collapsed .bio-panel {
    width: var(--left-w);
    min-width: var(--left-w);
    overflow-y: hidden;
    pointer-events: none;
    transform: translateX(calc(100px - var(--left-w)));
  }

  /* Reset bio-inner transform — panel itself slides, no double offset */
  .layout.collapsed .bio-inner {
    transform: translateX(0);
  }

  /* Knob tracks the right edge of the bio panel — both animate transform
     so they run on the compositor thread in perfect lock-step */
  .col-divider {
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--left-w);
    z-index: 21;
    transform: translateX(0);
    transition: transform 500ms cubic-bezier(0.69, 0.01, 0.53, 1.01);
  }

  .layout.collapsed .col-divider {
    transform: translateX(calc(100px - var(--left-w)));
  }

  /* No scale effect — main panel width never changes */
  .layout.collapsed .work-section > div {
    transform: none;
  }

  /* Offset left padding to account for the 100px bio-panel peek */
  .main-panel {
    padding-left: calc(100px + var(--center-pad));
  }

  /* Click/tap interaction on tablet+mobile — use pointer instead of text cursor */
  .link-nepal,
  .link-kyrgyzstan,
  .link-manor,
  .link-bass,
  .link-morbier,
  .link-newzealand {
    cursor: pointer;
  }
}


/* ─── Responsive: Mobile (≤ 768px) ──────────────── */
@media (max-width: 768px) {
  html, body {
    height: auto;
    overflow: auto;
  }

  .layout {
    flex-direction: column;
    height: auto;
    overflow: visible;
    position: static;
  }

  /* Thumb strip: fixed frosted overlay at top */
  .thumb-strip {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    min-width: 0;
    flex-direction: row;
    align-items: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    height: 69px;
    padding: 8px;
    gap: 8px;
    z-index: 100;
    border-top: none;
    background: rgba(28, 29, 33, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }

  .thumb-strip::before,
  .thumb-strip::after {
    display: none;
  }

  /* Thumb items — consistent height, width derives from aspect-ratio */
  .thumb {
    position: relative;
    width: auto;
    height: 53px;
    flex-shrink: 0;
    background: transparent;
  }

  .thumb.empty {
    width: 40px;
    height: 53px;
    background: transparent;
  }

  /* Main panel: full viewport, scrolls behind fixed strip */
  .main-panel {
    order: 1;
    flex: none;
    width: 100%;
    min-width: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 69px 32px 48px;
    height: 100vh;
    height: 100svh;
    align-items: stretch;
    scroll-snap-type: y mandatory;
    scroll-padding-top: 69px;
  }

  .work-section {
    height: calc(100vh - 117px);
    height: calc(100svh - 117px);
    width: 100%;
    scroll-snap-align: start;
  }

  /* Col-divider: anchored at its expanded position (top: 69px), then
     translated down by the same amount as the bio panel so both animate
     on the compositor thread (transform) in perfect lock-step */
  .col-divider {
    position: fixed;
    top: 69px;
    left: 0;
    right: 0;
    width: 100%;
    height: 48px;
    z-index: 152;
    cursor: n-resize;
    pointer-events: auto;
    background: transparent;
    transform: translateY(calc(100vh - 117px));
    transform: translateY(calc(100svh - 117px));
    transition: transform 500ms cubic-bezier(0.69, 0.01, 0.53, 1.01);
  }

  .col-divider::before {
    display: none;
  }

  /* Knob: rotated 90° to horizontal, centered on the top edge of the col-divider
     so it straddles the dark/light boundary in both collapsed and expanded states */
  .col-knob {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translate(-50%, -50%) rotate(90deg);
    pointer-events: auto;
  }

  /* Expanded: both bio panel and col-divider reach translateY(0) simultaneously */
  .layout.bio-open .col-divider {
    transform: translateY(0);
    cursor: s-resize;
  }

  /* Bio panel: fixed bottom sheet — peeks 48px showing top of bio content */
  .bio-panel {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    min-width: 0;
    height: calc(100vh - 69px);
    height: calc(100svh - 69px);
    overflow: hidden;
    pointer-events: none;
    transform: translateY(calc(100% - 48px));
    transition: transform 500ms cubic-bezier(0.69, 0.01, 0.53, 1.01);
    z-index: 150;
    background: var(--bg-left);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12);
  }

  .layout.bio-open .bio-panel {
    transform: translateY(0);
    overflow-y: auto;
    pointer-events: auto;
  }

  /* Dim backdrop behind bio panel when open */
  .layout.bio-open::before {
    content: '';
    position: fixed;
    inset: 69px 0 0 0;
    z-index: 149;
    background: rgba(0, 0, 0, 0.3);
    pointer-events: none;
  }

  /* 32px padding all around */
  .bio-inner {
    width: 100%;
    padding: 32px;
    transform: none;
    transition: none;
  }

  .portrait-frame,
  .figma-ads-frame {
    width: 100%;
    height: auto;
  }

  /* Overlays hidden by default on mobile; JS shows them on tap */
  .hover-overlay {
    display: none;
  }
}

/* ─── Responsive: Short viewports (≤ 750px tall, desktop/tablet only) ─── */
@media (max-height: 750px) and (min-width: 769px) {
  .main-panel {
    padding-top: 48px;
    padding-bottom: 48px;
  }
}

/* ─── Loading screen ─────────────────────────────── */
#loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #1c1d21;
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.5;
  color: #8f94a3;
  pointer-events: none;
  transition: opacity 400ms ease;
}

#loader-left {
  position: absolute;
  left: 32px;
  top: 32px;
  display: flex;
  flex-direction: column;
}

#loader-right {
  position: absolute;
  right: 32px;
  top: 32px;
  text-align: right;
}
