/* ── Animated gradient background ── */
#bg-gradient {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  transform-origin: center center;
  transition: transform 2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Psychedelic — scale the whole container outward from center */
:root[data-psychedelic] #bg-gradient {
  transform: scale(1.9);
}

.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  will-change: transform;
  transition: opacity 1.8s ease, filter 1.8s ease;
}

/* Blue-violet — dead center */
.bg-orb--1 {
  width: 65vw;
  height: 42vh;
  left: calc(50% - 32.5vw);
  top: calc(50% - 21vh);
  background: radial-gradient(circle at center, #4400ff 0%, #9900dd 55%, transparent 80%);
  opacity: 0.85;
  animation: orbDrift1 24s ease-in-out infinite alternate;
}

/* Orange-amber — dead center, slightly smaller */
.bg-orb--2 {
  width: 55vw;
  height: 36vh;
  left: calc(50% - 27.5vw);
  top: calc(50% - 18vh);
  background: radial-gradient(circle at center, #ff3300 0%, #ff8800 55%, transparent 80%);
  opacity: 0.75;
  animation: orbDrift2 30s ease-in-out infinite alternate;
}

/* Cyan-teal — dead center, smallest */
.bg-orb--3 {
  width: 45vw;
  height: 30vh;
  left: calc(50% - 22.5vw);
  top: calc(50% - 15vh);
  background: radial-gradient(circle at center, #00ddff 0%, #00ffcc 55%, transparent 80%);
  opacity: 0.65;
  animation: orbDrift3 20s ease-in-out infinite alternate;
}

/* Grain texture — SVG feTurbulence tile, no JS, no canvas */
#bg-gradient::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='256' height='256'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 256px 256px;
  opacity: 0.04;
  pointer-events: none;
  transition: opacity 1.8s ease;
}

/* Psychedelic — looser blur so the scaled-up orbs blend smoothly */
:root[data-psychedelic] .bg-orb { filter: blur(80px); }
:root[data-psychedelic] .bg-orb--1 { opacity: 0.95; }
:root[data-psychedelic] .bg-orb--2 { opacity: 0.90; }
:root[data-psychedelic] .bg-orb--3 { opacity: 0.92; }
:root[data-psychedelic] #bg-gradient::after { opacity: 0.08; }

/* Small drifts — orbs stay near centre, just breathe gently */
@keyframes orbDrift1 {
  0%   { transform: translate(0,    0)   scale(1);    }
  100% { transform: translate(8vw,  7vh) scale(1.08); }
}

@keyframes orbDrift2 {
  0%   { transform: translate(0,    0)    scale(1);    }
  100% { transform: translate(-7vw, -8vh) scale(1.06); }
}

@keyframes orbDrift3 {
  0%   { transform: translate(0,   0)   scale(1);    }
  100% { transform: translate(-6vw, 9vh) scale(0.94); }
}

/* ── Loader ── */
#loader {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: var(--c-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
}

.loader__counter {
  font-family: var(--font-display);
  font-size: clamp(5rem, 16vw, 14rem);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--c-text);
  font-variant-numeric: tabular-nums;
}

.loader__label {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--c-text-dim);
}

/* ── Spiral section ── */
.spiral-section {
  position: relative;
  height: 220vh;
}

@media (max-width: 768px) {
  .spiral-section { height: auto; }
}

.spiral-stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 2100px;
  perspective-origin: 50% 50%;
}

/* Depth-of-field fade at top and bottom edges */
.spiral-stage::before,
.spiral-stage::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 22%;
  z-index: 6;
  pointer-events: none;
}

.spiral-stage::before {
  top: 0;
  background: linear-gradient(to bottom, var(--c-bg) 0%, transparent 100%);
}

.spiral-stage::after {
  bottom: 0;
  background: linear-gradient(to top, var(--c-bg) 0%, transparent 100%);
}

/* ── Spiral group — the 3D container that rotates ── */
.spiral-group {
  position: relative;
  width: 0;
  height: 0;
  flex-shrink: 0;
  transform-style: preserve-3d;
  will-change: transform;
}

/* ── Individual spiral card — billboard (always faces camera) ── */
.spiral-item {
  position: absolute;
  overflow: visible;
  cursor: none;
}

.spiral-item__link {
  display: block;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  text-decoration: none;
  border-radius: 18px;
}

.spiral-item__img-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.spiral-item__img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.55);
  transform: scale(1.06);
  transition:
    filter    0.9s var(--ease-expo),
    transform 1.2s var(--ease-expo);
  will-change: transform, filter;
}

.spiral-item:hover .spiral-item__img-wrap img {
  filter: brightness(0.22);
  transform: scale(1.0);
}

.spiral-item__tint {
  position: absolute;
  inset: 0;
  opacity: 0;
  mix-blend-mode: color;
  transition: opacity 0.7s var(--ease-expo);
  background: var(--item-accent, #fff);
}

.spiral-item:hover .spiral-item__tint { opacity: 0.35; }

.spiral-item__info {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 1.5rem 1.75rem;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.92) 0%,
    rgba(0, 0, 0, 0.6) 40%,
    rgba(0, 0, 0, 0.1) 70%,
    transparent 100%
  );
  z-index: 2;
}

.spiral-item__num {
  font-family: var(--font-mono);
  font-size: 0.5rem;
  letter-spacing: 0.26em;
  color: var(--c-text-dim);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

.spiral-item__title {
  font-family: var(--font-display);
  font-size: clamp(1rem, 2.2vw, 1.6rem);
  font-weight: 400;
  line-height: 0.92;
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--c-text);
  margin-bottom: 0.65rem;
  transition: transform 0.5s var(--ease-expo);
  will-change: transform;
  text-shadow: 0 2px 12px rgba(0,0,0,0.7);
}

.spiral-item:hover .spiral-item__title {
  transform: translateY(-4px);
}

.spiral-item__client {
  font-family: var(--font-body);
  font-size: var(--size-label);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--c-text-dim);
}

/* ── Spiral UI overlays ── */
.spiral-counter {
  position: absolute;
  bottom: 2.5rem;
  left: var(--gutter);
  font-family: var(--font-mono);
  font-size: 0.55rem;
  letter-spacing: 0.22em;
  color: var(--c-text-dim);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  z-index: 10;
  pointer-events: none;
}

.spiral-counter__sep {
  opacity: 0.35;
}

.spiral-hint {
  position: absolute;
  bottom: 2.5rem;
  right: var(--gutter);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.5rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--c-text-dim);
  pointer-events: none;
  z-index: 10;
}

.spiral-hint__line {
  display: block;
  width: 2rem;
  height: 1px;
  background: var(--c-text-dim);
}

/* ── Identity section ── */
.identity {
  padding: clamp(6rem, 10vw, 12rem) var(--gutter) clamp(4rem, 6vw, 8rem);
  border-top: 1px solid var(--c-border);
  overflow: hidden;
}

.identity__name {
  display: flex;
  flex-direction: column;
  margin-bottom: clamp(3rem, 6vw, 7rem);
  line-height: 0.88;
}

.identity__name-word {
  font-family: var(--font-display);
  font-size: clamp(7rem, 16vw, 22rem);
  font-weight: 300;
  font-style: italic;
  letter-spacing: -0.04em;
  color: var(--c-text);
  display: block;
  will-change: transform;
  overflow: hidden;
  line-height: 0.95;
  padding-bottom: 0.06em;
}

.identity__name-word--right {
  align-self: flex-end;
}

.identity__body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  border-top: 1px solid var(--c-border);
  padding-top: var(--space-lg);
}

.identity__tagline {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 2.5vw, 2.8rem);
  font-weight: 300;
  font-style: italic;
  line-height: 1.15;
  color: var(--c-text);
  max-width: 28ch;
}

.identity__sub {
  font-size: var(--size-label);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--c-text-dim);
  margin-top: var(--space-sm);
}

.identity__awards {
  font-size: var(--size-label);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--c-text-dim);
  line-height: 2;
  align-self: end;
}

/* ── Footer strip ── */
.home-footer {
  padding: clamp(3rem, 6vw, 6rem) var(--gutter);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: var(--space-xl);
  border-top: 1px solid var(--c-border);
}

.home-footer__cta {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 5vw, 6rem);
  font-weight: 300;
  font-style: italic;
  line-height: 1;
  color: var(--c-text);
}

.home-footer__cta a {
  display: inline-block;
  position: relative;
  overflow: hidden;
}

.home-footer__cta a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--c-accent-gradient);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.6s var(--ease-expo);
}

.home-footer__cta a:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

.home-footer__links {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  align-items: flex-end;
  padding-bottom: 0.5rem;
}

.home-footer__link {
  font-size: var(--size-label);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--c-text-dim);
  transition: color var(--dur-fast) var(--ease-expo);
}

.home-footer__link:hover { color: var(--c-accent); }

.home-footer__copy {
  grid-column: 1 / -1;
  font-size: var(--size-label);
  letter-spacing: 0.1em;
  color: var(--c-text-dim);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--c-border);
  display: flex;
  justify-content: space-between;
}

/* ── Mobile ── */
@media (max-width: 768px) {

  /* Spiral: flat vertical grid */
  .spiral-stage {
    position: static;
    height: auto;
    perspective: none;
    display: block;
    padding: var(--gutter);
    padding-top: calc(var(--nav-h) + 2rem);
    overflow: visible;
  }

  /* Hide top/bottom depth-of-field fades — irrelevant in flat grid layout */
  .spiral-stage::before,
  .spiral-stage::after { display: none; }

  .spiral-group {
    position: static;
    width: 100%;
    height: auto;
    transform-style: flat;
    transform: none !important;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }

  .spiral-item {
    position: relative !important;
    width: 100% !important;
    height: 0 !important;
    padding-bottom: 125% !important; /* 4:5 portrait — fills phone screen nicely */
    left: auto !important;
    top: auto !important;
    transform: none !important;
    cursor: auto !important;
  }

  .spiral-item .spiral-item__link {
    position: absolute !important;
    inset: 0 !important;
    height: 100% !important;
  }

  .spiral-item__img-wrap img,
  .spiral-item__img-wrap video {
    filter: brightness(0.65) !important;
    transform: none !important;
  }

  .spiral-counter,
  .spiral-hint {
    display: none;
  }

  .spiral-item__title {
    font-size: clamp(1.1rem, 5vw, 1.6rem);
  }

  /* Identity */
  .identity__name-word {
    font-size: clamp(5rem, 18vw, 10rem);
  }

  .identity__body {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }

  /* Footer */
  .home-footer {
    grid-template-columns: 1fr;
  }
  .home-footer__links { align-items: flex-start; }
  .home-footer__copy {
    flex-direction: column;
    gap: 0.5rem;
  }

  /* Hide custom cursor on touch */
  #cursor { display: none; }
  body { cursor: auto; }
}

/* ── View toggle button — lives inside .nav__center-controls ── */
.view-toggle {
  position: static;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(240, 237, 232, 0.07);
  border: 1px solid var(--c-border);
  border-radius: 99px;
  padding: 5px 10px;
  cursor: none;
  z-index: 10;
  transition: background 0.25s, border-color 0.25s;
}

.view-toggle:hover {
  background: rgba(240, 237, 232, 0.13);
  border-color: var(--c-border-hover);
}

.view-toggle__opt {
  display: flex;
  width: 18px;
  height: 18px;
  color: var(--c-text-dim);
  transition: color 0.2s;
}

.view-toggle__opt svg { width: 100%; height: 100%; }

.view-toggle__opt.active {
  color: var(--c-text);
}

/* ── Falling / rain mode ── */

/* drop-shadow on the outer element traces the rendered alpha (SVG clip shape),
   not the element's box — so no rectangle bleed */
.falling-item {
  filter: drop-shadow(0 8px 48px rgba(0, 0, 0, 0.55));
}

.falling-item .spiral-item__link {
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.falling-item:hover .spiral-item__link {
  transform: scale(1.08);
}

/* Remove the gradient overlay — it bleeds outside the SVG clip as a visible rectangle. */
.falling-item .spiral-item__info {
  background: none;
}

/* Restore legibility with text-shadow instead of background gradient */
.falling-item .spiral-item__title {
  text-shadow:
    0 1px 20px rgba(0,0,0,1),
    0 2px 40px rgba(0,0,0,0.95),
    0 0 80px rgba(0,0,0,0.8);
}
.falling-item .spiral-item__client,
.falling-item .spiral-item__num {
  text-shadow: 0 1px 12px rgba(0,0,0,1), 0 2px 24px rgba(0,0,0,0.9);
}

/* Bring hovered falling tile to front */
.falling-item:hover {
  z-index: 10;
}

/* ── Grid group ── */
.grid-group {
  transform-style: preserve-3d;
}

.grid-item {
  position: relative !important;
  width: auto !important;
  height: auto !important;
  left: auto !important;
  top: auto !important;
  transform: none;
  transform-style: preserve-3d;
  cursor: none;
  overflow: visible !important;
  filter: drop-shadow(0 8px 48px rgba(0, 0, 0, 0.55));
}

.grid-item .spiral-item__link {
  overflow: visible !important;
  border-radius: 0 !important;
}

/* Same gradient-bleed fix as falling items */
.grid-item .spiral-item__info {
  background: none;
}

.grid-item .spiral-item__title {
  text-shadow:
    0 1px 20px rgba(0,0,0,1),
    0 2px 40px rgba(0,0,0,0.95),
    0 0 80px rgba(0,0,0,0.8);
}
.grid-item .spiral-item__client,
.grid-item .spiral-item__num {
  text-shadow: 0 1px 12px rgba(0,0,0,1), 0 2px 24px rgba(0,0,0,0.9);
}

/* ── Psychedelic mode — homepage-specific overrides ── */
:root[data-psychedelic] canvas[aria-hidden="true"] {
  opacity: 0.75 !important;
}

/* Hide the dark edge fades — psychedelic bg handles the atmosphere */
:root[data-psychedelic] .spiral-stage::before,
:root[data-psychedelic] .spiral-stage::after {
  display: none;
}

:root[data-psychedelic] .spiral-item__info {
  background: linear-gradient(
    to top,
    rgba(60, 0, 15, 0.92) 0%,
    rgba(60, 0, 15, 0.4)  50%,
    transparent 100%
  );
}

/* Falling and grid tiles use SVG clip shapes — gradient bleeds outside the clip as a rectangle */
:root[data-psychedelic] .falling-item .spiral-item__info,
:root[data-psychedelic] .grid-item .spiral-item__info {
  background: none;
}

/* Videos are black by default before playback — keep transparent so bg shows through clip */
.spiral-item__img-wrap video {
  background: transparent;
  display: block;
}

:root[data-psychedelic] .psych-switch {
  background: rgba(255, 150, 180, 0.15);
  border-color: rgba(255, 150, 180, 0.3);
}

:root[data-psychedelic] .identity,
:root[data-psychedelic] .home-footer {
  border-color: rgba(255, 100, 150, 0.2);
}

:root[data-psychedelic] .identity__name-word,
:root[data-psychedelic] .home-footer__cta {
  color: #fff5f8;
}
