/* ============================================================
   hugonarciso.net — shared chrome for hosted games
   Injected into every /projects/<slug>/index.html by
   scripts/sync-games.mjs (between hn:vt markers). Provides:
   1. the cross-document view-transition opt-in,
   2. the persistent site topbar (pairs with the portfolio nav),
   3. the "card unfolds into the game" choreography.
   Everything is px-based so per-game root font sizes can't skew
   the topbar geometry (it must match the portfolio nav 1:1).
   ============================================================ */

@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }

  /* the whole game viewport is the stage the project card morphs into */
  body {
    view-transition-name: stage;
  }
}

/* — fonts: same Geist as the portfolio, so the topbar crossfade is invisible — */
@font-face {
  font-family: "Geist VT";
  src: url("/projects/_shared/fonts/geist-var.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono VT";
  src: url("/projects/_shared/fonts/geist-mono-var.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Fraunces VT";
  src: url("/projects/_shared/fonts/fraunces-var.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

/* — the topbar: geometry-matched to the portfolio nav (ink/scrolled state) — */
#hn-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  padding: 14.4px clamp(20px, 5vw, 88px);
  box-sizing: border-box;
  background: color-mix(in srgb, #17150f 86%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  backdrop-filter: blur(14px) saturate(120%);
  box-shadow: 0 1px 0 rgba(240, 233, 216, 0.1);
  color: #f0e9d8;
  font-family: "Geist VT", system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  view-transition-name: topbar;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
#hn-topbar * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
#hn-topbar a {
  color: inherit;
  text-decoration: none;
}

/* tucked away while playing; a 5px ink lip stays as the handle */
#hn-topbar.hn-hidden {
  transform: translateY(calc(-100% + 5px));
}
#hn-topbar.hn-hidden:hover,
#hn-topbar:focus-within {
  transform: none;
}
/* generous invisible hit area under the lip so touch can summon it */
#hn-topbar.hn-hidden::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 16px;
}

.hn-brand {
  display: inline-flex;
  align-items: center;
  gap: 12.8px;
  min-width: 0;
}
.hn-mark {
  width: 30px;
  height: 30px;
  flex: none;
  background: #f0e9d8;
  -webkit-mask: url("/projects/_shared/hn-mark.svg") center / contain no-repeat;
  mask: url("/projects/_shared/hn-mark.svg") center / contain no-repeat;
}
.hn-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  font-size: 12.8px;
  font-weight: 550;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.hn-brand-text em {
  font-family: "Geist Mono VT", ui-monospace, "SF Mono", monospace;
  font-style: normal;
  font-size: 9.3px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(240, 233, 216, 0.6);
}

/* the project name — the card heading flies into this spot (hn-title) */
.hn-title {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: 38vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: "Fraunces VT", "Iowan Old Style", Georgia, serif;
  font-size: 15px;
  font-weight: 460;
  letter-spacing: -0.01em;
  line-height: 1.1;
  font-variation-settings: "SOFT" 0, "WONK" 1;
  color: #f0e9d8;
  pointer-events: none;
  view-transition-name: hn-title;
}

.hn-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: "Geist Mono VT", ui-monospace, "SF Mono", monospace;
  font-size: 11.2px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
}
.hn-back svg {
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.hn-back:hover svg {
  transform: translateX(-3px);
}

@media (max-width: 640px) {
  .hn-title {
    display: none;
  }
}
@media (max-width: 480px) {
  .hn-brand-text em {
    display: none;
  }
}

/* ============================================================
   Arriving here from the portfolio: the clicked card unfolds
   into the full game while the page recedes underneath.
   (These pseudos only exist on the destination document.)
   ============================================================ */

::view-transition-group(topbar) {
  z-index: 100;
  animation-duration: 0.45s;
}
::view-transition-old(topbar),
::view-transition-new(topbar) {
  height: 100%;
}

::view-transition-group(hn-title) {
  z-index: 120;
  animation-duration: 0.65s;
  animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
}
::view-transition-old(hn-title),
::view-transition-new(hn-title) {
  height: 100%;
  width: auto;
  object-fit: contain;
}

::view-transition-group(stage) {
  z-index: 10;
  animation-duration: 0.65s;
  animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
}
::view-transition-image-pair(stage) {
  overflow: clip;
  animation: hn-vt-unround 0.65s cubic-bezier(0.22, 1, 0.36, 1) both;
}
::view-transition-old(stage),
::view-transition-new(stage) {
  height: 100%;
  width: 100%;
  object-fit: cover;
}
@keyframes hn-vt-unround {
  from {
    border-radius: 10px;
  }
  to {
    border-radius: 0;
  }
}

::view-transition-old(root) {
  animation: hn-vt-home-out 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
}
::view-transition-new(root) {
  animation: hn-vt-game-in 0.6s cubic-bezier(0.4, 0, 0.2, 1) both;
}
@keyframes hn-vt-home-out {
  to {
    opacity: 0;
    transform: scale(0.985);
  }
}
@keyframes hn-vt-game-in {
  from {
    opacity: 0;
  }
}
