/* physics-shell.css — shared presentation shell for every Physics Lab sim.
 * Full-viewport canvas is the hero; everything else floats over it: a title,
 * a controls dock, a small dismissible discovery card, and an ⓘ "learn more"
 * drawer. Class prefix: ps-  */

:root { --ps-panel: 520px; }
html, body { margin: 0; height: 100%; background: #0a0d12; color: #e6ecf2;
  font-family: 'Inter', system-ui, sans-serif; overflow: hidden; }

/* the hero canvas fills the viewport; on wide screens it narrows to make room for
   the learn panel instead of being covered by it (the width animates smoothly).
   NOTE: <canvas> is a replaced element, so it needs an explicit width/height —
   top/right/bottom/left:0 will NOT stretch it. Animate `width`, not `right`. */
#scene { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; display: block; touch-action: none;
  transition: width .3s cubic-bezier(.22,.61,.36,1);
  background: radial-gradient(130% 130% at 50% 0%, #0e131b 0%, #070a0e 78%); }
@media (min-width: 760px) { body.ps-learn-open #scene { width: calc(100vw - var(--ps-panel)); } }

/* floating title (top-left) */
.ps-title { position: fixed; top: 15px; left: 18px; z-index: 5; max-width: 60vw; }
.ps-title a { color: #8e98a6; text-decoration: none; font-size: 12.5px; }
.ps-title a:hover { color: #e6ecf2; }
.ps-title h1 { margin: 4px 0 2px; font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
.ps-title .ps-papers { font-size: 12px; color: #6f7c8c; }
.ps-title .ps-papers b { color: #6aabff; font-weight: 600; }

/* controls dock — tall panel on the RIGHT (desktop); a bottom sheet on phones (see media query) */
.ps-dock { position: fixed; top: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; flex-direction: column; gap: 13px; align-items: stretch; justify-content: flex-start;
  width: 310px; max-width: 88vw; max-height: 100vh; overflow-y: auto; padding: 58px 16px 22px;
  background: rgba(17,21,28,.9); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-left: 1px solid #1b222c; box-shadow: -12px 0 40px rgba(0,0,0,.45); }
.ps-dock .ps-seg { flex-wrap: wrap; }
.ps-k { display: flex; flex-direction: column; gap: 5px; min-width: 118px; }
.ps-k > label { font-size: 12px; color: #aeb7c4; font-weight: 600; display: flex; justify-content: space-between; gap: 10px; }
.ps-k > label span { color: #6aabff; }
.ps-k input[type=range] { width: 100%; -webkit-appearance: none; appearance: none; height: 4px; border-radius: 999px; background: #232b36; outline: none; }
.ps-k input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 15px; height: 15px; border-radius: 50%; background: #4d9aff; cursor: pointer; border: 2px solid #0a0d12; }
.ps-k input[type=range]::-moz-range-thumb { width: 13px; height: 13px; border-radius: 50%; background: #4d9aff; cursor: pointer; border: 2px solid #0a0d12; }
.ps-seg { display: flex; gap: 5px; }
.ps-seg button { padding: 6px 11px; border-radius: 8px; border: 1px solid #232b36; background: #161c25; color: #aeb7c4; font: 600 12px 'Inter'; cursor: pointer; }
.ps-seg button.on { background: rgba(77,154,255,.16); color: #6aabff; border-color: rgba(77,154,255,.5); }
.ps-btn { padding: 9px 14px; border-radius: 10px; border: 1px solid #232b36; background: #4d9aff; color: #06111f; font: 700 13px 'Inter'; cursor: pointer; }
.ps-btn:hover { background: #6aabff; }
.ps-btn.ghost { background: #161c25; color: #e6ecf2; }
.ps-btn.ghost:hover { background: #1d2530; }

/* live readouts strip (optional, sits above the dock) */
.ps-readout { position: fixed; left: 50%; transform: translateX(-50%); bottom: 92px; z-index: 5;
  display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; max-width: 92vw;
  font-size: 12.5px; color: #aeb7c4; padding: 7px 14px; border-radius: 12px;
  background: rgba(13,17,23,.7); border: 1px solid #161c25; }
.ps-readout b { color: #e6ecf2; } .ps-readout .hl { color: #6aabff; }

/* discovery card — small dismissible top-centre toast, never covers the action */
.ps-card { position: fixed; top: 16px; left: 50%; z-index: 7; display: flex; align-items: center; gap: 10px;
  max-width: 92vw; padding: 8px 8px 8px 14px; border-radius: 999px;
  background: rgba(20,32,22,.94); border: 1px solid #1c4a30; box-shadow: 0 10px 30px rgba(0,0,0,.5);
  opacity: 0; transform: translateX(-50%) translateY(-14px); transition: opacity .25s, transform .25s; pointer-events: none; }
.ps-card.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.ps-card .ps-msg { font-size: 13px; color: #cfe0d6; }
.ps-card .ps-msg b { color: #7fe0a0; font-weight: 600; }
.ps-card .ps-why { background: rgba(127,224,160,.16); color: #7fe0a0; border: 1px solid #1c4a30; border-radius: 999px;
  padding: 4px 11px; font: 600 12px 'Inter'; cursor: pointer; white-space: nowrap; }
.ps-card .ps-why:hover { background: rgba(127,224,160,.28); }
.ps-card .ps-cardx { background: none; border: none; color: #8e98a6; font-size: 17px; line-height: 1; cursor: pointer; padding: 2px 6px; }
.ps-card .ps-cardx:hover { color: #e6ecf2; }

/* ⓘ button + learn drawer (right) */
.ps-info { position: fixed; top: 15px; right: 18px; z-index: 7; width: 40px; height: 40px; border-radius: 50%;
  background: rgba(17,21,28,.82); border: 1px solid #1b222c; color: #e6ecf2; font-size: 18px; cursor: pointer; }
.ps-info:hover { background: rgba(30,38,50,.9); }
.ps-learn { position: fixed; top: 0; right: 0; bottom: 0; width: var(--ps-panel); max-width: 90vw; z-index: 8; transform: translateX(100%);
  box-sizing: border-box; /* keep total width == --ps-panel so the canvas meets it exactly (no overlap) */
  transition: transform .3s cubic-bezier(.22,.61,.36,1); background: #0d1117; border-left: 1px solid #1b222c; padding: 22px 22px 40px; overflow-y: auto; }
.ps-learn.open { transform: translateX(0); }
.ps-learn .ps-x { float: right; background: none; border: none; color: #8e98a6; font-size: 22px; cursor: pointer; }
.ps-learn h2 { font-size: 17px; margin: 2px 0 14px; }
.ps-q { font-weight: 700; color: #6aabff; font-size: 14px; margin: 18px 0 6px; }
.ps-a { font-size: 13.5px; line-height: 1.6; color: #c3ccd8; margin: 0; }
.ps-a b { color: #e6ecf2; font-weight: 600; }
/* Simple↔Deep toggle inside an answer */
.ps-deep { margin-top: 8px; }
.ps-deep summary { cursor: pointer; color: #6aabff; font-size: 12.5px; font-weight: 600; list-style: none; }
.ps-deep summary::-webkit-details-marker { display: none; }
.ps-deep summary::before { content: "▸ "; }
.ps-deep[open] summary::before { content: "▾ "; }
.ps-deep .body { margin-top: 8px; font-size: 13px; line-height: 1.55; color: #aeb7c4; }
.ps-deep .formula { font-family: 'JetBrains Mono', monospace; color: #7fbfff; background: #0f1620; border: 1px solid #1b222c; border-radius: 8px; padding: 8px 10px; margin: 6px 0; font-size: 13px; }

/* source figures (reuse the lightbox: figure.page a > img) */
.ps-sources { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
figure.page { margin: 0; background: #11151c; border: 1px solid #1b222c; border-radius: 10px; overflow: hidden; }
figure.page img { display: block; width: 100%; height: auto; background: #fff; }
figure.page figcaption { font-size: 11px; color: #8e98a6; padding: 6px 8px; border-top: 1px solid #1b222c; }
figure.page figcaption b { color: #e6ecf2; }
.ps-srcnote { font-size: 12px; color: #6f7c8c; margin-top: 14px; }

/* scenario caption (what am I looking at right now) */
.ps-scncap { font-size: 13px; color: #aeb7c4; line-height: 1.55; background: #0f1620; border: 1px solid #1b222c;
  border-radius: 10px; padding: 11px 13px; margin: 2px 0 6px; }
.ps-scncap b { color: #6aabff; }

/* live "worked calculation" cards — rendered equation + numbers plugged in, updating in real time */
.ps-live-note { font-size: 12px; color: #7fe0a0; margin: 4px 0 10px; display: flex; align-items: center; gap: 6px; }
.ps-live-note::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #7fe0a0; box-shadow: 0 0 8px #7fe0a0; animation: psPulse 1.2s infinite; }
@keyframes psPulse { 0%,100%{opacity:1} 50%{opacity:.3} }
.ps-eq { background: #0f1620; border: 1px solid #1b222c; border-radius: 11px; padding: 11px 13px 12px; margin-bottom: 9px; }
.ps-eq-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 5px; }
.ps-eq-name { font-size: 13px; font-weight: 700; color: #e6ecf2; }
.ps-eq-cite { font-size: 10.5px; color: #6f7c8c; font-family: 'JetBrains Mono', monospace; white-space: nowrap; }
/* symbolic formula: centred, scaled to fit — never scrolls */
.ps-eq-sym { color: #dfe7f0; margin: 4px 0 8px; text-align: center; overflow: hidden; }
.ps-eq-sym .katex { font-size: 1em; white-space: normal; }
/* live line: big glanceable RESULT on top, small substitution underneath (wraps, no scroll) */
.ps-eq-live .res { display: block; font: 700 16px 'JetBrains Mono', monospace; color: #7fe0a0; }
.ps-eq-live .subline { font: 11.5px/1.55 'JetBrains Mono', monospace; margin-top: 3px; color: #6f7c8c; word-break: break-word; }
.ps-eq-live .muted { color: #6f7c8c; font-size: 12px; }
/* running-live pill (numbers that tick as the sim plays) */
.ps-live-run { display: inline-flex; align-items: center; gap: 7px; font: 600 12px 'JetBrains Mono', monospace; color: #7fbfff;
  background: #0f1a26; border: 1px solid #1b3350; border-radius: 999px; padding: 5px 11px; margin: 0 0 10px; }
.ps-live-run::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #4d9aff; box-shadow: 0 0 8px #4d9aff; animation: psPulse 1s infinite; }
/* plain-language explanation under each equation */
.ps-eq-explain { font-size: 12.5px; color: #aeb7c4; line-height: 1.5; margin: 7px 0 1px; }
.ps-eq-explain b { color: #cdd7e3; font-weight: 600; }
/* "ways to view this" block in the learn panel */
.ps-views { background: #0f1620; border: 1px solid #1b222c; border-radius: 12px; padding: 12px 14px; margin: 4px 0 14px; }
.ps-views h4 { margin: 0 0 9px; font-size: 13px; color: #e6ecf2; font-weight: 700; }
.ps-views .vrow { font-size: 13px; color: #c3ccd8; line-height: 1.55; margin-bottom: 8px; }
.ps-views .vrow:last-child { margin-bottom: 0; }
.ps-views .vrow b { color: #6aabff; font-weight: 600; }

/* when the learn panel pushes the canvas, keep the floating HUD centred in the
   visible (narrowed) canvas area, animating along with it */
.ps-dock, .ps-readout { transition: left .3s cubic-bezier(.22,.61,.36,1); }
.ps-card { transition: opacity .25s, transform .25s, left .3s cubic-bezier(.22,.61,.36,1); }
@media (min-width: 760px) {
  body.ps-learn-open .ps-dock,
  body.ps-learn-open .ps-readout,
  body.ps-learn-open .ps-card { left: calc(50% - var(--ps-panel) / 2); }
}

/* ===================== Ask the paper (embedded grounded Q&A) ===================== */
.ps-ask { margin: 2px 0 18px; border: 1px solid #1b2430; border-radius: 14px;
  background: linear-gradient(180deg, #101823, #0c1118); overflow: hidden; }
.ps-ask-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 11px 13px 9px; }
.ps-ask-title { font-size: 13.5px; font-weight: 700; color: #e6ecf2; }
.ps-ask-src { font-size: 10.5px; color: #6b7686; text-align: right; }
.ps-ask-form { display: flex; gap: 7px; padding: 0 11px 10px; }
.ps-ask-in { flex: 1 1 auto; min-width: 0; background: #0a0e14; border: 1px solid #232d3a; border-radius: 10px;
  padding: 9px 12px; color: #e6ecf2; font: inherit; font-size: 13px; outline: none; transition: border-color .15s, box-shadow .15s; }
.ps-ask-in:focus { border-color: #3d7bd9; box-shadow: 0 0 0 3px rgba(61,123,217,.18); }
.ps-ask-in::placeholder { color: #5a6472; }
.ps-ask-btn { flex: 0 0 auto; background: linear-gradient(180deg, #4d9aff, #3d7bd9); color: #fff; border: none;
  border-radius: 10px; padding: 0 16px; font-weight: 700; font-size: 13px; cursor: pointer; transition: filter .15s; }
.ps-ask-btn:hover { filter: brightness(1.08); }
.ps-ask-btn:active { filter: brightness(.94); }
.ps-ask-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 11px 11px; }
.ps-ask-chips:empty { display: none; }
.ps-ask-chip { background: #141c27; border: 1px solid #232d3a; color: #9fb0c4; border-radius: 999px;
  padding: 5px 11px; font-size: 11.5px; cursor: pointer; transition: all .15s; text-align: left; line-height: 1.3; }
.ps-ask-chip:hover { border-color: #3d7bd9; color: #cfe0f5; background: #16202e; }
.ps-ask-thread { display: flex; flex-direction: column; gap: 13px; padding: 0 11px; }
.ps-ask-thread:not(:empty) { padding-bottom: 12px; }
.ps-ask-msg { display: flex; flex-direction: column; gap: 7px; }
.ps-ask-q { align-self: flex-end; max-width: 88%; background: linear-gradient(180deg, #2f4d7d, #274069);
  color: #eaf1fb; border-radius: 13px 13px 4px 13px; padding: 8px 12px; font-size: 13px; line-height: 1.45; }
.ps-ask-a { background: #0e141d; border: 1px solid #1b2430; border-radius: 4px 13px 13px 13px;
  padding: 11px 13px; font-size: 13.5px; line-height: 1.6; color: #d2dae4; overflow-wrap: anywhere; }
.ps-ask-a p { margin: 0 0 9px; } .ps-ask-a p:last-child { margin-bottom: 0; }
.ps-ask-a b { color: #eef3f9; } .ps-ask-a ul { margin: 6px 0; padding-left: 20px; } .ps-ask-a li { margin: 3px 0; }
.ps-ask-a code { background: #0a0e14; border: 1px solid #202a36; border-radius: 5px; padding: 1px 5px; font-size: 12px; }
.ps-ask-pre { background: #0a0e14; border: 1px solid #202a36; border-radius: 8px; padding: 9px 11px;
  overflow-x: auto; font-size: 12px; white-space: pre-wrap; }
.ps-ask-a img { max-width: 100%; border-radius: 8px; margin: 6px 0; }
.ps-ask-err { color: #ff9a9a; font-size: 12.5px; }
.ps-ask-dots { display: inline-flex; gap: 4px; padding: 3px 0; }
.ps-ask-dots i { width: 6px; height: 6px; border-radius: 50%; background: #4d9aff; opacity: .35; animation: psAskDot 1s infinite; }
.ps-ask-dots i:nth-child(2) { animation-delay: .18s; } .ps-ask-dots i:nth-child(3) { animation-delay: .36s; }
@keyframes psAskDot { 0%,100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
/* mobile: the panel is a full-width sheet; keep Ask comfortable to type in */
@media (max-width: 759px) {
  .ps-learn { width: 100vw; max-width: 100vw; }
  .ps-ask-src { display: none; }
  .ps-ask-in { font-size: 16px; } /* iOS: >=16px avoids zoom-on-focus */
}

/* ---- Ask: loading spiral (shown whenever it's still thinking) ---- */
.ps-ask-spin { display: inline-block; width: 15px; height: 15px; vertical-align: middle;
  border: 2px solid rgba(77,154,255,.25); border-top-color: #4d9aff; border-radius: 50%;
  animation: psSpin .7s linear infinite; }
.ps-ask-spin-sm { width: 12px; height: 12px; border-width: 2px; }
@keyframes psSpin { to { transform: rotate(360deg); } }
.ps-ask-thinking { display: inline-flex; align-items: center; gap: 8px; color: #8e98a6; font-size: 12.5px; }
/* ---- Ask: header right group + Clear button ---- */
.ps-ask-headr { display: flex; align-items: center; gap: 10px; }
.ps-ask-clear { background: #141c27; border: 1px solid #232d3a; color: #9fb0c4; border-radius: 8px;
  padding: 4px 9px; font-size: 11px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: all .15s; }
.ps-ask-clear:hover { border-color: #d9534f; color: #ffb3b0; background: #1c1416; }

/* ---- collapsible controls dock — friendly bottom sheet on phones ---- */
.ps-dock-handle { display: none; }                       /* desktop: no handle, dock unchanged */
@media (max-width: 759px) {
  .ps-dock {
    left: 0; right: 0; top: auto; bottom: 0; transform: none; width: 100vw; max-width: 100vw;
    flex-direction: row; flex-wrap: wrap; align-items: flex-end;   /* phones: back to a bottom sheet, not the right panel; WRAP so slider blocks (sun/galaxy) take their own rows */
    border-left: none; border-radius: 18px 18px 0 0; padding: 0 14px 16px; gap: 12px;
    max-height: 62vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
    transition: transform .32s cubic-bezier(.22,.61,.36,1);
    box-shadow: 0 -10px 40px rgba(0,0,0,.6);
  }
  .ps-dock.ps-collapsed { transform: translateY(calc(100% - 156px)); }   /* peek: handle + view tabs + primary tuners */
  .ps-dock-handle {
    display: flex; position: sticky; top: 0; z-index: 3; flex: 0 0 100%; width: 100%;
    height: 38px; align-items: flex-end; justify-content: center; padding: 0 0 6px; margin: 0 -14px;
    background: linear-gradient(180deg, rgba(17,21,28,.98) 68%, rgba(17,21,28,0));
    border: none; color: #9fb0c4; font: 600 12px 'Inter'; letter-spacing: .01em; cursor: pointer;
  }
  .ps-dock-handle::before {
    content: ""; position: absolute; top: 7px; left: 50%; transform: translateX(-50%);
    width: 42px; height: 5px; border-radius: 999px; background: #3a4757;
  }
  /* most-used controls first (visible in the collapsed peek): view tabs + tuner sliders on top;
     scenario + buttons tucked below (reach by expanding) — so you can tune without covering the canvas. */
  .ps-dock-handle { order: -3; }
  .ps-dock #segView { order: -2; flex-wrap: nowrap; overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
  .ps-dock .ps-seg button { flex: 0 0 auto; white-space: nowrap; }
  .ps-dock .ps-k { order: -1; min-width: 96px; flex: 1 1 96px; }
  .ps-dock .ps-k > label { font-size: 11px; }
  .ps-dock .ps-seg.scn { order: 4; flex-wrap: nowrap; overflow-x: auto; max-width: 100%; }
  .ps-dock .ps-btn { order: 5; }
  .ps-readout { display: none; }   /* live values live in the ⓘ panel; keep the canvas clear */
}

/* ---- hide/show the whole bottom controls panel ---- */
.ps-dock-hide { position: fixed; top: 15px; right: 66px; z-index: 7; height: 40px; padding: 0 13px;
  border-radius: 999px; background: rgba(17,21,28,.82); border: 1px solid #1b222c; color: #aeb7c4;
  font: 600 12.5px 'Inter'; cursor: pointer; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.ps-dock-hide:hover { color: #e6ecf2; background: rgba(30,38,50,.9); }
body.ps-dock-hidden .ps-dock { display: none !important; }
body.ps-dock-hidden .ps-readout { display: none !important; }
