/* Altair 8800 front-panel emulator — museum presentation */

:root {
  --bg0: #1a1612;
  --bg1: #2a241c;
  --ink: #efe8d8;
  --muted: #b7ae9c;
  --accent: #c9a45c;
  --panel: #2c2d29;
  --panel-hi: #3a3b36;
  --silk: #e6e1d2;
  --blue: #4e8fc4;
  --blue-dk: #2f6a9a;
  --blue-hi: #7eb3d8;
  --led-off: #3a1212;
  --led-on: #ff3a2a;
  --led-core: #ffd0a8;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { height: 100%; }
body {
  min-height: 100%;
  color: var(--ink);
  font-family: "Noto Sans TC", "Barlow Condensed", "Segoe UI", sans-serif;
  background:
    radial-gradient(1200px 600px at 50% 18%, #3a3228 0%, transparent 55%),
    radial-gradient(800px 500px at 80% 100%, #1c1814 0%, transparent 50%),
    linear-gradient(180deg, #241e18 0%, #14110e 100%);
  line-height: 1.55;
}

.bg-grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.9'/%3E%3C/svg%3E");
  z-index: 0;
}

.page {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
  padding: 1.1rem 1.1rem 2.5rem;
}

header.site {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem 1.5rem;
  margin-bottom: 0.9rem;
}
header.site h1 {
  margin: 0;
  font-family: "Oswald", "Noto Sans TC", sans-serif;
  font-weight: 600;
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  letter-spacing: 0.06em;
}
header.site .sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}
header.site .sub em { font-style: normal; color: var(--accent); }

/* ---------- chassis ---------- */
.machine-wrap {
  width: min(100%, calc((100svh - 7.2rem) * 2.18));
  margin: 0 auto;
}
.chassis {
  position: relative;
  width: 100%;
  filter: drop-shadow(0 22px 36px rgba(0, 0, 0, 0.55));
}
.case-top {
  height: 14px;
  margin: 0 10px;
  border-radius: 3px 3px 0 0;
  background:
    linear-gradient(180deg, #efebe0 0%, #cfc8b6 55%, #b4ad9a 100%);
  box-shadow: inset 0 1px 0 #fff8, 0 1px 0 #0004;
  transform: perspective(280px) rotateX(48deg);
  transform-origin: bottom center;
}
.case-front {
  position: relative;
  z-index: 1;
}
.bezel {
  container-type: inline-size;
  background:
    linear-gradient(180deg, var(--blue-hi) 0%, var(--blue) 18%, var(--blue-dk) 60%, #2a5d86 100%);
  border-radius: 3px;
  padding: 11px 12px 10px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    inset 0 -2px 3px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(0, 0, 0, 0.35);
}
.panel {
  position: relative;
  container-type: inline-size;
  aspect-ratio: 2.4656 / 1;
  background:
    radial-gradient(120% 80% at 50% 0%, #40413c 0%, transparent 50%),
    linear-gradient(180deg, #35362f 0%, var(--panel) 40%, #252621 100%);
  box-shadow:
    inset 0 0 0 1px #0008,
    inset 0 8px 18px rgba(0, 0, 0, 0.25),
    inset 0 -6px 12px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}
.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.11;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}
.case-cheek {
  display: none; /* reserved; bezel already frames the plate */
}

/* nameplate */
.nameplate {
  margin-top: 0;
  height: 52px;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,0.04) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, #ece9e1 0%, #c5c1b6 18%, #a9a59a 48%, #d2cfc6 72%, #8f8b80 100%);
  box-shadow:
    inset 0 2px 2px rgba(255, 255, 255, 0.55),
    inset 0 -2px 3px rgba(0, 0, 0, 0.28),
    0 1px 0 #0004;
  color: #161616;
  display: flex;
  align-items: center;
  overflow: hidden;
}
.np-inner {
  display: flex;
  align-items: baseline;
  gap: 1.4cqi;
  padding: 0 3.2cqi 0 2.4cqi;
  width: 100%;
  white-space: nowrap;
}
.mits-logo {
  width: 7.4cqi;
  height: 2.3cqi;
  flex: 0 0 auto;
  overflow: visible;
}
.mits-word {
  font-family: "Oswald", sans-serif;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.06em;
  fill: #141414;
}
.mits-bolt {
  fill: #141414;
}
.np-altair, .np-8800, .np-computer {
  font-family: "Oswald", "Impact", sans-serif;
  font-weight: 700;
  color: #141414;
  line-height: 1;
  transform: scaleY(1.08);
  display: inline-block;
}
.np-altair {
  font-size: 3.15cqi;
  letter-spacing: 0.14em;
  font-weight: 700;
}
.np-8800 {
  font-size: 3.35cqi;
  letter-spacing: 0.08em;
  font-weight: 700;
}
.np-computer {
  font-size: 2.15cqi;
  letter-spacing: 0.22em;
  font-weight: 500;
  margin-left: 0.3cqi;
}

/* silkscreen overlay */
.silk {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}
.silk-dash {
  fill: none;
  stroke: var(--silk);
  stroke-width: 1.1;
  stroke-dasharray: 1.6 2.4;
  stroke-linecap: butt;
  opacity: 0.82;
}
.silk-rule {
  fill: none;
  stroke: var(--silk);
  stroke-width: 1.35;
  opacity: 0.9;
}
.silk-text {
  fill: var(--silk);
  font-family: "Barlow Condensed", "Helvetica Neue", sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  opacity: 0.95;
}
.silk-text-left { font-size: 10.5px; letter-spacing: 0.08em; }

/* lamps */
.lamp {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 2;
  --b: 0;
  pointer-events: none;
}
.lamp-label {
  font-family: "Barlow Condensed", "Helvetica Neue", sans-serif;
  font-size: 1.12cqw;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--silk);
  margin-bottom: 0.28cqw;
  line-height: 1;
  white-space: nowrap;
  text-shadow: 0 1px 0 #0006;
}
.lamp-lens {
  width: 1.32cqw;
  height: 1.32cqw;
  min-width: 8px;
  min-height: 8px;
  border-radius: 50%;
  position: relative;
  background:
    radial-gradient(circle at 35% 30%,
      color-mix(in srgb, #6a2220 70%, #ff6248 calc(var(--b) * 100%)) 0%,
      color-mix(in srgb, #2a0c0c 80%, #c01008 calc(var(--b) * 100%)) 70%,
      #1a0808 100%);
  box-shadow:
    inset 0 -0.12cqw 0.15cqw #0008,
    inset 0 0.1cqw 0.12cqw rgba(255, 220, 200, calc(0.12 + var(--b) * 0.35)),
    0 0 calc(0.15cqw + var(--b) * 0.9cqw) calc(var(--b) * 0.25cqw) rgba(255, 50, 30, calc(var(--b) * 0.85)),
    0 0 calc(0.4cqw + var(--b) * 1.6cqw) calc(var(--b) * 0.15cqw) rgba(255, 40, 20, calc(var(--b) * 0.45)),
    0 0 0 0.07cqw #1a1a18;
}
.lamp-cap {
  position: absolute;
  left: 18%;
  top: 14%;
  width: 42%;
  height: 30%;
  border-radius: 50%;
  background: rgba(255, 230, 210, calc(0.18 + var(--b) * 0.55));
  filter: blur(0.08cqw);
  pointer-events: none;
}
.lamp.is-on .lamp-lens {
  background:
    radial-gradient(circle at 38% 32%,
      #ffe0c4 0%,
      #ff7a4a 28%,
      #ff2a18 62%,
      #8a0a08 100%);
}

/* paddles */
.paddle {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 4.2%;
  height: 16%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--silk);
  cursor: pointer;
  z-index: 3;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}
.paddle-ctrl, .paddle-power { height: 20%; }
.paddle:focus { outline: none; }
.paddle:focus-visible .paddle-nut {
  box-shadow: 0 0 0 2px #ffe08a, 0 1px 2px #000;
}
.paddle-hit {
  position: absolute;
  inset: 0;
  z-index: 4;
}
.paddle-body {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1.7cqw;
  height: 1.7cqw;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 2;
}
.paddle-nut {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, #f3f3f0 0%, #b4b4b0 38%, #7a7a76 62%, #3a3a38 100%);
  box-shadow:
    0 0.12cqw 0.18cqw #0009,
    inset 0 0.08cqw 0.08cqw #fff8,
    inset 0 -0.08cqw 0.1cqw #0006;
  z-index: 2;
}
.paddle-nut::after {
  content: "";
  position: absolute;
  left: 18%;
  top: 18%;
  right: 18%;
  bottom: 18%;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #2c2c2a, #111);
  box-shadow: inset 0 0 0 0.07cqw #666;
}
.paddle-bat-wrap {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1.05cqw;
  height: 1.05cqw;
  margin: -0.525cqw 0 0 -0.525cqw;
  perspective: 7cqw;
  z-index: 3;
}
.paddle-bat {
  position: absolute;
  left: 0;
  top: 50%;
  width: 1.05cqw;
  height: 2.7cqw;
  margin-top: -1.35cqw;
  border-radius: 0.28cqw;
  background:
    linear-gradient(90deg,
      #2a2a28 0%,
      #6e6e6a 14%,
      #c8c8c4 36%,
      #ffffff 50%,
      #b0b0ac 64%,
      #5a5a56 86%,
      #1c1c1a 100%);
  box-shadow:
    0 0.15cqw 0.25cqw rgba(0, 0, 0, 0.7),
    inset 0 0 0 0.05cqw rgba(255, 255, 255, 0.25);
  transform-origin: 50% 50%;
  transform: rotateX(0deg);
  transition: transform 90ms cubic-bezier(0.2, 0.7, 0.3, 1);
}
.paddle-shine {
  position: absolute;
  left: 28%;
  top: 8%;
  width: 22%;
  height: 70%;
  border-radius: 0.2cqw;
  background: linear-gradient(180deg, #fff, transparent 70%);
  opacity: 0.45;
}
.paddle.is-up .paddle-bat {
  transform: translateY(-1.05cqw) rotateX(22deg);
}
.paddle.is-down .paddle-bat {
  transform: translateY(1.05cqw) rotateX(-22deg);
}
.paddle.is-mid .paddle-bat {
  transform: translateY(0) scaleY(0.58);
}

/* Power bat: slightly cream, like some surviving units */
.paddle-power .paddle-bat {
  background:
    linear-gradient(90deg,
      #5a4e3c 0%,
      #b8a88a 16%,
      #f0e6ce 42%,
      #fffaf0 50%,
      #d8ccb4 64%,
      #8a7c64 86%,
      #3a3228 100%);
}

.sw-label, .sw-num {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-family: "Barlow Condensed", "Helvetica Neue", sans-serif;
  font-weight: 500;
  color: var(--silk);
  letter-spacing: 0.06em;
  white-space: nowrap;
  line-height: 1.05;
  pointer-events: none;
  text-align: center;
  z-index: 1;
}
.sw-num {
  top: -1.35cqw;
  font-size: 1.05cqw;
}
.sw-label-top {
  bottom: 62%;
  font-size: 1.05cqw;
  margin-bottom: 0.9cqw;
}
.sw-label-bot {
  top: 62%;
  font-size: 1.0cqw;
  margin-top: 0.85cqw;
}
.paddle-power .sw-label-top { bottom: 58%; font-size: 1.15cqw; }
.paddle-power .sw-label-bot { top: 58%; font-size: 1.15cqw; }

/* machine off: dim the plate a little */
.machine-wrap.is-off .lamp-lens {
  filter: grayscale(0.15) brightness(0.85);
}
.machine-wrap.is-off .panel {
  filter: brightness(0.96);
}

/* ---------- toolbar + help ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.7rem;
  align-items: center;
  margin: 1rem 0 0.4rem;
}
.toolbar button, .toolbar label.toggle {
  font-family: inherit;
  font-size: 0.92rem;
  border: 1px solid #6a5e4a;
  background: linear-gradient(180deg, #3a342c, #2a251f);
  color: var(--ink);
  padding: 0.38rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
}
.toolbar button:hover, .toolbar label.toggle:hover {
  border-color: var(--accent);
  background: linear-gradient(180deg, #4a4236, #322c24);
}
.toolbar button:active { transform: translateY(1px); }
.toolbar .speed {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.88rem;
}
.toolbar input[type="range"] { accent-color: var(--accent); width: 110px; }
.toolbar label.toggle { display: inline-flex; align-items: center; gap: 0.4rem; }
.toolbar .status-readout {
  margin-left: auto;
  font-family: "Barlow Condensed", ui-monospace, monospace;
  font-size: 0.98rem;
  letter-spacing: 0.06em;
  color: #d8c8a0;
  background: #161410;
  border: 1px solid #3a342c;
  border-radius: 6px;
  padding: 0.3rem 0.7rem;
}

.help {
  margin-top: 1.15rem;
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1.1rem 1.6rem;
  color: #ddd6c6;
  font-size: 0.95rem;
}
.help h2 {
  font-family: "Oswald", "Noto Sans TC", sans-serif;
  font-weight: 500;
  font-size: 1.15rem;
  letter-spacing: 0.08em;
  margin: 0 0 0.5rem;
  color: var(--accent);
}
.help h3 {
  margin: 0.9rem 0 0.3rem;
  font-size: 1rem;
  font-weight: 600;
}
.help p, .help li { margin: 0 0 0.45rem; }
.help ol, .help ul { margin: 0 0 0.5rem; padding-left: 1.2rem; }
.help code, .octal {
  font-family: "Barlow Condensed", ui-monospace, monospace;
  background: #0006;
  padding: 0.05em 0.35em;
  border-radius: 4px;
  letter-spacing: 0.04em;
}
.octal-block {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.82rem;
  background: #120f0c;
  border: 1px solid #3a342c;
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  overflow-x: auto;
  color: #e8dcc0;
  line-height: 1.45;
}
.note {
  color: var(--muted);
  font-size: 0.88rem;
}
footer.colophon {
  margin-top: 1.6rem;
  border-top: 1px solid #3a342c;
  padding-top: 0.8rem;
  color: var(--muted);
  font-size: 0.82rem;
}
footer.colophon a { color: #d4c29a; }

@media (max-width: 960px) {
  .help { grid-template-columns: 1fr; }
  .toolbar .status-readout { margin-left: 0; width: 100%; }
  .nameplate { height: 42px; }
  .page { padding: 0.7rem 0.6rem 1.8rem; }
}
@media (max-height: 560px) and (orientation: landscape) {
  header.site { margin-bottom: 0.25rem; }
  header.site h1 { font-size: 1.05rem; }
  header.site .sub { display: none; }
  .help { margin-top: 0.5rem; }
  .nameplate { height: 30px; }
  .case-top { height: 6px; }
  .bezel { padding: 7px 8px 6px; }
  .page { padding: 0.35rem 0.5rem 1rem; }
  .toolbar { margin-top: 0.45rem; }
}

@media (prefers-reduced-motion: reduce) {
  .paddle-bat { transition: none; }
}
