/* ============================================================
   PJ portfolio — Act 2 (desktop) + Act 3 (agent) styles
   Palette keyed to the dusk film: deep indigo bg, warm amber ink
   ============================================================ */
:root {
  --bg: #0d0f1a;
  --bg-raise: #151827;
  --ink: #f2ead9;
  --ink-soft: #9a94a8;
  --amber: #ffb454;
  --line: rgba(242, 234, 217, 0.08);
  --font-display: "Instrument Serif", ui-serif, Georgia, serif;
  --font-body: ui-sans-serif, -apple-system, "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;
}
* { box-sizing: border-box; margin: 0; }
html { scroll-behavior: smooth; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); line-height: 1.6; }
a { color: inherit; }
.verify { font-size: 0.65em; color: #d4574e; letter-spacing: 0.02em; } /* fact-check flags, stripped before ship */

/* ---------- Act 1 placeholder (until flight clips land) ---------- */
.descent-placeholder { position: relative; height: 100svh; overflow: hidden; display: grid; place-items: center; }
.descent-placeholder__bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.85; }
.descent-placeholder__copy { position: relative; text-align: center; padding: 0 24px; text-shadow: 0 2px 24px rgba(0,0,0,0.7); }
.descent-line { font-family: var(--font-display); font-size: clamp(1.6rem, 4.5vw, 3rem); max-width: 18em; }
.descent-hint { margin-top: 2rem; font-family: var(--font-mono); font-size: 0.8rem; color: var(--ink-soft);
  animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(6px); } }
.corner-nav { position: absolute; top: 20px; right: 24px; display: flex; gap: 20px; font-family: var(--font-mono);
  font-size: 0.8rem; }
.corner-nav a { text-decoration: none; opacity: 0.75; } .corner-nav a:hover { opacity: 1; }

/* ---------- The desktop ---------- */
/* z-index above every fixed layer the flight engine injects (max 120), so the
   desktop slides up OVER the film's held final frame instead of a fade through
   an empty buffer screen. Opaque bg for the same reason. */
.desktop { position: relative; z-index: 200; background: var(--bg); }
.cortex, .footer { position: relative; z-index: 200; background: var(--bg); }
/* film → desktop handoff: the flight ends on a full-frame screen glow; the desktop
   resolves out of the same glow. Plays once when the desktop first scrolls into view. */
.desktop::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 100svh;
  background: radial-gradient(ellipse at 50% 42%, #ffd9a0 0%, #f2b96a 34%, rgba(13,15,26,0) 72%);
  opacity: 0; pointer-events: none; z-index: 30; }
.desktop.is-resolving::before { animation: focus-resolve 1.4s ease-out forwards; }
@keyframes focus-resolve {
  0% { opacity: 1; filter: blur(0px); }
  100% { opacity: 0; filter: blur(18px); }
}
.menubar { position: sticky; top: 0; z-index: 40; display: flex; gap: 22px; align-items: center;
  padding: 8px 18px; font-size: 0.78rem; font-family: var(--font-mono);
  background: rgba(13, 15, 26, 0.72); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.menubar__logo { color: var(--amber); }
.menubar__item a { text-decoration: none; }
.menubar__clock { margin-left: auto; color: var(--ink-soft); }

/* ---------- Chapters ---------- */
.chapter { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: clamp(24px, 5vw, 72px);
  align-items: center; min-height: 92svh; padding: 8svh clamp(20px, 6vw, 96px); }
.chapter--flip { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
.chapter--flip .chapter__window { order: 2; }
.chapter__date { font-family: var(--font-mono); font-size: 0.75rem; color: var(--ink-soft); }
.chapter__eyebrow { margin-top: 6px; font-family: var(--font-mono); font-size: 0.8rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--accent, var(--amber)); }
.chapter h2 { font-family: var(--font-display); font-size: clamp(2rem, 4.2vw, 3.4rem); line-height: 1.08; margin: 14px 0 18px; }
.chapter__body { color: var(--ink-soft); max-width: 46ch; }
.metrics { list-style: none; padding: 0; margin: 22px 0 0; display: flex; flex-wrap: wrap; gap: 26px; }
.metrics b { display: block; font-family: var(--font-display); font-size: 1.9rem; color: var(--ink); }
.metrics li { font-size: 0.8rem; color: var(--ink-soft); }

/* ---------- Windows ---------- */
.window { background: var(--bg-raise); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5); overflow: hidden;
  opacity: 0; transform: translateY(34px) scale(0.97); transition: opacity 0.7s ease, transform 0.7s cubic-bezier(.2,.7,.2,1); }
.window.is-visible { opacity: 1; transform: none; }
.window__titlebar { display: flex; align-items: center; gap: 7px; padding: 10px 14px; border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02); }
.tl { width: 11px; height: 11px; border-radius: 50%; background: #3a3f55; }
.window:hover .tl:nth-child(1) { background: #ff5f57; }
.window:hover .tl:nth-child(2) { background: #febc2e; }
.window:hover .tl:nth-child(3) { background: #28c840; }
.window__title { margin-left: 8px; font-family: var(--font-mono); font-size: 0.72rem; color: var(--ink-soft); }
.window__body { aspect-ratio: 16 / 10; position: relative; }
.media-slot { display: grid; place-items: center; height: 100%; color: var(--ink-soft);
  font-family: var(--font-mono); font-size: 0.8rem; background:
  repeating-linear-gradient(45deg, transparent 0 12px, rgba(255,255,255,0.015) 12px 24px); }
.media-video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- Launch replay terminal ---------- */
.window__body--terminal { background: #0a0c14; padding: 18px; font-family: var(--font-mono);
  font-size: clamp(0.68rem, 1.1vw, 0.85rem); color: #b9c5a9; overflow: hidden; }
.replay-line { opacity: 0; transform: translateY(4px); transition: opacity 0.3s, transform 0.3s; white-space: pre-wrap; }
.replay-line.on { opacity: 1; transform: none; }
.replay-line .t { color: #5b647e; }
.replay-line.crash { color: #ff5c57; }
.replay-line.big { color: var(--ink); font-weight: 700; }
.window--glitch { animation: glitch 0.45s steps(2) 2; }
@keyframes glitch {
  20% { transform: translate(-3px, 2px) skewX(-2deg); filter: hue-rotate(-30deg); }
  40% { transform: translate(4px, -2px); clip-path: inset(8% 0 12% 0); }
  60% { transform: translate(-2px, 1px) skewX(3deg); filter: saturate(3); }
  80% { transform: translate(1px, -1px); clip-path: inset(40% 0 5% 0); }
}

/* ---------- Stamps ---------- */
.stamp { display: inline-block; margin: 20px 14px 0 0; padding: 8px 16px; border: 3px double currentColor;
  border-radius: 6px; color: var(--amber); font-family: var(--font-mono); font-weight: 700; letter-spacing: 0.1em;
  font-size: 0.82rem; transform: rotate(-4deg) scale(2.4); opacity: 0;
  transition: transform 0.34s cubic-bezier(.34,1.4,.64,1), opacity 0.2s; }
.stamp small { display: block; font-weight: 400; letter-spacing: 0.02em; font-size: 0.68em; opacity: 0.85; }
.stamp.is-stamped { transform: rotate(-4deg) scale(1); opacity: 0.92; }
.stamp--red { color: #e0574e; transform: rotate(3deg) scale(2.4); }
.stamp--red.is-stamped { transform: rotate(3deg) scale(1); }
.stamp--blue { color: #6ea8ff; }

/* ---------- Stamp wall ---------- */
.stampwall { padding: 6svh clamp(20px, 6vw, 96px) 2svh; }
.stampwall__row { display: flex; flex-wrap: wrap; gap: 6px 10px; max-width: 900px; }
.stampwall .stamp { font-size: 0.72rem; margin: 10px 8px 0 0; }

/* ---------- Folder grid ---------- */
.folder { padding: 10svh clamp(20px, 6vw, 96px) 14svh; }
.folder__title { font-family: var(--font-mono); font-size: 1rem; color: var(--ink-soft); margin-bottom: 28px; }
.folder__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px; }
.folder-item { background: none; border: 1px solid transparent; border-radius: 10px; padding: 18px 10px;
  text-align: center; color: var(--ink); cursor: pointer; font-family: var(--font-body); }
.folder-item:hover, .folder-item:focus-visible { border-color: var(--line); background: rgba(255,255,255,0.03); }
.folder-item__icon { font-size: 2rem; display: block; margin-bottom: 8px; }
.folder-item__name { font-family: var(--font-mono); font-size: 0.78rem; }
.folder-item__desc { font-size: 0.7rem; color: var(--ink-soft); margin-top: 4px; }

/* case card modal */
.case-card { border: none; border-radius: 14px; background: var(--bg-raise); color: var(--ink);
  max-width: min(680px, 92vw); padding: 0; }
.case-card::backdrop { background: rgba(5, 6, 12, 0.72); backdrop-filter: blur(6px); }
.case-card__inner { padding: 28px 30px; }
.case-card h4 { font-family: var(--font-display); font-size: 1.7rem; margin-bottom: 8px; }
.case-card p { color: var(--ink-soft); font-size: 0.95rem; }
.case-card .tags { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.case-card .tags span { font-family: var(--font-mono); font-size: 0.68rem; padding: 3px 10px;
  border: 1px solid var(--line); border-radius: 99px; color: var(--ink-soft); }
.case-card .close { position: absolute; top: 12px; right: 14px; background: none; border: none;
  color: var(--ink-soft); font-size: 1.1rem; cursor: pointer; }

/* ---------- Cortex graph (ported from the Mitosis homepage proof graph) ---------- */
.cortex { display: grid; place-items: center; gap: 22px; padding: 12svh clamp(16px, 5vw, 60px); }
.window--cortex { width: min(860px, 100%); }
.window__body--cortex { aspect-ratio: 840 / 640; background: #0a0c14; }
.cortex__caption { max-width: 56ch; text-align: center; color: var(--ink-soft); font-size: 0.9rem; }
.cortex__caption a { color: var(--amber); }
.hv-pg { position: relative; width: 100%; height: 100%; overflow: hidden; }
.hv-pg__svg { width: 100%; height: 100%; display: block; }
.hv-pg__edge { stroke: #3a3f55; stroke-width: 1; opacity: 0.38; transition: opacity 0.4s ease, stroke 0.3s ease; }
.hv-pg.has-focus .hv-pg__edge { opacity: 0.1; }
.hv-pg.has-focus .hv-pg__edge.is-lit { stroke: var(--amber); opacity: 0.7; }
.hv-pg__node { opacity: 0.92; transition: opacity 0.4s ease; }
.hv-pg.has-focus .hv-pg__node { opacity: 0.14; }
.hv-pg.has-focus .hv-pg__node.is-lit { opacity: 0.92; }
.hv-pg.has-focus .hv-pg__node.is-focus { opacity: 1; stroke: var(--amber); stroke-width: 2; }
.hv-pg__hit { fill: transparent; pointer-events: all; }
.hv-pg__tooltip { position: absolute; transform: translate(-50%, calc(-100% - 10px)); z-index: 2;
  background: rgba(13, 15, 26, 0.92); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; pointer-events: none; backdrop-filter: blur(8px); }
.hv-pg__tooltip-label { display: flex; gap: 4px; margin-bottom: 7px; }
.hv-pg__tooltip-label span { height: 8px; border-radius: 4px; background: rgba(242, 234, 217, 0.22); }
.hv-pg__tooltip-label span:nth-child(1) { width: 34px; }
.hv-pg__tooltip-label span:nth-child(2) { width: 18px; }
.hv-pg__tooltip-label span:nth-child(3) { width: 26px; }
.hv-pg__tooltip-label span:nth-child(4) { width: 12px; }
.hv-pg__tooltip-label span:nth-child(5) { width: 22px; }
.hv-pg__tooltip-msg { display: flex; gap: 6px; align-items: center; white-space: nowrap;
  font-family: var(--font-mono); font-size: 0.68rem; color: var(--ink-soft); }
.hv-pg__tooltip-msg svg { color: var(--amber); flex: none; }

/* ---------- Footer ---------- */
.footer { text-align: center; padding: 10svh 20px 14svh; border-top: 1px solid var(--line); }
.footer h3 { font-family: var(--font-display); font-size: clamp(1.8rem, 4vw, 2.6rem); margin-bottom: 18px; }
.footer__links { display: flex; gap: 26px; justify-content: center; font-family: var(--font-mono); font-size: 0.85rem; }
.footer__fine { margin-top: 40px; font-size: 0.72rem; color: var(--ink-soft); }

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  .chapter, .chapter--flip { grid-template-columns: 1fr; min-height: auto; padding: 9svh 20px; }
  .chapter--flip .chapter__window { order: 0; }
  .chapter__window { margin-bottom: 26px; }
  .metrics { gap: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .window { opacity: 1; transform: none; transition: none; }
  .stamp { transition: none; }
  .descent-hint { animation: none; }
  html { scroll-behavior: auto; }
}
