/* POWERGEO shell: a dark, quiet room with one CRT and the front of a 1993 PC case. */

:root {
  --room: #0a0a0c;
  --room-glow: #15131a;
  --bezel: #3a3733;
  --bezel-edge: #211f1c;
  --bezel-light: #4a4641;
  --case: #2c2a27;
  --case-edge: #1a1917;
  --led-off: #2a0606;
  --led-on: #ff3b2f;
  --text: #a7a39b;
  --text-dim: #6c6963;
  --link: #c9c4ba;
  --gutter: 16px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

/* Author display rules (e.g. .dos { display: flex }) would otherwise override the hidden attribute. */
[hidden] { display: none !important; }

body {
  min-height: 100vh;
  background: radial-gradient(ellipse 90% 70% at 50% 30%, var(--room-glow) 0%, var(--room) 70%) fixed var(--room);
  color: var(--text);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  overflow-x: hidden;
}

.room {
  width: 100%;
  max-width: 100vw;
  margin: 0 auto;
  padding: 24px var(--gutter) 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

/* ---------- monitor ---------- */

/* The monitor sits on the desktop case; both share one width that fits the
   viewport width and the height left for the case and footer. */
.rig {
  width: min(100%, calc((100vh - 250px) * 4 / 3));
  min-width: min(100%, 320px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
}

.dos {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.monitor {
  width: 100%;
  transform-origin: 50% 50%;
}

.bezel {
  padding: 4.2% 4.2% 5.4%;
  border-radius: 18px;
  background: linear-gradient(170deg, var(--bezel-light) 0%, var(--bezel) 40%, var(--bezel-edge) 100%);
  box-shadow:
    0 30px 60px -20px rgba(0, 0, 0, 0.9),
    0 0 0 1px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.screen {
  position: relative;
  aspect-ratio: 4 / 3;
  width: 100%;
  border-radius: 10px / 12px;
  overflow: hidden;
  background: #050505;
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.9),
    inset 0 0 40px rgba(0, 0, 0, 0.9);
  cursor: default;
  outline: none;
}

.screen:focus-visible {
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.9),
    inset 0 0 40px rgba(0, 0, 0, 0.9),
    0 0 0 2px rgba(210, 200, 180, 0.55);
}

.screen canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  opacity: 0.96;
}

.screen.lit canvas {
  filter: saturate(1.05) contrast(1.02);
}

/* restrained scanlines, vignette, and phosphor glow */
.screen-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 100% 100% at 50% 50%, rgba(0, 0, 0, 0) 60%, rgba(0, 0, 0, 0.35) 100%),
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 2px, rgba(0, 0, 0, 0.14) 3px);
  mix-blend-mode: multiply;
}

.screen.lit::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 60px rgba(120, 140, 255, 0.07);
}

.boot {
  position: absolute;
  inset: 0;
  margin: 0;
  display: grid;
  place-items: center;
  color: #8f8b84;
  font: 13px/1.4 ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: 0.04em;
  background: #050505;
  transition: opacity 400ms ease;
}

.boot.gone { opacity: 0; pointer-events: none; }
.boot.failed { color: #d98a7a; white-space: pre-wrap; padding: 0 1em; text-align: center; }

/* The phone keyboard target: present, focusable, and invisible. */
.phone-input {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: 0;
  border: 0;
  opacity: 0.01;
  resize: none;
  overflow: hidden;
  font-size: 16px; /* 16px keeps iOS from zooming on focus */
  background: transparent;
  color: transparent;
  caret-color: transparent;
  pointer-events: none;
}

.monitor-foot {
  height: 14px;
  margin: 0 12%;
  border-radius: 0 0 10px 10px;
  background: linear-gradient(180deg, var(--bezel-edge), #151412);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding-right: 10%;
}

.power-led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6fbf5a;
  box-shadow: 0 0 6px 1px rgba(111, 191, 90, 0.6);
}

/* "Run again" lives on the case; space is reserved so nothing shifts when it appears. */
.exited {
  margin-left: auto;
  display: inline-flex;
}

.exited[hidden] {
  display: inline-flex;
  visibility: hidden;
}

.quiet-button {
  font: 12px/1.2 inherit;
  font-family: inherit;
  color: var(--link);
  background: transparent;
  border: 1px solid rgba(201, 196, 186, 0.3);
  border-radius: 4px;
  padding: 5px 10px;
  cursor: pointer;
  white-space: nowrap;
}

.quiet-button:hover { border-color: rgba(201, 196, 186, 0.7); }

/* ---------- the PC case front panel ---------- */

.case {
  width: 100%;
}

.drive-bay {
  flex: 0 1 110px;
  height: 5px;
  margin-left: 6px;
  border-radius: 1px;
  background: #14130f;
  box-shadow: inset 0 1px 1px #000, 0 1px 0 rgba(255, 255, 255, 0.05);
}

.case-panel {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 18px;
  border-radius: 4px 4px 8px 8px;
  background: linear-gradient(180deg, #343129 0%, var(--case) 50%, var(--case-edge) 100%);
  box-shadow:
    0 20px 40px -24px rgba(0, 0, 0, 0.9),
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 0 0 1px rgba(0, 0, 0, 0.6);
}

.led-display {
  display: inline-flex;
  gap: 4px;
  padding: 6px 8px;
  border-radius: 3px;
  background: #140404;
  box-shadow: inset 0 0 0 1px #000, inset 0 2px 6px rgba(0, 0, 0, 0.9);
}

.led-display svg {
  display: block;
  width: 16px;
  height: 28px;
}

.led-display .seg {
  fill: var(--led-off);
  transition: fill 120ms linear;
}

.led-display .seg.on {
  fill: var(--led-on);
  filter: drop-shadow(0 0 2px rgba(255, 59, 47, 0.8));
}

.turbo {
  appearance: none;
  position: relative;
  margin-left: 2px;
  padding: 0;
  width: 64px;
  height: 30px;
  border: 0;
  border-radius: 3px;
  background: linear-gradient(180deg, #d8d1c2 0%, #b9b2a3 60%, #9c9586 100%);
  box-shadow:
    0 3px 0 #6f695d,
    0 4px 0 1px #1a1917,
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: transform 90ms ease, box-shadow 90ms ease;
}

.turbo-cap {
  display: block;
  font: 600 10px/30px ui-sans-serif, system-ui, Helvetica, Arial, sans-serif;
  letter-spacing: 0.18em;
  color: #3b372f;
  text-align: center;
  user-select: none;
}

.turbo:hover { filter: brightness(1.05); }

.turbo:active,
.turbo[aria-pressed="true"] {
  transform: translateY(2px);
  box-shadow:
    0 1px 0 #6f695d,
    0 2px 0 1px #1a1917,
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.turbo:focus-visible {
  outline: 2px solid rgba(210, 200, 180, 0.7);
  outline-offset: 3px;
}

.case-led {
  width: 7px;
  height: 7px;
  border-radius: 1px;
}

.case-led-power {
  background: #6fbf5a;
  box-shadow: 0 0 6px 1px rgba(111, 191, 90, 0.55);
}

.case-led-hdd {
  background: #4a1208;
  transition: background 80ms linear, box-shadow 80ms linear;
}

.case-led-hdd.busy {
  background: var(--led-on);
  box-shadow: 0 0 6px 1px rgba(255, 59, 47, 0.6);
}

/* ---------- modern view ---------- */

/* Contract with web/src/modern: the root is an empty full-viewport element and
   the shell draws nothing on top of it. .pg-root fills it with position:absolute. */
.modern {
  position: fixed;
  inset: 0;
  z-index: 10;
  transition: opacity 300ms ease;
}

body.modern-active { overflow: hidden; }

.modern.faded { opacity: 0; }

/* ---------- transitions ---------- */

@keyframes crt-off {
  0%   { transform: scale(1, 1); filter: brightness(1); }
  35%  { transform: scale(1, 0.006); filter: brightness(2.2); }
  60%  { transform: scale(1, 0.006); filter: brightness(1.6); }
  100% { transform: scale(0, 0.006); filter: brightness(0.4); }
}

@keyframes crt-on {
  0%   { transform: scale(0, 0.006); filter: brightness(0.4); }
  40%  { transform: scale(1, 0.006); filter: brightness(2.2); }
  100% { transform: scale(1, 1); filter: brightness(1); }
}

.monitor.crt-off { animation: crt-off 520ms cubic-bezier(0.4, 0, 0.6, 1) forwards; }
.monitor.crt-on  { animation: crt-on 520ms cubic-bezier(0.4, 0, 0.6, 1) forwards; }

.dos.faded { opacity: 0; }
.dos { transition: opacity 300ms ease; }

@media (prefers-reduced-motion: reduce) {
  .monitor.crt-off,
  .monitor.crt-on { animation: none; }
  .boot { transition: none; }
}

/* ---------- footer ---------- */

.footer {
  margin-top: 6px;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
}

.footer p { margin: 2px 0; }

.footer a {
  color: var(--text);
  white-space: nowrap;
  text-decoration: none;
  border-bottom: 1px solid rgba(167, 163, 155, 0.35);
}

.footer a:hover { color: var(--link); border-bottom-color: var(--link); }

/* ---------- phones ---------- */

@media (max-width: 600px) {
  .room { padding-top: 14px; gap: 12px; }
  .monitor { width: 100%; }
  .bezel { padding: 3.6% 3.6% 4.6%; border-radius: 12px; }
  .screen { border-radius: 6px / 8px; }
  .case-panel { gap: 10px; padding: 10px 12px; }
  .drive-bay { display: none; }
  .quiet-button { font-size: 11px; padding: 4px 8px; }
  .footer { font-size: 11px; }
}
