@import '../../landing/css/base.css';

/* Figma case studies frame — fixed palette, not site colorway */
html:has(body.case-studies-page) {
  --fg: #e7bba4;
  --bg: #1b1813;
}

body.case-studies-page {
  --fg: #e7bba4;
  --bg: #1b1813;
  --cs-fg: #e7bba4;
  --cs-bg: #1b1813;
  --cs-rule: rgba(231, 187, 164, 0.45);
  --cs-tagline-size: 36px;
  --cs-label-size: 12px;
  --cs-from-size: 20px;
  --cs-project-size: 18px;
  --cs-row-pad: 0.55rem;
  --cs-block-width: 640px;
  background: var(--cs-bg);
  color: var(--cs-fg);
  overflow: hidden;
  height: 100vh;
  overscroll-behavior: none;
}

body.case-studies-page .nav-top {
  position: relative;
  z-index: 10;
  background: none;
}

body.case-studies-page .nav-link {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  letter-spacing: 0;
  text-transform: none;
  font-weight: 400;
  opacity: 1;
  color: var(--cs-fg);
  transition: opacity 0.25s ease;
}

body.case-studies-page a.nav-link:hover {
  opacity: 0.7;
}

body.case-studies-page .nav-left {
  display: none;
}

/* ── Infinite moodboard ── */
.cs-main {
  position: relative;
  height: 100vh;
  overflow: hidden;
  isolation: isolate;
}

.cs-board-viewport {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

body.cs-board-dragging .cs-board-viewport,
body.cs-board-dragging {
  cursor: grabbing;
}

.cs-board-canvas {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
  backface-visibility: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.cs-board-layers {
  position: relative;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.cs-board-copy {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.cs-board-layer {
  position: absolute;
  inset: 0;
}

.cs-board-item {
  position: absolute;
  margin: 0;
  overflow: visible;
  border-radius: 3px;
  opacity: 0;
  transition: opacity 0.5s ease;
  box-shadow: none;
  z-index: 1;
}

.cs-board-layers.is-visible .cs-board-item {
  opacity: 1;
  transition-delay: var(--delay, 0ms);
}

.cs-board-media {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* Center copy — always above images, counter-scaled for readable type */
.cs-center-wrap {
  position: absolute;
  z-index: 9;
  pointer-events: none;
  text-align: center;
  box-sizing: border-box;
  /* Counter-scale about the centre so the wrap's centre stays locked to the
     focal point (screen centre); flex-centre the copy so the *text* — not the
     taller reserved box — is what sits at the centre. */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  transform: scale(calc(1 / var(--board-scale, 1)));
  transform-origin: center;
  isolation: isolate;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.cs-center-wrap--tile {
  z-index: 9;
}

.cs-center-block {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.cs-tagline {
  font-family: 'Eterne', serif;
  font-style: normal;
  font-size: clamp(1.35rem, 2.6vw, var(--cs-tagline-size));
  line-height: 1.28;
  color: var(--cs-fg);
  margin: 0 auto 2.25rem;
  max-width: 100%;
  text-wrap: pretty;
}

.cs-tagline em {
  font-style: italic;
}

.cs-projects-head,
.cs-project-row {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.7fr) minmax(0, 0.95fr);
  gap: 0 0.75rem;
  align-items: baseline;
  text-align: left;
}

.cs-projects-head {
  font-family: 'SharpEarth', sans-serif;
  font-size: var(--cs-label-size);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cs-fg);
  padding-bottom: var(--cs-row-pad);
}

.cs-projects-head span:nth-child(2) {
  text-align: center;
}

.cs-projects-head span:nth-child(3) {
  text-align: right;
}

.cs-rule {
  border: none;
  border-top: 1px solid var(--cs-rule);
  margin: 0 0 var(--cs-row-pad);
}

.cs-projects-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.cs-project-row {
  padding: var(--cs-row-pad) 0;
  border-bottom: 1px solid var(--cs-rule);
}

.cs-from {
  font-family: 'Eterne', serif;
  font-style: normal;
  font-size: var(--cs-from-size);
  line-height: 1.2;
  text-align: left;
}

.cs-project-name {
  font-family: 'SharpEarth', sans-serif;
  font-size: var(--cs-project-size);
  line-height: 1.25;
  letter-spacing: -0.02em;
  text-align: center;
  white-space: nowrap;
}

.cs-to {
  font-family: 'Eterne', serif;
  font-style: normal;
  font-size: var(--cs-from-size);
  line-height: 1.2;
  text-align: right;
}

.nav-mobile-toggle {
  display: none !important;
}

@media (max-width: 1024px) {
  :root {
    --cs-from-size: 17px;
    --cs-project-size: 18px;
  }

  /* Mobile/tablet 3: infinite image feed */
  html:has(body.case-studies-page) {
    --fg: #b9c264;
    --bg: #1b1a18;
  }

  body.case-studies-page {
    --fg: #b9c264;
    --bg: #1b1a18;
    --cs-fg: #b9c264;
    --cs-bg: #1b1a18;
    background: var(--cs-bg);
    color: var(--cs-fg);
    overflow-x: hidden;
    overflow-y: auto;
    height: auto;
    min-height: 100%;
    overscroll-behavior: auto;
  }

  body.case-studies-page .nav-links-desktop {
    display: none !important;
  }

  body.case-studies-page .nav-mobile-toggle {
    display: inline !important;
  }

  body.case-studies-page .nav-brand {
    font-family: 'SharpEarth', sans-serif;
    font-size: 18px;
    letter-spacing: -0.05em;
    pointer-events: auto;
  }

  body.case-studies-page .nav-top {
    position: fixed;
    padding-left: 27px;
    padding-right: 27px;
    z-index: 20;
  }

  body.case-studies-page .nav-link {
    font-family: 'SharpEarth', sans-serif;
    font-size: 18px;
    letter-spacing: -0.05em;
    color: #b9c264 !important;
    opacity: 1 !important;
  }

  body.case-studies-page .cs-main {
    height: auto;
    min-height: 100%;
    overflow: visible;
  }

  .cs-board-viewport {
    display: none !important;
  }

  .cs-mobile-feed,
  .cs-mobile-feed[hidden] {
    display: block;
    box-sizing: border-box;
    padding: calc(var(--nav-stack-height) + 10px) 10px 10px;
  }

  .cs-mobile-feed-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    overflow: hidden;
  }

  .cs-mobile-item,
  .cs-mobile-item--landscape,
  .cs-mobile-item--portrait,
  .cs-mobile-item--left,
  .cs-mobile-item--right,
  .cs-mobile-item--center {
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 100%;
    align-self: stretch;
    display: block;
    line-height: 0;
    background: transparent;
    overflow: hidden;
    border-radius: 10px;
  }

  .cs-mobile-media {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    object-fit: contain;
    object-position: center;
    background: transparent;
    -webkit-user-drag: none;
    user-select: none;
    border-radius: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cs-board-item {
    transition: none;
  }

  .cs-board-layers.is-visible .cs-board-item {
    transition-delay: 0ms;
  }
}
