/* Additive waveguide display.
   Pure #000 is FULLY TRANSPARENT (it emits no light), so surfaces use a
   near-black that still registers. Bright, high-contrast foregrounds are the
   most legible because they add light on top of the real world. */
:root {
  --bg: #0a0a0f;
  --surface: #1c1e21;
  --fg: #f2f4f8;
  --dim: #9aa4b2;
  --accent: #5ac8fa;
  --ok: #3ddc84;
  --warn: #ffb020;
  --bad: #ff5f56;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 600px;
  height: 600px;
  overflow: hidden;                 /* there is NO scrolling on this device */
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, Helvetica, Arial, sans-serif;
  font-size: 16px;                  /* documented minimum body size */
}

#app {
  position: relative;
  width: 584px;                     /* 600 minus the 8dp safe-area margin */
  height: 584px;
  margin: 8px;
}

.screen { display: none; height: 100%; }
.screen.on { display: flex; flex-direction: column; }

.hdr { font-size: 14px; color: var(--dim); margin-bottom: 6px; flex: 0 0 auto; }
.body { flex: 1 1 auto; overflow: hidden; }
.foot { flex: 0 0 auto; padding-top: 6px; }

h1 { font-size: 24px; margin: 0 0 8px; }
p { margin: 0 0 8px; }
.dim { color: var(--dim); font-size: 14px; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .bad { color: var(--bad); }

button, input {
  font: inherit;
  font-size: 20px;
  min-height: 44px;                 /* well above the 88dp tap-target floor */
  padding: 8px 14px;
  margin: 4px 6px 0 0;
  background: var(--surface);
  color: var(--fg);
  border: 2px solid #2c2f33;
  border-radius: 10px;
}

/* No cursor exists on this device: focus IS the pointer. It must be
   unmistakable at a glance, mid-workout. */
button:focus, input:focus {
  outline: none;
  border-color: var(--accent);
  background: #24303a;
  transform: scale(1.04);
}

.grades { display: flex; flex-wrap: wrap; }
.grades button { flex: 1 1 44%; }
button[data-g="1"]:focus { border-color: var(--bad); }
button[data-g="4"]:focus { border-color: var(--ok); }

#status {
  position: absolute; bottom: 0; left: 0; right: 0;
  font-size: 12px; color: var(--dim);
  display: flex; justify-content: space-between;
}

/* ---- Anki card face -----------------------------------------------------
   The card's own <style> block is STRIPPED before insertion (see cards.js):
   Anki ships black-on-white, which on an additive display means invisible
   text on a glaring background. This layer owns presentation entirely. */
.anki { font-size: 24px; line-height: 1.35; }
.anki, .anki * {
  background: transparent !important;
  color: var(--fg) !important;
  border-color: #3a4048 !important;
  font-family: inherit !important;
}
.anki b, .anki strong { color: #fff !important; }
.anki .cloze { color: var(--accent) !important; font-weight: 700; }
/* Cards in real med decks are frequently SCREENSHOTS OF SLIDES — raster
   images, dark text on white. Stripping the card's CSS cannot help those: the
   content is pixels. On an additive display such an image is a glaring white
   rectangle whose dark text emits no light at all.

   `.invert` is applied per-image at runtime by app.js, only to images measured
   as predominantly light (documents, slides, diagrams). It is deliberately NOT
   blanket: inverting a histology slide, a radiograph or any photo destroys it,
   and med decks are full of those. hue-rotate restores hue after the luminance
   flip so colour diagrams stay recognisable. */
.anki img {
  width: 100%;
  max-width: 100%;
  max-height: 440px;
  object-fit: contain;
}
.anki img.invert { filter: invert(1) hue-rotate(180deg); }
.anki table { border-collapse: collapse; font-size: 18px; }
.anki td, .anki th { border: 1px solid #3a4048 !important; padding: 3px 6px; }
.anki hr { border: 0; border-top: 1px solid #3a4048; margin: 10px 0; }
