/* R.M.S. Titanic — loss model. Night-ocean exhibit chrome.
   Single committed dark theme: the subject is a moonless night at sea. */

:root {
  --bg: #070b12;
  --ink: #e9dfc8;
  --ink-dim: rgba(233, 223, 200, 0.58);
  --ink-faint: rgba(233, 223, 200, 0.28);
  --accent: #c9503c;
  --brass: #b08d4f;
  --panel: rgba(9, 14, 22, 0.82);
  --panel-line: rgba(233, 223, 200, 0.16);
  --serif: Georgia, 'Palatino Linotype', Palatino, 'Times New Roman', serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  overflow: hidden;
}

#sea {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

/* ---------------------------------------------------------------- chrome */
.hud { position: fixed; z-index: 5; pointer-events: none; }
.hud * { pointer-events: none; }
.hud .live, .hud .live * { pointer-events: auto; }

#topbar {
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px 0;
}

.masthead .over {
  font-size: 10px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--brass);
}
.masthead h1 {
  font-size: clamp(15px, 2.1vw, 21px);
  font-weight: 400;
  letter-spacing: 0.12em;
  font-variant: small-caps;
  text-wrap: balance;
}
.masthead .sub {
  font-size: 11px;
  font-style: italic;
  color: var(--ink-dim);
  margin-top: 2px;
}

#clockbox { text-align: center; }
#clock {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(20px, 3vw, 30px);
  letter-spacing: 0.08em;
}
#phase {
  font-size: 10px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-top: 2px;
}
#phase.alarm { color: var(--accent); }

/* gauges */
#gauges {
  top: 84px; right: 18px;
  width: 172px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  padding: 12px 14px;
  backdrop-filter: blur(3px);
}
.gauge .lab {
  font-size: 9px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.gauge .val {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  margin-top: 1px;
}
.gauge .val small { font-size: 10px; color: var(--ink-dim); }
.gauge .bar {
  height: 3px;
  background: rgba(233, 223, 200, 0.12);
  margin-top: 4px;
  position: relative;
  overflow: hidden;
}
.gauge .bar i {
  position: absolute; inset: 0 auto 0 0;
  width: 0%;
  background: var(--brass);
  transition: width 0.3s linear;
}
.gauge .bar.flood i { background: #3f88ae; }
.gauge .bar.air i { background: #9fd7de; }
.gauge.crit .val { color: var(--accent); }

/* caption + controls */
#bottombar {
  left: 0; right: 0; bottom: 0;
  padding: 0 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#caption {
  align-self: center;
  max-width: 760px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  padding: 8px 22px 9px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.5s, transform 0.5s;
}
#caption.show { opacity: 1; transform: none; }
#caption .num {
  font-size: 9px;
  letter-spacing: 0.3em;
  color: var(--brass);
  text-transform: uppercase;
}
#caption .txt { font-size: 14px; font-style: italic; line-height: 1.45; }
#caption.major { border-color: rgba(201, 80, 60, 0.55); }
#caption.major .num { color: var(--accent); }

#timeline { width: 100%; }
#rail {
  position: relative;
  height: 26px;
  cursor: pointer;
}
#rail .track {
  position: absolute; left: 0; right: 0; top: 12px;
  height: 2px;
  background: rgba(233, 223, 200, 0.22);
}
#rail .done {
  position: absolute; left: 0; top: 12px;
  height: 2px; width: 0;
  background: var(--brass);
}
#rail .tick {
  position: absolute; top: 9px;
  width: 1px; height: 8px;
  background: var(--ink-faint);
}
#rail .tick.major { background: var(--accent); height: 10px; top: 8px; }
#rail .knob {
  position: absolute; top: 13px;
  width: 11px; height: 11px;
  border: 1px solid var(--ink);
  background: var(--bg);
  transform: translate(-50%, -50%) rotate(45deg);
}
#rail .hourlab {
  position: absolute; top: 22px;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--ink-faint);
  transform: translateX(-50%);
}

#controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.btn {
  font-family: var(--serif);
  font-variant: small-caps;
  letter-spacing: 0.14em;
  font-size: 13px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--panel-line);
  padding: 6px 16px;
  cursor: pointer;
}
.btn:hover { border-color: var(--brass); }
.btn:focus-visible, .seg button:focus-visible {
  outline: 1px solid var(--brass);
  outline-offset: 2px;
}
.seg {
  display: flex;
  border: 1px solid var(--panel-line);
  background: var(--panel);
}
.seg button {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-dim);
  background: none;
  border: 0;
  padding: 6px 10px;
  cursor: pointer;
}
.seg button.on { color: var(--bg); background: var(--brass); }
.seg .cap {
  font-family: var(--serif);
  font-variant: small-caps;
  letter-spacing: 0.12em;
  font-size: 12px;
}
#controls .spacer { flex: 1; }
#controls .note {
  font-size: 10px;
  font-style: italic;
  color: var(--ink-faint);
}

/* compartment tooltip */
#tip {
  position: fixed;
  z-index: 8;
  pointer-events: none;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  padding: 8px 12px;
  max-width: 240px;
  opacity: 0;
  transition: opacity 0.15s;
}
#tip.show { opacity: 1; }
#tip .name { font-variant: small-caps; letter-spacing: 0.08em; font-size: 13px; }
#tip .row {
  display: flex; justify-content: space-between; gap: 18px;
  font-family: var(--mono); font-size: 10.5px;
  color: var(--ink-dim);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
#tip .row b { color: var(--ink); font-weight: 400; }
#tip .imploded { color: var(--accent); font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; margin-top: 4px; }

/* ------------------------------------------------------------- overlay */
#intro {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 38%, rgba(10, 17, 28, 0.6), rgba(4, 7, 12, 0.94) 75%);
  transition: opacity 0.9s;
}
#intro.gone { opacity: 0; pointer-events: none; }
.plate {
  max-width: 560px;
  text-align: center;
  padding: 40px 44px;
  border: 1px solid var(--panel-line);
  outline: 1px solid rgba(233, 223, 200, 0.05);
  outline-offset: 5px;
  background: rgba(7, 11, 18, 0.72);
}
.plate .over {
  font-size: 10px; letter-spacing: 0.42em;
  text-transform: uppercase; color: var(--brass);
}
.plate h2 {
  font-size: clamp(26px, 5vw, 40px);
  font-weight: 400;
  font-variant: small-caps;
  letter-spacing: 0.1em;
  margin: 10px 0 4px;
  text-wrap: balance;
}
.plate .rule {
  width: 64px; height: 1px;
  background: var(--brass);
  margin: 14px auto;
}
.plate p {
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--ink-dim);
  font-style: italic;
  max-width: 46ch;
  margin: 0 auto;
}
.legend {
  display: flex; justify-content: center; gap: 18px;
  margin: 20px 0 6px;
  flex-wrap: wrap;
}
.legend span {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
  display: inline-flex; align-items: center; gap: 6px;
}
.legend i { width: 14px; height: 8px; display: inline-block; }
.legend .k-breach { background: var(--accent); height: 3px; }
.legend .k-water { background: linear-gradient(#3f88ae, #1d4a66); }
.legend .k-air { background: #cfeef2; opacity: 0.85; }
.legend .k-air2 { background: radial-gradient(circle at 50% 50%, #fff, #9fd7de); border-radius: 50%; width: 9px; height: 9px; }
#begin {
  margin-top: 18px;
  font-size: 15px;
  padding: 10px 30px;
}
#begin[disabled] { opacity: 0.45; cursor: wait; }
.plate .hint { margin-top: 12px; font-size: 10px; font-style: normal; letter-spacing: 0.14em; color: var(--ink-faint); text-transform: uppercase; }

@media (max-width: 900px) {
  #gauges { display: none; }
  .masthead .sub { display: none; }
}
@media (max-width: 620px) {
  #topbar { padding: 10px 12px 0; gap: 8px; }
  #topbar > div:last-child { display: none; }
  .masthead { max-width: 46vw; }
  .masthead .over { display: none; }
  .masthead h1 { font-size: 14px; letter-spacing: 0.06em; }
  #clockbox { text-align: right; }
  #clock { font-size: 19px; }
  #phase { letter-spacing: 0.16em; }
  #controls { gap: 8px; }
  .seg button { padding: 5px 7px; }
  #caption .txt { font-size: 12px; }
  #controls .note { display: none; }
}
@media (hover: none) {
  #controls .note { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  #caption, #intro, #tip { transition: none; }
}
