/* ==========================================================================
   Luke Carrington — single screen landing page
   Everything reusable lives here so future pages can share these primitives.
   ========================================================================== */

:root {
  /* Colour */
  --color-bg: #ffffff;
  --color-ink: #0b0b0c;
  --color-ink-soft: #8a8a8f;
  --color-halo: rgba(11, 11, 12, 0.07);

  /* Type */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  --font-weight-thin: 200;
  --font-weight-light: 300;
  --font-weight-medium: 500;
  /* Monospace stack for HUD-style readouts (see intro.css). */
  --font-mono: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  --tracking-display: -0.045em;
  --tracking-label: 0.32em;

  /* Motion */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --duration-slow: 1.2s;
  --duration-fast: 0.45s;

  /* Layout */
  --stage-padding: clamp(1.5rem, 5vw, 5rem);

  /* Artwork */
  --corner-size: min(30vw, 24rem);
  --corner-max-height: 48svh;
  /* Two pieces stack in the right-hand column, so the shared height also has to
     fit inside half the viewport — that way they can never overlap or push off
     screen on short displays. */
  --corner-height: min(var(--corner-size), var(--corner-max-height), calc((100svh - 3 * var(--corner-inset)) / 2));
  --corner-inset: clamp(0.75rem, 2vw, 2rem);
  --radius-artwork: clamp(0.9rem, 1.6vw, 1.75rem);
  --shadow-artwork: 0 1.25rem 2.5rem rgba(11, 11, 12, 0.14);
  /* Hover state: flat (no offset, no blur) and deliberately faint. */
  --shadow-artwork-hover: 0 0 0 0.6rem rgba(11, 11, 12, 0.05);
  --float-distance: -0.9rem;
  --subtitle-width: clamp(8rem, 18vw, 16rem);
  --backdrop-opacity: 0.25;
  --backdrop-veil: rgba(255, 255, 255, 0.62);
  /* Head-room for the backdrop parallax so the artwork never exposes an edge. */
  --backdrop-scale: 1.08;

  /* Layers — back to front */
  --z-backdrop: 0;
  --z-glow: 1000;
  --z-artwork: 1;
  --z-stage: 2;
  /* Above the glow: the cold open drapes over the entire page. */
  --z-intro: 2000;
}

/* --------------------------------------------------------------------------
   Reset
   -------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background-color: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   Backdrop — full-bleed artwork faded back into the white page
   -------------------------------------------------------------------------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-backdrop);
  overflow: hidden;
  pointer-events: none;
  animation: fade-in var(--duration-slow) var(--ease-out-expo) both;
}

.backdrop__image {
  /* Cover the viewport at any ratio without distorting the artwork. */
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  /* The fade: the image sits over the white body at reduced strength, then a
     veil softens the edges so the artwork dissolves into the page rather than
     stopping sharply. */
  opacity: var(--backdrop-opacity);
  /* Parallax depth: scaled up slightly so the horizontal/vertical drift never
     pulls an empty edge into view. Values are written by index.js. */
  transform: scale(var(--backdrop-scale)) translate3d(var(--parallax-x, 0px), var(--parallax-y, 0px), 0);
  will-change: transform;
}

.backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%,
      rgba(255, 255, 255, 0) 0%,
      var(--backdrop-veil) 78%);
}

/* --------------------------------------------------------------------------
   Corner artwork — floating, rounded cards tucked just inside the corners
   -------------------------------------------------------------------------- */

.corner-art {
  position: fixed;
  bottom: var(--corner-inset);
  z-index: var(--z-artwork);
  /* `--corner-aspect` is the width ÷ height ratio of the asset (SideA 600×600
     = 1, SideB 216×321 ≈ 0.67), so the box matches the artwork exactly. Without
     it the portrait asset would letterbox inside a wider box and the rounded
     corners would no longer hug the art.
     `--corner-size / --corner-aspect` caps the shared height so a wide piece
     can never grow past the size limit on small screens. */
  --artwork-height: min(var(--corner-height), calc(var(--corner-size) / var(--corner-aspect, 1)));
  height: var(--artwork-height);
  width: calc(var(--artwork-height) * var(--corner-aspect, 1));
  pointer-events: none;
  /* Depth parallax — the wrapper owns the offset, values written by index.js. */
  transform: translate3d(var(--parallax-art-x, 0px), var(--parallax-art-y, 0px), 0);
  will-change: transform;
}

.corner-art--left {
  left: var(--corner-inset);
  --corner-aspect: 1;
  /* Out-of-phase timings keep the pieces from bobbing in lockstep. */
  --artwork-rotate: -1.4deg;
  --float-duration: 7s;
  --float-delay: 0s;
}

.corner-art--right {
  right: var(--corner-inset);
  --corner-aspect: 0.67;
  --artwork-rotate: 1.4deg;
  --float-duration: 8.5s;
  --float-delay: -2.6s;
}

/* The second piece in the right-hand column; `bottom: auto` clears the base
   rule so it hangs from the top instead. */
.corner-art--top-right {
  top: var(--corner-inset);
  right: var(--corner-inset);
  bottom: auto;
  --corner-aspect: 1;
  --artwork-rotate: 1.8deg;
  --float-duration: 9.5s;
  --float-delay: -4.2s;
}

.corner-art__image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-artwork);
  box-shadow: var(--shadow-artwork);
  user-select: none;
  /* The wrapper is inert, but the artwork itself opts back in so it can be
     hovered. */
  pointer-events: auto;
  transition: box-shadow var(--duration-fast) var(--ease-out-expo);
  animation: fade-in var(--duration-slow) var(--ease-out-expo) both,
    artwork-float var(--float-duration, 7s) ease-in-out infinite alternate;
  animation-delay: 0s, var(--float-delay, 0s);
}

/* Hover adds a faint flat halo on top of the resting lift — no offset, no blur. */
.corner-art__image:hover {
  box-shadow: var(--shadow-artwork), var(--shadow-artwork-hover);
}

/* Slow drift upwards and back, with a hint of tilt, so the corner pieces feel
   like they are floating rather than pinned to the page. */
@keyframes artwork-float {
  from {
    transform: rotate(var(--artwork-rotate, 0deg)) translateY(0);
  }

  to {
    transform: rotate(var(--artwork-rotate, 0deg)) translateY(var(--float-distance, -0.9rem));
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* --------------------------------------------------------------------------
   Stage — centres the display type on a full-bleed white screen
   -------------------------------------------------------------------------- */

.stage {
  position: relative;
  z-index: var(--z-stage);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100svh;
  padding: var(--stage-padding);
}

/* --------------------------------------------------------------------------
   Hero — the name and its subtitle, held on one 3D plane
   -------------------------------------------------------------------------- */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(0.75rem, 2vw, 1.75rem);

  /* Pointer parallax; values are written by index.js. The hero is the nearest
     layer, so it drifts as well as tilts — the drift is kept small so the tilt
     stays the dominant cue. Because the name and subtitle both live inside,
     they share this one transform and read as a single object.
     No CSS transition here — the values are already eased every frame, and a
     transition on top of that would double-smooth them into a lag. */
  transform: translate3d(var(--parallax-text-x, 0px), var(--parallax-text-y, 0px), 0) perspective(1000px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg));
  transform-style: preserve-3d;
  will-change: transform;
}

.hero__subtitle {
  display: block;
  width: var(--subtitle-width);
  border-radius: var(--radius-artwork);
  height: auto;
  user-select: none;
  /* Enters just after the last word lands. */
  animation: fade-in var(--duration-slow) var(--ease-out-expo) both;
  animation-delay: 0.35s;
}

/* --------------------------------------------------------------------------
   Name
   -------------------------------------------------------------------------- */

.name {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 0 clamp(0.35em, 1.5vw, 0.6em);
  margin: 0;

  font-size: clamp(3rem, 13vw, 11rem);
  font-weight: var(--font-weight-thin);
  line-height: 0.95;
  letter-spacing: var(--tracking-display);
  text-align: center;
  text-wrap: balance;
}

.name__word {
  display: inline-block;
  opacity: 0;
  transform: translateY(0.5em);
  animation: word-rise var(--duration-slow) var(--ease-out-expo) forwards;
  /* Each word enters slightly after the one before it. */
  animation-delay: calc(var(--index, 0) * 0.14s);
}

.name__word:nth-child(1) {
  --index: 0;
}

.name__word:nth-child(2) {
  --index: 1;
  font-weight: var(--font-weight-light);
}

@keyframes word-rise {
  from {
    opacity: 0;
    transform: translateY(0.5em);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --------------------------------------------------------------------------
   Cursor glow — reusable pointer-following halo
   -------------------------------------------------------------------------- */

.cursor-glow {
  position: fixed;
  top: 0;
  left: 0;
  z-index: var(--z-glow);
  width: clamp(18rem, 42vw, 38rem);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, var(--color-halo) 0%, transparent 68%);
  filter: blur(28px);
  opacity: 0.9;
  pointer-events: none;
  transform: translate3d(-50%, -50%, 0);
  transition: opacity var(--duration-fast) ease;
  will-change: transform;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 30rem) {
  .name {
    flex-direction: column;
    align-items: center;
    gap: 0.1em;
    line-height: 1.02;
  }
}

/* --------------------------------------------------------------------------
   Reduced motion — show the end state immediately, drop the glow smoothing
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .hero {
    transform: none;
  }

  .name__word,
  .hero__subtitle {
    opacity: 1;
    transform: none;
    animation: none;
  }

  .backdrop,
  .corner-art__image {
    animation: none;
  }

  .corner-art,
  .backdrop__image {
    transform: none;
  }

  .cursor-glow {
    display: none;
  }
}