/* ==========================================================================
   Quest Apps page — builds on styles.css
   ========================================================================== */
@font-face { font-family: "Press Start 2P"; font-style: normal; font-weight: 400; font-display: swap; src: url("assets/fonts/press-start-2p-latin.woff2") format("woff2"); }
@property --app-c { syntax: "<color>"; inherits: true; initial-value: #8b5cf6; }

.pixel { font-family: "Press Start 2P", ui-monospace, monospace; letter-spacing: .04em; text-transform: uppercase; }
.blink { animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }

.quest-page { --app-c: #8b5cf6; transition: --app-c 1s var(--ease); }
.qtint {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(55vw 55vw at 72% 55%, color-mix(in srgb, var(--app-c) 16%, transparent), transparent 65%),
    radial-gradient(40vw 40vw at 15% 10%, color-mix(in srgb, var(--app-c) 8%, transparent), transparent 70%);
}
.qscan { position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: .05; background: repeating-linear-gradient(to bottom, #fff 0 1px, transparent 1px 3px); mix-blend-mode: overlay; }

/* nav app icons */
.qnav-apps { display: flex; gap: 6px; padding: 6px; border: 1px solid var(--line); border-radius: 18px; background: rgba(10, 17, 40, .45); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.qnav-apps a { width: 38px; height: 38px; border-radius: 11px; overflow: hidden; outline: 2px solid transparent; outline-offset: 2px; transition: transform .35s var(--ease), outline-color .3s; }
.qnav-apps a img { width: 100%; height: 100%; object-fit: cover; }
.qnav-apps a:hover { transform: translateY(-3px) scale(1.08); }
.qnav-apps a.is-active { outline-color: var(--c); transform: translateY(-2px); }

/* ---------- hero ---------- */
.qhero { min-height: 100svh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding-top: 130px; gap: 26px; }
.qhero__start { font-size: clamp(10px, 1.1vw, 13px); color: #ffe27a; text-shadow: 0 0 18px rgba(255, 210, 90, .6); }
.qhero__title { font-size: clamp(46px, 9.5vw, 150px); letter-spacing: -0.04em; line-height: .95; }
.qhero__title .line { display: block; overflow: hidden; padding-bottom: .06em; }
.qhero__title .word { display: inline-block; }
.qhero__lead { max-width: 62ch; color: var(--ink-2); text-shadow: 0 2px 20px rgba(5,10,24,.9); font-size: clamp(16px, 1.4vw, 19px); }
.qhero__icons { display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(10px, 2vw, 22px); margin: 10px 0 14px; perspective: 800px; }
.qhero__icon { position: relative; display: grid; justify-items: center; gap: 10px; width: clamp(56px, 8vw, 96px); flex: none; }
.qhero__icon img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 24%; box-shadow: 0 18px 40px -12px var(--c), 0 0 0 1px rgba(255,255,255,.1); animation: bob 4s ease-in-out infinite; animation-delay: calc(var(--i) * -.6s); transition: scale .45s var(--ease), translate .45s var(--ease), box-shadow .3s; }
.qhero__icon span { font-size: 11px; color: var(--muted); white-space: nowrap; opacity: 0; transform: translateY(-4px); transition: opacity .3s, transform .3s; }
.qhero__icon:hover img, .qhero__icon:focus-visible img { scale: 1.1; translate: 0 -8px; box-shadow: 0 24px 50px -10px var(--c), 0 0 0 2px var(--c); }
.qhero__icon:hover span { opacity: 1; transform: none; color: #fff; }
@keyframes bob { 50% { transform: translateY(-8px); } }

/* ---------- shared DNA flip cards ---------- */
.qflips { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; max-width: 1300px; margin: 0 auto; perspective: 1200px; }
.qflip { all: unset; cursor: pointer; height: 230px; display: block; }
.qflip:focus-visible .qflip__face { outline: 2px solid var(--cyan); outline-offset: 3px; }
.qflip__inner { position: relative; display: block; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .8s var(--ease); }
.qflip:hover .qflip__inner, .qflip[aria-pressed="true"] .qflip__inner { transform: rotateY(180deg); }
.qflip__face {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; padding: 22px;
  border-radius: 20px; border: 1px solid var(--line); background: linear-gradient(160deg, rgba(255,255,255,.07), rgba(255,255,255,.015)), var(--glass);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.qflip__glyph { font-size: 42px; margin-bottom: auto; filter: drop-shadow(0 8px 18px rgba(139,92,246,.5)); }
.qflip__face b { font-family: var(--font-display); font-weight: 500; font-size: 17px; }
.qflip__face small { color: var(--muted); font-size: 13px; }
.qflip__back { transform: rotateY(180deg); justify-content: center; font-size: 15px; line-height: 1.5; color: var(--ink); background: linear-gradient(150deg, rgba(58,123,255,.35), rgba(224,75,255,.25)), var(--glass-2); }

/* ---------- app worlds ---------- */
.qapp { position: relative; min-height: 100svh; padding-top: clamp(100px, 14vh, 150px); overflow: hidden; }
.qapp__word {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: -1; pointer-events: none;
  font-family: var(--font-display); font-weight: 700; font-size: clamp(90px, 22vw, 360px); letter-spacing: -0.04em; white-space: nowrap;
  color: transparent; -webkit-text-stroke: 1px color-mix(in srgb, var(--c) 35%, transparent); opacity: .5;
}
.qapp__grid { display: grid; grid-template-columns: 1fr 1.05fr; gap: clamp(30px, 5vw, 80px); align-items: center; max-width: 1320px; margin: 0 auto; }
.qapp--flip .qapp__text { order: 2; }
.qapp__text {
  padding: clamp(26px, 3.5vw, 44px); border-radius: 28px; border: 1px solid color-mix(in srgb, var(--c) 28%, var(--line));
  background: linear-gradient(160deg, rgba(10,17,40,.78), rgba(10,17,40,.5)); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 40px 100px -50px var(--c);
}
.qapp__idx { font-size: 11px; color: var(--c); margin-bottom: 22px; }
.qapp__title { display: flex; align-items: center; gap: 18px; }
.qapp__title img { width: 72px; height: 72px; border-radius: 18px; box-shadow: 0 14px 34px -10px var(--c); }
.qapp__title h2 { font-size: clamp(30px, 3.8vw, 52px); }
.qapp__tagline { margin: 16px 0 14px; font-family: var(--font-display); font-size: clamp(16px, 1.5vw, 20px); background: linear-gradient(90deg, var(--c), var(--c2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.qapp__about { color: var(--ink-2); font-size: 16px; }
.qchips { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0; }
.qchips span { padding: 7px 13px; border-radius: 999px; font-size: 12.5px; border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); background: color-mix(in srgb, var(--c) 10%, transparent); }
.qstats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.qstat { padding: 14px 12px; border-radius: 14px; background: rgba(255,255,255,.035); border: 1px solid var(--line); }
.qstat b { display: block; font-family: "Press Start 2P", monospace; font-size: clamp(14px, 1.5vw, 19px); color: var(--c); text-shadow: 0 0 16px color-mix(in srgb, var(--c) 60%, transparent); }
.qstat span { display: block; margin-top: 8px; font-size: 12px; line-height: 1.35; color: var(--muted); }
.qfeatures { list-style: none; padding: 0; margin: 20px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 22px; }
.qfeatures li { display: grid; gap: 2px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 14px; }
.qfeatures b { font-family: var(--font-display); font-weight: 500; font-size: 13.5px; color: #fff; }
.qfeatures span { color: var(--muted); }

/* phone fan */
.qstage { position: relative; height: clamp(440px, 52vw, 600px); perspective: 1400px; }
.qfan { position: absolute; inset: 0; transform-style: preserve-3d; transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform .6s var(--ease); }
.qphone {
  all: unset; cursor: zoom-in; position: absolute; left: 50%; top: 50%; width: clamp(150px, 15vw, 220px); aspect-ratio: 9 / 19.4;
  padding: 7px; border-radius: 30px; background: linear-gradient(145deg, #3a3f55, #0e1019 45%, #262a3b);
  box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.16), 0 40px 80px -30px rgba(0,0,0,.9), 0 0 80px -30px var(--c);
  transform-style: preserve-3d; transition: transform 1.2s var(--ease), box-shadow .4s;
}
.qphone__scr { position: relative; display: block; width: 100%; height: 100%; border-radius: 24px; overflow: hidden; background: #000; }
.qphone__scr img { width: 100%; height: 100%; object-fit: cover; object-position: top; image-rendering: auto; }
.qphone__glare { position: absolute; inset: 0; background: linear-gradient(115deg, rgba(255,255,255,.22), transparent 35%, transparent 70%, rgba(255,255,255,.05)); pointer-events: none; }
.qphone:focus-visible { box-shadow: 0 0 0 3px var(--c); }
.qphone--l { transform: translate(-50%, -50%) translateX(-62%) translateZ(-90px) rotateY(26deg) rotateZ(-7deg); }
.qphone--c { transform: translate(-50%, -50%) translateZ(50px); z-index: 2; }
.qphone--r { transform: translate(-50%, -50%) translateX(62%) translateZ(-90px) rotateY(-26deg) rotateZ(7deg); }
.qphone--l:hover { transform: translate(-50%, -52%) translateX(-66%) translateZ(-40px) rotateY(16deg) rotateZ(-4deg); }
.qphone--r:hover { transform: translate(-50%, -52%) translateX(66%) translateZ(-40px) rotateY(-16deg) rotateZ(4deg); }
.qphone--c:hover { transform: translate(-50%, -52%) translateZ(80px); }
/* stacked "closed" state before the world enters view */
.qapp.is-armed .qphone { transform: translate(-50%, -50%) translateZ(-200px) rotateY(0) scale(.85); }
.qapp.is-armed .qmascot { opacity: 0; transform: translateZ(140px) translateY(60px) scale(.6); }

.qmascot {
  position: absolute; left: 4%; bottom: 2%; width: clamp(90px, 10vw, 150px); height: auto; z-index: 3;
  transform: translateZ(140px); filter: drop-shadow(0 18px 24px rgba(0,0,0,.6)) drop-shadow(0 0 22px color-mix(in srgb, var(--c) 50%, transparent));
  image-rendering: pixelated; animation: hop 3.2s ease-in-out infinite; transition: opacity .8s .5s, transform 1s .5s var(--ease);
}
.qapp--flip .qmascot { left: auto; right: 4%; }
.qmascot--bit { aspect-ratio: 1; background: url("assets/quest/pcb_sprites.png") 0 0 / 400% 400% no-repeat; animation: bitframes .9s steps(1) infinite, hop 3.2s ease-in-out infinite; }
@keyframes bitframes { 0% { background-position: 0 66.666%; } 25% { background-position: 33.333% 66.666%; } 50% { background-position: 66.666% 66.666%; } 75% { background-position: 100% 66.666%; } }
@keyframes hop { 0%, 100% { translate: 0 0; rotate: -3deg; } 50% { translate: 0 -22px; rotate: 3deg; } }

/* lower strip */
.qapp__lower { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; max-width: 1320px; margin: clamp(30px, 5vh, 60px) auto 0; }
.qapp__lower--nowide { grid-template-columns: 1fr; }
.qwide { margin: 0; position: relative; border-radius: 22px; overflow: hidden; border: 1px solid var(--line); cursor: zoom-in; }
.qwide img { width: 100%; height: 100%; max-height: 360px; object-fit: cover; transition: transform 1.2s var(--ease); }
.qwide:hover img { transform: scale(1.04); }
.qwide figcaption { position: absolute; left: 14px; bottom: 14px; padding: 6px 12px; border-radius: 999px; font-size: 12px; background: rgba(5,10,24,.75); backdrop-filter: blur(8px); }
.qgallery { padding: 20px; border-radius: 22px; border: 1px solid var(--line); background: rgba(10,17,40,.5); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.qgallery h4 { margin: 0 0 14px; font-size: 9px; color: var(--muted); font-weight: 400; }
.qthumbs { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.qthumb { all: unset; cursor: zoom-in; flex: none; width: 74px; aspect-ratio: 9 / 19.4; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); transition: transform .35s var(--ease), border-color .3s; }
.qthumb--land { width: 170px; aspect-ratio: 3 / 2; }
.qthumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.qthumb:hover, .qthumb:focus-visible { transform: translateY(-4px); border-color: var(--c); }

/* ---------- at a glance ---------- */
.qtable-wrap { max-width: 1200px; margin: 0 auto; overflow-x: auto; border-radius: 22px; border: 1px solid var(--line); background: rgba(10,17,40,.6); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.qtable { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 760px; }
.qtable th { text-align: left; padding: 16px; font-weight: 500; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); }
.qtable td { padding: 14px 16px; border-bottom: 1px solid var(--line); color: var(--ink-2); }
.qtable tr:last-child td { border-bottom: 0; }
.qtable tbody tr { transition: background .3s; }
.qtable tbody tr:hover { background: rgba(139,92,246,.1); }
.qtable a { display: flex; align-items: center; gap: 12px; color: #fff; font-weight: 600; white-space: nowrap; }
.qtable a img { border-radius: 9px; }
.qnote { text-align: center; color: var(--muted); font-size: 13px; margin-top: 18px; }
.qcta .pixel { font-size: 11px; }

/* ---------- lightbox ---------- */
.qlb { position: fixed; inset: 0; z-index: 99; display: grid; place-items: center; align-content: center; gap: 14px; padding: 30px 16px; background: rgba(3, 6, 15, .9); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.qlb[hidden] { display: none; }
.qlb__img { max-width: min(92vw, 1100px); max-height: 80svh; border-radius: 18px; box-shadow: 0 30px 80px rgba(0,0,0,.7); animation: lbIn .5s var(--ease); }
.qlb__cap { color: var(--ink-2); font-size: 14px; text-align: center; }
.qlb__close { position: absolute; top: 18px; right: 18px; width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255,255,255,.06); color: #fff; font-size: 26px; cursor: pointer; }
.qlb__close:focus-visible { outline: 2px solid var(--cyan); }
@keyframes lbIn { from { opacity: 0; transform: scale(.92) rotateX(10deg); } }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .qflips { grid-template-columns: repeat(3, 1fr); }
  .qnav-apps a { width: 32px; height: 32px; }
}
@media (max-width: 900px) {
  .qapp__grid { grid-template-columns: 1fr; }
  .qapp--flip .qapp__text { order: 0; }
  .qapp__lower { grid-template-columns: 1fr; }
  .qstats { grid-template-columns: repeat(2, 1fr); }
  .qstage { height: 500px; }
}
@media (max-width: 640px) {
  .qnav-apps { display: none; }
  .qflips { grid-template-columns: 1fr 1fr; }
  .qflip { height: 190px; }
  .qfeatures { grid-template-columns: 1fr; }
  .qphone { width: 44vw; }
  .qphone--l { transform: translate(-50%, -50%) translateX(-48%) translateZ(-90px) rotateY(24deg) rotateZ(-6deg); }
  .qphone--r { transform: translate(-50%, -50%) translateX(48%) translateZ(-90px) rotateY(-24deg) rotateZ(6deg); }
  .qstage { height: 440px; }
}
@media (prefers-reduced-motion: reduce) {
  .qapp.is-armed .qphone, .qapp.is-armed .qmascot { transform: none; opacity: 1; }
}
