/* core/base.css: pixel font, palette, frames. Owner: Person 1. RULEBOOK section 9. */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

/* ---------- Palette: 16 colors, no others anywhere.
   TEMPORARY: this is the PICO-8 palette as a stand-in.
   Replace the 16 values with the Lospec palette the team picks, and credit it. */
:root {
  --c0: #050816;  --c1: #c3d5eb;  --c2: #bb6a52;  --c3: #8a8177;
  --c4: #10192e;  --c5: #486846;  --c6: #c9783e;  --c7: #e6aa85;
  --c8: #1f3b73;  --c9: #89ad84;  --c10: #d6aa4f; --c11: #915841;
  --c12: #6d95ca; --c13: #844136; --c14: #746b61; --c15: #e5bda3;

  /* The same 16 colors as "r, g, b" triplets, so a palette color can be made see-through:
     rgba(var(--c0-rgb), 0.8). Keep these in step with the hex values above on a palette swap. */
  --c0-rgb: 5, 8, 22;       --c1-rgb: 195, 213, 235;  --c2-rgb: 187, 106, 82;   --c3-rgb: 138, 129, 119;
  --c4-rgb: 16, 25, 46;     --c5-rgb: 72, 104, 70;    --c6-rgb: 201, 120, 62;   --c7-rgb: 230, 170, 133;
  --c8-rgb: 31, 59, 115;    --c9-rgb: 137, 173, 132;  --c10-rgb: 214, 170, 79;  --c11-rgb: 145, 88, 65;
  --c12-rgb: 109, 149, 202; --c13-rgb: 132, 65, 54;   --c14-rgb: 116, 107, 97;  --c15-rgb: 229, 189, 163;

  /* See-through panel fill: the darkest palette color (c0) at --panel-alpha.
     A container that needs to be more solid sets its own --panel-alpha AND --panel-bg, because
     a custom property is worked out where it is declared (here), not where it is used. */
  --panel-alpha: 0.8;
  --panel-bg: rgba(var(--c0-rgb), var(--panel-alpha));

  /* Names to use in slice CSS, so a palette swap only changes the lines above. */
  --bg: var(--c0);
  --ink: var(--c7); 
  --muted: var(--c6);
  --frame: var(--c1);
  --frame-edge: var(--c12);
  --accent: var(--c10);
  --good: var(--c11);
  --danger: var(--c8);
  --placeholder: var(--c13);
  /* The most neutral grey in the palette (c14 is the darker, slightly warmer one). */
  --border-grey: var(--c3);

  --font: 'Press Start 2P', monospace;
  --title: 32px;
  --body: 16px;
  --small: 12px;
  --scale: 1; /* set by core/ui.js so the 1280x720 game fits the window */
}

/* ---------- Page and scaling */
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--body);
  overflow: hidden;
}
body { display: grid; place-items: center; }

#app {
  position: relative;
  width: 1280px;
  height: 720px;
  transform: scale(var(--scale));
  flex: none;
}
#game {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--bg);
  transition: opacity 300ms; /* screens.js fades between slices */
}
#game.is-fading { opacity: 0; }
@media (prefers-reduced-motion: reduce) {
  #game { transition: none; }
}
#dashboard {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 5;
  pointer-events: none; /* Person 2: set pointer-events: auto on anything clickable */
}
/* ui.screen(bg, { dashboard: false }) sets [hidden]. This wins even if a display rule is added later. */
#dashboard[hidden] { display: none !important; }

img, .screen { image-rendering: pixelated; }
h1 { font-size: var(--title); margin: 0 0 24px; }
h2 { font-size: var(--body); margin: 0 0 16px; }
p { line-height: 1.6; margin: 0 0 16px; }
small, .small { font-size: var(--small); }

/* ---------- Screens and placeholders */
.screen {
  position: absolute;
  inset: 0;
  padding: 64px;
  background-size: 1280px 720px; /* 320x180 art shown at 4x */
  background-repeat: no-repeat;
}
.placeholder-bg { background: var(--frame); }
.placeholder-bg::after {
  content: attr(data-label);
  position: absolute;
  right: 16px;
  bottom: 16px;
  font-size: var(--small);
  color: var(--muted);
}
.placeholder-box {
  display: grid;
  place-items: center;
  background: var(--placeholder);
  color: var(--ink);
  font-size: var(--small);
  text-align: center;
  padding: 4px;
  overflow: hidden;
}
/* A sad face with no art yet gets a calmer, darker box, so testers can tell the moods apart.
   Kept quiet on purpose: sad faces appear in serious moments (Amendment A10 tone rule). */
.placeholder-box[data-mood="sad"] { background: var(--c8); color: var(--c1); }

/* Every portrait (art or placeholder box), icon and card image gets the same thin grey edge.
   border-box keeps the border inside the given size, so a 64px portrait stays 64px and no card shifts. */
.portrait, .placeholder-box, .icon, .card img {
  box-sizing: border-box;
  border: 2px solid var(--border-grey);
}

/* ---------- Frames
   Text boxes are see-through dark (--panel-bg) so the background art shows behind them.
   The pixel frame (border and outer ring) stays fully opaque, so they still read as boxes. */
.panel, .dialogue, .card, .toast {
  background: var(--panel-bg);
  border: 4px solid var(--frame-edge);
  box-shadow: 0 0 0 4px var(--bg); /* chunky double border, no blur */
  /* A 1px dark edge on every letter keeps text crisp when bright art shows through. */
  text-shadow: 1px 1px 0 var(--bg);
}
/* Solid controls inside a box keep plain text: their own fill already gives contrast. */
.btn, .bar, input, textarea, select { text-shadow: none; }
.panel { padding: 24px; margin-bottom: 24px; }
/* A light blur behind the dialogue box and panels only (not cards over portrait art).
   Browsers without backdrop-filter skip this block and show the plain see-through fill,
   which is readable on its own, so nothing breaks. */
@supports ((backdrop-filter: blur(2px)) or (-webkit-backdrop-filter: blur(2px))) {
  .dialogue, .panel {
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
  }
}

/* ---------- Dialogue box */
.dialogue {
  position: absolute;
  left: 32px; right: 32px; bottom: 32px;
  display: flex;
  gap: 24px;
  padding: 24px;
  z-index: 10;
}
.dialogue .portrait { flex: none; }
.dialogue-body { flex: 1; }
.dialogue-name { color: var(--accent); margin-bottom: 12px; }
.dialogue-text { line-height: 1.8; min-height: 3.6em; }
.dialogue-hint {
  position: absolute;
  right: 16px; bottom: 12px;
  color: var(--accent);
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---------- Buttons and choices */
.btn {
  font: inherit;
  font-size: var(--body);
  color: var(--bg);
  background: var(--accent);
  border: 4px solid var(--bg);
  padding: 12px 20px;
  margin: 8px 8px 0 0;
  cursor: pointer;
}
.btn:hover, .btn:focus-visible { outline: 4px solid var(--ink); }
.btn-quiet { background: var(--muted); }
.btn-danger { background: var(--danger); color: var(--ink); }
.btn:disabled { background: var(--c5); color: var(--muted); cursor: not-allowed; outline: none; }
.choices { display: flex; flex-direction: column; align-items: flex-start; margin-top: 16px; }
.why { font-size: var(--small); }

/* ---------- Progress bar */
.bar {
  position: relative;
  height: 24px;
  background: var(--bg);
  border: 4px solid var(--frame-edge);
}
.bar-fill { height: 100%; background: var(--good); }
/* Set by ui.bar(): green over 50%, yellow over 25%, red below. */
.bar-ok .bar-fill { background: var(--c9); }
.bar-warn .bar-fill { background: var(--c10); }
.bar-bad .bar-fill { background: var(--c2); }
.bar-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: var(--small);
}

/* ---------- Toast and modal card */
.toast {
  position: absolute;
  top: 96px; left: 50%;
  transform: translateX(-50%);
  padding: 16px 24px;
  z-index: 30;
}
.card-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--panel-bg); /* was raw black at 0.7, now the palette's darkest color */
  z-index: 20;
}
.card { width: 900px; max-height: 620px; overflow: auto; padding: 32px; line-height: 1.8; }
/* Links in any text box use the light frame color: 7.6:1 or better over the brightest art.
   The browser's default dark blue can't be read on a dark see-through box at any alpha. */
.panel a, .dialogue a, .toast a, .card a { color: var(--frame); }

/* ---------- Placeholder slices and the dev panel */
.stub { padding: 96px; }
.dev-panel {
  position: fixed;
  top: 8px; left: 8px;
  z-index: 100;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px;
  font: 12px monospace;
  background: #ffffff;
  color: #000000;
  border: 2px solid #000000;
}