/* Enigma Viewer — DOM overlay on top of the WebGL canvas (DESIGN.md §6, §10). */

:root {
  --bg: #0d0f13;
  --card: rgba(22, 25, 31, 0.92);
  --ink: #e6e2d6;
  --muted: #9aa0aa;
  --amber: #ffb347;
  --cyan: #4fd6ff;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #c9a24b;
  font-synthesis: none;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must win over author display rules (id/class selectors
   otherwise override the UA `[hidden] { display:none }`). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  overflow: hidden;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

/* ---- top bar ---- */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  background: linear-gradient(180deg, rgba(0,0,0,0.55), transparent);
  pointer-events: none;
}
#topbar h1 { font-size: 18px; margin: 0; letter-spacing: 0.5px; }
#topbar h1 span { color: var(--accent); font-weight: 400; }
#topbar h1 .ver { color: var(--muted); font-size: 12px; font-weight: 400; letter-spacing: 0; }
#topbar .hint { color: var(--muted); font-size: 13px; }
#topbar #share {
  margin-left: auto;
  pointer-events: auto;
}

/* ---- side panels ---- */
#panel-left, #panel-right {
  position: fixed;
  top: 56px;
  bottom: 16px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 4px;
}
#panel-left { left: 14px; }
#panel-right { right: 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 24px rgba(0,0,0,0.35);
}

h2 { font-size: 14px; margin: 0 0 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); }

/* ---- form controls ---- */
.field { margin-bottom: 12px; }
.field > label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

select, input, button {
  background: #1a1d23;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  font: inherit;
}
input.mono { letter-spacing: 3px; text-transform: uppercase; width: 100%; }
button { cursor: pointer; transition: background 0.15s, border-color 0.15s; }
button:hover { background: #242833; border-color: var(--accent); }

.rotors { display: flex; gap: 8px; }
.rotors select { flex: 1; text-align: center; }

/* ---- plugboard mini-keyboard ---- */
.plug-grid {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 4px;
}
.plug-key {
  padding: 6px 0;
  font-size: 12px;
  border-radius: 6px;
}
.plug-key.plugged { background: #6c2a22; border-color: #cc5544; color: #fff; }
.plug-key sub { font-size: 0.62em; opacity: 0.92; margin-left: 1px; }
.plug-key.selecting { outline: 2px solid var(--amber); }
.plug-pairs { margin-top: 8px; color: var(--muted); font-size: 12px; min-height: 1em; }

.err {
  background: #5a2020;
  border: 1px solid #aa4444;
  color: #ffd6d6;
  padding: 6px 10px;
  border-radius: 8px;
  margin-bottom: 10px;
  font-size: 13px;
}

/* ---- transcript ---- */
.tx-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.tx-head > span { font-size: 14px; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); }
.tx-actions { display: flex; gap: 6px; }
.tx-actions button { font-size: 12px; padding: 4px 8px; }
.tx-row { display: flex; align-items: baseline; gap: 8px; margin: 4px 0; }
.tx-row label { width: 26px; color: var(--muted); font-size: 12px; }
.tx-row code {
  font-family: ui-monospace, Menlo, monospace;
  letter-spacing: 2px;
  overflow-x: auto;
  white-space: nowrap;
  flex: 1;
  padding-bottom: 4px;
}
.tx-out { color: var(--amber); }
.tx-expected { color: #9a8fd0; }   /* expected-but-not-yet-produced output */
.tx-reading { margin-top: 6px; border-top: 1px solid rgba(255,255,255,0.08); padding-top: 6px; }
.tx-reading .tx-row { align-items: flex-start; }
.tx-reading span { flex: 1; font-size: 12.5px; line-height: 1.5; white-space: normal; }
.tx-de { color: #d8d2c4; }
.tx-en { color: var(--muted); font-style: italic; }

/* ---- controls ---- */
.ctl-group { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.switch, .slider { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.cams { gap: 6px; }
.cams button { font-size: 12px; padding: 5px 9px; text-transform: capitalize; }
.step-bar { background: rgba(255,179,71,0.08); border-radius: 8px; padding: 8px 10px; }
.step-bar .caption { color: var(--amber); font-size: 13px; }

/* ---- webgl error ---- */
#webgl-error {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: start;
  max-width: 640px;
  margin: 0 auto;
  padding: 40px;
  color: var(--ink);
}
#webgl-error h2 { color: var(--amber); }
#webgl-error [data-reason] { color: var(--amber); font-size: 15px; }
#webgl-error .fix { color: var(--muted); }
#webgl-error ul { color: var(--muted); line-height: 1.6; }
#webgl-error code { color: var(--cyan); }

#walkthrough {
  position: fixed;
  top: 58px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: rgba(16, 26, 38, 0.95);
  border: 1px solid var(--cyan);
  color: #d9ecff;
  padding: 9px 18px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 10;
  max-width: 70vw;
}
#walkthrough.show { opacity: 1; transform: translateX(-50%) translateY(0); }

#toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(108, 42, 34, 0.95);
  border: 1px solid #ff7a5c;
  color: #ffe6df;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 10;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 920px) {
  #panel-left, #panel-right { position: static; width: auto; max-height: 40vh; }
  body { overflow: auto; }
}
