/* ---------- Fonts ---------- */
@font-face { font-family: 'SF UI Display'; src: url('../../fonts/SFUIDisplay-Thin.otf') format('opentype'); font-weight: 100; font-display: swap; }
@font-face { font-family: 'SF UI Display'; src: url('../../fonts/SFUIDisplay-Regular.otf') format('opentype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'SF UI Display'; src: url('../../fonts/SFUIDisplay-Medium.otf') format('opentype'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'SF UI Display'; src: url('../../fonts/SFUIDisplay-Semibold.otf') format('opentype'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'SF UI Display'; src: url('../../fonts/SFUIDisplay-Bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Art Post Black'; src: url('../../fonts/Art Post black.ttf') format('truetype'); font-weight: 400; font-display: swap; }

/* ---------- Preloader ---------- */
#preloader {
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow: hidden;
}

#preloader.is-done {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.pl-paper {
  position: absolute;
  will-change: transform;
}

.pl-paper img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  animation: pl-drift 6s ease-in-out infinite;
}

@keyframes pl-drift {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  50% { transform: translate(3px, -4px) rotate(0.6deg); }
}

/* Resting positions: exact pixel boxes from the source PSD (1920x1080
 * canvas), converted to vw so the whole collage scales as one rigid
 * sheet with viewport width and keeps the designed proportions. Rotation
 * is already baked into each image, so no CSS rotate() here. */
.pl-paper--ecotap { left: -7.76vw; top: -21.77vw; width: 46.56vw; height: 54.32vw; z-index: 8; }
.pl-paper--dubom { left: 60.52vw; top: -21.46vw; width: 65.16vw; height: 58.85vw; z-index: 7; }
.pl-paper--nafra { left: 28.02vw; top: -21.77vw; width: 59.53vw; height: 45.52vw; z-index: 6; }
.pl-paper--strangerthings { left: -14.95vw; top: 12.71vw; width: 55.99vw; height: 70.42vw; z-index: 5; }
.pl-paper--connectteen { left: 61.35vw; top: 12.71vw; width: 64.32vw; height: 71.51vw; z-index: 4; }
.pl-paper--independencia { left: 10.52vw; top: 7.97vw; width: 86.67vw; height: 67.03vw; z-index: 3; }

.pl-paper--nafra img,
.pl-paper--independencia img { animation-duration: 7s; }
.pl-paper--dubom img { animation-duration: 5s; animation-delay: -1.5s; }
.pl-paper--strangerthings img { animation-duration: 6.5s; animation-delay: -3s; }
.pl-paper--connectteen img { animation-duration: 5.5s; animation-delay: -2s; }

/* Exit motion (zigzag translate/rotate, per piece, with randomized
 * per-step wobble) is driven from preloader.js via the Web Animations
 * API, so it can share the exact same logic with the logo's travel. */

#pl-logo {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 20;
  width: 42vw;
  max-width: 560px;
  transform: translate(-50%, -50%);
  filter: brightness(0) invert(1);
  animation: pl-logo-breathe 2.4s ease-in-out infinite;
}

@keyframes pl-logo-breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}

@media (prefers-reduced-motion: reduce) {
  .pl-paper img { animation: none; }
  #pl-logo { animation: none; }
}

/* ---------- Reset ---------- */
* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overscroll-behavior: none;
}

body {
  overflow: hidden;
  background: #000;
  color: #fff;
  font-family: 'SF UI Display', sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- Stage ---------- */
.stage {
  position: relative;
  z-index: 0;
  width: 100vw;
  height: 100dvh;
  min-height: 100svh;
  background: #000;
}

/* WebGL-rendered background photo, warped by a flow-field shader. */
#bg-canvas {
  position: absolute;
  inset: 0;
  z-index: -1;
  display: block;
  width: 100%;
  height: 100%;
}

/* Vignette, sitting between the background photo and the 3D scene. */
.stage::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  background: radial-gradient(circle, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.85) 100%);
  pointer-events: none;
}

.scene-wrap {
  position: absolute;
  inset: 0;
  z-index: 1;
}

#scene {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
  opacity: 0;
  transition: opacity 1s ease;
}

#scene.is-ready { opacity: 1; }
#scene:active { cursor: grabbing; }

.loading {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  margin: 0;
  transform: translate(-50%, -50%);
  color: rgba(255, 255, 255, 0.75);
  font-family: 'Art Post Black', 'SF UI Display', sans-serif;
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: opacity 0.4s ease;
}

.loading.is-hidden { opacity: 0; pointer-events: none; }

/* ---------- Topbar ---------- */
.topbar {
  position: absolute;
  top: clamp(20px, 3.4vw, 40px);
  left: clamp(24px, 4.6vw, 88px);
  right: clamp(24px, 4.6vw, 88px);
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-start {
  display: flex;
  align-items: center;
  gap: 34px;
}

.logo {
  position: relative;
  display: block;
  width: clamp(195px, 15vw, 267px);
  --mx: -999px;
  --my: -999px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* The preloader's own logo stands in until it finishes traveling to this
 * exact spot — only then does the real header logo fade in, so it never
 * looks like two logos at once. */
body.preloader-done .logo { opacity: 1; }

.logo img { display: block; width: 100%; height: auto; filter: brightness(0) invert(1); }

.logo-base { opacity: 0.65; }

.logo-glow,
.logo-scramble {
  position: absolute;
  inset: 0;
}

.logo-glow {
  filter: brightness(0) invert(1)
    drop-shadow(0 0 10px #fff)
    drop-shadow(0 0 24px #fff)
    drop-shadow(0 0 44px #fff)
    drop-shadow(0 0 44px #fff)
    drop-shadow(0 0 70px #fff);
  -webkit-mask-image: radial-gradient(circle 60px at var(--mx) var(--my), black 45%, transparent 100%);
  mask-image: radial-gradient(circle 60px at var(--mx) var(--my), black 45%, transparent 100%);
}

.logo-scramble {
  filter: brightness(0) invert(1) url(#logo-distort);
  -webkit-mask-image: radial-gradient(circle 35px at var(--mx) var(--my), black 55%, transparent 100%);
  mask-image: radial-gradient(circle 35px at var(--mx) var(--my), black 55%, transparent 100%);
}

.topbar-end {
  display: flex;
  align-items: center;
  gap: 18px;
}

.socials {
  display: flex;
  align-items: center;
  gap: 10px;
}

.socials a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: #fff;
  opacity: 0.8;
}

.socials a:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.12);
}

.socials svg {
  width: 19px;
  height: 19px;
}

.cta {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-height: 58px;
  padding: 0 26px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(30, 12, 10, 0.45);
  backdrop-filter: blur(10px);
  color: #fff;
  font-family: 'SF UI Display', sans-serif;
  font-size: 17px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  --mx: 50%;
  --my: 50%;
}

.cta-label,
.cta-dot { position: relative; z-index: 1; }

.cta-label { transition: color 0.4s ease; }

.cta-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #3ddc73;
  box-shadow: 0 0 8px 2px rgba(61, 220, 115, 0.75);
  flex-shrink: 0;
}

.cta-fill {
  position: absolute;
  top: var(--my);
  left: var(--mx);
  z-index: 0;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border-radius: 50%;
  background: #fff;
  transform: scale(0);
  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
  pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
  .cta:hover .cta-fill { transform: scale(24); }
  .cta:hover .cta-label { color: #14100e; }
}

/* ---------- Side column (bio card + services) ---------- */
/* On desktop this wrapper has no layout effect: bio-card and services
 * keep their own independent absolute positions, as designed. */
.side-col { display: contents; }

/* ---------- Sound hint ---------- */
.sound-hint {
  position: absolute;
  top: 34%;
  left: clamp(24px, 4.6vw, 88px);
  z-index: 4;
  margin: 0;
  transform: translateY(calc(-100% - 12px));
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  letter-spacing: 0.02em;
  transition: opacity 0.4s ease;
}

.sound-hint.is-hidden { opacity: 0; pointer-events: none; }

/* ---------- Bio card ---------- */
@keyframes bio-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.bio-card {
  position: absolute;
  top: 34%;
  left: clamp(24px, 4.6vw, 88px);
  z-index: 4;
  width: 360px;
  padding: 24px 28px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
  animation: bio-float 5s ease-in-out infinite;
  cursor: grab;
  touch-action: none;
  transition: opacity 0.3s ease;
}

.bio-card.is-dragging {
  cursor: grabbing;
  user-select: none;
  animation-play-state: paused;
}

.bio-card.is-closed {
  opacity: 0;
  pointer-events: none;
  animation-play-state: paused;
}

.bio-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font-family: 'SF UI Display', sans-serif;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.bio-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.bio-card h2 {
  margin: 0 0 32px;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.15;
}

.bio-card p {
  min-height: 65px;
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.4;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.bio-card p.is-changing { opacity: 0; transform: translateY(4px); }

/* ---------- Headline ---------- */
.headline {
  position: absolute;
  bottom: clamp(28px, 6vh, 75px);
  left: clamp(24px, 4.6vw, 88px);
  z-index: 3;
  max-width: 480px;
  pointer-events: none;
}

h1 {
  margin: 0;
  font-size: clamp(38px, 4.1vw, 76px);
  font-weight: 100;
  line-height: 1.04;
  letter-spacing: 0em;
}

h1 span { display: block; white-space: nowrap; }
h1 strong { font-weight: 700; }

.headline-mobile { display: none; }

/* ---------- Services ---------- */
.services {
  position: absolute;
  right: clamp(24px, 4.6vw, 88px);
  bottom: clamp(28px, 7vh, 68px);
  z-index: 3;
  display: grid;
  gap: 22px;
  width: min(460px, 30vw);
}

.services a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  padding-bottom: 12px;
  font-size: clamp(17px, 1.6vw, 28px);
  line-height: 1;
  text-decoration: none;
}

.services a:last-child { border-bottom: 0; }

.services a:hover {
  font-weight: 700;
  font-style: italic;
  transform: translateX(-14px) rotate(-2deg);
}

.services a::after {
  width: 11px;
  height: 11px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  content: '';
  transform: rotate(45deg);
  flex-shrink: 0;
  margin-left: 12px;
}

/* ---------- Mobile ---------- */
@media (max-width: 700px) {
  :root { --side-w: clamp(150px, 42vw, 220px); --edge: 20px; --bottom-gap: 16px; }

  .topbar { top: 22px; }
  .logo { width: 150px; }
  /* The glow/scramble layers only ever show on hover-capable devices, so
   * on mobile the dimmed base layer has no payoff to pair with — keep
   * it fully white there instead. */
  .logo-base { opacity: 1; }
  .cta { min-height: 52px; padding: 0 18px; font-size: 14px; }

  .topbar-end { flex-direction: column-reverse; align-items: flex-end; gap: 10px; }
  .socials a { width: 32px; height: 32px; }
  .socials svg { width: 17px; height: 17px; }

  /* Preloader collage: exact pixel boxes from the mobile PSD (1080x1920
   * canvas), converted to vw the same way as the desktop version. */
  .pl-paper--nafra { left: 17.59vw; top: -51.30vw; width: 118.15vw; height: 88.24vw; z-index: 7; }
  .pl-paper--dubom { left: 50.00vw; top: -32.41vw; width: 96.85vw; height: 117.96vw; z-index: 6; }
  .pl-paper--ecotap { left: -29.72vw; top: -14.44vw; width: 82.78vw; height: 96.57vw; z-index: 5; }
  .pl-paper--strangerthings { left: -39.91vw; top: 103.61vw; width: 110.74vw; height: 107.31vw; z-index: 4; }
  .pl-paper--connectteen { left: 26.67vw; top: 90.56vw; width: 109.07vw; height: 111.48vw; z-index: 3; }
  .pl-paper--independencia { left: -47.87vw; top: 9.72vw; width: 178.43vw; height: 167.69vw; z-index: 2; }

  /* Bio card + services become one real column, stacked top-to-bottom
   * in DOM order (bio card first, so it sits right above services),
   * sharing the exact same width. */
  .side-col {
    display: flex;
    position: absolute;
    right: var(--edge);
    bottom: var(--bottom-gap);
    z-index: 3;
    flex-direction: column;
    gap: 14px;
    width: var(--side-w);
  }

  .sound-hint {
    position: static;
    transform: none;
    font-size: 11px;
  }

  .bio-card {
    position: static;
    width: 100%;
    padding: 16px 18px;
  }

  .bio-card h2 { margin-bottom: 18px; font-size: 16px; }
  .bio-card p { min-height: 0; font-size: 12px; }

  .services {
    position: static;
    width: 100%;
    gap: 12px;
  }

  .services a { font-size: clamp(12px, 3.4vw, 15px); padding-bottom: 8px; }
  .services a::after { width: 8px; height: 8px; margin-left: 6px; }

  /* Headline gets everything to the left of the side column, with a
   * fixed gap between them — the two blocks can never overlap. */
  .headline {
    bottom: var(--bottom-gap);
    left: var(--edge);
    right: calc(var(--side-w) + var(--edge) + var(--bottom-gap));
    max-width: none;
    overflow: hidden;
  }

  h1 { font-size: clamp(22px, 7vw, 38px); letter-spacing: -0.045em; }
  h1 span { white-space: nowrap; overflow-wrap: break-word; }

  .headline-desktop { display: none; }
  .headline-mobile { display: block; }
}

@media (max-width: 380px) {
  :root { --side-w: clamp(130px, 44vw, 190px); }
  .logo { width: 130px; }
  .cta { font-size: 12px; padding: 0 14px; }
  .bio-card { padding: 14px 16px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  #scene { transition: none; }
  .bio-card { animation: none; }
  .bio-card p { transition: none; }
}
