/* ==========================================================================
   Spectrum Studio — desktop shell
   --------------------------------------------------------------------------
   Turns the one-long-page layout into a workspace: the spectrum fills the
   window, and every other feature (regions, assignments, mass, Ka, response
   factors, tables, diff, copilot) lives in a floating window opened from the
   dock along the bottom or from the launcher.

   The panels themselves are untouched — desktop.js moves each <section
   class="panel"> into a window body, so every id app.js queries still resolves.
   Everything in this file is therefore chrome: windows, dock, launcher.
   ========================================================================== */

:root {
  --ss-dock-h: 54px;
  --ss-win-bar: 38px;
}

/* The shell fills the viewport exactly once, with the dock pinned under it, so
   the chart can take all the room the stacked panels used to occupy. */
body.ss-desktop { min-width: 980px; overflow: hidden; }
body.ss-desktop .app-shell { height: 100vh; padding-bottom: var(--ss-dock-h); }
body.ss-desktop .workspace {
  display: flex; flex-direction: column; min-height: 0; height: 100%;
  padding: 22px 26px 14px; overflow: hidden;
}
body.ss-desktop .topbar { margin-bottom: 16px; }
body.ss-desktop .metric-strip { flex: none; }
body.ss-desktop .chart-card { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
body.ss-desktop .chart-wrap { flex: 1 1 auto; height: auto; min-height: 220px; }
body.ss-desktop .source-details { flex: none; }
body.ss-desktop .analysis-grid { display: none; }

/* --- windows ------------------------------------------------------------ */

.ss-windows { position: fixed; inset: 0 0 var(--ss-dock-h) 0; pointer-events: none; z-index: 40; }

.ss-win {
  position: absolute; display: flex; flex-direction: column; min-width: 320px; min-height: 140px;
  border: 1px solid var(--ss-win-line, var(--line)); border-radius: 13px;
  background: var(--panel); box-shadow: 0 26px 70px rgba(6, 14, 20, .30), 0 2px 8px rgba(6, 14, 20, .14);
  pointer-events: auto; overflow: hidden;
  animation: ss-win-in .16s ease-out;
}
@keyframes ss-win-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.ss-win[hidden] { display: none; }
.ss-win.is-max { inset: 8px !important; width: auto !important; height: auto !important; }
.ss-win.is-focus { box-shadow: 0 30px 80px rgba(6, 14, 20, .38), 0 0 0 1px var(--ss-accent, #49d6cf) inset; }

.ss-win-bar {
  flex: none; height: var(--ss-win-bar); display: flex; align-items: center; gap: 9px;
  padding: 0 6px 0 13px; border-bottom: 1px solid var(--line);
  background: var(--ss-win-bar-bg, rgba(0, 0, 0, .03));
  cursor: grab; user-select: none; touch-action: none;
}
.ss-win-bar.is-dragging { cursor: grabbing; }
.ss-win-icon { flex: none; width: 20px; text-align: center; color: var(--ss-accent, #157c78); font-size: 15px; line-height: 1; }
.ss-win-title { flex: 1; min-width: 0; overflow: hidden; color: var(--ink); font-size: 12.5px; font-weight: 750; letter-spacing: .2px; white-space: nowrap; text-overflow: ellipsis; }
.ss-win-actions { flex: none; display: flex; gap: 2px; }
.ss-win-actions button {
  width: 26px; height: 26px; display: grid; place-items: center;
  border: 0; border-radius: 7px; color: var(--muted); background: transparent; font-size: 14px; line-height: 1;
}
.ss-win-actions button:hover { color: var(--ink); background: rgba(125, 145, 155, .18); }
.ss-win-actions button[data-act="close"]:hover { color: #fff; background: #b4432a; }

.ss-win-body { flex: 1; min-height: 0; overflow: auto; scrollbar-width: thin; }
/* A panel inside a window IS the window: no card of its own. */
.ss-win-body > .panel { min-height: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.ss-win-body > .panel[hidden] { display: none; }
.ss-win-body > .panel > .panel-header { padding-top: 15px; }
.ss-win-body .panel-toggle { display: none; }
.ss-win-hint { display: none; padding: 26px 24px; color: var(--muted); font-size: 12.5px; line-height: 1.7; }
.ss-win-hint b { color: var(--ink); }
.ss-win.is-empty .ss-win-hint { display: block; }

.ss-win-grip { position: absolute; touch-action: none; }
.ss-win-grip[data-dir="se"] { right: 0; bottom: 0; width: 16px; height: 16px; cursor: nwse-resize; }
.ss-win-grip[data-dir="sw"] { left: 0; bottom: 0; width: 16px; height: 16px; cursor: nesw-resize; }
.ss-win-grip[data-dir="e"] { top: 12px; right: 0; bottom: 12px; width: 6px; cursor: ew-resize; }
.ss-win-grip[data-dir="w"] { top: 12px; left: 0; bottom: 12px; width: 6px; cursor: ew-resize; }
.ss-win-grip[data-dir="s"] { left: 12px; right: 12px; bottom: 0; height: 6px; cursor: ns-resize; }
.ss-win-grip[data-dir="n"] { left: 12px; right: 12px; top: 0; height: 5px; cursor: ns-resize; }
.ss-win.is-max .ss-win-grip { display: none; }

/* --- dock --------------------------------------------------------------- */

.ss-dock {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--ss-dock-h); z-index: 60;
  display: flex; align-items: center; gap: 10px; padding: 0 14px;
  border-top: 1px solid var(--ss-dock-line, rgba(255, 255, 255, .08));
  background: var(--ss-dock-bg, #0d1a24); color: #cfe0e5;
  box-shadow: 0 -10px 30px rgba(6, 14, 20, .18);
}
.ss-dock-items { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.ss-dock-items::-webkit-scrollbar { display: none; }

.ss-tile {
  flex: none; display: flex; align-items: center; gap: 7px; height: 34px; padding: 0 11px;
  border: 1px solid transparent; border-radius: 9px; color: #9db2bb; background: rgba(255, 255, 255, .04);
  font-size: 12px; font-weight: 700; white-space: nowrap; transition: .15s ease;
}
.ss-tile:hover { color: #eafcfa; background: rgba(73, 214, 207, .14); }
.ss-tile em { font-style: normal; font-size: 15px; opacity: .9; }
.ss-tile.is-open { color: #d8fffb; border-color: rgba(73, 214, 207, .35); background: rgba(73, 214, 207, .13); }
.ss-tile.is-open::after { content: ""; width: 5px; height: 5px; border-radius: 50%; background: #49d6cf; }
.ss-tile.is-min { opacity: .62; }

.ss-dock-launch {
  flex: none; display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px;
  border: 1px solid rgba(73, 214, 207, .32); border-radius: 9px;
  color: #d8fffb; background: rgba(73, 214, 207, .12); font-size: 12px; font-weight: 800; letter-spacing: .4px;
}
.ss-dock-launch:hover { background: rgba(73, 214, 207, .2); }
.ss-dock-right { flex: none; display: flex; align-items: center; gap: 6px; }
.ss-dock-right button {
  height: 30px; padding: 0 10px; border: 1px solid rgba(255, 255, 255, .1); border-radius: 8px;
  color: #93a8b1; background: transparent; font-size: 11.5px; font-weight: 750;
}
.ss-dock-right button:hover { color: #eafcfa; border-color: rgba(73, 214, 207, .3); background: rgba(73, 214, 207, .1); }
.ss-dock-right button:disabled { opacity: .35; cursor: not-allowed; }

.ss-dock-right button.is-on { color: #d8fffb; border-color: rgba(73, 214, 207, .4); background: rgba(73, 214, 207, .14); }

/* --- explanations on / off ----------------------------------------------
   The prose in the panels explains the method; the panels are also used by
   someone who already knows it. Off, only the working parts remain — the notes
   are hidden, never removed, so nothing has to be rewritten to bring them back.
   Empty-state hints (what to do when a panel has nothing in it yet) always
   stay: they are instructions, not explanations. */
html[data-explain="off"] .calc-intro,
html[data-explain="off"] .rf-note,
html[data-explain="off"] .rf-aside,
html[data-explain="off"] .panel-footer-note { display: none; }

/* --- launcher ----------------------------------------------------------- */

.ss-launcher {
  position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center;
  padding: 40px; background: rgba(6, 14, 20, .58); backdrop-filter: blur(6px);
  animation: ss-fade .14s ease-out;
}
.ss-launcher[hidden] { display: none; }
@keyframes ss-fade { from { opacity: 0; } }
.ss-launcher-card {
  width: min(1040px, 100%); max-height: 100%; overflow: auto; padding: 26px 28px 28px;
  border: 1px solid var(--line); border-radius: 18px; background: var(--panel);
  box-shadow: 0 40px 90px rgba(6, 14, 20, .45);
}
.ss-launcher-head { display: flex; align-items: end; justify-content: space-between; margin-bottom: 18px; }
.ss-launcher-head h2 { margin: 3px 0 0; font-family: Georgia, "Times New Roman", serif; font-size: 25px; font-weight: 500; }
.ss-launcher-close { width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: transparent; font-size: 17px; }
.ss-launcher-close:hover { color: var(--ink); }
.ss-launcher-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 12px; }
.ss-card {
  display: flex; flex-direction: column; gap: 7px; min-height: 132px; padding: 15px 16px 16px; text-align: left;
  border: 1px solid var(--line); border-radius: 13px; background: var(--ss-card-bg, rgba(255, 255, 255, .5));
  color: var(--ink); transition: .16s ease;
}
.ss-card:hover { border-color: var(--ss-accent, #49d6cf); transform: translateY(-2px); box-shadow: 0 14px 34px rgba(6, 14, 20, .16); }
.ss-card-top { display: flex; align-items: center; gap: 10px; }
.ss-card-icon {
  width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 9px;
  color: var(--ss-accent, #157c78); background: rgba(22, 127, 122, .1); font-size: 17px;
}
.ss-card-name { font-size: 14.5px; font-weight: 750; }
.ss-card-eyebrow { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; }
.ss-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.ss-card .ss-card-open { margin-top: auto; color: var(--ss-accent, #157c78); font-size: 11px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; }
.ss-card.is-open .ss-card-open::before { content: "● "; }

/* --- narrow windows ------------------------------------------------------
   At 150% display scaling a 1560-pixel window is only ~1040 CSS pixels wide, so
   the layout has to hold together there: the sidebar gives up width first, and
   the dock drops the tile labels rather than scrolling four features out of
   reach (each tile keeps its name in a tooltip). */
@media (max-width: 1520px) {
  body.ss-desktop .ss-tile span { display: none; }
  body.ss-desktop .ss-tile { padding: 0 10px; }
  body.ss-desktop .ss-tile em { font-size: 16px; }
  body.ss-desktop .ss-dock-launch span { display: none; }
}
@media (max-width: 1200px) {
  body.ss-desktop { min-width: 900px; }
  body.ss-desktop .app-shell { grid-template-columns: 236px minmax(0, 1fr); }
  body.ss-desktop .workspace { padding: 16px 18px 10px; }
  body.ss-desktop .topbar h2 { font-size: 25.5px; }
  body.ss-desktop .metric-strip { grid-template-columns: repeat(3, minmax(96px, 1fr)) minmax(150px, 1.2fr); }
  body.ss-desktop .metric-strip .metric:nth-child(4) { display: none; }
}

/* Feature button in the top bar, for anyone who never looks at the dock. */
.ss-top-launch { display: flex; align-items: center; gap: 7px; height: 34px; padding: 0 13px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: transparent; font-size: 12px; font-weight: 750; }
.ss-top-launch:hover { border-color: var(--ss-accent, #49d6cf); }
