/* ── Local ITC Garamond (same @font-face as index.html) ── */
@font-face {
  font-family: 'ITC Garamond Std';
  font-style: italic;
  font-weight: 300;
  src: local('ITC Garamond Std Light Narrow Italic'),
    local('ITCGaramondStd-LtNarrIt'),
    local('ITC Garamond Std Light Italic');
}

/* ── Design tokens ── */
:root {
  --font-mono: 'JetBrains Mono', monospace;
  --font-display: 'Bai Jamjuree', sans-serif;
  --font-body: 'Recoleta', Georgia, serif;
  --brand-teal: #58F0E0;
  --brand-teal-deep: #178B84;
  --accent: var(--brand-teal);
  --divider: #e0e0e0;
  color-scheme: dark;
}

@property --cs-arrow-shine-angle {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

/* ── Two-panel shell ── */
.cs-shell {
  display: flex;
  min-height: 100vh;
  align-items: flex-start;
  position: relative;
  z-index: 1;
  opacity: 0;
}

/* ── LEFT panel — sticky slider ── */
.cs-left {
  width: 35vw;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

/* "← Close" link — mono, top-left */
.cs-close {
  position: absolute;
  top: 32px;
  left: 40px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #000;
  text-decoration: none;
  opacity: 0.5;
  transition: opacity 0.18s;
}

.cs-close:hover {
  opacity: 1;
}

/* Slider container */
.cs-slider {
  width: 100%;
  height: 100%;
}

/* ── RIGHT panel — scrolling article ── */
.cs-right {
  width: 65vw;
  height: 100vh;
  overflow-y: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  /* Hide scrollbar visually, keep scroll functional */
  scrollbar-width: none;
  border-left: 1px solid var(--divider);
  background: #fff;
}

.cs-right::-webkit-scrollbar {
  display: none;
}

#cs-right-content {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding: 32px 140px 0;
}

/* Row holding the right-panel close control + "Source ↗" link */
.cs-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 48px;
  /* Pull the left edge out to the video block's left (48px from panel edge) so
     the close control lines up with the media; width grows to hold source in place. */
  margin-left: -92px;
  width: calc(100% + 92px);
}

/* "× Close" — right-panel close control, top-left, mirrors .cs-close's action */
.cs-right-close {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: #000;
  text-decoration: none;
  opacity: 0.7;
  transition: opacity 0.18s;
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.cs-right-close svg {
  display: block;
}

.cs-right-close:hover {
  opacity: 1;
}

/* "Source ↗" link — mono, underlined, hidden when sourceUrl is empty */
.cs-source {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #000;
  text-decoration: underline;
  text-underline-offset: 3px;
  opacity: 0.5;
  transition: opacity 0.18s;
}

.cs-source:hover {
  opacity: 1;
}

.cs-source[hidden] {
  display: none;
}

.cs-top-row:has(.cs-source[hidden]) {
  justify-content: flex-start;
}

/* Detail container */
.cs-detail {
  flex: 1;
}

/* ── Mobile (<900px): stack panels vertically, left on top ── */
@media (max-width: 900px) {
  .cs-shell {
    flex-direction: column;
  }

  .cs-left {
    width: 100%;
    position: relative;
    height: 56vw;
    min-height: 260px;
    border-right: none;
    border-bottom: 1px solid var(--divider);
  }

  .cs-right {
    width: 100%;
    padding: 0;
    border-left: none;
  }

  #cs-right-content {
    padding: 24px 24px 0;
  }
}

/* ── Left-panel slider ───────────────────────────────── */

/* Base .proj-card — mirrors index.html; needed since that file's CSS isn't loaded here */
.proj-card {
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

/* Slider track — horizontal strip of cards */
.cs-slider {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Each slide wrapper — positioned absolutely, stacked/offset by JS.
   Negative margins = half the card size (keeps the centre intact when GSAP
   overwrites transform); set per shape to match the card sizes below. */
.cs-slide {
  position: absolute;
  top: 50%;
  left: 50%;
  margin-left: -160px;  /* fallback: legacy 320×380 */
  margin-top: -190px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  pointer-events: auto;
}
.cs-slide.is-portrait  { margin-left: -150px; margin-top: -200px; }
.cs-slide.is-square    { margin-left: -170px; margin-top: -170px; }
.cs-slide.is-landscape { margin-left: -210px; margin-top: -152px; }

/* The image card itself — reuse .proj-card from index.html.
   Sized per proj.shape in the SAME proportions as the homepage cards
   (420×560 / 480×480 / 580×420), scaled to fit the left panel. */
.cs-slide .proj-card {
  width: 320px;   /* fallback when a project has no shape */
  height: 380px;
}
.cs-slide .proj-card.is-portrait  { width: 300px; height: 400px; }
.cs-slide .proj-card.is-square    { width: 340px; height: 340px; }
.cs-slide .proj-card.is-landscape { width: 420px; height: 304px; }

/* Color/gradient placeholder shown when no image src */
.cs-slide .proj-card-ph {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Project name — display font, centred above the card (Figma) */
.cs-slide-title {
  position: absolute;
  bottom: calc(100% + 24px);
  left: 0;
  right: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 32px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  text-align: center;
  white-space: pre-line; /* render the "\n" in subtitle as a line break */
  color: #1a1a1a;
  user-select: none;
}

/* Arrow nav + counter — bottom centre of left panel (Figma) */
.cs-slider-nav {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 32px;
  z-index: 5;
}

/* Arrow buttons use the same chamfered container as the menu button.
   Keep the arrow icon at its existing 20px size. */
.cs-slider-arrow {
  position: relative;
  -webkit-appearance: none;
  appearance: none;
  border: none;
  width: 48px;
  height: 48px;
  padding: 0;
  background: transparent;
  color: #fff; /* arrow fill = currentColor */
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.18s;
}
.cs-slider-arrow::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url('assets/images/menu-button-default.svg') center / 100% 100% no-repeat;
  pointer-events: none;
}
.cs-slider-arrow::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  padding: 1.5px;
  pointer-events: none;
  clip-path: polygon(0 0, 91% 0, 100% 18%, 100% 100%, 5% 100%, 0 88%);
  background: conic-gradient(
    from var(--cs-arrow-shine-angle),
    transparent 0 56%,
    #5271ED 68%,
    #52EDE2 76%,
    rgba(255, 255, 255, 0.95) 80%,
    #52EDE2 84%,
    transparent 96% 100%
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask-composite: exclude;
  opacity: 0;
}
.cs-slider-arrow:is(:hover, :focus-visible)::after {
  opacity: 1;
  animation: cs-arrow-shine 1.6s linear infinite;
}
.cs-slider-arrow:is(:hover, :focus-visible)::before {
  background-image: url('assets/images/menu-button-hover.svg');
}
.cs-slider-arrow svg {
  position: relative;
  z-index: 3;
  display: block;
}
.cs-arrow-prev svg { transform: rotate(180deg); }
.cs-slider-arrow:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

@keyframes cs-arrow-shine {
  to { --cs-arrow-shine-angle: 360deg; }
}

.cs-slider-counter {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #1a1a1a;
  user-select: none;
  text-align: center;
}

/* ── Detail panel content ────────────────────────────── */

/* Top spacing after source link */
.cs-detail {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ── Headline ── */
.cs-headline {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(40px, 5.5vw, 64px);
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: #000;
  margin-bottom: 40px;
  overflow: visible;
}

.cs-title-line {
  display: block;
}

/* ── Meta row — Role / Client / Year ── */
.cs-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 60px 120px;
  margin-bottom: 32px;
}

.cs-meta-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cs-meta-item-label {
  font-family: var(--font-body);
  font-weight: 300;
  font-size: 16px;
  letter-spacing: -0.03em;
  color: rgba(0, 0, 0, 0.4);
}

.cs-meta-item-value {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 18px;
  letter-spacing: -0.03em;
  color: #000;
  white-space: nowrap;
}

/* Thin divider between meta row and body paragraph */
.cs-meta-divider {
  border-top: 1px dashed var(--divider);
  margin-bottom: 32px;
}

/* ── "Link Apps →" app link (Figma) — sits between meta row and divider ── */
.cs-applink {
  display: flex;
  width: fit-content;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.03em;
  color: #000;
  text-decoration: none;
  transition: color 160ms ease;
}

.cs-applink-text {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.cs-applink-arrow {
  display: block;
  flex-shrink: 0;
  color: var(--brand-teal);
  opacity: 1;
}

.cs-applink-letter {
  display: inline-block;
  transform-origin: center;
  backface-visibility: hidden;
  will-change: transform;
}

/* ── Body paragraphs ── */
.cs-body-block {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-bottom: 64px;
}

.cs-body-para {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 300;
  line-height: 1.6;
  letter-spacing: -0.18px;
  color: rgba(0, 0, 0, 0.7);
}

/* ── Section-based gallery ─────────────────────────────
   Three content presets: full, square-left and square-right. The split grid
   follows the source-art ratio (1010:1564), so the square and landscape
   frames keep the same height as the Figma composition. */
.cs-gallery {
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: calc(100% + 184px);
  margin-left: -92px;
  padding-bottom: 120px;
}
.cs-gallery-section {
  --section-gap: 12px;
  --section-bg: transparent;
  display: grid;
  gap: var(--section-gap);
  background: var(--section-bg);
}
.cs-gallery-section--full { grid-template-columns: 1fr; }
.cs-gallery-section--split-square-left { grid-template-columns: 1010fr 1564fr; }
.cs-gallery-section--split-square-right { grid-template-columns: 1564fr 1010fr; }
.cs-g-fig { min-width: 0; margin: 0; }
.cs-g-frame {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: #f0f0f0;
}
.cs-gallery-section--full .cs-g-frame { aspect-ratio: 16 / 9; }
.cs-gallery-section--split-square-left .cs-g-fig:first-child .cs-g-frame,
.cs-gallery-section--split-square-right .cs-g-fig:last-child .cs-g-frame { aspect-ratio: 1 / 1; }
.cs-gallery-section--split-square-left .cs-g-fig:last-child .cs-g-frame,
.cs-gallery-section--split-square-right .cs-g-fig:first-child .cs-g-frame { aspect-ratio: 1564 / 1010; }
.cs-g-ph { position: absolute; inset: 0; }
.cs-g-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}
.cs-g-img.is-contain { object-fit: contain; }
/* ── Video showcase — inset 48px from the panel's true edges ── */
.cs-video-block {
  width: calc(100% + 184px);
  margin-left: -92px;
  aspect-ratio: 16/9;
  overflow: hidden;
  position: relative;
  background: #111;
  margin-bottom: 24px;
}

.cs-gallery .cs-video-block {
  width: 100%;
  margin-left: 0;
}

.cs-video-block video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cs-video-ph {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
}

.cs-video-ph-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.2);
}

/* ── Whisper-fade: reveal targets start hidden only when JS motion is on. ── */
html.motion-on [data-reveal],
html.motion-on [data-reveal-scroll] { opacity: 0; }

/* ── Mobile adjustments ── */
@media (max-width: 900px) {
  .cs-meta-row {
    gap: 32px 60px;
  }

  .cs-video-block {
    width: 100%;
    margin-left: 0;
  }

  .cs-gallery {
    width: 100%;
    margin-left: 0;
    gap: 16px;
  }
  .cs-gallery-section--split-square-left,
  .cs-gallery-section--split-square-right { grid-template-columns: 1fr; }
  .cs-gallery-section--split-square-left .cs-g-frame,
  .cs-gallery-section--split-square-right .cs-g-frame { aspect-ratio: auto; min-height: 62vw; }

  .cs-headline {
    font-size: clamp(32px, 9vw, 56px);
    letter-spacing: -0.02em;
  }

  .cs-title-line {
    display: inline;
  }
}

/* ── Lenis smooth scroll ── */
html.lenis {
  height: auto;
}

.lenis.lenis-smooth {
  scroll-behavior: auto !important;
}

.lenis.lenis-smooth [data-lenis-prevent] {
  overscroll-behavior: contain;
}

.cs-close:focus-visible,
.cs-right-close:focus-visible,
.cs-source:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  opacity: 1;
}

/* ── Dark theme (html.dark) ── */
html.dark { --divider: rgba(255, 255, 255, 0.14); }
/* Standalone page: home.css isn't loaded here, so darken body/wipe ourselves */
html.dark body,
html.dark #page-wipe { background: #020202; }
html.dark .cs-right { background: #020202; }
html.dark .cs-close,
html.dark .cs-right-close,
html.dark .cs-source,
html.dark .cs-applink,
html.dark .cs-headline,
html.dark .cs-meta-item-value { color: #fff; }
html.dark .cs-slide-title { color: #d9d9d9; }
html.dark .cs-slider-counter { color: #d9d9d9; }
html.dark .cs-meta-item-label { color: rgba(255, 255, 255, 0.4); }
html.dark .cs-body-para { color: rgba(255, 255, 255, 0.82); }
html.dark .cs-g-fig { background: #1c1b1b; }
/* ══ Responsive additions ═════════════════════════════════ */

/* ── Tablet (901–1200px): narrower article gutters ── */
@media (max-width: 1200px) and (min-width: 901px) {
  #cs-right-content { padding: 32px 48px 0; }
  .cs-video-block { width: calc(100% + 96px); margin-left: -48px; }
  .cs-gallery { width: calc(100% + 96px); margin-left: -48px; }
  .cs-top-row { width: calc(100% + 48px); margin-left: -48px; }
}

/* ── Mobile (≤900px): bottom project-navigation overlay ── */
@media (max-width: 900px) {
  /* Pin the shell to the viewport; the article remains the only scroll area. */
  .cs-shell { height: 100vh; min-height: 0; }
  .cs-right { height: auto; flex: 1; min-height: 0; }

  .cs-left {
    box-sizing: border-box;
    position: fixed;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 20;
    height: auto;
    min-height: 0;
    max-height: none;
    padding: 120px 24px max(24px, env(safe-area-inset-bottom));
    border-bottom: 0;
    background: transparent;
    pointer-events: none;
  }

  .cs-left::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
      to top,
      #020202 0%,
      rgba(2, 2, 2, 0.96) 36%,
      rgba(2, 2, 2, 0) 100%
    );
    -webkit-backdrop-filter: blur(36px);
    backdrop-filter: blur(36px);
    -webkit-mask-image: linear-gradient(to top, #000 0 36%, transparent 100%);
    mask-image: linear-gradient(to top, #000 0 36%, transparent 100%);
    pointer-events: none;
  }

  /* Keep project navigation without the desktop artwork or counter. */
  .cs-slider { height: 48px; }
  .cs-slide { display: none; }
  .cs-slider-nav {
    position: fixed;
    right: 24px;
    bottom: max(24px, env(safe-area-inset-bottom));
    left: auto;
    width: auto;
    transform: none;
    justify-content: flex-end;
    gap: 24px;
    pointer-events: none;
  }
  .cs-slider-arrow { pointer-events: auto; }
  .cs-slider-counter { display: none; }
  .cs-right-close {
    position: fixed;
    bottom: max(24px, env(safe-area-inset-bottom));
    left: 24px;
    z-index: 22;
    height: 48px;
    opacity: 1;
  }
  .cs-close { top: 20px; left: 20px; }
  .cs-top-row { margin-bottom: 32px; margin-left: 0; width: auto; }
  .cs-headline { margin-bottom: 32px; }
  .cs-body-block { margin-bottom: 48px; }
  .cs-video-block { margin-bottom: 16px; }
}
