/* ============================================================================
   WAVE MEMBRANE  ·  stylesheet
   ----------------------------------------------------------------------------
   Dark shell, the same palette as Resonance 3D. Type comes from lib/sci.css
   (loaded after this file): STIX Two Text for the site name, Inter for text,
   the system mono for numbers only. Labels are sentence case. The WebGL canvas fills the
   frame. The control panel slides in from the left. The colorbar legend sits
   at the lower right. The status bar sits at the base. The governing
   equations sit in their own panel at the upper left of the canvas.
     grep -n 'EQUATIONS'  the equation panel

   PHONE (max-width 768px, or a short landscape touch screen). A dock at the
   base holds the panel button, the three color modes, and play. In portrait
   the panel is a bottom sheet above the dock. In landscape it is a drawer on
   the right edge. Every control is at least 44px high.
     grep -n 'TOUCH'      target and text sizes for any touch screen
     grep -n 'PHONE'      the phone block
     grep -n 'LANDSCAPE'  the landscape overrides
     grep -n 'sn-saver'   the screensaver mode (lib/screensaver.js)
   ========================================================================== */
:root{
  --bg:#04030880; --bg2:#0c0912; --ink:#d6cfe0; --dim:#8a7a9a; --faint:#3a2a48;
  --line:rgba(220,150,200,0.10); --line-b:rgba(240,150,120,0.22);
  --warm:#fca35e; --pink:#cd4071; --blue:#9f2f7f; --panel-w:290px}
html,body{background:#040308}
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html,body{width:100%;height:100%;overflow:hidden;background:var(--bg);overscroll-behavior:none}
body{font-family:var(--sci-sans);color:var(--ink);-webkit-font-smoothing:antialiased}

.topbar{
  position:fixed;top:0;left:0;right:0;height:52px;z-index:30;display:flex;align-items:center;gap:18px;padding:0 20px;
  background:transparent;pointer-events:none}
.brand{font-family:var(--sci-serif);font-size:1.15rem;color:#e8eef8;display:flex;align-items:center;gap:9px}
.pagetitle{font-size:0.8rem;color:var(--dim);margin-left:auto}
html.in-frame .topbar{display:none}

#gl{position:fixed;inset:0;width:100%;height:100%;display:block;touch-action:none}
button{touch-action:manipulation;-webkit-tap-highlight-color:transparent}
#hint{transition:opacity 0.6s}
#hint.gone{opacity:0}
#dock,#sheetGrip{display:none}
#hint{
  position:fixed;left:50%;bottom:52px;transform:translateX(-50%);z-index:20;
  font-size:0.76rem;color:var(--dim);pointer-events:none}

#gear{
  position:fixed;top:14px;left:14px;z-index:40;width:38px;height:38px;
  border:1px solid var(--line-b);background:rgba(12,15,22,0.7);color:var(--ink);
  border-radius:9px;font-size:1.05rem;cursor:pointer;display:none}
html.in-frame #gear{top:12px}
#gear:hover{border-color:var(--warm);color:var(--warm)}

#panel{
  position:fixed;top:0;left:0;bottom:0;width:var(--panel-w);z-index:35;
  background:rgba(10,9,15,0.97);
  border-right:1px solid var(--line-b);padding:64px 18px 20px;overflow-y:auto;
  transform:translateX(-100%);transition:transform 0.28s cubic-bezier(0.4,0,0.2,1)}
#panel.open{transform:translateX(0)}
html.in-frame #panel{padding-top:24px}
#panelClose{position:absolute;top:14px;right:14px;width:30px;height:30px;border:1px solid var(--line);background:transparent;color:var(--dim);border-radius:7px;cursor:pointer}
#panelClose:hover{color:var(--warm);border-color:var(--warm)}

.sec-label{font-size:0.8rem;font-weight:600;color:var(--ink);margin:18px 0 9px}
.sec-label:first-of-type{margin-top:0}

.ratio-row{display:flex;align-items:center;justify-content:space-between;gap:6px}
.stepper{display:grid;grid-template-columns:auto auto auto;align-items:center;gap:4px;position:relative;padding-bottom:15px;justify-items:center}
.stepper button{width:26px;height:28px;border:1px solid var(--line-b);background:var(--bg2);color:var(--ink);border-radius:6px;cursor:pointer;font-size:1rem;line-height:1}
.stepper button:hover{border-color:var(--warm);color:var(--warm)}
.stepper .num{min-width:26px;text-align:center;font-size:1.3rem;font-weight:500;color:#eef4ff}
.axis-tag{position:absolute;bottom:0;left:0;right:0;text-align:center;font-size:0.76rem}

.presets{display:grid;grid-template-columns:repeat(3,1fr);gap:6px}
.presets button{padding:8px 4px;border:1px solid var(--line);background:var(--bg2);color:var(--dim);border-radius:6px;cursor:pointer;font-family:inherit;font-size:0.78rem;text-align:center}
.presets button:hover{border-color:var(--line-b);color:var(--ink)}
.presets button.on{border-color:var(--warm);background:rgba(255,200,50,0.06);color:var(--warm)}

/* Parameter row: label (math symbol and a word) and value on one line, the
   slider under them at full width. The DOM order is label, input, value,
   so grid placement does the layout. */
.row{display:grid;grid-template-columns:1fr auto;align-items:center;gap:3px 8px;margin:10px 0}
.row label{grid-row:1;grid-column:1;font-size:0.78rem;color:var(--ink)}
.row label .sci-sym{font-size:0.95rem;margin-right:3px}
.row label .w{color:var(--dim)}
.row input[type=range]{grid-row:2;grid-column:1/3;width:100%;accent-color:var(--warm);height:3px;margin:4px 0}
.row .val{grid-row:1;grid-column:2;text-align:right;font:0.76rem var(--sci-mono);color:var(--ink);font-variant-numeric:tabular-nums}
.hint{font-size:0.76rem;line-height:1.5;color:var(--dim);margin:8px 0 2px}

.modes{display:flex;gap:8px}
.modes button{flex:1;padding:10px;border:1px solid var(--line-b);background:var(--bg2);color:var(--ink);border-radius:7px;cursor:pointer;font-family:inherit;font-size:0.78rem}
.modes button.on{border-color:var(--warm);background:rgba(255,200,50,0.08);color:var(--warm)}
.modes button:hover{border-color:var(--warm)}

#status{
  position:fixed;left:0;bottom:0;z-index:25;display:flex;gap:16px;align-items:center;padding:10px 18px;
  font-size:0.78rem;color:var(--ink);background:rgba(7,9,13,0.85);
  max-width:calc(100% - var(--panel-w))}
#status .fn{color:var(--warm)}
#status .right{color:var(--dim);font-family:var(--sci-mono)}

#mode2Box.off{display:none}
#mode2Box{margin-top:10px}
.stepper button:disabled{opacity:0.35;cursor:default;border-color:var(--line);color:var(--dim)}
.modes + .modes{margin-top:8px}
.modes button{padding:9px 4px}

/* EQUATIONS. A fixed panel at the upper left of the canvas, the same form as
   the Atomic Orbital VR panel. A row that is wider than the panel scrolls
   sideways, so an equation never runs out of its box. */
#eqPanel{
  position:fixed;top:64px;left:calc(var(--panel-w) + 24px);z-index:22;
  max-width:min(560px, calc(100vw - var(--panel-w) - 48px));
  padding:14px 20px 14px;background:rgba(9,8,14,0.92);border:1px solid var(--line-b);
  border-radius:8px}
html.in-frame #eqPanel{top:16px}
.eq-head{display:flex;align-items:center;gap:10px;margin:0 34px 8px 0}
.eq-head .lbl{font-size:0.8rem;color:var(--ink);font-weight:600;white-space:nowrap}
.eq-block{padding:4px 0}
.eq-block + .eq-block{border-top:1px solid var(--line);margin-top:8px;padding-top:10px}
.eq-sublabel{font-size:0.76rem;color:var(--dim);margin-bottom:2px}
.eq-row{color:#eef4ff;min-height:1.4em;overflow-x:auto;overflow-y:hidden}
/* .eq-row is a .sci-eq box (lib/sci.css loads later; the #eqPanel prefix
   wins). font-size sets the formula size. */
#eqPanel .eq-row{font-size:1.05rem;padding:3px 0}
.eq-row::-webkit-scrollbar{height:0}
#eqCollapse{
  position:absolute;top:10px;right:10px;width:26px;height:26px;display:flex;align-items:center;justify-content:center;
  background:transparent;border:1px solid var(--line-b);border-radius:6px;color:var(--dim);font-size:0.76rem;font-family:inherit;cursor:pointer}
#eqCollapse:hover{border-color:var(--warm);color:var(--warm)}
#eqPanel.collapsed{padding:10px 16px}
#eqPanel.collapsed .eq-head{margin-bottom:0}
#eqPanel.collapsed .eq-block{display:none}
#eqPanel.collapsed #eqCollapse{top:5px}
.readout{width:100%;border-collapse:collapse;margin-top:8px;font-size:0.76rem}
.readout td{padding:3px 0;border-bottom:1px solid var(--line)}
.readout td:first-child{color:var(--dim)}
.readout td:last-child{text-align:right;color:var(--ink);font-family:var(--sci-mono);font-variant-numeric:tabular-nums}
.readout .sci-sym{font-size:0.9rem}
.about p{font-size:0.8rem;line-height:1.6;color:var(--dim);margin:0 0 8px}

/* The panel covers the left edge on wide screens. The status bar and the
   topbar content start after it. The stacking order stays as in Resonance 3D. */
@media(min-width:769px){
  #status{left:var(--panel-w)}
  .topbar{padding-left:calc(var(--panel-w) + 20px)}
  body.panel-closed #gear{display:block}
  body.panel-closed #status{left:0}
  body.panel-closed .topbar{padding-left:68px}
  body.panel-closed #eqPanel{left:24px;max-width:min(560px, calc(100vw - 48px))}
}

#legend{
  position:fixed;right:18px;bottom:46px;z-index:20;padding:9px 11px 7px;
  background:rgba(12,15,22,0.72);border:1px solid var(--line);border-radius:8px;
  pointer-events:none}
#legend.off{display:none}
.lg-title{font-size:0.76rem;color:var(--dim);margin-bottom:6px}
#lgBar{display:block;width:180px;height:10px;border-radius:2px}
.lg-ticks{display:flex;justify-content:space-between;font:0.76rem var(--sci-mono);color:var(--ink);margin-top:4px;font-variant-numeric:tabular-nums}

/* TOUCH. Any touch screen or narrow window, phone or tablet: every target is
   44px or more, and all text is 11px or more. The layout does not change. */
@media (pointer:coarse), (max-width:768px){
  :root{--panel-w:320px}
  #panelClose{width:44px;height:44px}
  .lg-title,.lg-ticks{font-size:0.78rem}
  #status{font-size:0.78rem}
  #hint{font-size:0.78rem}
  .sec-label{font-size:0.78rem;margin:22px 0 10px}
  .stepper{padding-bottom:18px}
  .stepper button{width:44px;height:44px;font-size:1.3rem;border-radius:10px}
  .stepper .num{min-width:34px;font-size:1.55rem}
  .axis-tag{font-size:0.78rem}
  .modes button,.presets button{min-height:46px;font-size:0.74rem;border-radius:10px}
  .row{min-height:44px;margin:4px 0}
  .row label{flex:0 0 80px;font-size:0.76rem}
  .row .val{flex:0 0 54px;font-size:0.76rem}
  .hint{font-size:0.74rem}
  #eqCollapse{width:44px;height:44px;top:4px;right:4px;font-size:0.8rem}
  #eqPanel.collapsed{padding-top:0;padding-bottom:0}
  #eqPanel.collapsed .eq-head{min-height:44px}
  #eqPanel.collapsed #eqCollapse{top:0;right:0;border:0}
  .eq-head{margin-right:44px}
  .eq-head .lbl{font-size:0.78rem}
  .eq-sublabel{font-size:0.78rem}
  .readout{font-size:0.76rem}
  .readout td{padding:7px 0}
  .about p{font-size:0.82rem;line-height:1.65}
  .row input[type=range]{-webkit-appearance:none;appearance:none;height:44px;background:transparent}
  .row input[type=range]::-webkit-slider-runnable-track{height:6px;border-radius:3px;background:var(--faint)}
  .row input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;width:26px;height:26px;margin-top:-10px;border-radius:50%;background:var(--warm);border:3px solid #1a1320;box-shadow:0 0 0 1px var(--warm)}
  .row input[type=range]::-moz-range-track{height:6px;border-radius:3px;background:var(--faint)}
  .row input[type=range]::-moz-range-thumb{width:22px;height:22px;border-radius:50%;background:var(--warm);border:3px solid #1a1320}
}

/* PHONE. The query matches PHONE_Q in main.js. */
@media (max-width:768px), (max-height:500px) and (pointer:coarse){
  :root{--dock-h:calc(64px + env(safe-area-inset-bottom))}
  .topbar{height:calc(48px + env(safe-area-inset-top));padding:env(safe-area-inset-top) 16px 0 calc(16px + env(safe-area-inset-left))}
  .brand{font-size:1.05rem}
  .sys,.pagetitle{display:none}
  #gear,body.panel-closed #gear{display:none}

  #dock{
    display:flex;position:fixed;left:0;right:0;bottom:0;z-index:45;gap:8px;align-items:center;
    padding:8px calc(10px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left));
    background:rgba(9,8,14,0.94);border-top:1px solid var(--line-b)}
  #dock > button{flex:0 0 48px;height:48px;border:1px solid var(--line-b);border-radius:12px;background:var(--bg2);color:var(--ink);font-size:1.1rem;cursor:pointer}
  #dock > button.on{border-color:var(--warm);color:var(--warm)}
  .seg{flex:1;display:flex;height:48px;min-width:0;border:1px solid var(--line-b);border-radius:12px;overflow:hidden}
  .seg button{flex:1;min-width:0;border:0;border-right:1px solid var(--line);background:var(--bg2);color:var(--dim);font-family:inherit;font-size:0.78rem;cursor:pointer}
  .seg button:last-child{border-right:0}
  .seg button.on{background:rgba(252,163,94,0.14);color:var(--warm)}

  #status{left:0;right:0;bottom:var(--dock-h);max-width:none;gap:10px;padding:6px calc(14px + env(safe-area-inset-right)) 6px calc(14px + env(safe-area-inset-left));white-space:nowrap;overflow:hidden}
  #status span{min-width:0;overflow:hidden;text-overflow:ellipsis}
  /* The legend is a slim strip under the topbar, so it never covers the
     membrane. main.js counts it as an overlay when it frames the camera. */
  #legend{
    left:calc(10px + env(safe-area-inset-left));right:calc(10px + env(safe-area-inset-right));top:calc(50px + env(safe-area-inset-top));bottom:auto;
    display:grid;grid-template-columns:auto 1fr;column-gap:12px;align-items:center;padding:6px 10px}
  html.in-frame #legend{top:8px}
  .lg-title{grid-row:1 / 3;margin:0;white-space:nowrap}
  #lgBar{grid-column:2;width:100%;height:8px}
  .lg-ticks{grid-column:2;margin-top:3px}
  #hint{bottom:auto;top:calc(100px + env(safe-area-inset-top));left:16px;right:16px;transform:none;text-align:center;line-height:1.6}
  /* The equations sit under the legend strip, full width. */
  #eqPanel{
    top:calc(98px + env(safe-area-inset-top));left:calc(10px + env(safe-area-inset-left));right:calc(10px + env(safe-area-inset-right));
    max-width:none;padding:10px 12px 12px}
  html.in-frame #eqPanel{top:56px}
  #eqPanel .eq-row{font-size:0.95rem}
  #hint{top:calc(150px + env(safe-area-inset-top))}
  html.in-frame #hint{top:108px}
  body:not(.panel-closed) #hint{opacity:0}

  /* The panel is a bottom sheet above the dock. */
  #panel{
    top:auto;left:0;right:0;bottom:var(--dock-h);width:auto;
    height:min(48vh,520px);height:min(48dvh,520px);
    border-right:0;border-top:1px solid var(--line-b);border-radius:18px 18px 0 0;
    padding:0 calc(18px + env(safe-area-inset-right)) 24px calc(18px + env(safe-area-inset-left));
    transform:translateY(calc(100% + var(--dock-h)));transition:transform 0.3s cubic-bezier(0.4,0,0.2,1),height 0.3s cubic-bezier(0.4,0,0.2,1);
    overscroll-behavior:contain;-webkit-overflow-scrolling:touch}
  #panel.open{transform:translateY(0)}
  #panel.full{height:calc(100vh - var(--dock-h) - 40px);height:calc(100dvh - var(--dock-h) - 40px)}
  html.in-frame #panel{padding-top:0}
  #panelClose{display:none}
  #sheetGrip{
    display:flex;position:sticky;top:0;z-index:2;justify-content:center;align-items:center;height:44px;margin:0 -18px 0;
    background:linear-gradient(180deg,rgba(12,15,22,1) 65%,rgba(12,15,22,0));touch-action:none;cursor:grab}
  #sheetGrip span{width:46px;height:5px;border-radius:3px;background:var(--dim);opacity:0.6}

}

/* LANDSCAPE phone. The panel is a drawer on the right edge. The dock is a
   tab at the lower left. The topbar and the status bar are hidden, because
   the readout in the panel shows the same values. */
@media (max-height:500px) and (orientation:landscape){
  .topbar,#status{display:none}
  #hint{top:10px;left:25%;right:25%}
  #legend,html.in-frame #legend{display:block;top:10px;right:auto;left:calc(10px + env(safe-area-inset-left))}
  #eqPanel,html.in-frame #eqPanel,body.panel-closed #eqPanel{top:78px;left:calc(10px + env(safe-area-inset-left));right:auto;width:min(380px,48vw);max-width:none}
  #hint,html.in-frame #hint{top:10px}
  #lgBar{width:130px;height:10px}
  .lg-ticks{margin-top:4px}
  #dock{right:auto;width:min(440px,56vw);border-right:1px solid var(--line-b);border-radius:0 16px 0 0}
  #panel,#panel.full{
    top:0;bottom:0;left:auto;right:0;width:min(46vw,380px);height:auto;
    border-top:0;border-left:1px solid var(--line-b);border-radius:0;
    padding:0 calc(16px + env(safe-area-inset-right)) 20px 16px;
    transform:translateX(100%)}
  #panel.open{transform:translateX(0)}
  #sheetGrip{display:none}
  #panelClose{display:block;position:sticky;top:10px;margin:10px 0 0 auto;width:44px;height:44px;z-index:2;background:var(--bg2)}
}

/* screensaver (lib/screensaver.js): the membrane alone fills the frame */
html.sn-saver #panel,html.sn-saver #dock,html.sn-saver #status,html.sn-saver #legend,
html.sn-saver #eqPanel,html.sn-saver #hint,html.sn-saver #gear,html.sn-saver .topbar{display:none}
html.sn-saver #gl{cursor:none}
