/* SUL-1 Volcano Observatory — instrument-room styling. */

:root {
  --bg: #040705;
  --bg2: #050a08;
  --panel: #08110d;
  --panel2: #0a1512;
  --line: #17352a;
  --line2: #0f241c;
  --green: #35ff9a;
  --green-dim: rgba(53, 255, 154, 0.55);
  --amber: #ffb020;
  --red: #ff4d3d;
  --cyan: #46d9ff;
  --violet: #b58cff;
  --text: #b8d8c8;
  --muted: #6f8f80;
  --accent: var(--amber);
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

body {
  background:
    radial-gradient(1200px 700px at 50% -10%, rgba(20, 60, 45, 0.28), transparent 70%),
    var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}

body[data-alert="WATCH"] { --accent: var(--amber); }
body[data-alert="WARNING"] { --accent: var(--red); }
body[data-alert="NORMAL"] { --accent: var(--green); }

/* ---- ambient overlays -------------------------------------------------- */
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.16) 3px,
    rgba(0, 0, 0, 0) 4px
  );
  opacity: 0.5;
  mix-blend-mode: multiply;
}
.pulse-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 49;
  box-shadow: inset 0 0 0 2px transparent;
  animation: pulse 3.2s ease-in-out infinite;
}
body[data-alert="ADVISORY"] .pulse-overlay { animation-duration: 2.6s; }
body[data-alert="WATCH"] .pulse-overlay {
  animation-duration: 1.5s;
  box-shadow: inset 0 0 90px rgba(255, 176, 32, 0.14), inset 0 0 0 2px rgba(255, 176, 32, 0.22);
}
body[data-alert="WARNING"] .pulse-overlay {
  animation-duration: 0.85s;
  box-shadow: inset 0 0 130px rgba(255, 77, 61, 0.22), inset 0 0 0 3px rgba(255, 77, 61, 0.5);
}
@keyframes pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .pulse-overlay { animation: none; }
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--green);
  color: #04140c;
  padding: 8px 12px;
  z-index: 100;
}
.skip-link:focus { left: 8px; top: 8px; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ---- header ------------------------------------------------------------ */
.hdr {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel2), rgba(8, 17, 13, 0.6));
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(4px);
}
.hdr-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mark {
  color: var(--green);
  font-size: 26px;
  line-height: 1;
  text-shadow: 0 0 12px var(--green-dim);
}
.org {
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--green);
  text-shadow: 0 0 10px rgba(53, 255, 154, 0.35);
  font-size: 13px;
}
.site { color: var(--muted); font-size: 10px; letter-spacing: 0.08em; }
.hdr-center { display: flex; gap: 8px; align-items: center; flex: 0 0 auto; }
.hdr-right {
  margin-left: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 16px;
  font-size: 11px;
  text-align: right;
}
.clock { white-space: nowrap; }
.clock em { color: var(--muted); font-style: normal; font-size: 9px; }
.clock.dim { color: var(--muted); }
.clock b { color: var(--text); }

.badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 6px 10px;
  border-radius: 3px;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.badge.alert { color: var(--amber); background: rgba(255, 176, 32, 0.08); }
.badge.aviation { color: #ffd24a; background: rgba(255, 210, 74, 0.06); }
.badge.sim { color: var(--muted); background: transparent; }
body[data-alert="NORMAL"] .badge.alert { color: var(--green); background: rgba(53,255,154,0.07); }
body[data-alert="ADVISORY"] .badge.alert { color: #ffd24a; background: rgba(255,210,74,0.07); }
body[data-alert="WATCH"] .badge.alert { color: var(--amber); background: rgba(255,176,32,0.1); }
body[data-alert="WARNING"] .badge.alert { color: var(--red); background: rgba(255,77,61,0.12); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.45; } }

/* ---- controls ---------------------------------------------------------- */
.controls {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line2);
  flex-wrap: wrap;
  background: var(--bg2);
}
.ctl-label { color: var(--muted); font-size: 10px; letter-spacing: 0.16em; margin-right: 4px; }
.spacer { flex: 1 1 auto; }
.ctl-hint { color: var(--muted); font-size: 10px; }
button.ctl {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--text);
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 7px 10px;
  min-height: 34px;
  cursor: pointer;
}
button.ctl:hover { border-color: var(--green-dim); color: var(--green); }
button.ctl:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
button.ctl.active { border-color: var(--green); color: var(--green); background: rgba(53,255,154,0.08); }
button.ctl.auto[aria-pressed="true"] { border-color: var(--amber); color: var(--amber); background: rgba(255,176,32,0.08); }
button.ctl.primary { border-color: var(--red); color: #ffb0a8; }
button.ctl.primary:hover { background: rgba(255,77,61,0.12); color: #fff; }

/* ---- grid -------------------------------------------------------------- */
.grid {
  display: grid;
  gap: 10px;
  padding: 10px 12px;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-template-areas:
    "heli heli heli heli heli heli rsam rsam rsam tilt tilt tilt"
    "gas gas gas thermal thermal thermal flank flank flank sat sat sat"
    "health health health health catalog catalog catalog catalog interp interp interp interp"
    "sample sample sample sample forecast forecast forecast forecast alert alert alert alert"
    "log log log log log log log log log log log log";
  align-items: stretch;
}
.area-heli { grid-area: heli; }
.area-rsam { grid-area: rsam; }
.area-tilt { grid-area: tilt; }
.area-gas { grid-area: gas; }
.area-thermal { grid-area: thermal; }
.area-flank { grid-area: flank; }
.area-sat { grid-area: sat; }
.area-health { grid-area: health; }
.area-catalog { grid-area: catalog; }
.area-interp { grid-area: interp; }
.area-forecast { grid-area: forecast; }
.area-sample { grid-area: sample; }
.area-log { grid-area: log; }
.area-alert { grid-area: alert; }

.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg2));
  border: 1px solid var(--line2);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.panel-hd {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border-bottom: 1px solid var(--line2);
  background: rgba(53, 255, 154, 0.03);
}
.panel-hd .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green-dim);
  flex: 0 0 auto;
}
.panel-hd h2 {
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 0;
  color: var(--green);
  font-weight: 600;
}
.panel-meta { margin-left: auto; font-size: 9.5px; color: var(--muted); letter-spacing: 0.06em; white-space: nowrap; }
.panel-bd { position: relative; flex: 1 1 auto; min-height: 0; min-width: 0; }

canvas { display: block; width: 100%; height: 100%; }

.area-heli .panel-bd { height: 232px; }
.area-rsam .panel-bd, .area-tilt .panel-bd, .area-gas .panel-bd { height: 168px; }
.area-thermal .panel-bd, .area-flank .panel-bd, .area-sat .panel-bd { height: 176px; }
.area-interp .panel-bd { height: 268px; }
.area-sample .panel-bd { height: 268px; }
.area-forecast .panel-bd { height: 300px; }
.area-log .panel-bd { height: 240px; }

.readout {
  position: absolute;
  left: 8px; bottom: 6px;
  display: flex; align-items: baseline; gap: 5px;
  pointer-events: none;
  text-shadow: 0 0 8px rgba(0,0,0,0.9);
}
.readout .big { font-size: 22px; font-weight: 700; color: var(--green); }
.readout .big.amber { color: var(--amber); }
.readout .big.violet { color: var(--violet); }
.readout .unit { font-size: 10px; color: var(--muted); }
.readout .unit.dim { color: #55705f; }

/* ---- health grid ------------------------------------------------------- */
.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1px;
  background: var(--line2);
  height: 100%;
  overflow: auto;
}
.station {
  background: var(--panel);
  padding: 7px 9px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 6px;
  font-size: 10px;
}
.station .sid { color: var(--text); font-weight: 700; letter-spacing: 0.08em; }
.station .kind { grid-column: 1 / -1; color: var(--muted); font-size: 9px; }
.station .stat { font-weight: 700; }
.station .stat.OK { color: var(--green); }
.station .stat.DEGRADED { color: var(--amber); }
.station .stat.OFFLINE { color: var(--red); }
.station .bar { grid-column: 1 / -1; height: 4px; background: #0c1a15; border-radius: 2px; overflow: hidden; }
.station .bar i { display: block; height: 100%; background: var(--green); }
.station .bar i.warn { background: var(--amber); }
.station .bar i.bad { background: var(--red); }
.station .nums { grid-column: 1 / -1; color: var(--muted); font-size: 9px; display: flex; gap: 8px; }

/* ---- event catalog ----------------------------------------------------- */
.catalog { padding: 8px 10px; display: grid; gap: 8px; height: 100%; overflow: auto; }
.cat-row { display: grid; grid-template-columns: 118px 1fr 58px; gap: 8px; align-items: center; font-size: 10px; }
.cat-row .lbl { color: var(--muted); }
.cat-row .val { text-align: right; color: var(--text); font-weight: 700; }
.cat-track { height: 8px; background: #0c1a15; border-radius: 2px; overflow: hidden; }
.cat-track i { display: block; height: 100%; }

/* ---- anomaly interpretation ------------------------------------------- */
.interp { display: grid; grid-template-rows: 1fr 1fr; }
.anomaly-list, .evidence-list, .log-list {
  list-style: none; margin: 0; padding: 0; overflow: auto;
}
.anomaly-list { border-bottom: 1px solid var(--line2); }
.anomaly {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px 9px;
  border-bottom: 1px solid var(--line2);
  cursor: pointer;
  font-size: 10.5px;
}
.anomaly:hover { background: rgba(53, 255, 154, 0.05); }
.anomaly.selected { background: rgba(53, 255, 154, 0.09); box-shadow: inset 2px 0 0 var(--green); }
.anomaly .icon {
  font-size: 9px; font-weight: 700; padding: 2px 5px; border-radius: 2px;
  border: 1px solid currentColor;
}
.anomaly .txt { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.anomaly .mag { color: var(--muted); font-size: 9px; }
.anomaly.dismissed { opacity: 0.45; text-decoration: line-through; }
.anomaly.confirmed .mag { color: var(--green); }
.anomaly-detail { padding: 9px 10px; overflow: auto; font-size: 11px; }
.anomaly-detail h3 { margin: 0 0 4px; font-size: 11.5px; color: var(--green); letter-spacing: 0.05em; }
.anomaly-detail .ev { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; margin: 6px 0; }
.anomaly-detail .ev div { font-size: 10px; color: var(--text); }
.anomaly-detail .ev .n { color: var(--muted); grid-column: 1 / -1; font-size: 9px; }
.anomaly-detail blockquote {
  margin: 8px 0; padding: 6px 9px; border-left: 2px solid var(--amber);
  color: #d8e8de; font-size: 10.5px; background: rgba(255,176,32,0.05);
}
.anomaly-detail .who { color: var(--amber); font-size: 9.5px; }
.detail-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.placeholder { color: var(--muted); font-size: 10.5px; margin: 6px 0; }

/* ---- forecast ---------------------------------------------------------- */
.forecast { display: grid; grid-template-rows: 160px 1fr; }
#cv-forecast { height: 160px; }
.evidence-list { border-top: 1px solid var(--line2); }
.evidence-list li {
  display: grid; grid-template-columns: 1fr auto; gap: 6px;
  padding: 4px 9px; font-size: 10px; border-bottom: 1px solid var(--line2);
}
.evidence-list .w { color: var(--amber); }
.evidence-list .meta { grid-column: 1 / -1; color: var(--muted); font-size: 9px; }
.forecast-note { padding: 6px 9px; font-size: 9.5px; color: var(--muted); }

/* ---- rock samples ------------------------------------------------------ */
.sample { display: grid; grid-template-columns: 44% 56%; }
.sample-left { display: grid; grid-template-rows: 1fr auto; border-right: 1px solid var(--line2); min-width: 0; }
.sample-tabs { display: flex; flex-wrap: wrap; gap: 3px; padding: 5px; border-top: 1px solid var(--line2); }
.sample-tabs button {
  font-family: var(--mono); font-size: 9px; padding: 4px 6px; min-height: 28px;
  background: var(--panel2); color: var(--muted); border: 1px solid var(--line2); border-radius: 2px; cursor: pointer;
}
.sample-tabs button.active { color: var(--green); border-color: var(--green-dim); }
.sample-detail { padding: 9px 10px; overflow: auto; font-size: 10.5px; }
.sample-detail h3 { margin: 0 0 2px; color: var(--green); font-size: 12px; }
.sample-detail .sub { color: var(--muted); font-size: 9.5px; margin-bottom: 6px; }
.sample-detail dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; margin: 6px 0; }
.sample-detail dt { color: var(--muted); font-size: 9.5px; }
.sample-detail dd { margin: 0; font-size: 10px; }
.minerals { display: grid; gap: 3px; margin: 6px 0; }
.mineral { display: grid; grid-template-columns: 96px 1fr 32px; gap: 6px; align-items: center; font-size: 9.5px; }
.mineral .bar { height: 6px; background: #0c1a15; border-radius: 2px; overflow: hidden; }
.mineral .bar i { display: block; height: 100%; }
.sample-detail .thin { font-size: 10px; color: #cfe4d8; margin: 6px 0; }
.sample-detail .note { font-size: 10px; color: #d8e8de; border-left: 2px solid var(--cyan); padding-left: 8px; margin: 6px 0; }
.chem { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chem span { font-size: 9px; color: var(--muted); border: 1px solid var(--line2); border-radius: 2px; padding: 2px 4px; }

/* ---- shift log --------------------------------------------------------- */
.log { display: grid; grid-template-rows: 1fr auto; }
.log-list li {
  padding: 5px 9px; border-bottom: 1px solid var(--line2); font-size: 10px;
}
.log-list .top { display: flex; gap: 8px; align-items: baseline; }
.log-list .tag { font-size: 8.5px; font-weight: 700; letter-spacing: 0.08em; padding: 1px 4px; border-radius: 2px; border: 1px solid currentColor; }
.log-list .tag.HANDOVER { color: var(--cyan); }
.log-list .tag.ALERT { color: var(--red); }
.log-list .tag.ANOMALY { color: var(--amber); }
.log-list .tag.EVENT { color: var(--red); }
.log-list .tag.INSTRUMENT, .log-list .tag.PUBLISH { color: var(--violet); }
.log-list .tag.OBS { color: var(--green); }
.log-list .time { color: var(--muted); font-size: 9px; margin-left: auto; }
.log-list .who { color: var(--text); font-size: 9px; }
.log-list .body { color: #cfe4d8; margin-top: 2px; }
.log-form { display: flex; gap: 6px; padding: 6px; border-top: 1px solid var(--line2); }
.log-form input {
  flex: 1 1 auto; min-width: 0; font-family: var(--mono); font-size: 11px;
  background: #06100c; color: var(--text); border: 1px solid var(--line); border-radius: 3px; padding: 7px 8px; min-height: 34px;
}
.log-form input:focus-visible { outline: 2px solid var(--green); outline-offset: 0; }

/* ---- alert console ----------------------------------------------------- */
.alert-console { padding: 9px 10px; display: grid; gap: 8px; align-content: start; overflow: auto; }
.alert-row { display: flex; gap: 6px; flex-wrap: wrap; }
button.ctl.lvl { flex: 1 1 auto; }
button.ctl.lvl[data-level="NORMAL"].active { border-color: var(--green); color: var(--green); }
button.ctl.lvl[data-level="ADVISORY"].active { border-color: #ffd24a; color: #ffd24a; }
button.ctl.lvl[data-level="WATCH"].active { border-color: var(--amber); color: var(--amber); }
button.ctl.lvl[data-level="WARNING"].active { border-color: var(--red); color: var(--red); }
.decision-out { font-size: 10.5px; }
.decision-out p { margin: 4px 0; color: #cfe4d8; }
.decision-out .risk { color: var(--red); }
.decision-out .cost { color: var(--amber); }
.decision-out .ok { color: var(--green); }
.advisory-out {
  border: 1px solid var(--line); border-radius: 3px; padding: 8px 9px;
  background: rgba(255, 77, 61, 0.05); font-size: 10px; color: #e6f0ea; white-space: pre-wrap;
}
.advisory-out h4 { margin: 0 0 4px; color: var(--red); font-size: 10.5px; letter-spacing: 0.06em; }

/* ---- footer ------------------------------------------------------------ */
.foot {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px 22px; color: var(--muted); font-size: 9.5px;
  border-top: 1px solid var(--line2);
}

/* ---- responsive -------------------------------------------------------- */
@media (max-width: 1080px) {
  .grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "heli" "rsam" "tilt" "gas" "thermal" "flank" "sat"
      "health" "catalog" "interp" "forecast" "sample" "alert" "log";
  }
  .area-heli .panel-bd { height: 260px; }
  .area-rsam .panel-bd, .area-tilt .panel-bd, .area-gas .panel-bd { height: 190px; }
  .area-thermal .panel-bd, .area-flank .panel-bd, .area-sat .panel-bd { height: 220px; }
  .area-interp .panel-bd { height: 340px; }
  .area-sample .panel-bd { height: 420px; }
  .area-forecast .panel-bd { height: 380px; }
  .area-log .panel-bd { height: 300px; }
  .hdr-right { grid-template-columns: 1fr; text-align: left; }
  .hdr { position: static; }
}

@media (max-width: 560px) {
  body { font-size: 12.5px; }
  .hdr { padding: 8px 10px; gap: 8px; }
  .org { font-size: 11px; letter-spacing: 0.08em; }
  .hdr-right { font-size: 10px; }
  .grid { padding: 8px; gap: 8px; }
  button.ctl { min-height: 44px; font-size: 11.5px; }
  .sample { grid-template-columns: 1fr; }
  .sample-left { border-right: 0; border-bottom: 1px solid var(--line2); }
  .sample-tabs button { min-height: 44px; }
  .log-form input { min-height: 44px; }
  .area-sample .panel-bd { height: 640px; }
  .anomaly { padding: 9px; min-height: 44px; }
  .readout .big { font-size: 19px; }
}
