/* Number Blocks — e-ink-first design system (Phase 0 skeleton)
   Rules: #000 on #FFF only. No transitions/animations. State via fill
   inversion, border weight, hatching. Tap targets >= 64px. */

:root {
  --ink: #000;
  --paper: #fff;
  --border-thin: 2px solid var(--ink);
  --border-thick: 4px solid var(--ink);
  --tap-min: 64px;
}

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

/* Intentionally NO transition/animation properties anywhere in this file.
   The only motion in the app is the JS-driven stepped squeegee sweep (eink.js). */

html, body {
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body {
  display: flex;
  flex-direction: column;
}

.chrome {
  padding: 8px 16px;
  border-bottom: var(--border-thin);
}

footer.chrome {
  border-bottom: none;
  border-top: var(--border-thin);
  margin-top: auto;
}

.brand {
  font-size: clamp(1rem, 2.5vw, 1.5rem);
  font-weight: 800;
  letter-spacing: 0.02em;
}

#screen {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 16px;
}

.chip {
  display: inline-block;
  border: var(--border-thin);
  padding: 4px 12px;
  font-weight: 700;
}

button, .tap-target {
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  background: var(--paper);
  color: var(--ink);
  border: var(--border-thick);
  font-size: clamp(1.25rem, 4vw, 2rem);
  font-weight: 800;
  cursor: pointer;
}

button:active, .tap-target:active {
  /* pressed state = full inversion (e-ink safe, no transition) */
  background: var(--ink);
  color: var(--paper);
}

/* Update chip: fixed, unobtrusive, high-contrast. */
.update-chip {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 9997;
  min-height: 44px;
  border: var(--border-thick);
  background: var(--ink);
  color: var(--paper);
  font-weight: 800;
  padding: 8px 16px;
}

/* Device settings row in the Parent Area */
.device-settings {
  border-top: var(--border-thin);
  margin-top: 24px;
  padding-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

/* E-ink invert-flash: full-screen black -> white to clear ghosting.
   State swap is instantaneous (no CSS transition) — JS toggles .clear. */
.eink-flash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--ink);
  pointer-events: none;
}
.eink-flash.clear { background: var(--paper); }

/* Squeegee sweep overlay. Motion comes entirely from JS-stepped inline
   transforms (deliberately NOT CSS-animated — e-ink needs discrete frames). */
.squeegee-overlay {
  position: fixed;
  z-index: 9998;
  pointer-events: none; /* taps pass through — never blocks input */
  overflow: hidden;
}
.squeegee-blade {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;              /* the 1px blade */
  height: 100%;
  background: var(--ink);
}
.squeegee-bot {
  position: absolute;
  top: 50%;
  left: 0;
  margin-top: -0.6em;
  font-size: 1.2em;
  font-weight: 900;
  color: var(--ink);
  line-height: 1;
  white-space: nowrap;
}

/* Mastery grid (reusable stats component) */
.mastery { width: min(94vw, 560px); }

.mastery-grid {
  display: grid;
  gap: 3px;
  margin: 0 auto;
}

.m-cell {
  aspect-ratio: 1;
  min-width: 0;               /* let cells shrink to fit the grid on phones */
  min-height: 0;
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font-size: clamp(0.5rem, 2.2vw, 1rem);
  font-weight: 700;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.m-cell.mastered { background: var(--ink); color: var(--paper); }

.m-cell.struggling {
  /* diagonal hatch — reads as "in progress" without color or gradient */
  background: repeating-linear-gradient(
    45deg, var(--paper), var(--paper) 3px, var(--ink) 3px, var(--ink) 5px
  );
  color: var(--ink);
}

.m-cell.sel { outline: 4px solid var(--ink); outline-offset: -2px; }

.mastery-detail {
  text-align: center;
  font-weight: 700;
  margin-top: 16px;
  min-height: 1.5em;
}

/* Stats dashboard */
.stats-view { width: min(94vw, 640px); align-self: start; }
.stats-game { margin-top: 24px; }
.stats-game h3 { margin-bottom: 8px; }
.stats-totals { font-weight: 700; margin: 8px 0; }
.celebrate-grid { margin-top: 24px; }

/* Count-to-100 game */
.game {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: min(96vw, 640px);
}

.game-target {
  font-size: clamp(4rem, 30vh, 12rem);
  font-weight: 900;
  line-height: 1;
}

.game-msg {
  font-weight: 700;
  min-height: 1.5em; /* reserved — no layout-shift repaint on miss messages */
  text-align: center;
}

.progress-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 2px;
  width: min(80vw, 320px);
}

.pg-cell {
  aspect-ratio: 1;
  border: 1px solid var(--ink);
  background: var(--paper);
}

.pg-cell.done { background: var(--ink); }

.game-back {
  align-self: flex-start;
  margin-bottom: 8px;
}

/* Celebration + run summary */
.celebrate {
  text-align: center;
  border: var(--border-thick);
  background: var(--ink);
  color: var(--paper);
  padding: 32px 48px;
}

.celebrate-num {
  font-size: clamp(4rem, 25vh, 10rem);
  font-weight: 900;
  line-height: 1;
}

.celebrate-sub {
  font-size: clamp(1.25rem, 4vw, 2rem);
  font-weight: 800;
  margin-top: 8px;
}

.run-summary {
  text-align: center;
  margin-top: 24px;
  font-weight: 700;
}

.run-summary-nums { font-weight: 400; margin-top: 8px; }

.celebrate-actions { justify-content: center; margin-top: 24px; }

/* Numeric keypad (tap input) */
.keypad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.keypad-display {
  border: var(--border-thick);
  min-width: 200px;
  min-height: 72px;
  padding: 8px 24px;
  font-size: clamp(2rem, 8vw, 3.5rem);
  font-weight: 900;
  text-align: center;
  line-height: 1.2;
}

.keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(var(--tap-min), 110px));
  gap: 12px;
}

.keypad-grid button {
  min-height: 72px;
  font-size: clamp(1.5rem, 5vw, 2.25rem);
}

/* Utility: hatched = struggling state (used by mastery grid later) */
.hatch {
  background: repeating-linear-gradient(
    45deg,
    var(--paper), var(--paper) 4px,
    var(--ink) 4px, var(--ink) 6px
  );
}

/* Login screen */
.login-form {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  margin-top: 24px;
}

.login-email {
  border: var(--border-thick);
  padding: 0 16px;
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  width: min(90vw, 420px);
}

.login-msg {
  margin-top: 16px;
  font-weight: 700;
  min-height: 1.5em; /* reserve space — avoid layout shift repaints */
}

/* PIN pad */
.pin-entry { text-align: center; }

.pin-dots {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin: 20px 0 8px;
}

.pin-dot {
  width: 20px;
  height: 20px;
  border: var(--border-thin);
  border-radius: 50%;
}

.pin-dot.filled { background: var(--ink); }

.pin-msg, .form-msg {
  font-weight: 700;
  min-height: 1.5em; /* reserve space — no layout-shift repaints */
  margin: 8px 0;
}

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, minmax(var(--tap-min), 96px));
  gap: 12px;
  justify-content: center;
  margin-top: 12px;
}

/* Profiles / Parent Area */
.profile-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 24px 0;
}

.profile-tile, .game-tile {
  font-size: clamp(1.5rem, 5vw, 2.5rem);
  padding: 16px 32px;
}

.game-tile { margin-top: 24px; }

.parent-area {
  width: min(92vw, 640px);
  align-self: start;
}

.parent-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 16px 0;
}

.parent-row {
  border: var(--border-thin);
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.row-actions button, .settings-form button, .chip-btn {
  min-height: 44px;
  min-width: 44px;
  font-size: 1rem;
  border: var(--border-thin);
  padding: 4px 12px;
}

.settings-form {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.settings-form input[type="number"] { width: 90px; padding: 8px; border: var(--border-thin); }

.parent-footer { margin-top: 24px; }

#status-chip { border: none; padding: 0; display: flex; gap: 8px; }

/* Placeholder boot screen */
.boot {
  text-align: center;
}
.boot .big {
  font-size: clamp(3rem, 30vh, 12rem);
  font-weight: 900;
  line-height: 1;
}
