/* Space Invaders hero (standalone, minimal dependencies) */

/* Page background should be white below the hero */
html, body {
  height: auto;
  background: #fff;
}/* ===== HERO LAYOUT ===== */
.si-hero { position: relative; height: 100vh; overflow: hidden; background:#fff; }
.si-grid { position:absolute; inset:0; display:flex; flex-direction:column; }

/* Five equal-height rows */
/* 3 equal rows that always fill the viewport */
.si-row{
  position: relative;
  flex: 1 1 33.333%;
  overflow: hidden;
  background: #0d0b24;
}



/* Alternate direction per row */
.si-row.dir-left  .si-tiles { animation-direction: reverse; }
.si-row.dir-right .si-tiles { animation-direction: normal;  }

/* Seamless tiling: fixed tile width + 1px overlap */
.si-tile{
  flex:0 0 auto;
  width: var(--tile-w);          /* set by JS per row */
  height: 100%;                  /* fill row height */
  display:grid; place-items:center;
  overflow:hidden;
}
.si-tile + .si-tile { margin-left:-1px; } /* hide sub-pixel seams */

/* Media fills the tile height; no size changes on stop */
.si-media{

  object-fit: contain;           /* portrait screens preserved */
  transform: translateZ(0);
  transition: none !important;

  object-fit: cover;
  width: 100%;
  height: 100%;

}
.si-gif{ display:none; }         /* only shown if video fails */



/* Pause cleanly at stop time */
.si-hero.si-stopped .si-tiles { animation-play-state: paused; }

/* Overlay + title (same style you had) */
.si-overlay{
  position:absolute; inset:0; pointer-events:none;
  background:linear-gradient(to bottom, rgba(91,33,182,.30), rgba(255,255,255,.10) 50%, rgba(255,255,255,.25) 100%);
  opacity:.35; transition:opacity .6s ease;
}

.si-hero.si-stopped .si-overlay{ opacity:.6; }
.si-hero.si-stopped .si-title{ opacity:1; transform:translateY(0); }

/* Content below */
.si-content{ min-height:120vh; background:#fff; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce){
  .si-tiles{ animation:none !important; transform:none !important; }
  .si-overlay,.si-title{ transition:none !important; }
}


/* ===== CONTENT BELOW ===== */
.si-content {
  min-height: 120vh;  /* ensure scrollable page on white */
  background: #fff;
}

/* ===== Mobile behavior ===== */
@media (max-width: 640px) {
  /* On small screens we usually only need 1 tile anyway; JS will compute that.
     Keep the same visuals; the title remains readable. */
  .si-title { font-size: clamp(1.8rem, 8vw, 2.6rem); }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  .si-overlay,
  .si-title,
  .si-tile { transition: none !important; }
}

/* After stop, let the center tile fill the viewport width */
.si-hero.si-stopped .si-media {
  width: 100vw;
  height: 100vh;
  object-fit: cover;   /* crop a bit vertically to fill */
}

/* Keep only the center tile visible (already in your CSS) */

.si-tiles {
  position: absolute;
  inset: 0;
  display: flex;
  flex-wrap: nowrap;   /* Keep everything in one row */
  justify-content: center;
  gap: 0;
  will-change: contents, transform;
}


/* When we stop, freeze the marquee at its current frame */
.si-hero.si-stopped .si-tiles {
  animation-play-state: paused;
}

/* IMPORTANT: keep every tile visible after pause */
.si-hero.si-stopped .si-tile { opacity: 1; }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .si-tiles { animation: none !important; transform: none !important; }
}
@keyframes siMarquee { from { transform: translateX(0); } to { transform: translateX(calc(-1 * var(--tile-w))); } }


.si-hero.si-stopped .si-tiles { animation-play-state: paused; }
.si-media {
  height: 100vh;
  width: auto;
  object-fit: contain;
  transform: none !important;
  transition: none !important;   /* prevent any size/transform tween */
}

/* On stop: do not change size */
.si-hero.si-stopped .si-media {
  height: 100vh;
  width: auto;
  object-fit: contain;
}
.si-hero.si-stopped .si-tiles {
  animation-play-state: paused;
  transform: translateX(var(--paused-pos, 0)); /* freeze current offset */
}


/* Each tile has a fixed width; overlap 1px to hide any seam */
.si-tile{
  flex:0 0 auto;
  width: var(--tile-w);
  height:100vh;
  display:grid; place-items:center;
  overflow:hidden;
}
.si-tile + .si-tile { margin-left:-1px; } /* seam killer */

/* Media never changes size */
.si-media{
  height:100vh; width:auto; object-fit:contain;
  transform: translateZ(0);        /* GPU rasterization */
  transition:none !important;
}
.si-gif{ display:none; }

/* Animate from the left lead offset across the full loop distance */
@keyframes siMarquee{
  from { transform: translate3d(calc(-1 * var(--lead-offset)), 0, 0); }
  to   { transform: translate3d(calc(-1 * (var(--lead-offset) + var(--loop-width))), 0, 0); }
}

/* Pause cleanly on stop */
.si-hero.si-stopped .si-tiles{ animation-play-state: paused; }


/* ===== Space Invaders — 4-row full-cover infinite marquee ===== */

html, body {
  height: 100%;
  margin: 0;
  background: #0d0b24;               /* safe while media initializes */
}

.si-hero{
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
}

.si-grid{
  position: absolute; inset: 0;
  display: flex;
  flex-direction: column;
}

/* 4 equal rows that always fill the viewport */
.si-row{
  position: relative;
  flex: 1 1 25%;
  overflow: hidden;
  background: #0d0b24;
}

/* Moving strip */
.si-tiles{
  position: absolute; inset: 0;
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: 0;
  will-change: transform;
  animation: siMarquee2 var(--si-speed, 20s) linear infinite;
  animation-delay: var(--phase, 0s);
}

/* Alternate directions per row */
.si-row.dir-right .si-tiles { animation-direction: normal; }
.si-row.dir-left  .si-tiles { animation-direction: reverse; }

/* Tile boxes */
.si-tile{
  flex: 0 0 auto;
  width: var(--tile-w);              /* set by JS per row */
  height: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #0d0b24;
}
/* tiny overlap to kill sub-pixel seams */
.si-tile + .si-tile { margin-left: -1px; }

/* Media fills each tile completely */
.si-media{
  width: 100%;
  height: 100%;
  object-fit: cover;                 /* full-bleed, no “background” visible */
  display: block;
  transform: translateZ(0);
}
.si-gif{ display: none; }

/* Double-track marquee: translate exactly half the track width */
@keyframes siMarquee2{
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(calc(-1 * var(--track-half, 0px)), 0, 0); }
}

/* Respect reduced motion (stops movement but still covers screen) */
@media (prefers-reduced-motion: reduce){
  .si-tiles{ animation: none !important; transform: none !important; }
}



/* 2) Intro pane layout (starts hidden, sits above mask) */
.si-intro{
  position:fixed; inset:0; display:grid; place-items:center;
  z-index:2; pointer-events:none; /* becomes clickable after reveal */
  opacity:0; transform: translateY(16px);
  transition: opacity 1.0s ease, transform 1.0s ease;

}
.si-intro.is-visible{
  opacity:1; transform:none; pointer-events:auto;
}

/* grid */
.si-intro__inner{
  width:min(1100px, 92vw);
  display:grid; grid-template-columns: 1.1fr 1fr; gap: clamp(16px, 4vw, 40px);
  align-items:center;
}


@keyframes gradientShift{
  0%{background-position:0% center;}
  50%{background-position:100% center;}
  100%{background-position:0% center;}
}
.si-tagline{
  color:#501b86; opacity:.85; font-size: clamp(1rem, 2.2vw, 1.25rem);
}

/* Right: hero video box */
.si-intro__right{
  margin:0; position:relative; overflow:hidden; border-radius:14px;
  box-shadow: 0 16px 40px rgba(0,0,0,.18);
  background:#0c0a1b;
  border:1px solid rgba(158,92,185,.18);
    aspect-ratio: 360 / 462;             /* your footage is portrait */
}
.si-intro-video{
  width:100%; height:100%; object-fit:cover; display:block;
}

/* Mobile: stack */
@media (max-width: 760px){
  .si-intro__inner{ grid-template-columns: 1fr; }
  .si-intro__right{ order:-1; aspect-ratio:auto; height:48vh; }
}




@keyframes siTaglineIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes gradientShift {
  0%   { background-position:   0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position:   0% 50%; }
}

/* Motion safety */

/* === Make intro title match the main title animation === */



/* when intro is shown: play the same entrance + then the gradient loop */

/* optional: stagger the tagline to appear a bit after the title entrance */

:root { --bg-h: 22vh; } /* band height */
:root { --bg-h: 22vh; }

/* 1) Fade the wall all the way to white, then show intro */
.si-hero::after{
  /* full-screen white mask we can animate */
  content:"";
  position:fixed; inset:0; pointer-events:none;
  background:#fff;
  opacity:0;                       /* invisible at start */
  transition:opacity 1.8s ease;     /* nice fade */
  z-index:1;                       /* above rows, below intro */
}
.si-hero.is-white::after{ opacity:1; }

/* Hide flowers by default on this page */
/* White fade sits lowest */
.si-hero::after { z-index: 1; }

/* Flower band above the fade, below the intro */
#bg{
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: var(--bg-h, 22vh);
  background: #fff url("images/bgmaf4.jpg") bottom center repeat-x;
  background-size: auto var(--bg-h, 22vh);
  -webkit-mask-image: linear-gradient(to top, rgba(0,0,0,1) 45%, rgba(0,0,0,0) 100%);
  mask-image: linear-gradient(to top, rgba(0,0,0,1) 45%, rgba(0,0,0,0) 100%);
  filter: saturate(1.35) hue-rotate(500deg) contrast(1.5) brightness(1.1);
  mix-blend-mode: lighten;
  pointer-events: none;

  z-index: 2 !important;       /* crucial: above the fade */
  opacity: 0 !important;        /* hidden by default */
  transition: opacity 900ms ease;
}

/* Show band only on the title/video screen */
/* Show the flowers on the title/video screen and disable blending on white */
.flowers-on #bg {
  opacity: 0.15 !important;
  mix-blend-mode: normal !important;  /* <- key line */
}


/* Intro panel sits on top of everything */
.si-intro { z-index: 3; }


/* Use the exact same entrance as the home page */
@keyframes header {
  0%   { transform: translate3d(0, 1em, 0); opacity: 0; }
  100% { transform: translate3d(0, 0, 0);  opacity: 1; }
}

/* delay identical to home */
:root { --title-delay: 2250ms; }




/* gradient keyframes */
@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50%{ background-position: 100% 50%; }
  100%{ background-position: 0% 50%; }
}
/* Make the intro video a little smaller on desktop */
@media (min-width: 761px) {
  /* tighten the grid and cap the video width */
  .si-intro__inner {
    grid-template-columns: 1.15fr auto;  /* a bit more room for the title */
  }

  .si-intro__right {
    width: clamp(260px, 28vw, 380px);    /* smaller, responsive cap */
    justify-self: end;                   /* keep it snug to the right */
  }
}


/* Make left and right margins visually symmetrical */
.si-intro__inner {
  width: min(1100px, 92vw);
  margin-inline: auto;                  /* center the whole block */
  grid-template-columns: 1fr auto;      /* balanced columns */
}

/* Left column: align to start (no centering) */
.si-intro__left { text-align: left; }
.si-intro__left .si-gradient-title,
.si-intro__left .si-tagline {
  margin-left: 0;
  margin-right: 0;
}

/* Keep the video snug to the right edge of the container */
.si-intro__right { justify-self: end; }

/* Optional: slightly smaller video on desktop to fine-tune balance */
@media (min-width: 761px) {
  .si-intro__right { width: clamp(240px, 26vw, 360px); }
}

/* === Title animation identical to main.css === */
/* Keep only one copy of these rules. */

:root { --title-delay: 2250ms; } /* same value your homepage uses */



/* Tagline timing identical to homepage */
.si-intro.is-visible .si-tagline{
  opacity: 0;
  transform: translate3d(0, .75em, 0);
  animation: header .8s calc(var(--title-delay) + 300ms) forwards;
}

/* Keyframes reused from the homepage (keep one copy only) */
@keyframes header {
  0%   { transform: translate3d(0, 1em, 0); opacity: 0; }
  100% { transform: translate3d(0, 0, 0);  opacity: 1; }
}
@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
/* 1) IDENTICAL ENTRANCE: apply to the left block (like #header on homepage) */
.si-intro__left{
  opacity: 0;
  transform: translate3d(0, 1em, 0);
}
.si-intro.is-visible .si-intro__left{
  animation: header 1s var(--title-delay, 2250ms) forwards;
}

/* 2) TITLE STYLE: only the gradient loop, same as homepage h1 */
.si-gradient-title{
  font-family: 'Montserrat', sans-serif;
  font-weight: 900;
  font-size: clamp(2.6rem, 6vw, 4.35rem);
  line-height: 1.15;
  white-space: nowrap;
  display: inline-block;

  background: linear-gradient(90deg, #7b22a0, #81389e, #8a5aaa);
  background-size: 300% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;

  /* No entrance animation here */
  animation: gradientShift 8s ease infinite;
}

/* Keep ONE copy of these keyframes in the file */
@keyframes header {
  0%   { transform: translate3d(0, 1em, 0); opacity: 0; }
  100% { transform: translate3d(0, 0, 0);  opacity: 1; }
}
@keyframes gradientShift {
  0%   { background-position:   0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position:   0% 50%; }
}

/* Motion safety */
@media (prefers-reduced-motion: reduce){
  .si-intro__left{ opacity: 1; transform: none; animation: none !important; }
  .si-gradient-title{ animation: none !important; }
}

/* === Center title + subtitle together === */
.si-intro__left {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;             /* Small spacing between title and subtitle */
  opacity: 0;
  transform: translate3d(0, 1em, 0);
}

.si-intro.is-visible .si-intro__left {
  animation: header 1s var(--title-delay, 2250ms) forwards;
}

/* Title style stays the same */
.si-gradient-title {
  font-family: 'Montserrat', sans-serif;
  font-weight: 900;
  font-size: clamp(2.6rem, 6vw, 4.35rem);
  line-height: 1.15;
  background: linear-gradient(90deg, #7b22a0, #81389e, #8a5aaa);
  background-size: 300% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gradientShift 8s ease infinite;
  display: inline-block;
}

/* Subtitle aligned under title */
.si-tagline {
text-align: center;
  font-size: clamp(1rem, 1.8vw, 1.25rem);
  color: #501b86;
  opacity: 0.85;
  margin-top: 0.4rem;
  max-width: 600px; /* Prevents it from stretching too wide */
}

/* Make the title + subtitle a shrink-to-content block */
.si-intro__left{
  display: inline-grid;
  grid-auto-flow: row;
  justify-items: center;   /* center children (title + subtitle) */
  align-items: start;
  width: max-content;      /* size to the widest child (the title) */
  max-width: 100%;         /* prevent overflow on small screens */
  justify-self: start;     /* keep the block left-aligned in the desktop grid */
}

/* Title as a block grid item (safer for centering math) */
.si-gradient-title{ display: block; }

/* Subtitle perfectly centered under the title */
.si-tagline{
  padding-left: 0;
  margin: 0.4rem 0 0;
  text-align: center;
  max-width: 60ch;         /* optional width cap */
}

/* === Equal gutters: [gutter] [title] [gutter] [video] [gutter] === */

/* Container centered on the page */
.si-intro__inner{
  width: min(1100px, 92vw);
  margin-inline: auto;

  display: grid;
  grid-template-columns: 1fr max-content 3.5fr max-content 1fr;
  align-items: center;
  column-gap: 0;                 /* gaps handled by the 1fr gutters */
}

/* Explicit placement so gutters remain empty tracks */
.si-intro__left  { grid-column: 2; }   /* title block */
.si-intro__right { grid-column: 4; }   /* video block */

/* Prevent items from stretching */
.si-intro__left, .si-intro__right { justify-self: center; }

/* Keep the subtitle centered under the title (from your previous fix) */
.si-intro__left{
  display: inline-grid;
  justify-items: center;
  width: max-content;
  max-width: 100%;
}
.si-gradient-title{ display:block; white-space: normal; }
.si-tagline{
  margin: .4rem 0 0;
  text-align: center;
  max-width: 60ch;
}

/* When there is no longer enough width, stack vertically */
@media (max-width: 860px){
  .si-intro__inner{
    grid-template-columns: 1fr;        /* single column */
    row-gap: 24px;                      /* vertical space between video and title */
  }
  .si-intro__right{ order: -1; justify-self: center; aspect-ratio: 16/9; width: min(92vw, 560px); }
  .si-intro__left { justify-self: center; text-align: center; }
}


.back-home-indicator {
    position: fixed;
    left: 30px;
    top: 50%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    cursor: pointer;
    outline: none;
    text-decoration: none;
    opacity: 0;
    pointer-events: none;
    transition: opacity .5s ease;
}

  /* Arrow stroke (LEFT) — same visual language as main */
  .back-home-arrow{
    width: 18px;
    height: 18px;
    border-top: 2px solid rgb(128, 36, 164);
    border-right: 2px solid rgb(128, 36, 164);
    transform: rotate(-135deg); /* points LEFT */
    opacity: .85;
    transition: transform .2s ease, opacity .2s ease, border-color .2s ease;
        text-decoration: none;
    outline: none;
  }

  .back-home-indicator:hover .back-home-arrow,
  .back-home-indicator:focus-visible .back-home-arrow{
    opacity: 1;
    border-color: #a25bd0;
    transform: rotate(-135deg) translateX(-1px);
        text-decoration: none;
    outline: none;
  }

  /* JS toggles this on <body> when intro is visible */
  body.back-arrow-on .back-home-indicator{
    opacity: 1;
    pointer-events: auto;
    transform: translateY(-50%) translateX(0);
  }

  @keyframes back-bounce{
    0%,100% { transform: rotate(-135deg) translateX(0); }
    50%     { transform: rotate(-135deg) translateX(-3px); }
  }

  @media (prefers-reduced-motion: reduce){
    .back-home-arrow{ animation: none; }
    .back-home-indicator{ transition: none; }
  }

  /* Optional: on small screens move near bottom-left */
  @media (max-width: 640px){
    .back-home-indicator{ top: auto; bottom: 20px; transform: translateY(0) translateX(-6px); }
    body.back-arrow-on .back-home-indicator{ transform: translateY(0) translateX(0); }
  }

  .back-home-indicator:link,
.back-home-indicator:visited,
.back-home-indicator:hover,
.back-home-indicator:focus {
    text-decoration: none !important;
}


/* Kill theme underline/border for the back arrow link */
.back-home-indicator,
.back-home-indicator:link,
.back-home-indicator:visited,
.back-home-indicator:hover,
.back-home-indicator:focus,
.back-home-indicator:active{
  text-decoration: none !important;
  border: 0 !important;
  border-bottom: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
}

/* In case the theme uses pseudo-elements for underlines */
.back-home-indicator::before,
.back-home-indicator::after{
  content: none !important;
  display: none !important;
  border: 0 !important;
  box-shadow: none !important;
}

/* Keyframes for progressive stroke color */
@keyframes arrowColorFill {
    0% {
        border-top-color: transparent;
        border-right-color: transparent;
    }
    50% {
        border-top-color: rgb(128, 36, 164);
        border-right-color: transparent;
    }
    100% {
        border-top-color: rgb(128, 36, 164);
        border-right-color: rgb(128, 36, 164);
    }
}

@media (max-width: 640px){
  article[data-repo="space_invaders"] .details-link{
    display: none !important;
  }
}
