/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Page fade-in (header stays instant, content below fades) ── */
body > *:not(.site-header):not(.nav-overlay):not(.form-modal) {
  opacity: 0;
  transition: opacity 0.2s ease;
}
body.page-loaded > *:not(.site-header):not(.nav-overlay):not(.form-modal) {
  opacity: 1;
}

/* ── Content fade-in items ── */
.fade-in-item {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}
.fade-in-item--visible {
  opacity: 1;
  transform: translateY(0);
}

:root {
  --bg: #ffffff;
  --fg: #111111;
  --muted: #666666;
  --accent: #111111;
  --border: #e5e5e5;
  --font: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --max: 1200px;
  --gap: 2rem;
}

html { scroll-behavior: smooth; }

/* ── Hide scrollbars (scrolling still works) ── */
::-webkit-scrollbar { display: none; }
* { scrollbar-width: none; }


body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img, video { display: block; max-width: 100%; }

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

a[href]:not(.btn):not(.logo):not(.site-header nav a):not(.nav-overlay a):not(.gallery-item):not(.social-links a):not(.project-nav-link) {
  text-decoration: underline;
  text-underline-offset: 3px;
  color: inherit;
}

/* ── Logo group + tagline ── */
.logo-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
}

.logo-tagline {
  display: inline-flex;
  align-items: baseline;
  font-style: normal;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--muted);
  white-space: nowrap;
  overflow: visible;
  line-height: 1.3;
}

.tagline-textbox {
  position: relative;
  display: inline-block;
}

.tagline-highlight {
  position: absolute;
  top: -1px; right: 0; bottom: -1px;
  width: 0;
  background: #111;
  pointer-events: none;
}

/* Hide cursor while text is being "selected" */
.logo-tagline.is-selecting .tagline-cursor {
  visibility: hidden;
}

/* Lift text above the highlight so it shows yellow on black */
.logo-tagline.is-selecting #taglineText {
  position: relative;
  z-index: 1;
  color: #fde104;
}

.tagline-cursor {
  display: inline-block;
  margin-left: 1px;
  font-style: normal;
  animation: tagline-blink 0.7s step-end infinite;
}

@keyframes tagline-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}


/* ── Header ── */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 160;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 2rem;
  background: #fde104;
}

.logo {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}

/* Nav: always visible on right, white bg covers tagline overflow */
.site-header nav {
  display: flex;
  gap: 2rem;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  background: #fde104;
  padding-left: 1.5rem;
}

.site-header nav a {
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--fg);
}

.site-header nav a:hover { font-weight: 500; }

.site-header nav a.nav-active,
.site-header nav a.nav-active:hover { color: white; }

.site-header .logo-tagline { color: var(--fg); }

@keyframes emoji-bounce {
  0%   { transform: translateY(0);     animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); }
  50%  { transform: translateY(-8px); animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19); }
  100% { transform: translateY(0); }
}

.nav-emoji {
  display: inline-block;
}

.nav-emoji.bouncing {
  animation: emoji-bounce 0.5s infinite;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  position: relative;
  z-index: 151;
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 1.5px;
  background: var(--fg);
  position: absolute;
  transform-origin: center;
  will-change: transform, opacity;
  transform: translateZ(0);
  transition: transform 0.35s cubic-bezier(0.23, 1, 0.32, 1),
              opacity 0.35s ease;
}

.nav-toggle span:nth-child(1) { transform: translateY(-6px); }
.nav-toggle span:nth-child(2) { transform: translateY(0); }
.nav-toggle span:nth-child(3) { transform: translateY(6px); }

/* X state */
.nav-toggle.is-open span:nth-child(1) { transform: translateY(0) rotate(45deg); }
.nav-toggle.is-open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-toggle.is-open span:nth-child(3) { transform: translateY(0) rotate(-45deg); }

/* When the mobile nav overlay is open, dissolve the top bar into it:
   drop the header background/border and hide the logo, leaving only the X. */
body.nav-open .site-header {
  background: transparent;
  border-bottom-color: transparent;
}

body.nav-open .logo-group {
  opacity: 0;
  pointer-events: none;
}

/* ── Fullscreen nav overlay ── */
.nav-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: #fde104;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4.5rem;
  /* sit slightly above true center — optically more natural.
     Use padding (not transform) so the background still covers the full screen. */
  padding-bottom: 7rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

.nav-overlay.is-open {
  opacity: 1;
  pointer-events: all;
}

.nav-overlay a {
  font-size: clamp(2rem, 8vw, 5rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--fg);
  text-decoration: none;
  line-height: 1;
  position: relative;
  transition: color 0.2s;
  /* stagger in */
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

.nav-overlay.is-open a {
  opacity: 1;
  transform: translateY(0);
}

.nav-overlay.is-open a:nth-child(1) { transition-delay: 0.08s; }
.nav-overlay.is-open a:nth-child(2) { transition-delay: 0.14s; }
.nav-overlay.is-open a:nth-child(3) { transition-delay: 0.20s; }
.nav-overlay.is-open a:nth-child(4) { transition-delay: 0.26s; }

.nav-overlay a:hover { color: white; }

/* ── Hero ── */
.hero {
  position: relative;
  height: 56dvh;
  min-height: 260px;
  margin-top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.hero-video-wrap {
  position: absolute;
  inset: 0;
}

.hero-video-wrap {
  overflow: hidden;
}

.hero-video-wrap video,
.hero-video-wrap iframe {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 177.78vh; /* 16/9 ratio */
  height: 100%;
  min-width: 100%;
  min-height: 56.25vw; /* 9/16 ratio */
  transform: translate(-50%, -50%);
  border: none;
  pointer-events: none;
}


.hero-text {
  position: relative;
  text-align: center;
  z-index: 1;
  padding: 1rem;
}

.hero-text h1 {
  font-size: clamp(2.5rem, 8vw, 6rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 0.5rem;
}

.hero-text p {
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  color: var(--muted);
  margin-bottom: 2rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 0.875rem;
}

/* ── Button ── */
.btn {
  display: inline-block;
  padding: 0.75rem 1.75rem;
  border: 1.5px solid var(--fg);
  font-size: 0.875rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: background 0.2s, color 0.2s;
}

.btn:hover {
  background: var(--fg);
  color: var(--bg);
}

/* ── Sections ── */
.section {
  padding: 6rem 2rem;
  max-width: var(--max);
  margin: 0 auto;
}

.section--alt {
  max-width: 100%;
  background: #f8f8f8;
  padding: 6rem 2rem;
}

.section--alt > * {
  max-width: var(--max);
  margin: 0 auto;
}

.section-title {
  margin-bottom: 3rem;
}

/* ── Gallery ── */
.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.gallery-item {
  cursor: pointer;
}

.gallery-item-thumb {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #f0f0f0;
}

.gallery-item-thumb img,
.gallery-item-thumb video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transform: scale(var(--thumb-scale, 1));
  transition: transform 0.4s ease;
}

.gallery-item:hover .gallery-item-thumb img,
.gallery-item:hover .gallery-item-thumb video {
  transform: scale(calc(var(--thumb-scale, 1) * 1.06));
}

/* Overlay: desktop hover only */
.gallery-item-thumb {
  position: relative;
}

.gallery-item-overlay {
  display: none;
}

@media (hover: hover) {
  .gallery-item-overlay {
    display: flex;
    position: absolute;
    inset: 0;
    align-items: flex-end;
    padding: 0.875rem 1rem;
    background: linear-gradient(transparent 40%, rgba(0,0,0,0.55));
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
  }

  .gallery-item-overlay span {
    color: #fff;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    transform: translateY(6px);
    transition: transform 0.3s ease;
    line-height: 1;
  }

  .gallery-item:hover .gallery-item-overlay {
    opacity: 1;
  }

  .gallery-item:hover .gallery-item-overlay span {
    transform: translateY(0);
  }

  .gallery-item-label {
    display: none;
  }
}

@media (hover: none) {
  .gallery-item-label {
    display: block;
  }
}

.gallery-item-label {
  padding: 0.6rem 0 0;
  font-size: 0.9375rem;
  color: var(--fg);
  text-align: center;
}

/* Gallery staggered fade-in */
.gallery-item {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.gallery-item--visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── About & Contact: sticky footer, full-width bg, centered content ── */
body.page-about,
body.page-contact {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.page-about main,
body.page-contact main {
  flex: 1 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
}

body.page-about main {
  background: #f8f8f8;
}

body.page-about main > section,
body.page-contact main > section {
  width: 100%;
  max-width: 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

body.page-about main > section > .about,
body.page-contact main > section > .contact {
  max-width: var(--max);
  margin-left: auto;
  margin-right: auto;
}

body.page-about > .site-footer,
body.page-contact > .site-footer {
  width: 100%;
  flex-shrink: 0;
}

/* ── About ── */
.about {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 2rem;
  align-items: start;
}

.about-image {
  display: flex;
  justify-content: flex-end;
}

.about-image img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
}

.rive-wrap {
  width: 75%;
  aspect-ratio: 1 / 1;
  overflow: visible;
  position: relative;
}

.rive-wrap iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  transform: scale(1.2);
  transform-origin: center center;
}

.about-text h2 {
  margin-bottom: 1.5rem;
}

.about-text p {
  margin-bottom: 2rem;
  font-size: 1.0625rem;
  line-height: 1.75;
  color: #333;
}

.about-text .btn { margin-top: 1rem; }

/* ── Contact ── */
.contact {
  text-align: center;
  max-width: 560px;
  margin: 0 auto;
}

/* ── Contact form modal ── */
.form-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.form-modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.form-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.75);
}

.form-modal-card {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  background: #fde104;
  padding: 2.5rem;
  transform: translateY(12px);
  transition: transform 0.2s ease;
}

.form-modal.is-open .form-modal-card {
  transform: translateY(0);
}

.form-modal-close {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--fg);
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem;
}

.form-modal-title {
  font-size: 2rem;
  margin-bottom: 1.5rem;
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  text-align: left;
}

.form-group-label {
  display: block;
  margin-bottom: 0.6rem;
  font-size: 1rem;
  color: var(--fg);
}

.form-name-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-label {
  font-size: 0.9rem;
  color: var(--fg);
}

.form-label .req {
  color: var(--muted);
  font-size: 0.8rem;
}

.contact-form input[type="text"],
.contact-form input[type="email"],
.contact-form textarea {
  width: 100%;
  font: inherit;
  font-size: 0.95rem;
  color: var(--fg);
  background: white;
  border: none;
  padding: 0.65rem 0.75rem;
}

.contact-form textarea {
  resize: vertical;
  min-height: 7rem;
}

.contact-form input:focus,
.contact-form textarea:focus {
  outline: none;
  box-shadow: none;
}

.form-submit {
  align-self: center;
  margin-top: 0.5rem;
  cursor: pointer;
  background: var(--fg);
  color: white;
  border: none;
}

.form-submit:disabled {
  opacity: 0.5;
  cursor: default;
}

.form-status {
  text-align: center;
  font-size: 0.85rem;
  min-height: 1.2em;
  margin: 0;
}

.form-status.is-success { color: var(--fg); }
.form-status.is-error { color: #c0392b; }
.form-status.is-pending { color: var(--muted); }

/* Thank-you completion state: box shrinks to show only the message */
.form-modal-done {
  display: none;
  text-align: center;
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--fg);
}
.form-modal-done p { margin: 0; }

.form-modal-card.is-complete { overflow: hidden; }
.form-modal-card.is-complete .form-modal-close,
.form-modal-card.is-complete .form-modal-title,
.form-modal-card.is-complete .contact-form { display: none; }
.form-modal-card.is-complete .form-modal-done { display: block; }

@media (max-width: 480px) {
  .form-name-row { grid-template-columns: 1fr; }
  .form-modal-card { padding: 1.75rem 1.25rem; }
}

.contact h2 { margin-bottom: 0.75rem; }

.contact p {
  color: #333;
  margin-bottom: 2rem;
  font-size: 1.0625rem;
  line-height: 1.75;
}

.social-links {
  margin-top: 2.5rem;
  display: flex;
  gap: 1.5rem;
  justify-content: center;
}

.social-links a {
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

.social-links a:hover {
  color: var(--fg);
  border-color: var(--fg);
}

/* ── Footer emoji animation ── */
.footer-emoji-anim {
  display: inline-block;
  vertical-align: baseline;
}

.fea-face {
  display: inline-block;
}

/*
  🙃 rotate(180deg) = looks like 😊
  🙃 rotate(0deg)   = looks like 🙃
  Total cycle: 3.2s
  0.00–0.50s  bounce 1 — no flip, stays 😊
  0.50–0.90s  bounce 2 — ~50ms flash flip at peak, lands as 🙃
  0.90–1.90s  hold as 🙃 (1s)
  1.90–2.20s  recovery jump — ~50ms flash flip at peak back to 😊
  2.20–3.20s  hold as 😊 (1s)
*/
@keyframes fea-face {
  /* Rest as 😊 */
  0%     { transform: translateY(0) rotate(180deg);     animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); }
  /* Bounce 1 peak — no flip */
  7.8%   { transform: translateY(-20px) rotate(180deg); animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19); }
  /* Bounce 1 land */
  15.6%  { transform: translateY(0) rotate(180deg);     animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); }
  /* Bounce 2 — approaching peak as 😊 */
  21.9%  { transform: translateY(-15px) rotate(180deg); animation-timing-function: linear; }
  /* Flip at peak (~100ms) — now 🙃 */
  25.0%  { transform: translateY(-15px) rotate(0deg);   animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19); }
  /* Bounce 2 land as 🙃 */
  28.1%  { transform: translateY(0) rotate(0deg); }
  /* Hold as 🙃 for 1s */
  59.4%  { transform: translateY(0) rotate(0deg);       animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); }
  /* Recovery jump — approaching peak as 🙃 */
  64.1%  { transform: translateY(-12px) rotate(0deg);   animation-timing-function: linear; }
  /* Flip at peak (~100ms) — back to 😊 */
  67.2%  { transform: translateY(-12px) rotate(180deg); animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19); }
  /* Land as 😊 */
  68.8%  { transform: translateY(0) rotate(180deg); }
  /* Hold as 😊 */
  100%   { transform: translateY(0) rotate(180deg); }
}

.fea-face { animation: fea-face 3.2s infinite; }

/* Hammer: pivot at bottom-right corner, head pointing top-left.
   Swings down 45° and back, ping-pong style. */
.fea-hammer {
  display: inline-block;
  transform-origin: 72% 80%; /* bottom of the hilt, so the swing pivots from the grip end */
  animation: fea-hammer 2.9s infinite;
}

/* Invisible mirror of the hammer: balances the trailing hammer's width so the
   sentence text stays centered (matches whatever width the emoji renders at). */
.fea-hammer-spacer {
  visibility: hidden;
}

/*
  3 taps, 0.3s each (slow out from the top, fast snap at the bottom hit,
  ease back up), then hold at rest for 2s before looping.
  Tap span = 0.3s / 2.9s = 10.345%; each downstroke/upstroke = 5.172%.
*/
@keyframes fea-hammer {
  /* Tap 1 */
  0%      { transform: rotate(0deg);   animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19); }
  5.172%  { transform: rotate(-45deg); animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); }
  10.345% { transform: rotate(0deg);   animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19); }
  /* Tap 2 */
  15.517% { transform: rotate(-45deg); animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); }
  20.690% { transform: rotate(0deg);   animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19); }
  /* Tap 3 */
  25.862% { transform: rotate(-45deg); animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); }
  31.034% { transform: rotate(0deg); }
  /* Hold at rest for ~2s */
  100%    { transform: rotate(0deg); }
}

/* ── Footer ── */
.site-footer {
  text-align: center;
  padding: 2rem;
  font-size: 0.8125rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  box-sizing: border-box;
}

/* ── Main content pushed below fixed header ── */
#main-content {
  padding-top: var(--header-h, 72px);
}

/* ── Home page: hero fills the full viewport, behind the fixed header ── */
body.home #main-content {
  padding-top: 0;
}

body.home .hero {
  height: 100dvh;
  min-height: 100dvh;
}

@media (max-width: 540px) {
  body.home .hero {
    height: 100dvh;
    min-height: 100dvh;
  }
}

/* ── Projects page: section handles its own offset from header ── */
body.projects #main-content {
  padding-top: 0;
}

/* ── Project view ── */
#project-view {
  padding-top: var(--header-h, 72px);
}

/* ── Project page dark theme ── */
#project-view {
  background: #111;
  min-height: 100vh;
  color: #fff;
}

.project-page {
  margin: 0 auto;
  padding: 2.5rem 2rem 6rem;
}

.project-page-title {
  font-size: clamp(1.75rem, 4.5vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.05em;
  text-transform: uppercase;
  margin: 0;
  margin-left: max(0px, calc(50% - 645px));
  line-height: 1;
  color: #fde104;
}

/* Project page slide-up entrance */
.project-page--enter {
  opacity: 0;
  transform: translateY(28px);
}

.project-page--enter-active {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.23, 1, 0.32, 1);
}

.project-page-description {
  font-size: 1.0625rem;
  line-height: 1.75;
  color: rgba(255,255,255,0.75);
  max-width: 680px;
  margin-inline: auto;
}

/* ── Project page spacing system ──────────────────────────────────────
   Every content block is a direct child of .project-page, so one owl
   selector sets the default rhythm and the rules under it are the named
   exceptions. Spacing is driven by margin-TOP only (block bottoms are
   zeroed) so changing a token here propagates to every project page. */
.project-page {
  --space-section: 4.5rem;   /* media ↔ copy, and any unlisted break   */
  --space-para: 2rem;        /* paragraph → paragraph                  */
  --space-head: 3rem;        /* copy → subheading (new subsection)     */
  --space-head-body: 0.5rem; /* subheading → its first copy            */
  --space-caption: 0.5rem;   /* media → its caption (caption hugs up)  */
  --space-stack: 2rem;       /* media → media, bracket → bracket       */
}

/* Default: full section breath between any two adjacent blocks */
.project-page > * + * { margin-top: var(--space-section); }

/* Consecutive paragraphs sit tight */
.project-page-description + .project-page-description { margin-top: var(--space-para); }

/* Copy → subheading: open a new subsection */
.project-page-description + .project-page-subheading,
.project-page-instruction + .project-page-subheading,
.project-page-bracket + .project-page-subheading { margin-top: var(--space-head); }

/* Subheading → its body copy */
.project-page-subheading + .project-page-description,
.project-page-subheading + .project-page-instruction { margin-top: var(--space-head-body); }

/* Instruction sits tight above its grid */
.project-page-instruction + .ba-grid,
.project-page-instruction + .project-media-grid { margin-top: var(--space-para); }

/* Caption hugs the media directly above it */
.project-page-media-item + .project-page-caption,
.project-media-grid + .project-page-caption,
.ba-grid + .project-page-caption { margin-top: var(--space-caption); }

/* Stacked media / consecutive placeholders sit closer than a section */
.project-page-media-item + .project-page-media-item,
.project-page-bracket + .project-page-bracket { margin-top: var(--space-stack); }

/* Placeholder brackets keep tight to neighbouring copy */
.project-page-description + .project-page-bracket,
.project-page-subheading + .project-page-bracket { margin-top: 1.5rem; }
.project-page-bracket + .project-page-description { margin-top: 2rem; }

/* ── Caption ── */
.project-page-caption {
  font-size: 0.75rem;
  line-height: 1.5;
  font-style: italic;
  color: rgba(255,255,255,0.45);
  max-width: 680px;
  margin-inline: auto;
  text-align: right;
}
/* Caption under full-width media aligns to the media's right edge */
.project-page-media-item + .project-page-caption,
.project-media-grid + .project-page-caption { max-width: 1290px; }

/* ── Instruction line — left-aligned to the media block edge ── */
.project-page-instruction {
  font-size: 1.0625rem;
  line-height: 1.75;
  font-style: italic;
  color: rgba(255,255,255,0.75);
  max-width: 1290px;
  margin-inline: auto;
  text-align: left;
}

/* ── Before/After compare ── */
.ba-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  max-width: 1290px;
  margin-inline: auto;
}

.ba-compare {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 16/9;
}

.ba-compare img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.3s ease;
}

.ba-compare .ba-after { opacity: 1; z-index: 2; }
.ba-compare .ba-before { opacity: 0; z-index: 1; }

.ba-compare .ba-label {
  position: absolute;
  top: 0;
  left: 0;
  padding: 4px 10px;
  font-size: 1.1rem;
  font-style: normal;
  color: white;
  text-shadow: 0 0 4px rgba(0,0,0,0.8);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 3;
  pointer-events: none;
}

@media (hover: hover) {
  .ba-compare:hover .ba-after { opacity: 0; }
  .ba-compare:hover .ba-before { opacity: 1; }
  .ba-compare:hover .ba-label { opacity: 1; }
}

.ba-compare.is-before .ba-after { opacity: 0; }
.ba-compare.is-before .ba-before { opacity: 1; }
.ba-compare.is-before .ba-label { opacity: 1; }

@media (max-width: 540px) {
  .ba-grid { grid-template-columns: repeat(2, 1fr); }
}

.project-page-media-item {
  margin-inline: auto;
  max-width: 1290px;
}

.project-page-media-item--narrow {
  max-width: 680px;
}

/* ── Multi-column media grid ── */
.project-media-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 2), 1fr);
  gap: 1rem;
  max-width: 1290px;
  margin-inline: auto;
}

.project-media-grid-item {
  display: flex;
  flex-direction: column;
}

.project-media-grid-item iframe,
.project-media-grid-item video {
  width: 100%;
  aspect-ratio: 16/9;
  border: none;
  display: block;
}

.project-media-grid-item img {
  width: 100%;
  height: auto;
  display: block;
}

.project-media-grid-item .project-page-caption {
  max-width: none;
  margin: 0.5rem 0 0;
}

@media (max-width: 920px) {
  .project-media-grid {
    grid-template-columns: 1fr;
  }
  .project-media-grid[style*="--cols:4"],
  .project-media-grid[style*="--cols:5"],
  .project-media-grid[style*="--cols: 4"],
  .project-media-grid[style*="--cols: 5"] {
    grid-template-columns: repeat(2, 1fr);
    padding-inline: 1rem;
  }
}

/* ── Text + stacked media split row ── */
.project-text-media-row {
  display: grid;
  grid-template-columns: var(--tmr-cols, 1fr 1.6fr);
  gap: 3rem;
  max-width: 1290px;
  margin-inline: auto;
  align-items: start;
}

.project-text-media-row__text {
  position: sticky;
  top: calc(var(--header-h, 60px) + 2rem);
}

.project-text-media-row__text .project-page-description {
  max-width: none;
  margin: 0;
}

.project-text-media-row__media {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.project-text-media-row__media iframe {
  width: 100%;
  aspect-ratio: 16/9;
  border: none;
  display: block;
}

.project-text-media-row__media .project-page-caption {
  max-width: none;
  margin: 0.5rem 0 1.5rem;
  text-align: right;
}

.project-text-media-row__media .project-page-caption:last-child {
  margin-bottom: 0;
}

@media (max-width: 860px) {
  .project-text-media-row {
    grid-template-columns: 1fr;
  }
  .project-text-media-row__text {
    position: static;
  }
}

#project-view a:not(.btn):not(.project-nav-link) {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.project-page-subheading {
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  max-width: 680px;
  margin-inline: auto;
  color: #fde104;
  text-align: left;
}

.project-page-bracket {
  font-family: 'Courier New', monospace;
  font-size: 0.875rem;
  color: rgba(255,255,255,0.4);
  border: 1px dashed rgba(255,255,255,0.2);
  padding: 1rem 1.25rem;
  margin-inline: auto;
  max-width: 680px;
}


.project-page-media-item img,
.project-page-media-item video {
  width: 100%;
  height: auto;
  display: block;
}

.project-page-media-item iframe {
  width: 100%;
  aspect-ratio: 16/9;
  border: none;
  display: block;
}

.project-page-media {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.project-page-media img,
.project-page-media video {
  width: 100%;
  height: auto;
  display: block;
}

.project-page-media iframe {
  width: 100%;
  aspect-ratio: 16/9;
  border: none;
  display: block;
}

.project-page-links {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  max-width: 680px;
  margin: 3.5rem auto 0;
}

/* ── Project prev/next nav ── */
.project-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6rem;
  padding-top: 2rem;
  border-top: 1px solid rgba(255,255,255,0.2);
  max-width: 1290px;
  margin-left: auto;
  margin-right: auto;
}

.project-nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  padding: 0;
  transition: opacity 0.2s;
}

.project-nav-link:hover { opacity: 0.45; }

.project-nav-arrow {
  font-size: 1rem;
  line-height: 1;
}

/* ── Heading letter bounce — ease-in up, ease-out down (gravity feel) ── */
@keyframes letter-bounce {
  0%   { transform: translateY(0);     animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); }
  40%  { transform: translateY(-10px); animation-timing-function: cubic-bezier(0.6, 0, 0.95, 0.97); }
  100% { transform: translateY(0); }
}

/* ── Hand 1-bounce (up and back down) ── */
@keyframes hand-bounce1 {
  0%   { transform: translateY(0);     animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); }
  45%  { transform: translateY(-18px); animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19); }
  100% { transform: translateY(0); }
}

/* ── Wave hand ── */
#waveHand {
  display: inline-block;
  font-size: 0.75em;
  vertical-align: 0.2em;
  transform-origin: center 70%;
}

/* Applied by JS during wave phase */
#waveHand.is-waving {
  animation: wave-hand 0.13s cubic-bezier(0.4, 0, 0.6, 1) infinite alternate;
}

@keyframes wave-hand {
  from { transform: rotate(-20deg); }
  to   { transform: rotate(20deg); }
}

/* ── Slay animation ── */
.slay-stage {
  position: relative;
  height: 4rem;
  max-width: 307px;  /* 20% narrower than previous 384px */
  margin: 1.5rem auto 2rem;
  font-size: 1.4rem;
  line-height: 1;
  user-select: none;
}

.slay-wizard       { position: absolute; bottom: 0; left: 0; }
.slay-elf          { position: absolute; bottom: 0; left: 1.8rem; }
/* One exclaim exactly above each hero */
.slay-exclaim-1    { position: absolute; bottom: 1.65rem; left: 0;     opacity: 0; }
.slay-exclaim-2    { position: absolute; bottom: 1.65rem; left: 1.8rem; opacity: 0; }
.slay-weapon-wrap  { position: absolute; bottom: 0; opacity: 0; }
.slay-monster      { position: absolute; bottom: 0; right: 0; opacity: 0; }

/* 2-bounce variant (0.9 s) */
@keyframes slay-bounce2 {
  0%   { transform: translateY(0);     animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); }
  22%  { transform: translateY(-20px); animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19); }
  44%  { transform: translateY(0);     animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); }
  62%  { transform: translateY(-11px); animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19); }
  76%  { transform: translateY(0); }
  100% { transform: translateY(0); }
}

/* Monster 3-bounce (1.3 s) — active through ~66%, hold to end */
@keyframes slay-bounce3 {
  0%   { transform: translateY(0);     animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); }
  14%  { transform: translateY(-20px); animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19); }
  28%  { transform: translateY(0);     animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); }
  39%  { transform: translateY(-12px); animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19); }
  50%  { transform: translateY(0);     animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); }
  58%  { transform: translateY(-6px);  animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19); }
  66%  { transform: translateY(0); }
  100% { transform: translateY(0); }
}

/* 3-flash — sharp on/off steps, reused for exclamation and explosion */
@keyframes slay-flash3 {
  0%,   10.9% { opacity: 1; }
  11%,  21.9% { opacity: 0; }
  22%,  32.9% { opacity: 1; }
  33%,  43.9% { opacity: 0; }
  44%,  54.9% { opacity: 1; }
  55%,  100%  { opacity: 0; }
}

/* Hero throw lunge — pure linear, snappy */
@keyframes slay-throw {
  0%   { transform: translateX(0);    animation-timing-function: linear; }
  35%  { transform: translateX(18px); animation-timing-function: linear; }
  100% { transform: translateX(0); }
}

/* Weapon spin */
@keyframes slay-weapon-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Skull floats up and fades out */
@keyframes slay-skull-exit {
  0%   { transform: translateY(0);     opacity: 1; }
  100% { transform: translateY(-28px); opacity: 0; }
}

/* Hero celebration bounce (loop, offset applied via delay in JS) */
@keyframes slay-celebrate {
  0%, 100% { transform: translateY(0);     animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); }
  50%      { transform: translateY(-14px); animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19); }
}

@media (max-width: 540px) {
  .project-page {
    padding-left: 0;
    padding-right: 0;
  }

  .project-page-title,
  .project-page-description,
  .project-page-caption,
  .project-page-subheading,
  .project-page-bracket,
  .project-page-instruction,
  .project-page-links,
  .project-nav {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }

  .project-page-media-item,
  .project-media-grid,
  .ba-grid {
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
  }
}

/* ── Mobile ── */
/* Switch to the hamburger before the longest tagline snippet (~266px) would
   collide with the nav (~325px) — keeps every snippet fully visible. */
@media (max-width: 720px) {
  .site-header nav { display: none; }
  .nav-toggle { display: flex; }
}

@media (max-width: 540px) {
  .hero {
    height: 36dvh;
    min-height: 200px;
  }

  .about {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .about-image {
    justify-content: flex-start;
  }

  .about-image img {
    aspect-ratio: 4/3;
  }

  .rive-wrap {
    max-height: 300px;
    max-width: 300px;
  }

  .gallery {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .section, .section--alt {
    padding: 4rem 1.25rem;
  }
}

/* ── Fluent emoji images (replace native emoji site-wide) ── */
.emoji-img {
  height: 1em;
  width: 1em;
  vertical-align: -0.15em;
  display: inline-block;
  object-fit: contain;
}

/* ── Intro "hello" animation ── */
.intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #fde104;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
  opacity: 1;
  will-change: opacity;
  transition: opacity 2s ease;
  --intro-emoji: clamp(1.75rem, 5.5vw, 2.75rem);
}

.intro-overlay.intro-out {
  opacity: 0;
  pointer-events: none;
}

.intro-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3rem;
  margin-top: 28vh;
}

.intro-text {
  position: relative;
  display: inline-block;
  font-family: var(--font-mono, 'DM Mono', monospace);
  font-size: clamp(1rem, 3vw, 1.4rem);
  color: #0a0a0a;
  line-height: 1.6;
  text-align: left;
  white-space: pre-line;
  min-height: 3.2em;
}

.intro-text-ghost { visibility: hidden; }

.intro-text-live {
  position: absolute;
  left: 0;
  top: 0;
  white-space: pre-line;
}

.intro-cursor {
  display: inline-block;
  margin-left: 1px;
  animation: tagline-blink 0.7s step-end infinite;
}

.intro-wizard {
  font-size: var(--intro-emoji);
  line-height: 1;
  will-change: transform;
}

.intro-trail-sparkle {
  position: absolute;
  font-size: var(--intro-emoji);
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: intro-sparkle-fade 0.9s ease-out forwards;
}

@keyframes intro-sparkle-fade {
  0%   { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.2); }
}
