/* Homepage rebuild — motion, sticky case study, horizontal work */

/* === 1. Hero === */
#hero-line-2,
#hero-line-2 .hero-char {
  font-style: italic;
}

.hero-scroll-prompt {
  position: relative;
  z-index: 10;
  align-self: center;
  margin-top: 2.75rem;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #9a9a9a;
  text-align: center;
}

/* === 2. Intro lead claim === */
.lead-claim {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.9rem, 4vw, 3rem);
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: #111111;
  margin-bottom: 1.5rem;
}

/* === 3. Brahmi Coffee Roasters case study — sticky left column, scrubbed story blocks === */
/* Base state: static, stacked, fully readable. This is the no-JS,
   reduced-motion, and tablet/mobile layout. JS adds `.csx-anim` to switch
   into the pinned sticky-left storytelling mode. */
#brahmi.csx .csx-grid {
  margin-top: 0;
}

#brahmi.csx .feature-visual {
  width: fit-content;
}

#brahmi.csx .feature-visual img {
  width: auto;
  max-width: 100%;
  max-height: calc(100vh - 180px);
  max-height: calc(100dvh - 180px);
}

.csx-right {
  position: relative;
}

.csx-stage {
  display: block;
}

.csx-block {
  opacity: 1;
  transform: none;
}

.csx-block + .csx-block {
  margin-top: clamp(56px, 8vh, 88px);
}

.csx-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 18px;
}

.csx-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.4rem, 2.4vw, 2rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--paper);
  margin: 0 0 20px;
}

.csx-copy {
  font-size: 18px;
  line-height: 1.7;
  color: #c9c8c4;
  max-width: 480px;
}

.csx-copy + .csx-copy {
  margin-top: 16px;
}

.csx-list {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 28px;
  max-width: 480px;
}

.csx-list li {
  position: relative;
  padding-left: 18px;
  font-size: 14px;
  color: #c9c8c4;
}

.csx-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.85;
}

.csx-cta {
  margin-top: 28px;
  display: inline-block;
}

.cs-insight {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(48px, 3.5vw, 68px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--paper);
  max-width: 32ch;
}

/* === 3b. Animated storytelling mode (enabled by JS) === */
/* Only the left column pins. The right side is natural document flow — each
   block reserves its own scroll distance (min-height) and fades in once on
   entry (opacity 0->1, y 30->0, power3.out), then stays fully opaque and
   scrolls away naturally. The hero image keeps its aspect ratio, crop, and
   border-radius — it is only capped to fit the viewport (never scaled up). */
#brahmi.csx.csx-anim .csx-left {
  position: sticky;
  top: 120px;
  align-self: flex-start;
}

#brahmi.csx.csx-anim .csx-right {
  height: auto;
}

#brahmi.csx.csx-anim .csx-stage {
  position: static;
  display: block;
}

#brahmi.csx.csx-anim .csx-block {
  position: relative;
  grid-area: auto;
  align-self: auto;
  justify-self: auto;
  margin-top: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 80vh;
  min-height: 80svh;
  will-change: transform, opacity;
}

#brahmi.csx.csx-anim .csx-block:first-child {
  min-height: 100vh;
  min-height: 100svh;
}

#brahmi.csx.csx-anim .csx-block:last-child {
  min-height: 40vh;
  min-height: 40svh;
}

#brahmi.csx.csx-anim .csx-cta {
  margin-top: 0;
}

/* === 5. Horizontal work section === */
.work-section {
  padding: 0;
}

.work-heading {
  flex-shrink: 0;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: clamp(88px, 12vh, 140px) clamp(24px, 4vw, 40px) 0;
}

.work-heading h2 {
  color: var(--ink);
}

.work-horizontal {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.work-horizontal-track {
  display: flex;
  flex: 1;
  height: auto;
  min-height: 0;
  will-change: transform;
}

.work-slide {
  flex-shrink: 0;
  width: 100vw;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.work-slide-inner {
  display: flex;
  align-items: center;
  gap: clamp(48px, 6vw, 100px);
  width: min(1200px, 100%);
  padding: 0 clamp(24px, 4vw, 40px);
}

.work-slide-media {
  width: min(44vw, 580px);
  height: auto;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: #efede6;
}

.work-slide-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.work-slide-body {
  flex: 1;
}

.work-slide-body h3 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2.4rem, 4.5vw, 3.8rem);
  letter-spacing: -0.01em;
  line-height: 1.05;
  margin-bottom: 20px;
}

.work-slide-body p {
  font-size: 16px;
  line-height: 1.65;
  color: var(--graphite);
  max-width: 420px;
  margin-bottom: 28px;
}

.work-slide-body .teaser-link {
  font-size: 13.5px;
}

@media (max-width: 900px) {
  .work-section {
    padding: 0 0 70px;
  }

  .work-heading {
    padding: 64px 20px 8px;
  }

  .work-horizontal {
    height: auto !important;
    overflow: visible;
  }

  .work-horizontal-track {
    display: grid;
    grid-template-columns: 1fr;
    gap: 28px;
    padding: 0 20px;
  }

  .work-slide {
    width: 100%;
    height: auto;
  }

  .work-slide-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 24px;
    width: 100%;
    padding: 0;
  }

  .work-slide-media {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
  }

  .work-slide-body p {
    max-width: 100%;
  }
}

/* Reduced-motion / no-pin fallback on desktop: static 3-col grid */
.work-horizontal--static {
  height: auto !important;
  overflow: visible;
}

.work-horizontal--static .work-horizontal-track {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  padding: 0 40px;
  max-width: 1240px;
  margin: 0 auto;
}

.work-horizontal--static .work-slide {
  width: 100%;
  height: auto;
}

.work-horizontal--static .work-slide-inner {
  flex-direction: column;
  align-items: flex-start;
  gap: 20px;
  width: 100%;
  padding: 0;
}

.work-horizontal--static .work-slide-media {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
}

@media (max-width: 900px) {
  .work-horizontal--static .work-horizontal-track {
    grid-template-columns: 1fr;
    gap: 28px;
    padding: 0 20px;
  }
}

/* === 6. Brahmi Coffee Roasters case study — tablet/mobile fallback: stack all content === */
@media (max-width: 820px) {
  #brahmi.csx .csx-list {
    grid-template-columns: 1fr;
  }

  #brahmi.csx.csx-anim .csx-left {
    position: static;
  }

  #brahmi.csx.csx-anim .csx-right {
    height: auto;
  }

  #brahmi.csx.csx-anim .csx-stage {
    position: static;
  }

  #brahmi.csx.csx-anim .csx-block {
    min-height: 0;
    display: block;
  }

  #brahmi.csx.csx-anim .csx-block + .csx-block {
    margin-top: clamp(56px, 8vh, 88px);
  }
}

/* === 6b. Featured case study — condensed mobile version === */
/* Above the mobile breakpoint only the full desktop story (.csx-desk) shows;
   the condensed mobile copy (.csx-mobile) stays hidden. Below it the swap
   happens. The sticky image, size, border radius, and animations are untouched. */
#brahmi.csx .csx-block.csx-mobile {
  display: none;
}

@media (max-width: 820px) {
  #brahmi.csx .feature-visual {
    width: auto;
  }

  #brahmi.csx .csx-block.csx-desk {
    display: none;
  }

  #brahmi.csx .csx-block.csx-mobile {
    display: block;
  }

  #brahmi.csx .csx-mobile .cs-insight {
    font-size: clamp(34px, 8vw, 46px);
    line-height: 1.08;
    max-width: none;
  }

  #brahmi.csx .csx-mobile .csx-title {
    font-size: clamp(1.3rem, 4.5vw, 1.6rem);
  }

  #brahmi.csx .csx-mobile .csx-copy {
    font-size: 16px;
    line-height: 1.6;
  }

  #brahmi.csx .csx-mobile .csx-label {
    font-size: 12px;
    letter-spacing: 0.16em;
    margin-bottom: 12px;
  }

  #brahmi.csx .csx-mobile .csx-list {
    grid-template-columns: 1fr;
  }

  #brahmi.csx .csx-block + .csx-block {
    margin-top: 32px;
  }

  #brahmi.csx .csx-cta {
    margin-top: 0;
  }
}

/* === 7. Sticky Featured Projects — Skiper17-style stacked images === */
.sticky-featured {
  background: var(--ink);
  color: var(--paper);
  border-top: 1px solid #222;
}

.sfp-stage {
  position: relative;
  height: 100vh;
  overflow: hidden;
}

.sfp-stack {
  position: relative;
  height: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 40px;
}

.sfp-card {
  position: absolute;
  inset: 0;
  padding-top: clamp(64px, 10vh, 128px);
  display: flex;
  align-items: center;
  justify-content: center;
  will-change: transform, opacity, filter;
}

.sfp-media {
  width: min(70vh * 0.8, 100%);
  aspect-ratio: 4 / 5;
}

.sfp-media img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: 8px;
}

.sfp-placeholder {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(160deg, #2a2a2a, #151515 60%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  overflow: hidden;
}

.sfp-placeholder::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.06;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.sfp-ph-label {
  position: relative;
  z-index: 1;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #9a9a9a;
}

.sfp-ph-size {
  position: relative;
  z-index: 1;
  font-size: 13px;
  color: #6b6b6b;
}

.sfp-ph-ratio {
  position: relative;
  z-index: 1;
  font-size: 11px;
  letter-spacing: 0.16em;
  color: #555;
}

/* Static fallback — reduced motion / pin disabled */
.sfp-static .sfp-stage {
  height: auto;
  overflow: visible;
}

.sfp-static .sfp-stack {
  position: static;
  height: auto;
  display: flex;
  flex-direction: column;
  gap: clamp(56px, 8vh, 96px);
  padding-top: 40px;
  padding-bottom: 120px;
}

.sfp-static .sfp-card {
  position: static;
  opacity: 1;
  transform: none;
  padding-top: 0;
}

.sfp-static .sfp-media {
  height: auto;
  width: min(520px, 100%);
  aspect-ratio: auto;
}

/* Mobile — same pinned slide animation as desktop */
@media (max-width: 900px) {
  .sfp-stage {
    height: 100svh;
    overflow: hidden;
  }

  .sfp-stack {
    position: relative;
    height: 100%;
    padding: 0 20px;
  }

  .sfp-card {
    position: absolute;
    inset: 0;
    padding-top: clamp(40px, 8vh, 88px);
  }

  .sfp-media {
    width: min(70vh * 0.8, 100%);
    aspect-ratio: 4 / 5;
  }
}

/* === 8. Floating pixel character — bottom-right hero accent === */
/* Entrance lives on the anchor (plays once, ends on natural state); the idle
   levitation lives on .floating-character-idle so it never fights the hover
   transform. The shadow is a sibling of the idle wrapper — it does NOT inherit
   the vertical drift, so it can react inversely as the character rises. */
.floating-character {
  position: absolute;
  right: clamp(32px, 6vw, 120px);
  bottom: clamp(24px, 7vh, 100px);
  z-index: 5;
  display: block;
  line-height: 0;
  text-decoration: none;
  cursor: pointer;
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
  animation: hero-char-enter 1.2s cubic-bezier(0.22, 1, 0.36, 1) 0.6s backwards;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
              filter 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.floating-character:hover,
.floating-character:focus-visible {
  transform: scale(1.04);
  filter: brightness(1.06);
}

/* Neutralise the site's cursor-img-active img scale so it never stacks with
   the hover scale above. */
.floating-character.cursor-img-active img {
  transform: none;
}

.floating-character-idle {
  display: block;
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
  animation: hero-char-float var(--char-duration, 6s) ease-in-out infinite;
}

.floating-character-shadow {
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 74%;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
  filter: blur(2px);
  pointer-events: none;
  will-change: transform, opacity;
  animation: hero-char-shadow var(--char-duration, 6s) ease-in-out infinite;
}

.floating-character img {
  display: block;
  width: auto;
  height: clamp(120px, 16vh, 180px);
  -webkit-user-drag: none;
}

@keyframes hero-char-enter {
  0%   { opacity: 0; transform: translate3d(0, 20px, 0) scale(0.95); }
  100% { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

@keyframes hero-char-float {
  0%   { transform: translate3d(0, 0, 0) rotate(-0.4deg) scale(1); }
  50%  { transform: translate3d(1.5px, -22px, 0) rotate(0.6deg) scale(1.015); }
  100% { transform: translate3d(0, 0, 0) rotate(-0.4deg) scale(1); }
}

@keyframes hero-char-shadow {
  0%   { transform: translateX(-50%) translateY(0) scale(1); opacity: 0.5; }
  50%  { transform: translateX(-50%) translateY(7px) scale(1.05); opacity: 0.2; }
  100% { transform: translateX(-50%) translateY(0) scale(1); opacity: 0.5; }
}

/* Large desktop */
@media (min-width: 1600px) {
  .floating-character {
    right: 7vw;
    bottom: 8vh;
  }
  .floating-character img {
    height: clamp(140px, 18vh, 200px);
  }
}

/* Tablet */
@media (max-width: 1024px) {
  .floating-character {
    right: 4vw;
    bottom: 6vh;
  }
  .floating-character img {
    height: clamp(96px, 13vh, 150px);
  }
}

/* Mobile */
@media (max-width: 700px) {
  .floating-character {
    right: 20px;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  }
  .floating-character img {
    height: clamp(80px, 11vh, 100px);
  }
}

/* Compact phones — shrink + soften so it never crowds the scroll prompt */
@media (max-width: 380px) and (max-height: 720px) {
  .floating-character {
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    opacity: 0.85;
  }
  .floating-character img {
    height: clamp(64px, 9vh, 80px);
  }
}

/* Reduced motion — static companion, no levitation or fade-in */
@media (prefers-reduced-motion: reduce) {
  .floating-character {
    animation: none;
    opacity: 1;
    transform: none;
    transition: none;
  }
  .floating-character-idle {
    animation: none;
  }
  .floating-character-shadow {
    animation: none;
    opacity: 0.45;
  }
}
