/* ==========================================================================
   FX layer: the interactive, game-like layer over the Cyberpunk Combined site.
   Splash screen, achievements and XP, reactive background grid, scroll
   reveals, scroll meter and a hidden debug view.
   Everything here is progressive: without JavaScript the site is unchanged,
   and reduced-motion visitors get the same features without the movement.
   ========================================================================== */

/* ---------- Reactive background grid (canvas behind everything) ---------- */
.fx-bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }

/* ---------- Scroll meter: a thin XP-style bar across the top ---------- */
.fx-meter { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 60; pointer-events: none; background: rgba(38, 48, 74, 0.6); }
.fx-meter__fill { height: 100%; width: 100%; transform-origin: 0 50%; transform: scaleX(0); background: linear-gradient(90deg, var(--cyan), var(--pink)); box-shadow: 0 0 10px rgba(53, 224, 240, 0.7); }

/* ---------- Scroll reveals ("scan-in") ---------- */
html.fx .fx-reveal { transition: opacity 0.7s cubic-bezier(0.2, 0.7, 0.2, 1), transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1), clip-path 0.8s cubic-bezier(0.2, 0.7, 0.2, 1); transition-delay: var(--fx-d, 0ms); }
html.fx .fx-reveal:not(.is-in) { opacity: 0; transform: translateY(28px); }
/* Timeline bars charge up like an XP bar when their row comes in */
html.fx .timeline__item.fx-reveal .timeline__bar { transform-origin: 0 50%; transition: transform 1.1s cubic-bezier(0.2, 0.7, 0.2, 1) calc(var(--fx-d, 0ms) + 250ms); }
html.fx .timeline__item.fx-reveal:not(.is-in) .timeline__bar { transform: scaleX(0); }

/* ---------- Achievements: HUD button, toasts and panel ---------- */
.fx-hud { position: fixed; right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); z-index: 70;
  display: flex; align-items: center; gap: 0.55rem; padding: 0.35rem 0.75rem 0.35rem 0.35rem;
  font: 600 0.72rem/1.1 var(--font-display); letter-spacing: 0.06em; color: var(--text-hi); background: rgba(18, 24, 41, 0.9);
  border: 1px solid var(--grid); cursor: pointer; backdrop-filter: blur(6px); opacity: 0.85; transition: opacity 0.2s, border-color 0.2s;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px)); }
.fx-hud:hover, .fx-hud:focus-visible { opacity: 1; border-color: var(--cyan); }
.fx-hud__lv { display: grid; place-items: center; width: 2.1rem; height: 2.1rem; font-size: 0.95rem; font-weight: 800; color: var(--void); background: var(--cyan); clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); }
.fx-hud__text { display: grid; gap: 0.3rem; min-width: 5.5rem; }
.fx-hud__xp { font-size: 0.7rem; color: var(--muted); }
.fx-hud__bar { height: 4px; background: var(--grid); overflow: hidden; }
.fx-hud__bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--pink)); transition: width 0.8s cubic-bezier(0.2, 0.7, 0.2, 1); }
.fx-hud.is-pinged { animation: fx-ping 0.9s; }
@keyframes fx-ping { 30% { box-shadow: 0 0 0 3px rgba(255, 79, 123, 0.6), 0 0 24px rgba(255, 79, 123, 0.6); } }

.fx-toasts { position: fixed; right: max(12px, env(safe-area-inset-right)); top: calc(env(safe-area-inset-top, 0px) + 84px); z-index: 80; display: grid; gap: 0.6rem; width: min(22rem, calc(100vw - 24px)); pointer-events: none; }
.fx-toast { display: grid; grid-template-columns: auto 1fr; gap: 0.15rem 0.8rem; align-items: center; padding: 0.8rem 1rem; color: var(--text-hi);
  background: linear-gradient(90deg, rgba(53, 224, 240, 0.14), rgba(18, 24, 41, 0.96) 40%); border: 1px solid var(--cyan); box-shadow: 0 0 22px rgba(53, 224, 240, 0.25);
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px)); animation: fx-toast-in 0.5s cubic-bezier(0.2, 0.9, 0.2, 1.2) both; }
.fx-toast.is-out { animation: fx-toast-out 0.4s ease-in both; }
.fx-toast__icon { grid-row: span 2; display: grid; place-items: center; width: 2.6rem; height: 2.6rem; color: var(--void); background: var(--pink); font: 700 1.1rem var(--font-display); clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); }
.fx-toast__kicker { font: 600 0.7rem var(--font-display); letter-spacing: 0.12em; text-transform: uppercase; color: var(--cyan); }
.fx-toast__name { font: 700 1rem var(--font-display); }
.fx-toast__xp { grid-column: 2; font-size: 0.8rem; color: var(--muted); }
@keyframes fx-toast-in { from { transform: translateX(110%); opacity: 0; } }
@keyframes fx-toast-out { to { transform: translateX(110%); opacity: 0; } }

.fx-panel { width: min(40rem, calc(100vw - 32px)); max-height: min(80vh, 44rem); padding: 0; color: var(--text-hi); background: var(--brackets), var(--glass); border: 1px solid var(--grid); }
.fx-panel::backdrop { background: rgba(5, 8, 15, 0.75); backdrop-filter: blur(3px); }
.fx-panel__inner { padding: 1.75rem; display: grid; gap: 1.25rem; }
.fx-panel__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem 1rem; }
.fx-panel__head h2 { font-size: var(--step-2); }
.fx-panel__stats { font: 600 0.85rem var(--font-display); color: var(--muted); }
.fx-panel__list { display: grid; gap: 0.6rem; margin: 0; padding: 0; list-style: none; }
.fx-panel__item { display: grid; grid-template-columns: auto 1fr auto; gap: 0.1rem 0.9rem; align-items: center; padding: 0.7rem 0.9rem; background: var(--void); border: 1px solid var(--grid); }
.fx-panel__item.is-unlocked { border-color: rgba(53, 224, 240, 0.55); }
.fx-panel__badge { grid-row: span 2; width: 2.2rem; height: 2.2rem; display: grid; place-items: center; font: 700 0.95rem var(--font-display); color: var(--muted); background: var(--grid); clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); }
.fx-panel__item.is-unlocked .fx-panel__badge { color: var(--void); background: var(--cyan); }
.fx-panel__name { font: 700 0.95rem var(--font-display); }
.fx-panel__item:not(.is-unlocked) .fx-panel__name { color: var(--muted); }
.fx-panel__desc { grid-column: 2; font-size: 0.85rem; color: var(--muted); }
.fx-panel__xp { grid-row: 1 / span 2; grid-column: 3; font: 600 0.8rem var(--font-display); color: var(--pink); }
.fx-panel__foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.75rem; align-items: center; font-size: 0.85rem; color: var(--muted); }
.fx-panel__btn { font: 600 0.85rem var(--font-display); letter-spacing: 0.04em; color: var(--cyan); background: transparent; border: 1px solid var(--cyan); padding: 0.45rem 0.9rem; cursor: pointer; }
.fx-panel__btn:hover, .fx-panel__btn:focus-visible { background: var(--cyan); color: var(--void); }
.fx-panel__btn--quiet { color: var(--muted); border-color: var(--grid); }
.fx-panel__btn--quiet:hover, .fx-panel__btn--quiet:focus-visible { background: var(--grid); color: var(--text-hi); }

/* ---------- Splash: a start screen on the home page ---------- */
html.fx-splash-open { overflow: hidden; }
.fx-splash { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; background: #05080f; color: var(--text-hi); overflow: hidden; }
.fx-splash__bg { position: absolute; inset: 0; width: 100%; height: 100%; }
.fx-splash__scan { position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 3px); }
.fx-splash__vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, 0.75)); }
.fx-splash__inner { position: relative; display: grid; justify-items: center; gap: 1.1rem; padding: 2rem 1.25rem; text-align: center; }
.fx-splash__logo { width: min(11rem, 40vw); height: auto; overflow: visible; }
.fx-splash__logo path, .fx-splash__logo circle { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.fx-splash__name { margin: 0; font: 800 clamp(2.4rem, 1.4rem + 5vw, 5rem)/1 var(--font-display); letter-spacing: 0.04em; text-shadow: 0 0 24px rgba(53, 224, 240, 0.35); }
.fx-splash__name span { color: var(--cyan); }
.fx-splash__role { margin: 0; font: 600 var(--step-1) var(--font-display); color: var(--pink); letter-spacing: 0.18em; text-transform: uppercase; }
.fx-splash__log { margin: 0.25rem 0 0; padding: 0; list-style: none; min-height: 6.2em; font: 500 0.85rem/1.55 "IBM Plex Mono", ui-monospace, monospace; color: var(--muted); text-align: left; }
.fx-splash__log li { white-space: pre; }
.fx-splash__log li b { color: var(--cyan); font-weight: 600; }
.fx-splash__start { margin-top: 0.5rem; padding: 0.95rem 2.2rem; font: 800 1.15rem var(--font-display); letter-spacing: 0.22em; text-transform: uppercase; color: var(--void); background: var(--cyan); border: 0; cursor: pointer;
  clip-path: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px); box-shadow: 0 0 30px rgba(53, 224, 240, 0.5); }
.fx-splash__start:hover, .fx-splash__start:focus-visible { background: var(--pink); outline: none; }
.fx-splash__hint { margin: 0; font: 500 0.8rem var(--font-display); letter-spacing: 0.12em; color: var(--muted); text-transform: uppercase; }
.fx-splash__skip { position: absolute; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); font: 600 0.85rem var(--font-display); letter-spacing: 0.08em; color: var(--muted); background: transparent; border: 1px solid var(--grid); padding: 0.5rem 1rem; cursor: pointer; }
.fx-splash__skip:hover, .fx-splash__skip:focus-visible { color: var(--text-hi); border-color: var(--cyan); }
@media (prefers-reduced-motion: no-preference) {
  .fx-splash__logo .draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: fx-draw 0.9s cubic-bezier(0.6, 0, 0.2, 1) forwards; animation-delay: var(--d); }
  @keyframes fx-draw { to { stroke-dashoffset: 0; } }
  .fx-splash__start { animation: fx-blink 1.4s steps(1) infinite 3.2s; }
  @keyframes fx-blink { 50% { box-shadow: 0 0 6px rgba(53, 224, 240, 0.2); filter: brightness(0.8); } }
  .fx-splash.is-leaving .fx-splash__inner { animation: fx-zoom 0.75s cubic-bezier(0.7, 0, 0.9, 0.4) forwards; }
  @keyframes fx-zoom { to { transform: scale(2.6); opacity: 0; filter: blur(6px); } }
  .fx-splash.is-leaving { animation: fx-crt 0.9s cubic-bezier(0.7, 0, 0.3, 1) forwards 0.35s; }
  @keyframes fx-crt { 60% { clip-path: inset(49.5% 0 49.5% 0); opacity: 1; } 100% { clip-path: inset(50% 50% 50% 50%); opacity: 0; } }
  .fx-splash__name { animation: fx-glitch 4s steps(1) infinite 3s; }
  @keyframes fx-glitch { 0%, 92%, 100% { transform: none; text-shadow: 0 0 24px rgba(53, 224, 240, 0.35); } 93% { transform: translateX(-3px); text-shadow: 3px 0 var(--pink), -3px 0 var(--cyan); } 95% { transform: translateX(2px); text-shadow: -2px 0 var(--pink), 2px 0 var(--cyan); } }
}
@media (prefers-reduced-motion: reduce) { .fx-splash.is-leaving { opacity: 0; transition: opacity 0.2s; } }

/* ---------- Debug view (secret) ---------- */
html.fx-debug main * { outline: 1px dashed rgba(53, 224, 240, 0.28); outline-offset: -1px; }
html.fx-debug [data-fx-label] { position: relative; outline: 1px solid rgba(255, 79, 123, 0.75) !important; }
html.fx-debug [data-fx-label]::before { content: attr(data-fx-label); position: absolute; left: 0; top: 0; z-index: 5; transform: translateY(-100%); padding: 0.1rem 0.4rem; font: 600 0.65rem/1.3 "IBM Plex Mono", monospace; color: var(--void); background: var(--pink); white-space: nowrap; pointer-events: none; }
.fx-debug-bar { position: fixed; left: max(12px, env(safe-area-inset-left)); bottom: max(12px, env(safe-area-inset-bottom)); z-index: 90; display: flex; gap: 1rem; align-items: center; padding: 0.5rem 0.8rem; font: 600 0.75rem "IBM Plex Mono", monospace; color: var(--void); background: var(--pink); }
.fx-debug-bar button { font: inherit; color: var(--void); background: transparent; border: 1px solid var(--void); padding: 0.15rem 0.5rem; cursor: pointer; }

/* ---------- Small extras ---------- */
/* Nav links glitch on hover */
@media (prefers-reduced-motion: no-preference) and (hover: hover) {
  .site-nav a:hover { animation: fx-navglitch 0.35s steps(2) 1; }
  @keyframes fx-navglitch { 0% { text-shadow: 2px 0 var(--pink), -2px 0 var(--cyan); transform: translateX(1px); } 50% { text-shadow: -2px 0 var(--pink), 2px 0 var(--cyan); transform: translateX(-1px); } 100% { text-shadow: none; transform: none; } }
}
/* Skill entries light up like unlocked nodes */
.skill-group li { transition: color 0.2s, text-shadow 0.2s, transform 0.2s; }
.skill-group li:hover { color: var(--cyan); text-shadow: 0 0 10px rgba(53, 224, 240, 0.6); transform: translateX(4px); }

@media (max-width: 599px) {
  .fx-hud { padding: 0.3rem; }
  .fx-hud__text { display: none; }
  .fx-toasts { top: auto; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 3.5rem); }
}

/* ==========================================================================
   Learning playground upgrades
   ========================================================================== */
/* Vector demo: projection of B onto A, and the angle between them */
.vec-proj { stroke: var(--cyan); stroke-width: 6; stroke-opacity: 0.28; stroke-linecap: round; }
.vec-perp { stroke: var(--pink); stroke-width: 1.5; stroke-dasharray: 4 4; fill: none; }
.vec-proj-dot { fill: var(--text-hi); }
.vec-arc { fill: none; stroke: var(--text-hi); stroke-width: 1.5; stroke-opacity: 0.6; }

/* Lerp demo: spacing ticks */
.lerp-ticks path { stroke: var(--cyan); stroke-width: 1.5; stroke-opacity: 0.55; }

/* Blueprint demo: execution pulses run along the wires */
@media (prefers-reduced-motion: no-preference) {
  .bp-wire { stroke-dasharray: 10 6; animation: fx-flow 1.1s linear infinite; }
  .bp-wire--exec { stroke-dasharray: 4 14; stroke-width: 3; animation-duration: 0.8s; filter: drop-shadow(0 0 3px rgba(230, 241, 243, 0.9)); }
  @keyframes fx-flow { to { stroke-dashoffset: -32; } }
}

/* Game Feel demo */
.feel-layout { display: grid; gap: 1.5rem; }
@media (min-width: 1024px) { .feel-layout { grid-template-columns: minmax(0, 1fr) 17rem; align-items: start; } }
.feel-stage { display: grid; gap: 0.9rem; min-width: 0; }
.feel-stage canvas { display: block; width: 100%; aspect-ratio: 2 / 1; background: var(--void); border: 1px solid var(--grid); cursor: pointer; touch-action: manipulation; }
.feel-stage canvas:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.feel-stage canvas:focus { border-color: var(--cyan); box-shadow: 0 0 24px rgba(53, 224, 240, 0.2); }
.feel-pad { display: none; gap: 0.6rem; }
@media (pointer: coarse) { .feel-pad { display: grid; grid-template-columns: 1fr 1fr 1.6fr; } }
.feel-pad button { min-height: 3.4rem; font: 700 1.1rem var(--font-display); color: var(--cyan); background: var(--glass); border: 1px solid var(--cyan); touch-action: none; user-select: none; -webkit-user-select: none; }
.feel-pad button.is-down { background: var(--cyan); color: var(--void); }
.feel-pad__jump { color: var(--pink) !important; border-color: var(--pink) !important; }
.feel-pad__jump.is-down { background: var(--pink) !important; color: var(--void) !important; }
.feel-readout { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.feel-opts { margin: 0; padding: 1rem 1.1rem 1.2rem; border: 1px solid var(--grid); display: grid; gap: 0.55rem; min-width: 0; }
.feel-opts legend { padding: 0 0.4rem; font: 700 0.8rem var(--font-display); letter-spacing: 0.1em; text-transform: uppercase; color: var(--pink); }
.feel-opt { display: grid; grid-template-columns: auto 1fr; gap: 0.6rem; align-items: start; cursor: pointer; }
.feel-opt input { margin-top: 0.2rem; width: 1.05rem; height: 1.05rem; accent-color: var(--cyan); }
.feel-opt b { display: block; font: 600 0.92rem var(--font-display); color: var(--text-hi); }
.feel-opt small { display: block; font-size: 0.8rem; color: var(--muted); line-height: 1.4; }
.feel-opt:has(input:not(:checked)) b { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--pink); }
.feel-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.4rem; }
