:root {
  --bg: #ffffff;
  --ink: #360303;
  --accent: #e72424;
  --animation: #ad84ab;
  --parametric: #bd8484;
  --built: #9a98eb;

  /* Kandinsky-inspired chord */
  --k-magenta: #c8307a;
  --k-ochre: #e0a32a;
  --k-cobalt: #1a4ec9;
  --k-vermilion: #d63a1a;
  --k-violet: #5c2a8a;
  --k-black: #1a1a1a;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Fraunces', serif;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  opacity: 0.04;
  mix-blend-mode: multiply;
}

/* ============ HEADER ============ */
header {
  position: fixed;
  top: 0; left: 0; right: 0;
  padding: 1.5rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 100;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  opacity: 0;
  animation: headerFade 0.8s 0.3s ease-out forwards;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
header.instant { animation: none; opacity: 1; }
@keyframes headerFade { to { opacity: 1; } }

header .logo {
  font-family: 'Fraunces', serif;
  font-weight: 900;
  font-size: 1.1rem;
  font-style: italic;
  letter-spacing: -0.02em;
  text-transform: none;
}
header nav { display: flex; gap: 2rem; }
header nav a { color: inherit; text-decoration: none; transition: opacity 0.3s; }
header nav a:hover { opacity: 0.6; }
header .meta { display: flex; gap: 1.5rem; }

/* ============ HERO STAGE — animation lives here ============ */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 6rem 2rem 4rem;
  position: relative;
  transition: opacity 1s cubic-bezier(0.65, 0, 0.35, 1);
}
.hero.dismissed {
  opacity: 0;
  pointer-events: none;
}
.hero.skipped { display: none; }

.marker {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0;
  margin-bottom: 3rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: fadeUp 0.8s 0.3s ease-out forwards;
}
.marker::before {
  content: '';
  width: 24px;
  height: 1px;
  background: currentColor;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 0.6; transform: translateY(0); }
}

.headline {
  font-family: 'Fraunces', serif;
  font-weight: 300;
  font-size: clamp(3rem, 11vw, 11rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.05em;
}

.word-row {
  position: relative;
  display: inline-block;
  height: 1em;
  line-height: 1;
}

/* PARAMETRIC */
.word-parametric {
  color: var(--parametric);
  font-style: italic;
  font-weight: 500;
  position: relative;
}
.word-parametric .char {
  display: inline-block;
  opacity: 0;
  animation: paramChar 0.5s ease-out forwards;
}
.param-geometry {
  position: absolute;
  inset: -10% -2%;
  pointer-events: none;
  opacity: 0;
  animation: paramGeo 1.6s 0.4s ease-out forwards;
}
.param-geometry svg { width: 100%; height: 100%; overflow: visible; }
.param-geometry path,
.param-geometry line,
.param-geometry circle {
  fill: none;
  stroke: var(--parametric);
  stroke-width: 1.5;
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: drawLine 1s 0.1s ease-out forwards;
}
@keyframes drawLine { to { stroke-dashoffset: 0; } }
@keyframes paramGeo {
  0% { opacity: 0; }
  20% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes paramChar {
  from { opacity: 0; transform: translateY(8px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ANIMATION — Kandinsky synesthetic field */
.word-animation {
  color: var(--ink);
  font-weight: 700;
  font-style: italic;
  position: relative;
}
.word-animation .chars {
  position: relative;
  z-index: 2;
  opacity: 0;
  animation: animFadeIn 0.6s 2.0s ease-out forwards;
}
@keyframes animFadeIn {
  from { opacity: 0; filter: blur(6px); }
  to { opacity: 1; filter: blur(0); }
}

.kandinsky-field {
  position: absolute;
  inset: -60% -25%;
  pointer-events: none;
  z-index: 1;
}
.ring {
  position: absolute;
  border-radius: 50%;
  border-style: solid;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0);
}
.geo-accent { position: absolute; opacity: 0; }
.geo-line { height: 1.5px; transform-origin: left center; }
.geo-tri { width: 0; height: 0; }

/* DESIGN — slab drop with orbit ring */
.word-design {
  color: var(--ink);
  font-weight: 900;
  font-style: normal;
  position: relative;
  display: inline-block;
  opacity: 0;
  transform: translateY(-110%);
  animation: slabDrop 0.7s 3.5s cubic-bezier(0.34, 1.4, 0.5, 1) forwards;
}
@keyframes slabDrop {
  0% { opacity: 0; transform: translateY(-110%) scaleY(1.15); }
  60% { opacity: 1; transform: translateY(6%) scaleY(0.92); }
  78% { transform: translateY(-1.5%) scaleY(1.04); }
  100% { opacity: 1; transform: translateY(0) scaleY(1); }
}

.design-orbit {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 108%;
  aspect-ratio: 1 / 0.42;
  border: 5px solid var(--k-ochre);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0) rotate(-6deg);
  z-index: 0;
  opacity: 0;
  animation: orbitSettle 0.9s 4.1s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
/* Single segment: the easing curve itself overshoots to ~1.06 and settles,
   so the ring never stalls mid-way and re-adjusts. */
@keyframes orbitSettle {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.4) rotate(-6deg); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-6deg); }
}

.word-design .chars {
  display: inline-block;
  position: relative;
  z-index: 2;
  text-shadow:
    -3px 0 0 var(--bg), 3px 0 0 var(--bg),
    0 -3px 0 var(--bg), 0 3px 0 var(--bg),
    -3px -3px 0 var(--bg), 3px -3px 0 var(--bg),
    -3px 3px 0 var(--bg), 3px 3px 0 var(--bg),
    -2px 0 0 var(--bg), 2px 0 0 var(--bg);
}
.word-design.landed .chars {
  animation: settleBounce 0.7s cubic-bezier(0.33, 1, 0.68, 1) 0s both;
}
@keyframes settleBounce {
  0%   { transform: translateY(0); }
  25%  { transform: translateY(-6px); }
  45%  { transform: translateY(0); }
  65%  { transform: translateY(-2px); }
  85%  { transform: translateY(0); }
  100% { transform: translateY(0); }
}

/* ============ TRI-SPLIT PANELS ============ */
.panels-section {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(40px);
  pointer-events: none;
  transition: opacity 1.2s cubic-bezier(0.16, 1, 0.3, 1),
              transform 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.panels-section.revealed {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.panels-section.instant {
  transition: none;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.panels-spacer {
  height: 5rem;
}

.worlds {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  flex: 1;
  min-height: 75vh;
}

.world {
  position: relative;
  padding: 3rem 2rem;
  border-right: 1px solid var(--ink);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  transition: flex 0.6s cubic-bezier(0.65, 0, 0.35, 1);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
.world:last-child { border-right: none; }
.world::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--world-color);
  transform: translateY(101%);
  transition: transform 0.7s cubic-bezier(0.65, 0, 0.35, 1);
  z-index: 0;
}
.world:hover::before { transform: translateY(0); }
.world > * { position: relative; z-index: 1; }

.world[data-world="animation"] { --world-color: var(--animation); }
.world[data-world="parametric"] { --world-color: var(--parametric); }
.world[data-world="built"] { --world-color: var(--built); }

.world-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
}

.world-title {
  font-family: 'Fraunces', serif;
  font-weight: 300;
  font-size: clamp(2.2rem, 4.2vw, 4rem);
  line-height: 0.9;
  letter-spacing: -0.03em;
  margin: 3rem 0 1rem;
}
.world-title em { font-weight: 700; font-style: italic; }

.world-desc {
  font-family: 'Fraunces', serif;
  font-size: 1rem;
  line-height: 1.5;
  max-width: 38ch;
  margin-bottom: 2rem;
}

.world-visual {
  aspect-ratio: 297 / 210;
  width: 100%;
  margin: 1.5rem 0;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--ink);
}

/* ============ IMAGE GALLERIES ============ */
.gallery {
  background: #0a0a0a;
  overflow: hidden;
}
.gallery img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.9s ease;
}
.gallery img.active { opacity: 1; }

.gallery-counter {
  position: absolute;
  bottom: 0.6rem;
  right: 0.75rem;
  z-index: 2;
  display: flex;
  gap: 5px;
}
.gallery-counter span {
  display: block;
  width: 18px;
  height: 2px;
  background: rgba(255,255,255,0.35);
  transition: background 0.4s ease;
  cursor: pointer;
}
.gallery-counter span.active {
  background: rgba(255,255,255,0.9);
}

.visual-built {
  background: linear-gradient(135deg, #8a7560 0%, #5c4d3e 100%);
  position: relative;
  display: flex;
  align-items: end;
  padding: 1rem;
}
.visual-built::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(180deg, transparent 60%, rgba(0,0,0,0.4) 100%),
    repeating-linear-gradient(90deg, transparent 0 80px, rgba(255,255,255,0.05) 80px 81px),
    repeating-linear-gradient(0deg, transparent 0 60px, rgba(255,255,255,0.05) 60px 61px);
}
.visual-built span {
  position: relative;
  color: rgba(255,255,255,0.7);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.world-tags {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  opacity: 0.7;
  margin-bottom: 1rem;
}

.world-cta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-top: 1rem;
  border-top: 1px solid var(--ink);
}
.world-cta .label {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-weight: 500;
  font-size: 1.1rem;
}
.world-cta .arrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.5rem;
  transition: transform 0.4s cubic-bezier(0.65, 0, 0.35, 1);
}
.world:hover .world-cta .arrow {
  transform: translateX(8px);
}

/* SCROLL CUE */
.scroll-cue {
  text-align: center;
  padding: 2.5rem 2rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0.5;
  border-top: 1px solid var(--ink);
  cursor: pointer;
  transition: opacity 0.3s;
}
.scroll-cue:hover { opacity: 1; }
.scroll-cue .arrow {
  display: inline-block;
  margin-left: 0.5rem;
  animation: drift 2s ease-in-out infinite;
}
@keyframes drift {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(4px); }
}

/* ABOUT (tucked dead-end) */
.about {
  min-height: 100vh;
  padding: 8rem 2rem 4rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  background: var(--ink);
  color: var(--bg);
  position: relative;
}

.about-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  opacity: 0.5;
  margin-bottom: 3rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.about-label::before {
  content: '';
  width: 24px;
  height: 1px;
  background: currentColor;
}

.about-text {
  font-family: 'Fraunces', serif;
  font-size: clamp(1.4rem, 2.6vw, 2.4rem);
  line-height: 1.4;
  font-weight: 300;
  letter-spacing: -0.01em;
  max-width: 28ch;
}
.about-text em { font-style: italic; font-weight: 500; }
.about-text .accent { color: var(--accent); font-style: italic; font-weight: 700; }

.about-back {
  margin-top: 5rem;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  color: var(--bg);
  padding: 1rem 2rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.3s;
}
.about-back:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.about-contact {
  margin-top: 3rem;
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 1.2rem;
  opacity: 0.7;
}
.about-contact a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,0.3);
  transition: border-color 0.3s, color 0.3s;
}
.about-contact a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

@media (max-width: 900px) {
  header { padding: 1rem; font-size: 0.6rem; gap: 1rem; }
  header nav { gap: 1rem; }
  header .meta { display: none; }
  .hero { padding: 5rem 1rem 4rem; }
.worlds { grid-template-columns: 1fr; }
  .world { border-right: none; border-bottom: 1px solid var(--ink); padding: 2rem 1.25rem; }
  .about { padding: 5rem 1.25rem 3rem; }
}

/* ============ PROJECT PAGES (animation.html, parametric.html) ============ */
.project-page {
  min-height: 100vh;
  padding: 8rem 2rem 6rem;
  max-width: 1100px;
  margin: 0 auto;
}

.project-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  opacity: 0.5;
  margin-bottom: 3rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.project-label::before {
  content: '';
  width: 24px;
  height: 1px;
  background: currentColor;
}
.project-label a { color: inherit; text-decoration: none; }
.project-label a:hover { text-decoration: underline; }

.project-title {
  font-family: 'Fraunces', serif;
  font-weight: 300;
  font-size: clamp(3rem, 7vw, 6.5rem);
  line-height: 0.92;
  letter-spacing: -0.04em;
  margin-bottom: 4rem;
}
.project-title em { font-style: italic; font-weight: 900; }

.project-body {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 4rem;
  border-top: 1px solid var(--ink);
  padding-top: 3rem;
  margin-bottom: 4rem;
}

.project-aside {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  line-height: 2;
  opacity: 0.55;
}
.project-aside p + p { margin-top: 2rem; }

.project-text {
  font-family: 'Fraunces', serif;
  font-size: clamp(1.1rem, 1.5vw, 1.35rem);
  font-weight: 300;
  line-height: 1.6;
  letter-spacing: -0.01em;
}
.project-text h2 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0.5;
  margin-bottom: 1rem;
}
.project-text p + h2 { margin-top: 2.5rem; }
.project-text em { font-style: italic; font-weight: 500; }

.video-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0a0a0a;
  border: 1px solid var(--ink);
}
.video-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.video-caption {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0.5;
  margin-top: 1rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
.video-caption a { color: inherit; }

@media (max-width: 700px) {
  .project-page { padding: 7rem 1.25rem 4rem; }
  .project-body { grid-template-columns: 1fr; gap: 2rem; }
}

/* Project image gallery (project-gallery.js) */
.project-gallery {
  border-top: 1px solid var(--ink);
  padding-top: 2rem;
}
.pg-stage {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--bg);
  border: 1px solid var(--ink);
  overflow: hidden;
  touch-action: pan-y;
}
.pg-stage img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: opacity 0.35s ease;
}
.pg-stage img.loading { opacity: 0; }
.pg-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink);
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.3s, color 0.3s;
}
.pg-arrow:hover { background: var(--ink); color: var(--bg); }
.pg-prev { left: 1rem; }
.pg-next { right: 1rem; }
.pg-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 1rem 0 1.5rem;
}
.pg-caption {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 1.1rem;
}
.pg-info {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0.5;
}
.pg-info a { color: inherit; }
.pg-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.5rem;
}
.pg-thumb {
  padding: 0;
  border: 1px solid transparent;
  background: var(--bg);
  aspect-ratio: 16 / 9;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.3s, border-color 0.3s;
}
.pg-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pg-thumb:hover { opacity: 0.85; }
.pg-thumb[aria-current="true"] { opacity: 1; border-color: var(--ink); }

@media (max-width: 700px) {
  .pg-arrow { width: 2.25rem; height: 2.25rem; }
  .pg-prev { left: 0.5rem; }
  .pg-next { right: 0.5rem; }
  .pg-meta { flex-direction: column; gap: 0.4rem; }
  .pg-thumbs { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
}
