/* ═══════════════════════════════════════════════════
   Oregon Trail AI — Terminal Aesthetic
   ═══════════════════════════════════════════════════ */

:root {
  --amber: #ffb000;
  --bg: #0a0a0a;
  --dim: #665500;
  --border: #444;
  --critical: #ff3333;
  --low: #ff8800;
  --newspaper-bg: #f4e4c1;
  --newspaper-fg: #2a1a0a;
  --newspaper-rule: #8a7a6a;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--amber);
}

/* ── Terminal Shell ─────────────────────────────── */

#terminal {
  max-width: 80ch;
  margin: 0 auto;
  min-height: 100vh;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  line-height: 1.5;
  color: var(--amber);
  background: var(--bg);
  padding: 1ch;
  display: flex;
  flex-direction: column;
}

/* ── Top Bar ────────────────────────────────────── */

#top-bar {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding: 0.5ch 0;
  min-height: 2em;
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 0.5ch 2ch;
}

#top-bar:empty {
  display: none;
}

.top-bar-item {
  white-space: nowrap;
}

.top-bar-label {
  color: var(--dim);
}

/* ── Game Area ──────────────────────────────────── */

#game-area {
  display: flex;
  flex-direction: row;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Roster ─────────────────────────────────────── */

#roster {
  width: 20ch;
  border-right: 1px solid var(--border);
  padding-right: 1ch;
  flex-shrink: 0;
  overflow-y: auto;
  padding-top: 1ch;
}

#roster:empty {
  display: none;
  border-right: none;
}

.roster-header {
  color: var(--dim);
  margin-bottom: 0.5em;
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.roster-member {
  margin-bottom: 0.75em;
}

.roster-name {
  display: block;
  margin-bottom: 0.2em;
  font-size: 0.9em;
}

.roster-name.dead {
  text-decoration: line-through;
  color: var(--dim);
}

.roster-death-date {
  display: block;
  color: var(--dim);
  font-size: 0.75em;
}

.roster-stats {
  display: flex;
  gap: 0.5ch;
  font-size: 0.75em;
  color: var(--dim);
}

.health-bar {
  display: inline-block;
  width: 8ch;
  height: 1em;
  background: #222;
  vertical-align: middle;
  overflow: hidden;
}

.health-fill {
  display: block;
  height: 100%;
  background: var(--amber);
  transition: width 0.3s ease;
}

.health-fill.critical {
  background: var(--critical);
}

.health-fill.low {
  background: var(--low);
}

/* ── Narrative ──────────────────────────────────── */

#narrative {
  flex: 1;
  overflow-y: auto;
  padding-left: 1ch;
  padding-top: 1ch;
  padding-bottom: 2ch;
}

.narrative-block {
  margin-bottom: 1em;
}

.narrative-title {
  font-weight: 700;
  margin-bottom: 0.5em;
}

.narrative-text {
  margin-bottom: 0.5em;
}

.narrative-dim {
  color: var(--dim);
}

.narrative-italic {
  font-style: italic;
  color: var(--dim);
}

.narrative-separator {
  color: var(--border);
  margin: 1em 0;
}

/* ── Typing Cursor ──────────────────────────────── */

.typing-cursor::after {
  content: '\2588';
  animation: blink 0.7s step-end infinite;
  color: var(--amber);
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ── Loading Dots ───────────────────────────────── */

.loading-dots::after {
  content: '.';
  animation: dots 1.5s step-end infinite;
}

@keyframes dots {
  0%   { content: '.'; }
  33%  { content: '..'; }
  66%  { content: '...'; }
}

/* ── Choices ────────────────────────────────────── */

.choices {
  margin-top: 1em;
}

.choice {
  display: block;
  width: 100%;
  background: none;
  border: 1px solid var(--border);
  color: var(--amber);
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  padding: 0.5ch 1ch;
  margin-bottom: 0.5ch;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s, color 0.1s;
}

.choice:hover, .choice:focus {
  background: var(--amber);
  color: var(--bg);
  outline: none;
}

.choice:active {
  background: #cc8e00;
  color: var(--bg);
}

.choice-number {
  font-weight: 700;
  margin-right: 1ch;
}

.choice.disabled {
  color: var(--dim);
  border-color: #333;
  cursor: not-allowed;
}

.choice.disabled:hover {
  background: none;
  color: var(--dim);
}

/* ── Action Bar ─────────────────────────────────── */

#action-bar {
  border-top: 1px solid var(--border);
  padding: 0.5ch 0;
  flex-shrink: 0;
}

#action-bar:empty {
  display: none;
}

.action-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5ch 2ch;
}

.action-group {
  display: flex;
  align-items: center;
  gap: 1ch;
}

.action-label {
  color: var(--dim);
  font-size: 0.85em;
}

.action-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--amber);
  font-family: inherit;
  font-size: 0.85em;
  padding: 0.25ch 1ch;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.action-btn:hover {
  background: var(--amber);
  color: var(--bg);
}

.action-btn.active {
  background: var(--amber);
  color: var(--bg);
}

/* ── Title Screen ───────────────────────────────── */

.title-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
}

.title-ascii {
  white-space: pre;
  font-size: 0.85em;
  line-height: 1.2;
  margin-bottom: 2em;
  color: var(--amber);
}

.title-subtitle {
  color: var(--dim);
  margin-bottom: 2em;
  font-size: 0.9em;
}

.title-rumor {
  max-width: 60ch;
  margin-bottom: 2em;
  font-style: italic;
  color: var(--dim);
}

.title-prompt {
  animation: blink 1.2s step-end infinite;
}

.title-footer {
  position: fixed;
  bottom: 1ch;
  left: 0;
  right: 0;
  text-align: center;
  color: var(--dim);
  font-size: 0.75em;
}

/* ── Input ──────────────────────────────────────── */

.terminal-input-line {
  display: flex;
  align-items: center;
  margin: 0.5em 0;
}

.terminal-prompt {
  color: var(--dim);
  margin-right: 1ch;
  white-space: nowrap;
}

.terminal-input {
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--amber);
  font-family: inherit;
  font-size: inherit;
  outline: none;
  padding: 0.25ch 0;
  width: 20ch;
  caret-color: var(--amber);
}

.terminal-input:focus {
  border-bottom-color: var(--amber);
}

.terminal-input-done {
  color: var(--amber);
}

/* ── Store ──────────────────────────────────────── */

.store-grid {
  width: 100%;
}

.store-row {
  display: flex;
  align-items: center;
  padding: 0.5ch 0;
  border-bottom: 1px solid #222;
  gap: 1ch;
}

.store-item-name {
  width: 12ch;
  flex-shrink: 0;
}

.store-item-price {
  width: 10ch;
  flex-shrink: 0;
  color: var(--dim);
  font-size: 0.85em;
}

.store-qty-controls {
  display: flex;
  align-items: center;
  gap: 0.5ch;
}

.store-qty-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--amber);
  font-family: inherit;
  font-size: inherit;
  width: 3ch;
  height: 2em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, color 0.1s;
}

.store-qty-btn:hover {
  background: var(--amber);
  color: var(--bg);
}

.store-qty {
  width: 3ch;
  text-align: center;
}

.store-item-cost {
  width: 8ch;
  text-align: right;
  flex-shrink: 0;
}

.store-tooltip {
  color: var(--dim);
  font-size: 0.75em;
  flex: 1;
  text-align: right;
}

.store-total {
  display: flex;
  justify-content: space-between;
  padding: 1ch 0;
  border-top: 1px solid var(--border);
  margin-top: 0.5ch;
  font-weight: 700;
}

/* ── Day Summary ────────────────────────────────── */

.day-summary {
  margin-bottom: 0.5em;
  padding-left: 1ch;
  border-left: 1px solid #222;
}

.day-summary.event-day {
  border-left-color: var(--amber);
}

.day-date {
  color: var(--dim);
  font-size: 0.85em;
}

.day-event {
  margin-left: 1ch;
}

/* ── Death Screen ───────────────────────────────── */

.death-screen {
  text-align: center;
  padding: 4ch 0;
}

.death-separator {
  color: var(--dim);
  margin: 1em 0;
}

.death-name {
  font-weight: 700;
  font-size: 1.2em;
  margin-bottom: 0.5em;
}

.death-epitaph {
  font-style: italic;
  color: var(--dim);
  max-width: 50ch;
  margin: 1em auto;
  line-height: 1.6;
}

/* ── Box Drawing ────────────────────────────────── */

.box {
  margin: 1em 0;
}

.box-top::before { content: '\250C'; }
.box-top::after  { content: '\2510'; }
.box-bot::before { content: '\2514'; }
.box-bot::after  { content: '\2518'; }

.box-top, .box-bot {
  display: flex;
  color: var(--border);
}

.box-top::before, .box-top::after,
.box-bot::before, .box-bot::after {
  flex-shrink: 0;
}

.box-rule {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
}

.box-rule::before {
  content: '\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500\2500';
}

.box-mid {
  display: flex;
  color: var(--border);
}

.box-mid::before { content: '\2502'; flex-shrink: 0; }
.box-mid::after  { content: '\2502'; flex-shrink: 0; }

.box-content {
  flex: 1;
  padding: 0 1ch;
}

/* ── Arrival Screen ─────────────────────────────── */

.arrival-screen {
  text-align: center;
  padding: 2ch 0;
}

.arrival-title {
  font-weight: 700;
  font-size: 1.2em;
  margin-bottom: 1em;
}

.arrival-survivors {
  margin: 1em 0;
}

.arrival-score {
  font-weight: 700;
  font-size: 1.1em;
  margin: 1em 0;
}

/* ── Share Buttons ──────────────────────────────── */

.share-buttons {
  display: flex;
  gap: 1ch;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1em;
}

.share-btn {
  background: none;
  border: 1px solid var(--amber);
  color: var(--amber);
  font-family: inherit;
  font-size: 0.85em;
  padding: 0.5ch 2ch;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.share-btn:hover {
  background: var(--amber);
  color: var(--bg);
}

/* ── Newspaper Overlay ──────────────────────────── */

#newspaper-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  overflow-y: auto;
  padding: 2rem;
}

#newspaper-overlay.hidden {
  display: none;
}

.newspaper {
  background: var(--newspaper-bg);
  color: var(--newspaper-fg);
  font-family: Georgia, 'Times New Roman', serif;
  max-width: 1200px;
  width: 100%;
  padding: 2rem;
  position: relative;
}

.newspaper-masthead {
  text-align: center;
  border-bottom: 3px double var(--newspaper-rule);
  padding-bottom: 1rem;
  margin-bottom: 1rem;
}

.newspaper-name {
  font-size: 2.5rem;
  font-variant: small-caps;
  letter-spacing: 0.3em;
  line-height: 1.2;
  margin-bottom: 0.25rem;
}

.newspaper-dateline {
  font-size: 0.85rem;
  color: #5a4a3a;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.newspaper-powered {
  font-style: italic;
  font-size: 0.75rem;
  color: #7a6a5a;
}

.newspaper-headline {
  font-size: 1.8rem;
  text-transform: uppercase;
  text-align: center;
  margin: 1rem 0 0.5rem;
  line-height: 1.2;
  font-weight: 700;
}

.newspaper-byline {
  text-align: center;
  font-style: italic;
  font-size: 0.9rem;
  color: #5a4a3a;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--newspaper-rule);
}

.newspaper-body {
  display: flex;
  gap: 2rem;
}

.newspaper-columns {
  flex: 1;
  column-count: 2;
  column-gap: 2rem;
  column-rule: 1px solid var(--newspaper-rule);
  font-size: 0.95rem;
  line-height: 1.6;
  text-align: justify;
}

.newspaper-columns p {
  margin-bottom: 0.75em;
  text-indent: 1.5em;
}

.newspaper-columns p:first-child {
  text-indent: 0;
}

.newspaper-columns p:first-child::first-letter {
  font-size: 2.5em;
  float: left;
  line-height: 1;
  margin-right: 0.1em;
  font-weight: 700;
}

.newspaper-sidebar {
  width: 220px;
  flex-shrink: 0;
  border-left: 1px solid var(--newspaper-rule);
  padding-left: 1.5rem;
}

.newspaper-sidebar-title {
  font-variant: small-caps;
  font-size: 1rem;
  letter-spacing: 0.15em;
  border-bottom: 1px solid var(--newspaper-rule);
  padding-bottom: 0.25rem;
  margin-bottom: 0.75rem;
}

.newspaper-death-entry {
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  line-height: 1.4;
}

.newspaper-death-name {
  font-weight: 700;
}

.newspaper-death-detail {
  color: #5a4a3a;
  font-style: italic;
}

.newspaper-trail-map {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--newspaper-rule);
}

.newspaper-trail-map pre {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  line-height: 1.3;
  color: #5a4a3a;
  white-space: pre;
}

.newspaper-footer {
  text-align: center;
  margin-top: 1.5rem;
  padding-top: 0.75rem;
  border-top: 3px double var(--newspaper-rule);
  font-size: 0.8rem;
  color: #7a6a5a;
}

.newspaper-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

.newspaper-action-btn {
  background: var(--newspaper-fg);
  color: var(--newspaper-bg);
  border: none;
  font-family: Georgia, serif;
  font-size: 0.9rem;
  padding: 0.5rem 1.5rem;
  cursor: pointer;
  transition: opacity 0.15s;
}

.newspaper-action-btn:hover {
  opacity: 0.8;
}

.newspaper-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--newspaper-fg);
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
}

/* ── Mobile ─────────────────────────────────────── */

@media (max-width: 600px) {
  #terminal {
    max-width: 45ch;
    font-size: 12px;
  }

  #roster {
    display: none;
  }

  .roster-compact {
    display: flex;
    gap: 1ch;
    flex-wrap: wrap;
    font-size: 0.8em;
  }

  .roster-compact-member {
    white-space: nowrap;
  }

  .roster-compact-member.dead {
    text-decoration: line-through;
    color: var(--dim);
  }

  .health-pip {
    display: inline-block;
    width: 0.6em;
    height: 0.6em;
    border-radius: 50%;
    background: var(--amber);
    vertical-align: middle;
    margin-left: 0.3ch;
  }

  .health-pip.critical { background: var(--critical); }
  .health-pip.low { background: var(--low); }
  .health-pip.dead { background: var(--dim); }

  .choice {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .store-tooltip {
    display: none;
  }

  .store-item-price {
    width: 8ch;
  }

  .title-ascii {
    font-size: 0.6em;
  }

  .newspaper {
    padding: 1rem;
  }

  .newspaper-name {
    font-size: 1.5rem;
    letter-spacing: 0.15em;
  }

  .newspaper-headline {
    font-size: 1.2rem;
  }

  .newspaper-columns {
    column-count: 1;
  }

  .newspaper-body {
    flex-direction: column;
  }

  .newspaper-sidebar {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--newspaper-rule);
    padding-left: 0;
    padding-top: 1rem;
    margin-top: 1rem;
  }
}
