/* ================================
   STRICT TWO-COLOR THEME / BASE
   ================================ */
:root {
  --ink: #1A1A1A;     /* off-black */
  --paper: #F5F5F5;   /* off-white */
  --maxw: 1400px;
  --t-fast: 180ms;
  --t-med: 350ms;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; }

html {
  background: var(--paper);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.1;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--t-med) ease, color var(--t-med) ease;
  scroll-behavior: smooth; /* smooth anchor scrolls */
}

/* Layout container */
.container {
  max-width: var(--maxw);
  margin-inline: auto;
  padding: 2rem 1.25rem;
}

/* ================================
   TYPOGRAPHY
   ================================ */
.display,
.display2 {
  font-weight: 1000;
  letter-spacing: -0.02em;
  font-size: clamp(4rem, 10vw + 0.5rem, 20rem);
  line-height: 0.9;
}
@media (max-width: 640px) {
  .display { font-size: clamp(4rem, 10vw + 2rem, 20rem); max-width: 90%; }
  .display2 { font-size: clamp(4rem, 6vw + 2rem, 20rem); max-width: 90%; }
}

.micro {
  font-size: clamp(0.85rem, 0.6rem + 0.5vw, 1.1rem);
  letter-spacing: 0.08em;
  opacity: 0.92;
  line-height: 1.3;
}

.description {
  font-size: clamp(1.2rem, 1rem + 1.2vw, 2.4rem);
  line-height: 1.3;
}

.description-contact {
  font-size: clamp(0.3rem, 2vw + 0.4rem, 2rem);
  line-height: 1.5;
}

.links { color: #1A1A1A; font-style: italic; }

@media (max-width: 640px) {
  p, h1 { max-width: 90%; }
}

/* ================================
   HERO
   ================================ */
.hero {
  position: relative;
  min-height: 100svh;
  display: grid;
  align-content: end;
  padding-block: 10vh 8vh;
  overflow: clip;
}
.hero__inner { max-width: 92ch; position: relative; z-index: 2; }
.scrollcue { position: absolute; left: 1.25rem; bottom: 1.25rem; opacity: 0.75; z-index: 2; }

/* ================================
   GALLERY GRID
   ================================ */
.gallery {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 320px));
  grid-auto-flow: dense;
  justify-content: center;
  padding-block: 4rem;
}
.card { position: relative; display: block; overflow: hidden; background: var(--paper); }
.card img {
  width: 100%; height: 100%; object-fit: cover; object-position: center;
  transition: transform var(--t-med) ease, opacity var(--t-fast) linear;
}
.card:hover img, .card:focus-visible img { transform: scale(1.02); }

.card.portrait { aspect-ratio: 3 / 4; grid-column: span 1; }
.card.portrait.main { grid-column: span 2; }
@media (max-width: 640px) { .card.portrait.main { grid-column: span 1; } }

.card.square { aspect-ratio: 1 / 1; grid-column: span 1; }
.card.landscape { aspect-ratio: 5 / 3; grid-column: span 2; }
.card.landscape.main { grid-column: span 4; }
/* specific selector kept intentionally */
@media (max-width: 640px) { .card.card.landscape.main.main { grid-column: span 1; } }

.card.wide { aspect-ratio: 2 / 1; grid-column: span 3; }
@media (max-width: 1200px) { .card.wide { grid-column: span 2; } }
@media (max-width: 900px)   { .card.landscape, .card.wide { grid-column: span 1; } }
@media (max-width: 640px)   { .gallery { grid-template-columns: 1fr; justify-content: stretch; gap: 1rem; } }

/* ================================
   CONTACT SECTION
   ================================ */
.contact { padding-block: 1vh 1vh; border-top: 1px solid currentColor; }
.contact a {
  color: inherit; text-decoration: none; border-bottom: 1px solid currentColor;
  transition: opacity var(--t-fast) linear;
}
.contact a:hover, .contact a:focus-visible { opacity: 0.7; }

/* Buttons in contact section */
.contact a {
  display: inline-block; margin: 0.4rem 0.3rem; padding: 0.4em 0.8em;
  font-family: inherit; font-weight: 700;
  font-size: clamp(1.6rem, 0.2vw + 0.3rem, 0.3rem);
  letter-spacing: -0.02em; text-decoration: none; text-transform: none;
  color: var(--ink); background: var(--paper); border: 2px solid currentColor;
  transition: background-color 0.25s ease, color 0.25s ease; cursor: pointer;
}
.contact a:hover, .contact a:focus-visible { background: var(--ink); color: var(--paper); }
.contact .micro { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; }

/* ================================
   ENTRANCE / SCROLL REVEAL
   ================================ */
[data-reveal] { opacity: 0; transform: translateY(8px); transition: opacity var(--t-med) ease, transform var(--t-med) ease; }
.is-inview { opacity: 1; transform: none; }
html.loaded .hero .display { animation: rise var(--t-med) ease both; }
@keyframes rise { from { transform: translateY(6px); } to { transform: none; } }

/* ================================
   ACCESSIBILITY / FALLBACKS
   ================================ */
:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
html:not(.js) [data-reveal] { opacity: 1 !important; transform: none !important; }
@media (prefers-reduced-motion: reduce) {
  html { transition: none; }
  .card img, [data-reveal] { transition: none; transform: none; }
  .display { animation: none; }
}

/* ================================
   BACK BUTTON
   ================================ */
.back-button {
  position: absolute; top: 17%; left: 2rem; z-index: 1000;
  font-family: inherit; font-weight: 700;
  font-size: clamp(0.9rem, 1vw + 0.5rem, 1.3rem); letter-spacing: -0.02em;
  color: var(--ink); background: var(--paper); text-decoration: none;
  border: 2px solid currentColor; padding: 0.4em 0.8em;
  opacity: 1; transition: opacity 0.4s ease, background-color 0.2s ease, color 0.2s ease;
  cursor: pointer;
}
.back-button:hover, .back-button:focus-visible { background: var(--ink); color: var(--paper); }
.back-button.is-hidden { opacity: 0 !important; pointer-events: none; }
@media (max-width: 640px) {
  .back-button { top: 1.2rem; left: 1.2rem; font-size: clamp(1rem, 2vw + 0.5rem, 1.5rem); padding: 0.35em 0.7em; }
}
.invert .back-button { color: var(--paper); background: var(--ink); border-color: var(--paper); }

/* =========================================
   HOME GALLERY — HOVER LABELS
   ========================================= */
.gallery--home .card { position: relative; isolation: isolate; }
.gallery--home .card::after {
  content: attr(data-caption);
  position: absolute; left: 0.8rem; bottom: 0.8rem; z-index: 1;
  display: inline-block; padding: 0.4em 0.8em;
  font-family: inherit; font-weight: 700; font-size: clamp(0.9rem, 1vw + 0.4rem, 1.2rem);
  letter-spacing: -0.02em; color: var(--ink); background: var(--paper);
  border: 2px solid var(--ink); box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  opacity: 0; transform: translateY(6px);
  transition: opacity var(--t-med) ease, transform var(--t-med) ease;
  pointer-events: none;
}
.gallery--home .card:hover::after, .gallery--home .card:focus-visible::after { opacity: 1; transform: none; }
.gallery--home .card:hover img, .gallery--home .card:focus-visible img { opacity: 0.9; }
@media (max-width: 640px) {
  .gallery--home .card::after {
    left: 0.6rem; bottom: 0.6rem; padding: 0.35em 0.7em;
    font-size: clamp(0.95rem, 0.8rem + 0.6vw, 1.05rem);
  }
}

/* =========================================
   FIXED CONTACT RAIL (top-right default)
   + animated hide, mobile centered on home
   ========================================= */
.contact-rail {
  position: fixed;
  top: 1.2rem;
  right: 1.2rem;
  z-index: 1100;
  display: flex;
  transition: opacity 0.35s ease; /* do not animate transform on the rail itself */
}
.contact-rail__bar {
  display: flex;
  gap: 0.5rem;
  transition: opacity 0.35s ease, transform 0.35s ease; /* slide/fade lives here */
  will-change: opacity, transform;
}
.contact-rail__btn {
  font-family: inherit; font-weight: 800;
  font-size: clamp(0.9rem, 1vw + 0.45rem, 1.15rem);
  letter-spacing: -0.02em; color: var(--ink); background: var(--paper);
  text-decoration: none; border: 2px solid currentColor;
  padding: 0.45em 0.8em; line-height: 1; cursor: pointer;
  transition: opacity 0.3s ease, transform 0.3s ease, background-color 0.2s ease, color 0.2s ease;
}
.contact-rail__btn:hover, .contact-rail__btn:focus-visible { background: var(--ink); color: var(--paper); }

/* Hidden states (by JS) */
.contact-rail.is-hidden .contact-rail__bar,
.contact-rail.is-near-top .contact-rail__bar,
.contact-rail.at-top .contact-rail__bar {
  opacity: 0;
  transform: translateY(-12px); /* slide up */
  pointer-events: none;
}
.contact-rail.is-hidden .contact-rail__btn,
.contact-rail.is-near-top .contact-rail__btn,
.contact-rail.at-top .contact-rail__btn {
  opacity: 0; transform: translateY(-6px);
}
.contact-rail__btn:nth-child(1) { transition-delay: 0ms; }
.contact-rail__btn:nth-child(2) { transition-delay: 40ms; }
.contact-rail__btn:nth-child(3) { transition-delay: 80ms; }

@media (prefers-reduced-motion: reduce) {
  .contact-rail__bar, .contact-rail__btn { transition: none !important; transform: none !important; }
}

/* ======= MOBILE LAYOUT ======= */
/* Default mobile: top-right */
@media (max-width: 640px) {
  .contact-rail {
    top: 0.9rem; right: 0.9rem; left: auto; bottom: auto; transform: none;
  }
}

/* Home page only (index.html): mobile top-center with off-white bar */
@media (max-width: 640px) {
  body.is-home .contact-rail {
    top: 0.9rem !important; left: 50% !important; right: auto !important; bottom: auto !important;
    transform: translateX(-50%) !important;
    width: auto !important; max-width: calc(100vw - 1rem) !important; justify-content: center !important;
  }
  body.is-home .contact-rail__bar {
    display: inline-flex !important; align-items: center !important; gap: 0.4rem !important;
    padding: 0.45rem 0.6rem !important;
    background: color-mix(in oklab, var(--paper) 92%, transparent) !important;
    border: 2px solid currentColor !important; box-shadow: 0 2px 6px rgba(0,0,0,0.08) !important;
    white-space: nowrap !important; overflow-x: auto !important; overflow-y: hidden !important; max-width: 100% !important;
    -webkit-overflow-scrolling: touch !important; scrollbar-width: none !important;
  }
  body.is-home .contact-rail__bar::-webkit-scrollbar { display: none !important; }
}
/* ==== SUBPAGES (non-home): mobile bottom-center + bar ==== */
@media (max-width: 640px) {
  body:not(.is-home) .contact-rail {
    position: fixed !important;
    top: 0.9rem !important;
    bottom: auto !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    width: auto !important;
    max-width: calc(100vw - 1rem) !important;
    justify-content: center !important;
  }

  body:not(.is-home) .contact-rail__bar {
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.4rem !important;
    padding: 0.5rem 0.6rem !important;
    background: color-mix(in oklab, var(--paper) 92%, transparent) !important;
    border: 2px solid currentColor !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08) !important;
    white-space: nowrap !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    max-width: 100% !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
  }
  body:not(.is-home) .contact-rail__bar::-webkit-scrollbar { display: none !important; }
}

/* =========================================================
   FILM REEL — transform-based infinite loop (pixel-perfect)
   ========================================================= */
.film-reel {
  border-top: 1px solid currentColor;
  padding-block: 6rem 4rem;
  overflow: hidden;
  --reel-height: clamp(500px, 36vh, 520px);
  --reel-gap: 1.2rem;                 /* used consistently in CSS & measured by JS */
}

.reel {
  position: relative;
  width: 100%;
  overflow: hidden;                    /* no native scroll; JS drives transform */
  user-select: none;
  -webkit-user-drag: none;
  touch-action: pan-y;                 /* vertical page scroll stays natural */
}

.reel__track {
  display: inline-flex;
  align-items: center;
  gap: var(--reel-gap);
  min-width: max-content;              /* honor intrinsic width */
  will-change: transform;
  transform: translate3d(0,0,0);       /* GPU path */
}

/* Videos keep native aspect via fixed height */
.reel__track video {
  flex: 0 0 auto;
  height: var(--reel-height);
  width: auto;
  display: block;
  object-fit: contain;                 /* switch to 'cover' for fill/crop look */
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 1rem;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  pointer-events: none;                /* smoother drag */
}

/* Drag feedback */
.reel.is-dragging { cursor: grabbing; }

@media (max-width: 640px) {
  .film-reel { padding-block: 4rem 2rem; }
  .film-reel { --reel-height: clamp(220px, 34vh, 420px); }
}

/* Respect reduced motion in other areas (reel is JS-driven) */
@media (prefers-reduced-motion: reduce) {
  .reel { scroll-behavior: auto !important; }
}