@font-face {
  font-family: "Qualia Sans";
  src: url("./fonts/qualia-sans-regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

/* Same-origin MPA morph into /live/ (Safari 18.2+, Chrome, etc.) */
@view-transition {
  navigation: auto;
}

::view-transition-old(qualia-orb),
::view-transition-new(qualia-orb) {
  animation-duration: 0.75s;
  animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
  mix-blend-mode: normal;
  height: 100%;
  overflow: clip;
}

:root {
  --qualia-black: #121212;
  --qualia-white: #f7f7f7;
  --qualia-purple: #7000ff;
  --q-font: "Qualia Sans", "Inter Variable", Inter, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mark-w: clamp(132px, 12.75vw, 220px);
  --mark-h: calc(var(--mark-w) * 171 / 128);
  --face-size: calc(var(--mark-w) * 1.7355);
  /* Approximate on-screen size of the live WebGPU orb */
  --orb-visual: min(28vh, 42vw);
  --portal-duration: 520ms;
  --portal-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --q-press-scale: 0.97;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
}

body {
  background: var(--qualia-black);
  color: var(--qualia-white);
  overflow: hidden;
  font-family: var(--q-font);
  transition: opacity 320ms var(--portal-ease);
}

body.is-leaving {
  opacity: 0;
}

.landing {
  --stage-pad: 2rem;
  /* Mild raise on desktop; phone tuned from Sef iPhone 13 annotated screenshot */
  --portal-shift: -0.5vh;
  width: 100%;
  min-height: 100svh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding-top: calc(var(--stage-pad) + env(safe-area-inset-top, 0px));
  padding-right: var(--stage-pad);
  padding-bottom: calc(var(--stage-pad) + env(safe-area-inset-bottom, 0px));
  padding-left: var(--stage-pad);
}

@media (max-width: 480px) {
  .landing {
    /*
      From iPhone 13 Safari annotation (red = current, green = desired):
      midpoints shift down ≈ 3.6vh (~30 CSS px). Prior phone shift was -5vh,
      so target ≈ -1.4vh — slightly above full-screen center to sit in the
      content aperture above the Safari toolbar.
    */
    --portal-shift: -1.0vh;
  }
}

.portal {
  display: grid;
  place-items: center;
  width: calc(var(--face-size) + 4rem);
  height: calc(var(--face-size) + 4rem);
  padding: 2rem;
  text-decoration: none;
  color: var(--qualia-white);
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  background: transparent;
  border: 0;
  translate: 0 var(--portal-shift);
}

.portal.is-busy {
  pointer-events: none;
  cursor: default;
}

.portal__face {
  position: relative;
  width: var(--face-size);
  height: var(--face-size);
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  overflow: hidden;
  transform-origin: center;
  box-shadow: none;
  transition:
    width var(--portal-duration) var(--portal-ease),
    height var(--portal-duration) var(--portal-ease),
    border-radius var(--portal-duration) var(--portal-ease),
    color var(--portal-duration) var(--portal-ease),
    background var(--portal-duration) var(--portal-ease),
    transform 180ms var(--portal-ease),
    box-shadow var(--portal-duration) var(--portal-ease);
}

.portal__logo,
.portal__label {
  position: absolute;
  inset: 0;
  margin: auto;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.portal__logo {
  width: var(--mark-w);
  height: auto;
  max-width: none;
  max-height: none;
  display: block;
  object-fit: contain;
  transform-origin: center;
  transition:
    opacity calc(var(--portal-duration) * 0.55) var(--portal-ease),
    transform var(--portal-duration) var(--portal-ease),
    filter calc(var(--portal-duration) * 0.55) var(--portal-ease);
}

.portal__label {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  opacity: 0;
  transform: scale(0.84);
  font-family: var(--q-font);
  font-size: 20pt;
  font-weight: 400;
  letter-spacing: 0.12em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
  color: inherit;
  transition:
    opacity calc(var(--portal-duration) * 0.45) calc(var(--portal-duration) * 0.2)
      var(--portal-ease),
    transform var(--portal-duration) var(--portal-ease);
}

/* Shared pill look: desktop hover preview + JS-driven Safari/touch path */
.portal.is-pill .portal__face,
.portal:focus-visible .portal__face {
  width: 10.5rem;
  height: 3.35rem;
  border-radius: 999px;
  color: var(--qualia-purple);
  background: transparent;
  box-shadow:
    0 0 0 2pt var(--qualia-purple),
    0 0 28px color-mix(in srgb, var(--qualia-purple) 32%, transparent);
}

.portal.is-pill .portal__logo,
.portal:focus-visible .portal__logo {
  opacity: 0;
  transform: scale(0.62);
  filter: blur(4px);
}

.portal.is-pill .portal__label,
.portal:focus-visible .portal__label {
  opacity: 1;
  transform: scale(1);
}

@media (hover: hover) and (pointer: fine) {
  .portal:hover:not(.is-busy) .portal__face {
    width: 10.5rem;
    height: 3.35rem;
    border-radius: 999px;
    color: var(--qualia-purple);
    box-shadow:
      0 0 0 2pt var(--qualia-purple),
      0 0 28px color-mix(in srgb, var(--qualia-purple) 32%, transparent);
  }

  .portal:hover:not(.is-busy) .portal__logo {
    opacity: 0;
    transform: scale(0.62);
    filter: blur(4px);
  }

  .portal:hover:not(.is-busy) .portal__label {
    opacity: 1;
    transform: scale(1);
  }
}

/* Pill → glowing orb bridge (hands off to /live/ via view-transition-name) */
.portal.is-orb .portal__face {
  view-transition-name: qualia-orb;
  width: var(--orb-visual);
  height: var(--orb-visual);
  border-radius: 50%;
  color: transparent;
  background:
    radial-gradient(
      circle at 32% 28%,
      #d4b8ff 0%,
      #7000ff 42%,
      #3b007a 78%,
      #120018 100%
    );
  box-shadow:
    0 0 36px color-mix(in srgb, var(--qualia-purple) 55%, transparent),
    0 0 72px color-mix(in srgb, var(--qualia-purple) 28%, transparent);
}

.portal.is-orb .portal__logo,
.portal.is-orb .portal__label {
  opacity: 0;
  transform: scale(0.5);
  filter: blur(6px);
}

.portal:active:not(.is-busy) .portal__face {
  transform: scale(var(--q-press-scale));
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --portal-duration: 0.01ms;
    --q-press-scale: 1;
  }

  body {
    transition: none;
  }
}
