/* ── TempleOS VGA-16 design tokens ─────────────────────────────
   TempleOS is famously WHITE, not black. Palette is the real
   VGA 16: this page uses white paper, black ink, and the loud
   saturated accents exactly as DolDoc does.                    */
:root {
  --white:  #FFFFFF;
  --black:  #000000;
  --blue:   #0000AA;
  --ltblue: #5555FF;
  --red:    #AA0000;
  --ltred:  #FF5555;
  --green:  #00AA00;
  --purple: #AA00AA;
  --yellow: #FFFF55;
  --ltgray: #AAAAAA;
  --dkgray: #555555;

  --font-term: 'VT323', 'Courier New', monospace;
  --font-disp: 'Press Start 2P', 'VT323', monospace;
}

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

/* The [hidden] attribute must win over element display rules (.controls,
   .keybar, etc. set display:flex, which would otherwise show them pre-boot). */
[hidden] { display: none !important; }

html { background: var(--white); }

body {
  font-family: var(--font-term);
  font-size: 22px;
  line-height: 1.35;
  color: var(--black);
  background: var(--white);
  /* faint scanline texture, barely-there */
  background-image: repeating-linear-gradient(
    to bottom, transparent 0 3px, rgba(0,0,0,0.015) 3px 4px);
}

a { color: var(--blue); }
a:focus-visible, button:focus-visible { outline: 3px solid var(--purple); outline-offset: 2px; }

code {
  font-family: var(--font-term);
  color: var(--green);
  background: transparent;
}

/* ── Title bar (the blue TempleOS window chrome) ─────────────── */
.titlebar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  background: var(--blue);
  color: var(--yellow);
  padding: 4px 12px;
  font-size: 20px;
  position: sticky;
  top: 0;
  z-index: 10;
  white-space: nowrap;
  overflow: hidden;
}

main { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* ── The shrine (emulator) ───────────────────────────────────── */
.shrine {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 0 12px;
}

.shrine-frame {
  border: 4px double var(--blue);
  padding: 6px;
  background: var(--black);
  max-width: 100%;
}

#screen_container {
  position: relative;
  width: 640px;
  height: 480px;
  background: var(--black);
  
  max-width: 100%;
}
#screen_container.scale2 { width: 1280px; height: 960px; }
#screen_container iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--black);
}
#screen_container:fullscreen { width: 100vw; height: 100vh; }
#screen_container:fullscreen iframe { width: 100vw; height: 100vh; }

/* Boot overlay — styled as a TempleOS dialog on the dark screen */
#boot_overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--black);
  color: var(--white);
  text-align: center;
  cursor: default;
  padding: 20px;
}
.temple-art {
  width: 128px;
  height: auto;
  display: block;
}
.overlay-title {
  font-family: var(--font-disp);
  font-size: 18px;
  color: var(--ltblue);
  letter-spacing: 2px;
}
.overlay-sub { color: var(--ltgray); font-size: 20px; }
.overlay-hint { color: var(--dkgray); font-size: 18px; }

#focus_hint {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--blue);
  color: var(--yellow);
  padding: 2px 10px;
  font-size: 18px;
  pointer-events: none;
}

/* ── Buttons: TempleOS renders buttons as <TEXT> in inverse ──── */
.tos-btn {
  font-family: var(--font-term);
  font-size: 22px;
  background: var(--white);
  color: var(--blue);
  border: 2px solid var(--blue);
  padding: 2px 14px;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--blue);
}
.tos-btn:hover:not(:disabled) { background: var(--blue); color: var(--yellow); }
.tos-btn:active:not(:disabled) { box-shadow: 0 0 0; transform: translate(3px,3px); }
.tos-btn:disabled { color: var(--ltgray); border-color: var(--ltgray); box-shadow: 3px 3px 0 var(--ltgray); cursor: default; }

.tos-btn-big {
  font-size: 28px;
  padding: 6px 22px;
  background: var(--black);
  color: var(--yellow);
  border-color: var(--yellow);
  box-shadow: 3px 3px 0 var(--yellow);
  animation: blink-border 1.2s steps(1) infinite;
}
@keyframes blink-border {
  50% { border-color: var(--dkgray); box-shadow: 3px 3px 0 var(--dkgray); }
}
@media (prefers-reduced-motion: reduce) {
  .tos-btn-big { animation: none; }
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 14px 0 4px;
  justify-content: center;
}
.ctl-note { color: var(--dkgray); font-size: 19px; }

/* ── DolDoc sections ─────────────────────────────────────────── */
.doldoc {
  border-top: 4px double var(--ltgray);
  padding: 26px 0 30px;
}
.doldoc h2 {
  font-family: var(--font-disp);
  font-size: 16px;
  color: var(--black);
  margin-bottom: 18px;
  letter-spacing: 1px;
}
.doldoc h3 {
  font-size: 24px;
  margin-bottom: 8px;
  font-weight: normal;
}
.doldoc p, .doldoc ul { margin-bottom: 12px; }
.doldoc ul { padding-left: 22px; }
.small { font-size: 19px; color: var(--dkgray); }

.fg-blue   { color: var(--ltblue); font-size: 15px; }
.fg-purple { color: var(--purple); }
.fg-yellow-on-blue { background: var(--blue); color: var(--yellow); padding: 2px 8px; }

.cols { display: flex; gap: 34px; flex-wrap: wrap; }
.col { flex: 1 1 280px; min-width: 260px; }
.col.wide { flex: 2 1 480px; }

table.cmds { border-collapse: collapse; margin-bottom: 12px; }
table.cmds td { padding: 2px 14px 2px 0; vertical-align: top; }
table.cmds td:last-child { color: var(--dkgray); }

/* ── Oracle ──────────────────────────────────────────────────── */
.oracle-row { display: flex; align-items: center; gap: 18px; min-height: 44px; flex-wrap: wrap; }
#oracle_out { font-size: 26px; letter-spacing: 1px; }
#oracle_out .w { margin-right: 14px; }

/* ── Footer ──────────────────────────────────────────────────── */
footer {
  margin-top: 20px;
  padding: 14px 16px 40px;
  text-align: center;
  font-size: 20px;
}

/* ── Small screens ───────────────────────────────────────────── */
@media (max-width: 700px) {
  body { font-size: 19px; }
  /* Before boot, the overlay content defines the height so nothing
     spills over the sections below. Once the emulator starts (the
     overlay is removed), the canvas keeps a 4:3 box. */
  #screen_container { width: 100%; height: auto; min-height: 0; }
  #screen_container:not(:has(#boot_overlay)) { aspect-ratio: 4 / 3; }
  #screen_container.scale2 { width: 100%; }
  #boot_overlay { position: static; min-height: 0; padding: 28px 14px; }
  .temple-art { width: 96px; }
  .overlay-title { font-size: 14px; }
  .overlay-sub { font-size: 18px; }
  .tos-btn-big { font-size: 21px; padding: 5px 14px; }
  .titlebar-right { display: none; }
}


/* ── Key bar: special keys + mobile text bridge ─────────────── */
.keybar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 6px 0 2px;
  max-width: 100%;
}
.keybar-label { color: var(--dkgray); font-size: 18px; }
.demonote {
  max-width: 640px;
  margin: 2px auto 4px;
  padding: 0 8px;
  text-align: center;
  font-size: 16px;
  line-height: 1.3;
  color: var(--dkgray);
}
.demonote b { color: var(--red); }
.tos-key {
  font-family: var(--font-term);
  font-size: 19px;
  background: var(--white);
  color: var(--purple);
  border: 2px solid var(--purple);
  padding: 1px 10px;
  cursor: pointer;
}
.tos-key:hover { background: var(--purple); color: var(--white); }
#vm_input {
  font-family: var(--font-term);
  font-size: 19px;
  border: 2px solid var(--dkgray);
  padding: 2px 8px;
  width: 200px;
  color: var(--black);
  background: var(--white);
}
#vm_input:focus { outline: 2px solid var(--blue); }

/* ── CRT effect (optional, off by default) ──────────────────── */
.crt iframe {
  filter: contrast(1.06) saturate(1.15) brightness(1.02);
}
.crt::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom,
      rgba(0,0,0,0.13) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}


/* ── Header ornaments (replaces literal DolDoc $FG$ tags) ────── */
.hdr-orn { color: var(--ltblue); }

/* ── Memorial footer with rotating quotes ───────────────────── */
footer { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.memorial { display: inline-block; }
.terry-quote {
  font-size: 24px;
  max-width: 720px;
  min-height: 2.6em;
  margin: 0;
}
.terry-quote cite {
  display: block;
  font-style: normal;
  font-size: 18px;
  color: var(--dkgray);
  margin-top: 2px;
}
.memorial-note {
  max-width: 720px;
  font-size: 18px;
  color: var(--dkgray);
}


/* ── Boot progress bar (TempleOS blue dialog style) ─────────── */
#boot_progress {
  width: 320px;
  max-width: 80%;
  border: 2px solid var(--yellow);
  height: 26px;
  position: relative;
  background: var(--black);
}
#boot_progress_fill {
  position: absolute; inset: 0;
  width: 0%;
  background: var(--blue);
  transition: width 0.15s steps(8);
}
#boot_progress_text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--yellow);
  font-size: 18px;
}

/* ── Demo buttons ────────────────────────────────────────────── */
.tos-demo {
  font-family: var(--font-term);
  font-size: 19px;
  background: var(--white);
  color: var(--green);
  border: 2px solid var(--green);
  padding: 1px 10px;
  cursor: pointer;
}
.tos-demo:hover { background: var(--green); color: var(--white); }

/* ── Guided tour panel ───────────────────────────────────────── */
#tour {
  width: 100%;
  max-width: 656px;
  border: 4px double var(--blue);
  background: var(--white);
  margin-top: 12px;
  padding: 0 0 10px;
}
.tour-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--blue);
  color: var(--yellow);
  padding: 3px 10px;
  font-size: 20px;
}
#tour p { padding: 12px 14px 6px; margin: 0; }
.tour-actions {
  display: flex;
  gap: 10px;
  padding: 4px 14px 0;
  flex-wrap: wrap;
}
#tour_type { color: var(--green); border-color: var(--green); }
#tour_type:hover { background: var(--green); color: var(--white); }

/* ── File dock ───────────────────────────────────────────────── */
.filedock select {
  font-family: var(--font-term);
  font-size: 19px;
  border: 2px solid var(--dkgray);
  background: var(--white);
  color: var(--black);
  padding: 1px 6px;
  max-width: 220px;
}
