/* =========================================================================
   iLoy — Montfort-inspired personal scroll narrative
   Design tokens sampled from mont-fort.com: slate #242729 ground,
   thin geometric uppercase type (Josefin Sans), oversized statements,
   generous whitespace, scroll-reveal animation.
   ========================================================================= */

:root {
  color-scheme: dark;        /* tell the UA we're already dark — no auto hue-rotate */

  --bg:        #242729;   /* Montfort slate */
  --bg-2:      #2c2f31;   /* slightly raised surface */
  --fg:        #ffffff;
  --fg-muted:  #9aa0a3;
  --fg-dim:    #6b7174;

  /* Flipper orange — the primary accent. Cyan is demoted to a sparing secondary
     (it survives mainly as a sprinkle of tinted stars in the WebGL backdrop). */
  --orange:       #ff8200;
  --orange-soft:  #ffb25a;
  --orange-line:  rgba(255,130,0,0.45);
  --orange-glow:  rgba(255,130,0,0.25);
  --cyan:         #38e1ff;
  --accent:       var(--orange);   /* legacy alias → orange (keeps old rules working) */
  --border:    rgba(255,255,255,0.10);

  --font: "Josefin Sans", "Century Gothic", system-ui, sans-serif;

  --maxw: 1280px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html { scroll-behavior: smooth; color-scheme: dark; }

body {
  margin: 0;
  background: transparent;     /* let #space-bg show through the whole page */
  color: var(--fg);
  font-family: var(--font);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

/* ===== Fixed space backdrop =====
   The Three.js twinkling starfield renders into #space-bg, fixed behind the
   whole page. A CSS "void" gradient is painted underneath so that on touch /
   reduced-motion / no-WebGL (when the canvas is never created) there is still a
   deep-space ground instead of flat slate. The page body is transparent above
   it; sections that need contrast carry their own translucent panels/cards. */
#space-bg {
  position: fixed;
  inset: 0;
  z-index: -1;                /* behind all content */
  pointer-events: none;
  background:
    radial-gradient(120% 120% at 50% 0%, #14181b 0%, #0b0d0f 45%, #07090a 100%);
}
#space-bg canvas { display: block; width: 100%; height: 100%; }

/* Body is transparent so the fixed backdrop shows through the whole scroll. */

/* ===== Intro animation ===== */
.intro {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  transition: opacity 0.8s var(--ease), visibility 0.8s var(--ease);
}
.intro.is-done { opacity: 0; visibility: hidden; pointer-events: none; }

.intro__mark {
  display: grid;
  grid-template-columns: repeat(3, 10px);
  gap: 8px;
  justify-content: center;
}
.intro__dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  animation: dotIn 0.5s var(--ease) forwards;
}
.intro__dot:nth-child(1) { animation-delay: 0.05s; }
.intro__dot:nth-child(2) { animation-delay: 0.10s; }
.intro__dot:nth-child(3) { animation-delay: 0.15s; }
.intro__dot:nth-child(4) { animation-delay: 0.20s; }
.intro__dot:nth-child(5) { animation-delay: 0.25s; }
.intro__dot:nth-child(6) { animation-delay: 0.30s; }
.intro__dot:nth-child(7) { animation-delay: 0.35s; }
@keyframes dotIn {
  from { opacity: 0; transform: translateY(8px) scale(0.5); }
  to   { opacity: 1; transform: none; }
}
.intro__word {
  font-size: clamp(2.5rem, 8vw, 5rem);
  font-weight: 200;
  letter-spacing: 0.3em;
  opacity: 0;
  animation: wordIn 0.8s var(--ease) 0.5s forwards;
}
@keyframes wordIn { to { opacity: 1; } }

/* ===== Top bar ===== */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.75rem clamp(1.5rem, 5vw, 4rem);
  mix-blend-mode: difference;  /* stays legible over light/dark sections */
}
.topbar__brand,
.topbar__menu {
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 400;
  letter-spacing: 0.25em;
  color: #fff;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.topbar__menu { text-transform: uppercase; }  /* MENU/CLOSE stay all-caps; brand keeps iLOY casing */
.topbar__menu:focus-visible,
.topbar__brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

/* ===== Nav overlay ===== */
.nav-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s var(--ease), visibility 0.5s var(--ease);
}
.nav-overlay.is-open { opacity: 1; visibility: visible; }
.nav-overlay__list {
  list-style: none;
  margin: 0; padding: 0;
  text-align: center;
}
.nav-overlay__list li { margin: 0.4em 0; }
.nav-overlay__list a {
  font-size: clamp(1.8rem, 6vw, 3.5rem);
  font-weight: 200;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  transition: color 0.3s var(--ease);
}
.nav-overlay__list a:hover { color: #fff; }

/* ===== Panels (full-screen scroll sections) ===== */
.panel {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8rem clamp(1.5rem, 6vw, 6rem);
  max-width: var(--maxw);
  margin: 0 auto;
}
.panel--hero {
  position: relative;          /* anchor the full-bleed bg + overlay */
  align-items: center;
  text-align: center;
  /* no overflow:hidden — the bg layers intentionally break out to 100vw */
}
.panel--gallery { min-height: auto; padding-top: 10rem; padding-bottom: 6rem; }

/* Full-bleed hero background — CSS starfield + earth-glow placeholder.
   Swap to a real asset by setting background-image on .hero__bg (see HTML note). */
.hero__bg {
  position: absolute;
  top: 0;
  bottom: 0;
  /* Break out of the panel's max-width to span the full viewport edge-to-edge. */
  left: 50%;
  width: 100vw;
  transform: translateX(-50%);
  z-index: 0;
  background-color: #0b0d0f;
  /* layered radial gradients: a cool earth-limb glow + scattered "stars" */
  background-image:
    radial-gradient(120% 90% at 50% 120%, rgba(255,130,0,0.40) 0%, rgba(255,130,0,0) 55%),
    radial-gradient(1.5px 1.5px at 20% 30%, rgba(255,255,255,0.7) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 75% 20%, rgba(255,255,255,0.55) 50%, transparent 51%),
    radial-gradient(1px 1px   at 40% 70%, rgba(255,255,255,0.6) 50%, transparent 51%),
    radial-gradient(1px 1px   at 85% 60%, rgba(255,255,255,0.5) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 60% 45%, rgba(255,255,255,0.45) 50%, transparent 51%),
    radial-gradient(1px 1px   at 10% 80%, rgba(255,255,255,0.5) 50%, transparent 51%),
    radial-gradient(1px 1px   at 92% 35%, rgba(255,255,255,0.55) 50%, transparent 51%);
  background-size: cover, 100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%;
  /* If you add a real image/video, this same element can carry it:
     background: #0b0d0f url("assets/hero.jpg") center/cover no-repeat; */
}
/* Looping hero video. Full-bleed like .hero__bg, layered just above it (z-0.5 via
   source order) and below the overlay. object-fit:cover crops to fill any aspect
   ratio without distortion — the 16:9 clip covers tall phones and wide desktops
   alike, edges cropped rather than letterboxed. The CSS starfield (.hero__bg)
   remains behind it as the poster/load backdrop. */
.hero__video {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 100vw;
  height: 100%;
  transform: translateX(-50%);
  z-index: 0;                  /* same plane as .hero__bg; later in DOM = on top */
  object-fit: cover;
  /* The poster (and any letterbox edge during load) blends with the void. */
  background-color: #0b0d0f;
  pointer-events: none;        /* never intercepts clicks/scroll */
  /* Feather the BOTTOM edge to transparent so the object-fit:cover crop line never
     reads as a hard seam against the #space-bg starfield below. The video is fully
     opaque through the top ~75%, then fades out over the last quarter — the
     transition into the void is gradual, not a cut. (Masked area shows whatever is
     behind: the CSS starfield, then #space-bg.) -webkit- prefix for Safari. */
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 72%, transparent 100%);
          mask-image: linear-gradient(to bottom, #000 0%, #000 72%, transparent 100%);
}

/* Accessibility: honor prefers-reduced-motion. Users who disable motion get the
   static poster frame instead of a moving video — the <video poster> already
   paints that frame, so hiding the playing video reveals the starfield + poster
   look without animation. (Skill rule: reduced-motion, High severity.) */
@media (prefers-reduced-motion: reduce) {
  .hero__video { display: none; }
}

/* Heavy dark overlay so the wordmark + white text stay crisp. */
.hero__overlay {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 100vw;
  transform: translateX(-50%);
  z-index: 1;
  background:
    linear-gradient(180deg, rgba(13,13,15,0.55) 0%, rgba(13,13,15,0.35) 40%, rgba(13,13,15,0.75) 100%);
}

.hero__title {
  position: relative;
  z-index: 2;                  /* above bg + overlay */
  font-size: clamp(4rem, 18vw, 14rem);
  font-weight: 100;
  letter-spacing: 0.15em;
  margin: 0;
  line-height: 1;
  text-shadow: 0 2px 40px rgba(0,0,0,0.5);
}
/* NOTE: no entrance animation on .hero__title. GSAP pins #hero (re-parenting the
   title into a pin-spacer), and a CSS animation on an element inside a GSAP pin
   has its animation clock frozen — the wordmark stranded mid-fade at ~0.14
   opacity. The wordmark is therefore simply visible immediately; GSAP still owns
   the scroll-scrubbed fade as you scroll into the pin. Reliability over a
   decorative fade-in on the single most important element on the page. */

.panel__eyebrow {
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 1.5rem;
}

.statement {
  font-size: clamp(2.2rem, 7vw, 5.5rem);
  font-weight: 200;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1.08;
  margin: 0;
  max-width: 18ch;
}
.statement--sm { font-size: clamp(1.8rem, 5vw, 3.5rem); max-width: 24ch; }

.signoff {
  font-size: clamp(1.5rem, 5vw, 3rem);
  font-weight: 200;
  letter-spacing: 0.15em;
  color: var(--fg-muted);
  text-align: center;
  width: 100%;
  margin: 0;
}
.panel--signoff { align-items: center; min-height: 60vh; }

/* ===== Scroll reveal =====
   Progressive enhancement: the "hidden initial state" only applies when motion
   is on — app.js adds .has-motion to <html> only when GSAP loaded AND the visitor
   is not on touch / reduced-motion. Without motion, everything is visible (no
   blank text or stranded cards). The engine animates these to opacity:1, y:0. */

/* Reveal targets: eyebrows, statements, sign-off (data-reveal / .reveal). */
.has-motion .reveal,
.has-motion [data-reveal] { opacity: 0; transform: translateY(28px); }

/* Cards (injected from JSON) animate in with a per-grid stagger. */
.has-motion .card { opacity: 0; transform: translateY(40px); }

/* ===== Gallery (cards, routed from exhibits.json by type) ===== */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-top: 3rem;
  width: 100%;
}
.card {
  display: flex;
  flex-direction: column;
  /* translucent so the starfield glows faintly behind the cards */
  background: rgba(44,47,49,0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  color: inherit;
  transition: transform 0.4s var(--ease), border-color 0.4s var(--ease),
              box-shadow 0.4s var(--ease);
}
a.card:hover {
  transform: translateY(-6px);
  border-color: var(--orange);
  box-shadow: 0 12px 40px -12px var(--orange-glow);   /* orange lift glow */
}
a.card:focus-visible { outline: 2px solid var(--orange); outline-offset: 3px; }

.card__media { aspect-ratio: 16/10; width: 100%; object-fit: cover; display: block; background: #1c1f20; }
.card__placeholder {
  aspect-ratio: 16/10;
  display: grid;
  place-items: center;
  font-size: 2.5rem;
  font-weight: 200;
  letter-spacing: 0.1em;
  color: var(--bg);
}
.card__body { padding: 1.5rem; display: flex; flex-direction: column; gap: 0.6rem; flex: 1; }
.card__meta {
  font-size: 0.7rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--fg-dim);
}
.card__title {
  font-size: 1.3rem; font-weight: 400; letter-spacing: 0.04em; text-transform: uppercase; margin: 0;
}
.card__desc { font-size: 0.95rem; font-weight: 300; color: var(--fg-muted); margin: 0; }
.card__tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: auto; padding-top: 1rem; }
.tag {
  font-size: 0.7rem; letter-spacing: 0.08em; color: var(--fg-muted);
  border: 1px solid var(--border); border-radius: 3px; padding: 0.2rem 0.55rem;
}
.card__cue { margin-top: 1rem; font-size: 0.8rem; letter-spacing: 0.15em; text-transform: uppercase; color: var(--accent); }

.gallery__empty { color: var(--fg-dim); font-size: 0.95rem; }

/* ===== Globe (Three.js, standalone spinning planet) =====
   A normal full-viewport panel — NOT a scroll journey. The globe just spins in
   place, viewed from above the northern hemisphere, with always-on city labels.
   The canvas is a SQUARE sized to the smaller viewport dimension so the whole
   round planet (plus its floating labels) sits inside the frame with margin:
   the camera framing guarantees nothing touches the edge, so no overflow crop. */
.globe__track {
  position: relative;
  height: 100vh;
  height: 100dvh;
}
.globe__stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.globe__canvas {
  display: block;
  /* Big — the planet is the hero and fills the section. Square box sized to the
     smaller viewport dimension. Labels fade before the rim (JS), so no margin is
     needed; the globe can run nearly edge to edge. */
  width: min(96vw, 96vh);
  height: min(96vw, 96vh);
}

/* Overlay holds the kicker + the focus caption, on top of the canvas.
   GSAP fades it out as the globe grows so the planet takes the screen. */
.globe__overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: clamp(2rem, 6vh, 5rem) 1.5rem;
}
.globe-kicker {
  margin: 0;
  text-shadow: 0 2px 30px rgba(0,0,0,0.9);   /* keep legible over the globe */
}

/* ===========================================================================
   THE BRIEFCASE — a sticky 3D scroll-scene (mirrors the globe's structure).
   A tall track holds a sticky stage; the WebGL canvas is the cinematic layer,
   the .case__items list is the functional/accessible layer underneath.
   =========================================================================== */
.case__track {
  position: relative;
  /* 220vh: the sticky stage pins the scene through the full open sequence
     (arrival -> approach -> open -> settle), then releases to page scroll. */
  height: 220vh;
}
.case__stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
}
.case__canvas {
  display: block;
  /* Big — the case is the hero of this section. Square box sized near the full
     viewport. The camera framing (solved for ~90% fill) keeps the open case
     inside the frame, so this can run large without clipping. */
  width: min(98vw, 96vh);
  height: min(98vw, 96vh);
  transform-origin: center center;
  will-change: transform;
}


/* --- Functional layer: the four items as real links --------------------------
   DEFAULT = VISIBLE (a clean 4-up grid). This is what keyboard, touch,
   reduced-motion, and no-WebGL visitors get. CSS hides it ONLY when JS adds
   .is-live to the stage AFTER confirming the WebGL canvas mounted — so if JS
   fails or WebGL is absent, the list stays. Fail OPEN to the content. */
.case__items {
  position: relative;
  z-index: 3;
  list-style: none;
  margin: 0;
  padding: clamp(1.5rem, 5vh, 4rem) clamp(1rem, 4vw, 2rem);
  width: 100%;
  max-width: 70rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1.25rem;
}
.case__stage.is-live .case__items {
  /* Scene is live: the list becomes the offscreen-but-focusable functional twin.
     Not display:none (that would drop it from the tab order); instead clipped
     so keyboard users still reach the same destinations behind the canvas. */
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}
.case__item {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  height: 100%;
  padding: 1.25rem 1.3rem;
  text-align: left;
  text-decoration: none;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.10);
  border-left: 3px solid var(--orange);
  border-radius: 12px;
  transition: transform 0.3s var(--ease), border-color 0.3s var(--ease),
              background 0.3s var(--ease);
}
a.case__item:hover {
  transform: translateY(-3px);
  border-color: var(--orange);
  background: rgba(255,130,0,0.06);
}
.case__item:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 3px;
}
/* When the scene is live the list is clipped to 1px so keyboard users can still
   tab to it — but a focus ring on a 1px box is invisible. So when ANY link in the
   clipped list receives keyboard focus, un-clip the list and surface it as a real
   panel (bottom-center, above the canvas) so the focus indicator is actually seen.
   This is the "focusable visually-hidden" pattern — a11y without showing it by
   default. (:focus-within keeps the panel up while tabbing between the links.) */
.case__stage.is-live .case__items:focus-within {
  position: absolute;
  left: 50%; bottom: clamp(1.5rem, 6vh, 4rem);
  transform: translateX(-50%);
  width: min(92vw, 60rem); height: auto;
  margin: 0; padding: 1rem;
  overflow: visible; clip: auto; clip-path: none;
  white-space: normal;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.75rem;
  background: rgba(12,14,16,0.82);
  -webkit-backdrop-filter: blur(10px);
          backdrop-filter: blur(10px);
  border: 1px solid rgba(255,130,0,0.3);
  border-radius: 14px;
  z-index: 4;
}
.case__item[aria-disabled="true"] { cursor: default; }
.case__item-kind {
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--orange);
}
.case__item-title {
  font-size: 1.15rem;
  font-weight: 300;
  letter-spacing: 0.03em;
  color: var(--fg);
}
.case__item-desc {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--fg-muted);
  white-space: normal;
}

/* ===== Motion preference ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .line-clip > span { transform: none !important; }
  .card { opacity: 1 !important; transform: none !important; }
  html { scroll-behavior: auto; }
}

@media (max-width: 600px) {
  .panel { padding: 6rem 1.5rem; }
}
