/* ───────────────────────────────────────────────────────────────
   404foundry — style.css
   ─────────────────────────────────────────────────────────────── */

@font-face {
  font-family: 'Pliant';
  src: url('../assets/fonts/Pliant-Medium.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
  font-display: block;
}
@font-face {
  font-family: 'Pliant';
  src: url('../assets/fonts/Pliant-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: block;
}

:root {
  --cream:       #F0EBE0;
  --ink:         #0D0D0D;
  --rule:        rgba(13, 13, 13, 0.10);
  --font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --font-pliant: 'Pliant', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }

body {
  font-family: var(--font);
  background: var(--cream);
  color: var(--ink);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Video backgrounds ──────────────────────────────────────── */

.vid-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0;
  transition: opacity 0.65s ease;
  pointer-events: none;
}
.vid-bg video {
  display: block;
  width: 100%; height: 100%;
  object-fit: cover;
}

/* Reveal the matching video on gateway hover */
body:has(#gw-madeby:hover) #vid-madeby,
body:has(#gw-not404:hover) #vid-not404 {
  opacity: 1;
}

/* ── Stage (sits above videos) ──────────────────────────────── */

.stage {
  position: relative;
  z-index: 1;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Header / logo ──────────────────────────────────────────── */

.brand {
  flex-shrink: 0;
  padding: 28px 36px;
  background: var(--cream);
  transition: background 0.65s ease;
}

/* Cream strip fades when video plays so logo stays readable */
body:has(.gateway:hover) .brand {
  background: rgba(240, 235, 224, 0.0);
}

.brand a { display: inline-block; line-height: 0; }

.logo {
  height: 18px;
  width: auto;
  display: block;
  transition: filter 0.5s ease;
}

/* Keep logo visible over video */
body:has(.gateway:hover) .logo {
  filter: invert(1) brightness(2);
}

/* ── Gateway buttons ────────────────────────────────────────── */

.gateways {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  position: relative;
}

/* Vertical hairline between the two panels */
.gateways::after {
  content: '';
  position: absolute;
  inset-block: 0;
  left: 50%;
  width: 1px;
  background: var(--rule);
  transition: opacity 0.5s ease;
  pointer-events: none;
}
body:has(.gateway:hover) .gateways::after {
  opacity: 0;
}
.gateway {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.gw-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.gw-logo {
  display: block;
  height: clamp(26px, 3vw, 48px);
  width: auto;
  transition: filter 0.45s ease, opacity 0.45s ease;
}

.gw-sub {
  font-family: var(--font-pliant);
  font-weight: 500;
  font-size: clamp(10px, 0.9vw, 12px);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(13, 13, 13, 0.45);
  transition: color 0.45s ease, opacity 0.45s ease;
}

/* ── Hover states ───────────────────────────────────────────── */

/* Hovered side: logo inverts to white, subtitle brightens */
body:has(#gw-madeby:hover) #gw-madeby .gw-logo,
body:has(#gw-not404:hover) #gw-not404 .gw-logo {
  filter: invert(1);
  opacity: 1;
}
body:has(#gw-madeby:hover) #gw-madeby .gw-sub,
body:has(#gw-not404:hover) #gw-not404 .gw-sub {
  color: rgba(255, 255, 255, 0.65);
}

/* Non-hovered side: also inverts but dimmer */
body:has(#gw-madeby:hover) #gw-not404 .gw-logo,
body:has(#gw-not404:hover) #gw-madeby .gw-logo {
  filter: invert(1);
  opacity: 0.35;
}
body:has(#gw-madeby:hover) #gw-not404 .gw-sub,
body:has(#gw-not404:hover) #gw-madeby .gw-sub {
  color: rgba(255, 255, 255, 0.25);
}

/* ── Footer ─────────────────────────────────────────────────── */

footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 36px;
  background: var(--cream);
  border-top: 1px solid var(--rule);
  font-family: var(--font-pliant);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.05em;
  color: rgba(13, 13, 13, 0.40);
  transition: background 0.65s ease, border-color 0.65s ease, color 0.65s ease;
}

body:has(.gateway:hover) footer {
  background: rgba(240, 235, 224, 0.0);
  border-color: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.35);
}

.footer-info {
  text-align: center;
  line-height: 1.6;
}

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

footer a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}
footer a:hover { color: rgba(255, 255, 255, 0.8); }

.footer-legal {
  display: flex;
  gap: 20px;
}

/* ── Loader ─────────────────────────────────────────────────── */

#loader {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--ink);
  transform: translateY(0);
  will-change: transform;
  transition: transform 1.2s cubic-bezier(0.16, 1, 0.3, 1), background-color 1s ease-in;
}
#loader.exit {
  transform: translateY(-100%);
  background-color: transparent;
  pointer-events: none;
}

#loader-canvas {
  position: absolute;
  inset: 0;
  display: block;
}

#loader-enter {
  position: absolute;
  bottom: 6vh;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  background: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.30);
  color: rgba(255, 255, 255, 0.85);
  font-family: var(--font);
  font-size: 1rem;
  letter-spacing: 0.38em;
  text-transform: uppercase;
  padding: 22px 72px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease, background 0.22s ease, color 0.22s ease, border-color 0.22s ease;
  white-space: nowrap;
}
#loader-enter:hover {
  background: #ffffff;
  color: var(--ink);
  border-color: #ffffff;
}

/* ── Flip card — desktop passthrough ───────────────────────── */
/* On desktop the intermediate divs are invisible wrappers     */

.flipcard-inner,
.flipcard-front { display: contents; }
.flipcard-back  { display: none; }

@keyframes card-float {
  0%   { transform: translateY(0px)    rotate(-0.4deg); }
  35%  { transform: translateY(-10px)  rotate(0.3deg);  }
  65%  { transform: translateY(5px)    rotate(-0.65deg); }
  100% { transform: translateY(0px)    rotate(-0.4deg); }
}

/* ── Mobile ─────────────────────────────────────────────────── */

@media (max-width: 600px) {
  .brand  { padding: 20px 24px; }
  footer  { padding: 16px 24px; }

  .gateways {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
    padding: 20px;
    gap: 16px;
    align-items: stretch;
  }
  .gateways::after { display: none; }

  /* ── Flip card mechanics ───────────────────────────────────── */
  .flipcard {
    position: relative;
    perspective: 900px;
    animation: card-float 5s ease-in-out infinite;
  }
  #gw-not404 { animation-delay: -2.5s; }
  .flipcard.is-flipped { animation-play-state: paused; }

  .flipcard-inner {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
    -webkit-transform-style: preserve-3d;
    transform-style: preserve-3d;
    transition: transform 0.7s cubic-bezier(0.4, 0.2, 0.2, 1);
    will-change: transform;
  }
  .flipcard.is-flipped .flipcard-inner {
    -webkit-transform: rotateY(180deg);
    transform: rotateY(180deg);
  }

  .flipcard-front,
  .flipcard-back {
    display: flex;
    position: absolute;
    inset: 0;
    border-radius: 16px;
    overflow: hidden;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
  }

  .flipcard-front {
    background: var(--cream);
    align-items: center;
    justify-content: center;
    box-shadow: 0 12px 40px rgba(0,0,0,0.13), 0 2px 8px rgba(0,0,0,0.06);
  }

  .flipcard-back {
    background: var(--ink);
    -webkit-transform: rotateY(180deg);
    transform: rotateY(180deg);
    align-items: flex-end;
    justify-content: flex-end;
    padding: 20px;
  }

  .flipcard-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.9;
  }

  .flipcard-cta {
    position: relative;
    z-index: 1;
    color: rgba(255,255,255,0.92);
    font-family: var(--font-pliant);
    font-weight: 500;
    font-size: 11px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    text-decoration: none;
    background: rgba(0,0,0,0.48);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 13px 28px;
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 2px;
    white-space: nowrap;
  }

  /* keep logo dark on card front (no hover invert on mobile) */
  .flipcard-front .gw-logo  { filter: none !important; opacity: 1 !important; }
  .flipcard-front .gw-sub   { color: rgba(13,13,13,0.45) !important; }
}

/* ── Touch devices: prevent :hover states sticking after tap ─── */
/* Without this, tapping a flipcard on mobile leaves .gateway:hover  */
/* "stuck", turning the header logo white and the footer text pale.  */

@media (hover: none) {
  body:has(.gateway:hover) .brand            { background: var(--cream); }
  body:has(.gateway:hover) .logo             { filter: none; }
  body:has(.gateway:hover) .gateways::after  { opacity: 1; }
  body:has(.gateway:hover) footer {
    background:   var(--cream);
    border-color: var(--rule);
    color:        rgba(13, 13, 13, 0.40);
  }
  body:has(#gw-madeby:hover) #vid-madeby,
  body:has(#gw-not404:hover) #vid-not404     { opacity: 0; }
  body:has(#gw-madeby:hover) #gw-madeby .gw-logo,
  body:has(#gw-not404:hover) #gw-not404 .gw-logo,
  body:has(#gw-madeby:hover) #gw-not404 .gw-logo,
  body:has(#gw-not404:hover) #gw-madeby .gw-logo { filter: none; opacity: 1; }
  body:has(#gw-madeby:hover) #gw-madeby .gw-sub,
  body:has(#gw-not404:hover) #gw-not404 .gw-sub,
  body:has(#gw-madeby:hover) #gw-not404 .gw-sub,
  body:has(#gw-not404:hover) #gw-madeby .gw-sub  { color: rgba(13, 13, 13, 0.45); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}