/* Science Lab — shared foundation for index.html and room.html.
   Palette: gold accent on deep navy; --c is the per-room accent, which
   room.html overrides at runtime from the room's own colour. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #1e2a3a;
  --bg2: #243347;
  --panel: #28384c;
  --fg: #e8ecf1;
  --muted: #8fa3ba;
  --border: #32445c;
  --gold: #d4a24c;
  --rule: #3a4d66;
  --c: #d4a24c;
}

body {
  font-family: Georgia, "Iowan Old Style", serif;
  background-attachment: fixed;
  color: var(--fg);
  line-height: 1.5;
  min-height: 100vh;
}

/* The shared hub-nav pill is position:fixed at top-left (see
   _shared/hub-nav.css). Reserve room for it so it never sits on top of the
   breadcrumb or the page heading at narrow widths. */
.page { max-width: 1100px; margin: 0 auto; padding: 2.6rem 1.6rem 3rem; }

/* Off-screen until focused, then the first thing the eye and the tab order
   reach. Both shells put the hub pill and the dock ahead of the content, so
   without this a keyboard user tabs through the furniture on every room. */
.skip-link {
  position: fixed; top: 0; left: 0; z-index: 100000;
  transform: translateY(-140%);
  font: 600 0.8rem/1 -apple-system, "Segoe UI", system-ui, sans-serif;
  color: #11161f; background: var(--gold);
  padding: 0.6rem 0.9rem; border-radius: 0 0 6px 0; text-decoration: none;
  transition: transform 0.15s;
}
.skip-link:focus { transform: translateY(0); }
/* The landmark takes focus from the skip link, and should not draw a ring
   round the whole page when it does. */
#main:focus { outline: none; }

/* Calculator internals — used by the dock on every page. */
.calc { max-width: 19rem; outline: none; border-radius: 6px; }
.calc:focus { box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 55%, transparent); }
.calc-display { background: #141d29; border: 1px solid var(--border); border-radius: 5px; padding: 0.6rem 0.7rem; margin-bottom: 0.5rem; min-height: 3.4rem; text-align: right; }

/* The angle unit lives in the display because it is the one piece of
   calculator state that silently changes what an answer means. It shares a
   flex row with the expression rather than floating over it, so a long
   expression wraps beside the control instead of underneath it. It is a
   two-state segmented control rather than one button showing the current
   mode — a lone "DEG" is ambiguous about whether it reports or promises. */
.calc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; }
.calc-top .calc-expr { flex: 1; text-align: right; }
.calc-mode { flex: none; display: inline-flex;
  border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.calc-mode-btn { font-family: -apple-system, sans-serif; font-size: 0.56rem; font-weight: 700;
  letter-spacing: 0.06em; color: var(--muted); background: transparent; border: none;
  padding: 0.14rem 0.42rem; cursor: pointer; }
.calc-mode-btn:hover { color: var(--fg); }
.calc-mode-btn.on { color: #11161f; background: var(--c); }
.calc-expr { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 0.78rem; color: var(--muted); min-height: 1rem; word-break: break-all; }
.calc-result { font-family: ui-monospace, Menlo, monospace; font-size: 1.5rem; font-weight: 700; color: var(--fg); word-break: break-all; }
.calc-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.3rem; }
.calc-btn { font-family: -apple-system, sans-serif; font-size: 0.85rem; color: var(--fg); background: var(--panel); border: 1px solid var(--border); border-radius: 5px; padding: 0.55rem 0; cursor: pointer; }
.calc-btn:hover { border-color: var(--c); }
.calc-btn:active { background: var(--bg2); }
.calc-btn.fn { color: var(--c); font-size: 0.74rem; }
.calc-btn.op { color: #79b6e0; }
.calc-btn.clear { color: #d9746b; }
.calc-btn.eq { background: var(--c); color: #11161f; border-color: var(--c); font-weight: 700; }
.calc-btn.wide { grid-column: span 2; }

/* ── The dock: tools that sit above the page, not inside it ──────────────
   Top-right, opposite the hub pill at top-left. */
.dock {
  position: fixed; top: 0.6rem; right: 0.6rem; z-index: 99998;
  display: flex; gap: 0.4rem;
}
/* Icon-only and round: the two tools are recognisable by their glyph, so the
   words next to them were only taking up the corner. */
.dock-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.15rem; height: 2.15rem; padding: 0;
  color: var(--fg); background: color-mix(in srgb, var(--gold) 16%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--gold) 40%, transparent);
  border-radius: 50%; cursor: pointer;
  box-shadow: 0 2px 10px -4px rgba(0,0,0,0.5);
  transition: transform 0.12s, border-color 0.2s, background 0.2s;
}
.dock-btn svg { width: 1.08rem; height: 1.08rem; display: block; }
.dock-btn:hover { transform: translateY(-1px); border-color: var(--gold);
  background: color-mix(in srgb, var(--gold) 26%, var(--panel)); }
.dock-btn[aria-expanded="true"] {
  background: color-mix(in srgb, var(--gold) 32%, var(--panel)); border-color: var(--gold); }

.dock-panel {
  position: fixed; top: 3.3rem; right: 0.6rem; z-index: 99997;
  width: 19.5rem; display: none;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.7rem;
  box-shadow: 0 16px 40px -12px rgba(0,0,0,0.65);
  /* The keypad grew a row of inverse-trig keys; on a short window the panel
     scrolls rather than running off the bottom of the screen. */
  max-height: calc(100vh - 4.2rem); overflow-y: auto;
}
.dock-panel.open { display: block; }
.dock-head {
  display: flex; align-items: center; justify-content: space-between;
  font: 700 0.64rem/1 -apple-system, sans-serif; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 0.55rem;
}
.dock-close {
  font-size: 1.1rem; line-height: 1; color: var(--muted);
  background: none; border: none; cursor: pointer; padding: 0 0.2rem;
}
.dock-close:hover { color: var(--fg); }

/* The notepad is deliberately roomier than the calculator, and search wider
   still — its rows are two lines of prose, not digits. */
.dock-panel.notepad { width: 22rem; }
.dock-panel.search { width: 26rem; }

/* ── Lab-wide search: one stylesheet for the board box and the ⌘K palette ── */
.sbox { position: relative; margin: 0 auto 1.4rem; max-width: 34rem; }
.sbox-in {
  width: 100%; font-family: -apple-system, "Segoe UI", sans-serif; font-size: 0.86rem;
  color: var(--fg); background: #1a2433; border: 1px solid var(--border);
  border-radius: 6px; padding: 0.55rem 0.8rem; outline: none;
}
.sbox-in::placeholder { color: var(--muted); }
.sbox-in:focus { border-color: var(--gold); }
.sbox-res { max-height: 22rem; overflow-y: auto; margin-top: 0.4rem; }
.sbox-res:empty { display: none; }

.sr-hint { font-family: -apple-system, sans-serif; font-size: 0.74rem; color: var(--muted); padding: 0.5rem 0.2rem; }
.sr-group { margin-bottom: 0.5rem; }
.sr-room {
  display: flex; align-items: center; gap: 0.35rem;
  font-family: -apple-system, sans-serif; font-size: 0.6rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--c);
  padding: 0.3rem 0.2rem 0.25rem;
}
.sr-hit {
  display: block; text-decoration: none; border-left: 2px solid transparent;
  padding: 0.32rem 0.5rem; border-radius: 3px;
}
.sr-hit:hover, .sr-hit.on { background: color-mix(in srgb, var(--c) 16%, var(--panel)); border-left-color: var(--c); }
.sr-kind {
  font-family: -apple-system, sans-serif; font-size: 0.52rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-right: 0.4rem;
}
.sr-title { font-family: -apple-system, sans-serif; font-size: 0.8rem; color: var(--fg); }
.sr-sym { font-family: Georgia, serif; font-size: 0.95rem; color: var(--c); }
.sr-snip {
  display: block; font-family: -apple-system, sans-serif; font-size: 0.68rem;
  color: var(--muted); margin-top: 0.1rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pad {
  width: 100%; min-height: 15rem; resize: vertical;
  font-family: ui-monospace, "Cascadia Code", monospace; font-size: 0.82rem; line-height: 1.55;
  color: var(--fg); background: #1a2433; border: 1px solid var(--border);
  border-radius: 5px; padding: 0.6rem 0.7rem; outline: none;
}
.pad:focus { border-color: var(--gold); }
.pad-status { font-family: -apple-system, sans-serif; font-size: 0.68rem; color: var(--muted); margin-top: 0.35rem; }
.pad-out { display: flex; gap: 0.4rem; margin-top: 0.45rem; }
.pad-out .rt-btn { flex: 1; padding: 0.4rem 0.5rem; font-size: 0.72rem; }

/* The small secondary button. It was in room.css, but the dock renders it on
   the board too, where that stylesheet is never loaded — the same trap the
   calculator keys fell into. */
.rt-btn { font-family: -apple-system, sans-serif; font-size: 0.78rem; font-weight: 600; color: var(--muted);
  background: var(--panel); border: 1px solid var(--border); border-radius: 4px; padding: 0.45rem 0.8rem; cursor: pointer; }
.rt-btn:hover { color: var(--fg); border-color: var(--c); }
.rt-btn:disabled { opacity: 0.75; cursor: default; }
.rt-btn[aria-pressed="true"] { color: #11161f; background: var(--c); border-color: var(--c); }

@media (max-width: 520px) {
  /* Still a comfortable thumb target — 2rem plus the 0.4rem gap. */
  .dock-btn { width: 2rem; height: 2rem; }
  .dock-panel, .dock-panel.notepad { left: 0.6rem; right: 0.6rem; width: auto; }
}

/* Every lift, scale and slide in the app is decoration on top of a state
   change that is also carried by colour or a border, so all of it can go.
   Transitions are neutralised rather than removed so nothing depends on a
   transitionend that would never fire. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .tile:hover, .tile:focus-visible,
  .tile-center:hover, .tile-center:focus-visible,
  .hub-card:hover, .hub-card:focus-visible,
  .quick:hover, .quick:focus-visible,
  .dock-btn:hover, .pt-cell:hover, .pt-cell.sel,
  .symkey:hover, .ref-item:hover {
    transform: none !important;
  }
}

@media print {
  body { background: #fff; color: #000; }
  .page { max-width: none; padding: 0; }
  .dock, .dock-panel { display: none !important; }
}
