@import url('https://fonts.googleapis.com/css2?family=Fira+Mono:wght@400;500;700&display=swap');

:root {
  --fg: #ffb000;
  --fg-dim: rgba(255, 176, 0, 0.15);
  --fg-glow: rgba(255, 176, 0, 0.6);
}

:root[data-theme='green'] {
  --fg: #33ff33;
  --fg-dim: rgba(51, 255, 51, 0.15);
  --fg-glow: rgba(51, 255, 51, 0.6);
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: #000;
  color: var(--fg);
  font-family: 'Fira Mono', 'Courier New', monospace;
  font-size: 15px;
}

a {
  color: var(--fg);
  text-decoration: underline;
  font-family: inherit;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.tui {
  width: 100%;
  max-width: 990px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-shadow: 0 0 4px var(--fg-glow);
}

.tui-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  letter-spacing: 2px;
}

.tui-header-title {
  flex: 1;
  text-align: center;
}

.tui-footer {
  text-align: center;
  letter-spacing: 2px;
}

.tui-footer {
  font-size: 16px;
  opacity: 0.8;
}

.tui-copyright {
  margin-top: 6px;
  font-size: 13px;
  letter-spacing: 1px;
}

.tui-body {
  display: flex;
  gap: 16px;
  height: 600px;
}

.tui-panel {
  border: 2px solid var(--fg);
  box-shadow: 0 0 8px var(--fg-glow), inset 0 0 8px var(--fg-dim);
  padding: 12px;
  background: #000;
}

.tui-menu {
  flex: 0 0 210px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

.tui-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.tui-panel-title {
  border-bottom: 1px solid var(--fg);
  margin-bottom: 10px;
  padding-bottom: 6px;
  letter-spacing: 3px;
}

#menu-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.menu-item {
  padding: 6px 8px;
  cursor: pointer;
  white-space: nowrap;
}

.menu-item:hover {
  background: var(--fg-dim);
}

.menu-item.selected {
  background: var(--fg);
  color: #000;
  text-shadow: none;
  font-weight: bold;
}

.tui-content-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  line-height: 1.5;
}

.tui-content-body h1 {
  font-size: 24px;
  margin: 0 0 10px 0;
}

.tui-content-body ul {
  margin: 6px 0;
  padding-left: 20px;
}

.tui-content-body p {
  margin: 8px 0;
}

/* Posts & Pages (shared list/detail rendering) */
.doc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.doc-list-item {
  padding: 6px 8px;
  cursor: pointer;
}

.doc-list-item:hover {
  background: var(--fg-dim);
}

.doc-back {
  margin-bottom: 12px;
}

.doc-body h1,
.doc-body h2,
.doc-body h3 {
  margin: 14px 0 8px;
  line-height: 1.3;
}

.doc-body h1 {
  font-size: 24px;
}

.doc-body h2 {
  font-size: 20px;
}

.doc-body h3 {
  font-size: 17px;
}

.doc-body p {
  margin: 8px 0;
}

.doc-body ul,
.doc-body ol {
  margin: 6px 0;
  padding-left: 28px;
}

.doc-body blockquote {
  margin: 8px 0;
  padding-left: 12px;
  border-left: 2px solid var(--fg);
  opacity: 0.85;
}

.doc-body code {
  background: var(--fg-dim);
  padding: 1px 4px;
}

.doc-body pre {
  background: var(--fg-dim);
  padding: 8px 10px;
  overflow-x: auto;
  margin: 8px 0;
}

.doc-body pre code {
  background: none;
  padding: 0;
}

.doc-body hr {
  border: none;
  border-top: 1px solid var(--fg);
  margin: 14px 0;
  opacity: 0.6;
}

.blink {
  animation: blink 1s step-start infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.tui-content-body::-webkit-scrollbar {
  width: 10px;
}
.tui-content-body::-webkit-scrollbar-track {
  background: #000;
}
.tui-content-body::-webkit-scrollbar-thumb {
  background: var(--fg);
}

/* Adventure game */
.adv-transcript {
  white-space: pre-wrap;
  margin-bottom: 10px;
}

.adv-line {
  margin: 2px 0;
}

.adv-line.adv-cmd {
  opacity: 0.7;
}

.adv-line.adv-banner {
  font-weight: bold;
}

.adv-inputline {
  display: flex;
  align-items: center;
  position: sticky;
  bottom: 0;
  background: #000;
  padding-top: 4px;
}

.adv-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--fg);
  caret-color: var(--fg);
  font-family: inherit;
  font-size: inherit;
  text-shadow: 0 0 4px var(--fg-glow);
}

/* Happy Trails game */
.ht-hud {
  display: flex;
  gap: 20px;
  margin-bottom: 10px;
  letter-spacing: 1px;
}

.ht-canvas {
  display: block;
  border: 2px solid var(--fg);
  box-shadow: 0 0 8px var(--fg-glow), inset 0 0 8px var(--fg-dim);
  background: #000;
  outline: none;
  max-width: 100%;
}

.ht-help {
  margin-top: 10px;
  font-size: 13px;
  opacity: 0.75;
}

/* Langton's Ant automaton */
.la-description {
  margin-bottom: 10px;
  font-size: 13px;
  opacity: 0.85;
}

.la-hud {
  display: flex;
  gap: 20px;
  margin-bottom: 10px;
  letter-spacing: 1px;
}

.la-canvas {
  display: block;
  border: 2px solid var(--fg);
  box-shadow: 0 0 8px var(--fg-glow), inset 0 0 8px var(--fg-dim);
  background: #000;
  outline: none;
  max-width: 100%;
}

.la-help {
  margin-top: 10px;
  font-size: 13px;
  opacity: 0.75;
}

/* Rule 110 automaton */
.r110-hud {
  display: flex;
  gap: 20px;
  margin-bottom: 10px;
  letter-spacing: 1px;
}

.r110-canvas {
  display: block;
  border: 2px solid var(--fg);
  box-shadow: 0 0 8px var(--fg-glow), inset 0 0 8px var(--fg-dim);
  background: #000;
  outline: none;
  max-width: 100%;
}

.r110-help {
  margin-top: 10px;
  font-size: 13px;
  opacity: 0.75;
}

/* Conway's Game of Life automaton */
.gol-hud {
  display: flex;
  gap: 20px;
  margin-bottom: 10px;
  letter-spacing: 1px;
}

.gol-canvas {
  display: block;
  border: 2px solid var(--fg);
  box-shadow: 0 0 8px var(--fg-glow), inset 0 0 8px var(--fg-dim);
  background: #000;
  outline: none;
  max-width: 100%;
}

.gol-help {
  margin-top: 10px;
  font-size: 13px;
  opacity: 0.75;
}

/* Forest Fire automaton */
.ff-hud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-bottom: 10px;
  letter-spacing: 1px;
}

.ff-canvas {
  display: block;
  border: 2px solid var(--fg);
  box-shadow: 0 0 8px var(--fg-glow), inset 0 0 8px var(--fg-dim);
  background: #000;
  outline: none;
  max-width: 100%;
}

.ff-help {
  margin-top: 10px;
  font-size: 13px;
  opacity: 0.75;
}

/* Retro theme toggle switch */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  letter-spacing: 1px;
  opacity: 0.9;
}

.theme-toggle-label {
  user-select: none;
}

.theme-toggle-label.dim {
  opacity: 0.5;
}

.theme-switch {
  --switch-w: 52px;
  --switch-h: 26px;
  position: relative;
  width: var(--switch-w);
  height: var(--switch-h);
  border: 2px solid var(--fg);
  border-radius: 3px;
  background: linear-gradient(180deg, #1a1a1a, #000);
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.8), 0 0 6px var(--fg-glow);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.theme-switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(var(--switch-h) - 8px);
  height: calc(var(--switch-h) - 8px);
  background: var(--fg);
  box-shadow: 0 0 8px var(--fg-glow);
  border-radius: 2px;
  transition: left 0.15s ease-out;
}

.theme-switch[aria-checked='true'] .theme-switch-knob {
  left: calc(var(--switch-w) - (var(--switch-h) - 8px) - 6px);
}

.theme-switch:focus-visible {
  outline: 1px dashed var(--fg);
  outline-offset: 2px;
}

/* Mobile layout: stack the menu above the content instead of side-by-side. */
@media (max-width: 700px) {
  body {
    padding: 10px;
  }

  .tui-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .tui-header-title {
    font-size: 13px;
  }

  .tui-body {
    flex-direction: column;
    height: auto;
  }

  .tui-menu {
    flex: 0 0 auto;
    overflow-y: visible;
  }

  #menu-list {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
  }

  .menu-item {
    flex-shrink: 0;
  }

  .tui-content {
    flex: 1 1 auto;
    min-height: 360px;
  }
}
