/* ============================================================================
   CIRCULAR POLARIZATION  ·  style.css
   ----------------------------------------------------------------------------
   Type comes from lib/sci.css, which loads after this file: Inter for the
   UI, STIX Two Text for the title and for the italic <em> symbols, the
   system mono for numbers only. Labels are sentence case with no
   letter-spacing. The scene colours (--e, --b, --e1, --e2) are the
   lib/sci.css math colors --m2, --m1, --m4 and --m6. COL in main.js uses
   the same values, and typeset.mjs puts the same classes on the symbols.

   grep -n targets
     tokens ............... ":root"
     two-pane layout ...... ".app"
     legend ............... ".legend"
     panel ................ "#panel"
     equations ............ ".eq"
     ellipse readout ...... ".pol-row"
     controls ............. ".ctrl"
     phone portrait ....... "@media (max-width:760px) and (orientation:portrait)"
     touch targets ........ "@media (pointer:coarse)"
     screensaver .......... "html.sn-saver"
   ============================================================================ */
:root{
  --bg:#0a0c12; --bg2:#0d1018; --panel:#0c0f17;
  --line:rgba(150,200,255,0.09); --line2:rgba(150,200,255,0.18);
  --ink:#eef3fb; --text:#c0cfe0; --dim:#7f91ad; --faint:#3a4a64;
  --gold:#d4a847;
  --e:#ff9a62; --b:#62c4ff; --e1:#e889dc; --e2:#a8a4ff;
  --f-sans:var(--sci-sans); --f-mono:var(--sci-mono); --f-serif:var(--sci-serif);
  --panel-w:380px; --top-h:44px;
}
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html,body{width:100%;height:100%;overflow:hidden;background:var(--bg)}
body{font-family:var(--f-sans);color:var(--text);-webkit-font-smoothing:antialiased;display:flex;flex-direction:column}
button{font:inherit;color:inherit}
em{font-family:var(--f-serif);font-style:italic;font-size:1.08em}
.sym{display:inline-block;line-height:0;vertical-align:middle;font-size:1rem}
.sym svg{overflow:visible}

/* ═══ TOPBAR (standalone only) ═══ */
.topbar{flex:none;height:var(--top-h);display:flex;align-items:center;gap:16px;padding:0 20px;border-bottom:1px solid var(--line);background:var(--bg2)}
.in-frame .topbar{display:none}
.sys-name{font:500 0.85rem/1 var(--f-sans);color:var(--dim)}
.sys-page{font:400 1.1rem/1 var(--f-serif);color:var(--ink);margin-left:auto}

/* ═══ TWO PANES: the scene and the panel side by side ═══ */
.app{flex:1;min-height:0;display:flex}
#stage{position:relative;flex:1;min-width:0;overflow:hidden;
  background:radial-gradient(ellipse 70% 60% at 50% 46%, #121827 0%, var(--bg) 70%)}
canvas#scene{display:block;width:100%;height:100%;touch-action:none}

/* ═══ LEGEND (bottom left of the scene) ═══ */
.legend{position:absolute;left:18px;bottom:40px;list-style:none;display:grid;gap:7px;padding:12px 14px;
  border:1px solid var(--line);border-radius:12px;background:rgba(10,12,18,0.72);
  backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);pointer-events:none}
.legend li{display:flex;align-items:center;gap:9px;font-size:0.8rem;color:var(--dim)}
.legend li b{font-weight:400;color:var(--ink);min-width:2.8em}
.legend i{width:18px;height:2px;border-radius:1px;background:var(--c)}
.legend li[hidden]{display:none}

.hint{position:absolute;left:18px;bottom:14px;font:400 0.74rem/1 var(--f-sans);color:var(--faint);pointer-events:none}
.hint span{color:var(--dim)}

.err{position:absolute;top:14px;left:14px;z-index:10;background:rgba(60,10,10,0.92);color:#ffb0b0;border:1px solid #803030;
  border-radius:8px;padding:10px 14px;font:0.72rem/1.4 var(--f-mono);max-width:80%;display:none;white-space:pre-wrap}

/* ═══ PANEL ═══ */
#panel{flex:none;width:var(--panel-w);overflow-y:auto;overflow-x:hidden;border-left:1px solid var(--line);background:var(--panel);
  padding:26px 24px 30px;scrollbar-width:thin;scrollbar-color:var(--faint) transparent}
.p-head{margin-bottom:22px}
.kicker{font:500 0.78rem/1 var(--f-sans);color:var(--dim);margin-bottom:10px}
#panel h1{font:400 1.8rem/1.1 var(--f-serif);color:var(--ink);margin-bottom:10px}
.lede{font-size:0.92rem;line-height:1.55;color:var(--text)}
.p-sec{padding:18px 0 4px;border-top:1px solid var(--line)}
.p-sec h2{font:600 0.82rem/1 var(--f-sans);color:var(--ink);margin-bottom:14px}

/* ═══ EQUATIONS (MathJax SVG; ex units scale with font-size) ═══ */
.eq{color:var(--ink);font-size:15px;overflow-x:auto;overflow-y:hidden;padding:2px 0;scrollbar-width:none}
.eq::-webkit-scrollbar{display:none}
.eq svg{display:block;max-width:none;height:auto}
.eq-note{font-size:0.8rem;line-height:1.5;color:var(--dim);margin:6px 0 16px}
.eq-note em{color:var(--text)}
.eq-note .sym,.pol-read dt .sym{font-size:.86rem}

/* ═══ POLARIZATION READOUT ═══ */
.pol-row{display:flex;gap:16px;align-items:center}
#ellipse{flex:none;width:132px;height:132px;border-radius:50%;background:radial-gradient(circle,#121827 0%,#0b0e16 75%);border:1px solid var(--line)}
.pol-read{min-width:0;flex:1}
.eq-j{font-size:13px;margin-bottom:8px}
.pol-read dl{display:grid;grid-template-columns:auto 1fr;gap:5px 10px;align-items:baseline}
.pol-read dt{font:400 0.76rem/1.2 var(--f-sans);color:var(--dim)}
.pol-read dd{font:400 0.8rem/1.2 var(--f-mono);color:var(--ink);font-variant-numeric:tabular-nums;white-space:nowrap}

/* ═══ CONTROLS ═══ */
.ctrl{display:grid;gap:16px}
.ctrl h2{margin-bottom:0}
.seg{display:grid;grid-template-columns:repeat(3,1fr);gap:4px;padding:4px;border:1px solid var(--line);border-radius:999px;background:rgba(150,200,255,0.03)}
.mode-btn{min-height:34px;border:0;border-radius:999px;background:none;cursor:pointer;font-size:0.84rem;color:var(--dim);transition:background .2s,color .2s}
.mode-btn:hover{color:var(--ink)}
.mode-btn.active{background:rgba(212,168,71,0.16);color:var(--ink);box-shadow:inset 0 0 0 1px rgba(212,168,71,0.45)}
.ctrl-cell{display:flex;flex-direction:column;gap:6px}
.ctrl-cell[hidden]{display:none}
.ctrl-row{display:flex;justify-content:space-between;align-items:center;min-height:22px}
.ctrl-row label{display:flex;align-items:center;gap:6px;font-size:0.82rem;color:var(--text)}
.ctrl-row label .d{font-size:0.78rem;color:var(--dim)}
.ctrl-val{font:400 0.8rem/1 var(--f-mono);color:var(--ink);font-variant-numeric:tabular-nums}
.snaps{display:flex;flex-wrap:wrap;gap:6px;margin-top:2px}
.snaps button{min-height:28px;padding:0 10px;border:1px solid var(--line);border-radius:999px;background:none;cursor:pointer;font:400 0.76rem/1 var(--f-sans);color:var(--dim);transition:border-color .2s,color .2s}
.snaps button:hover,.snaps button.on{border-color:rgba(212,168,71,0.5);color:var(--ink)}

input[type="range"]{-webkit-appearance:none;appearance:none;width:100%;height:4px;border-radius:2px;outline:none;cursor:pointer;margin:6px 0;
  background:linear-gradient(to right,var(--gold) 0%,var(--gold) var(--pct,50%),rgba(150,200,255,0.14) var(--pct,50%))}
input[type="range"]::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:16px;height:16px;border-radius:50%;background:var(--bg);border:2px solid var(--gold)}
input[type="range"]::-moz-range-thumb{width:16px;height:16px;border-radius:50%;background:var(--bg);border:2px solid var(--gold)}
input[type="range"]:focus-visible{box-shadow:0 0 0 3px rgba(212,168,71,0.25)}

.togs{display:flex;flex-wrap:wrap;gap:10px 18px;align-items:center}
.tog{display:inline-flex;align-items:center;gap:9px;cursor:pointer;user-select:none;font-size:0.84rem;color:var(--dim);min-height:30px}
.tog[hidden]{display:none}
.tog input{position:absolute;opacity:0;width:0;height:0}
.tog .sw{position:relative;width:34px;height:20px;border-radius:999px;border:1px solid var(--line2);background:rgba(0,0,0,0.3);transition:background .2s,border-color .2s;flex:none}
.tog .sw::after{content:'';position:absolute;top:2px;left:2px;width:14px;height:14px;border-radius:50%;background:var(--faint);transition:transform .2s,background .2s}
.tog input:checked + .sw{border-color:rgba(212,168,71,0.5);background:rgba(212,168,71,0.12)}
.tog input:checked + .sw::after{transform:translateX(14px);background:var(--gold)}
.tog input:checked ~ span:last-child{color:var(--ink)}
.tog input:focus-visible + .sw{box-shadow:0 0 0 3px rgba(212,168,71,0.25)}
.play{margin-left:auto;min-height:30px;padding:0 14px;border:1px solid var(--line2);border-radius:999px;background:none;cursor:pointer;font:500 0.8rem/1 var(--f-sans);color:var(--dim)}
.play:hover{color:var(--ink);border-color:rgba(212,168,71,0.5)}
/* Headset buttons (lib/xr-view.js shows them when WebXR is there). */
.xr-row{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.xr-btn{min-height:34px;padding:0 12px;border:1px solid var(--line2);border-radius:999px;background:none;cursor:pointer;font:500 0.8rem/1 var(--f-sans);color:var(--dim)}
.xr-btn:hover{color:var(--ink);border-color:rgba(212,168,71,0.5)}
.xr-btn[hidden],#xrSec[hidden]{display:none}
.xr-btn:disabled{opacity:.5;cursor:default}

/* ═══ NARROW LANDSCAPE: a slimmer panel ═══ */
@media (max-width:1100px){:root{--panel-w:330px}#panel{padding:22px 18px 26px}#panel h1{font-size:1.8rem}}

/* ═══ PHONE PORTRAIT: the scene on top, the panel below it, never over it ═══ */
@media (max-width:760px) and (orientation:portrait){
  .topbar{height:40px;padding:0 14px}
  .app{flex-direction:column}
  #stage{flex:none;height:52svh;height:52vh}
  #panel{flex:1;width:auto;border-left:0;border-top:1px solid var(--line2);padding:18px 16px calc(24px + env(safe-area-inset-bottom))}
  #panel h1{font-size:1.6rem}
  .lede{font-size:0.86rem}
  .legend{left:8px;right:8px;bottom:8px;display:flex;flex-wrap:wrap;justify-content:center;gap:4px 14px;padding:7px 10px}
  .legend li{font-size:0;gap:6px}
  .legend li b{font-size:0.72rem;min-width:0}
  .hint{display:none}
  .eq{font-size:13px}
}

/* ═══ TOUCH: 44 px targets and 11 px minimum text ═══ */
@media (pointer:coarse){
  .mode-btn{min-height:44px}
  .snaps button{min-height:44px;padding:0 14px;font-size:0.72rem}
  .tog{min-height:44px}
  .play{min-height:44px}
  .xr-btn{min-height:44px}
  input[type="range"]{height:6px;margin:12px 0}
  input[type="range"]::-webkit-slider-thumb{width:26px;height:26px}
  input[type="range"]::-moz-range-thumb{width:26px;height:26px}
  .pol-read dt{font-size:0.7rem}
}

/* ═══ SCREENSAVER (lib/screensaver.js): the scene alone fills the frame ═══ */
html.sn-saver #panel,html.sn-saver .legend,html.sn-saver .hint,html.sn-saver .topbar{display:none}
html.sn-saver #stage{flex:1;height:auto}
html.sn-saver .app{flex-direction:row}
html.sn-saver canvas#scene{cursor:none}
