/* ── PiggyBankMath Design Tokens ─────────────────────────────────────────────── */
:root {
  /* Brand colors */
  --color-primary:        #FF6B9D;
  --color-primary-dark:   #E8527F;
  --color-primary-light:  #FFD6E7;
  --color-accent:         #FFD93D;
  --color-accent-dark:    #F0C414;
  --color-success:        #6BCB77;
  --color-success-dark:   #4CAF59;
  --color-warning-bg:     #FFF3CD;
  --color-warning-border: #FFCA2C;
  --color-warning-text:   #856404;

  /* Coach tip (kid-detail Progress tab) — warm/gold like the warning family,
     but a DELIBERATELY DIFFERENT palette: .notice--warning already means real
     trouble elsewhere (an overdue payday, a session that failed to save), and
     the coach tip is a positive, actionable insight that must not borrow it. */
  --color-coach-bg:     #FFF1DA;
  --color-coach-border: #FFA94D;
  --color-coach-text:   #8A4B00;

  --color-bg:             #FFF8FB;
  --color-surface:        #FFFFFF;
  --color-text:           #2D2D2D;
  --color-text-muted:     #888899;
  --color-border:         #F0E0EA;

  /* Neutrals */
  --color-white:  #ffffff;
  --color-danger: #DC3545;
  /* Danger family — used where money is being TAKEN AWAY, so the direction of a
     balance change is never carried by text alone. */
  --color-danger-dark:   #B02A37;
  --color-danger-bg:     #FDECEE;
  --color-danger-border: #F5C2C7;
  --color-danger-shadow: rgba(220, 53, 69, 0.28);

  /* Parent palette */
  --color-parent-primary: #5B7FFF;
  --color-parent-dark:    #3D5EDB;
  --color-parent-light:   #E8EEFF;
  --color-parent-border:  #E4E8FF;
  --color-parent-bg:      #F4F6FF;

  /* Typography */
  --font-display: 'Nunito', system-ui, sans-serif;
  --font-body:    'Nunito', system-ui, sans-serif;

  /* Spacing */
  --space-xs:  4px;
  --space-sm:  8px;
  --space-md:  16px;
  --space-lg:  24px;
  --space-xl:  40px;
  --space-2xl: 64px;

  /* Radii */
  --radius-sm:   8px;
  --radius-md:   16px;
  --radius-lg:   24px;
  --radius-full: 999px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(255, 107, 157, 0.12);
  --shadow-md: 0 4px 20px rgba(255, 107, 157, 0.18);
  --shadow-lg: 0 8px 40px rgba(255, 107, 157, 0.22);
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font-body); background: var(--color-bg); color: var(--color-text); min-height: 100vh; line-height: 1.5; }

/* The `hidden` attribute must always win, even when an element sets display
   (e.g. modals/overlays with display:flex). Without this, [hidden] is ignored. */
[hidden] { display: none !important; }

/* `.hidden` was used as a class in session-complete.html markup and defined
   NOWHERE, so the empty "⭐ Mastered!" block and the level-up notice rendered on
   every single session. Prefer the `hidden` ATTRIBUTE above for anything new;
   this exists so the existing class-toggling JS means what it reads as. */
.hidden { display: none; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 14px var(--space-xl);
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }

/* A disabled button must LOOK disabled. kid-detail's "Apply what I ticked"
   starts disabled — the parent has to pick something first — and without this
   it read as an ordinary button that silently did nothing when pressed. */
.btn:disabled,
.btn[disabled] { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.btn:disabled:active,
.btn[disabled]:active { transform: none; }

.btn--primary  { background: var(--color-primary); color: #fff; box-shadow: var(--shadow-md); }
.btn--primary:hover { background: var(--color-primary-dark); box-shadow: var(--shadow-lg); }

.btn--accent   { background: var(--color-accent); color: var(--color-text); box-shadow: 0 4px 16px rgba(255, 217, 61, 0.35); }
.btn--accent:hover { background: var(--color-accent-dark); }

.btn--parent   { background: var(--color-parent-primary); color: #fff; box-shadow: 0 4px 16px rgba(91, 127, 255, 0.3); }
.btn--parent:hover { background: var(--color-parent-dark); }

.btn--outline  { background: transparent; color: var(--color-text-muted); border: 1.5px solid var(--color-border); }

.btn--sm       { font-size: 0.95rem; padding: 12px var(--space-lg); }
.btn--full     { width: 100%; margin-top: 2rem; }

/* ── Card ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  border: 1.5px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.card--highlight {
  border-color: var(--color-accent);
  box-shadow: 0 2px 20px rgba(255, 217, 61, 0.25);
}

.card--parent {
  border-color: var(--color-parent-border);
  box-shadow: 0 2px 12px rgba(91, 127, 255, 0.08);
}

.card + .card { margin-top: var(--space-md); }

/* ── Notice ───────────────────────────────────────────────────────────────── */
.notice {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  font-weight: 700;
  font-size: 0.95rem;
}

.notice__icon { font-size: 1.4rem; flex-shrink: 0; }

.notice--warning {
  background: var(--color-warning-bg);
  border: 1.5px solid var(--color-warning-border);
  color: var(--color-warning-text);
}

.notice--success {
  background: #EDFBEE;
  border: 1.5px solid var(--color-success);
  color: var(--color-success-dark);
}

.notice--spaced { margin-bottom: var(--space-lg); }

.notice--info {
  background: var(--color-parent-light);
  border: 1.5px solid var(--color-parent-border);
  color: var(--color-parent-primary);
}

/* ── Skeleton loading placeholder ─────────────────────────────────────────── */
/* For a value element whose markup ships a fake default ($0.00, 0) that's
   replaced once real data loads — on a slow connection that default is
   visible long enough to be misread as real money. Add class="skeleton" in
   markup; the page's JS removes it at the same point it writes the real
   value, revealing the real text underneath (never re-rendered/re-inserted). */
.skeleton {
  color: transparent !important;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--color-border) 25%, #fff 50%, var(--color-border) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; background-position: 50% 0; }
}

/* ── Badge ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  border-radius: var(--radius-full);
  padding: 2px 10px;
  font-size: 0.72rem;
  font-weight: 800;
  vertical-align: middle;
  margin-left: var(--space-sm);
}

.badge--accent  { background: var(--color-accent); color: var(--color-text); }
.badge--success { background: var(--color-success); color: #fff; }
/* Same palette as .coach-tip (detail.css) — this color already means
   "coach tip" elsewhere in the app; reused here for the dashboard indicator. */
.badge--tip {
  background: var(--color-coach-bg);
  color: var(--color-coach-text);
  border: 1.5px solid var(--color-coach-border);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
/* When rendered as a link (parent-dashboard.html) rather than a bare span. */
a.badge--tip {
  text-decoration: none;
  cursor: pointer;
}
a.badge--tip:hover { background: var(--color-coach-border); }
.badge--tip svg { width: 11px; height: 11px; }
.badge--primary { background: var(--color-primary); color: #fff; }

/* ── Progress Bar ─────────────────────────────────────────────────────────── */
.progress-bar {
  height: 8px;
  background: #EEEEFF;
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
  background: var(--color-accent);
}

.progress-bar__fill--primary { background: var(--color-primary); }
.progress-bar__fill--parent  { background: var(--color-parent-primary); }
.progress-bar__fill--success { background: var(--color-success); }

/* ── Section Label ────────────────────────────────────────────────────────── */
.section-label {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--color-parent-primary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding-top: 2rem;
  margin-bottom: var(--space-sm);
}

/* ── Divider ──────────────────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-md) 0;
}

/* ── Lucide icon sizing ───────────────────────────────────────────────────── */
.lucide {
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  stroke-width: 2.5;
  flex-shrink: 0;
}

/* ── PIN entry overlay ────────────────────────────────────────────────────── */
/* Shared by the kid PIN sheet (child-selection.html) and the parent-area PIN
   sheet that js/parent-guard.js injects into every protected parent page.
   Lives here rather than in kid.css because parent pages do not load kid.css. */
.pin-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(45, 45, 45, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: pinFade 0.18s ease;
}
@keyframes pinFade { from { opacity: 0; } to { opacity: 1; } }

.pin-sheet {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-xl) var(--space-md) var(--space-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  box-shadow: var(--shadow-lg);
  animation: pinSlide 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.1);
}
@keyframes pinSlide { from { transform: translateY(100%); } to { transform: translateY(0); } }

.pin-sheet--shake { animation: pinShake 0.4s ease; }
@keyframes pinShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.pin-sheet__close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  width: 32px;
  height: 32px;
  border: none;
  background: var(--color-bg);
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--color-text-muted);
  cursor: pointer;
}

.pin-sheet__avatar {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--color-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
}

.pin-sheet__name {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--color-text);
}

.pin-sheet__prompt {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-text-muted);
}

.pin-dots {
  display: flex;
  gap: var(--space-md);
  margin: var(--space-sm) 0;
}

.pin-dot {
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  border: 2px solid var(--color-primary);
  background: transparent;
  transition: background 0.12s;
}
.pin-dot--filled { background: var(--color-primary); }

.pin-error {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--color-danger);
  margin-bottom: var(--space-xs);
}

.pin-keypad {
  margin-top: var(--space-xs);
}

/* PIN keypad standalone styles — practice.css owns .keypad/.key but is not
   loaded on the pages that show a PIN sheet, so scope a full set here. */
.pin-keypad.keypad {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
}
.pin-keypad .key {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px 0;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.12s, transform 0.1s, border-color 0.12s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.pin-keypad .key:active {
  transform: scale(0.94);
  background: var(--color-primary-light);
  border-color: var(--color-primary);
}
.pin-keypad .key--clear {
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-size: 1.3rem;
}

/* Full-screen PIN sheet on mobile so the keypad never gets cut off by the
   Safari toolbar / home indicator. Content centers; overlay scrolls if needed. */
@media (max-width: 480px) {
  .pin-overlay { align-items: stretch; }
  .pin-sheet {
    min-height: 100vh;
    min-height: 100dvh;
    max-width: none;
    border-radius: 0;
    justify-content: center;
    padding-bottom: calc(var(--space-xl) + env(safe-area-inset-bottom));
  }
}

/* Escape hatches on the parent-area sheet. There is deliberately no close
   button and no click-outside-to-close: the only ways off this sheet are the
   correct PIN, kid mode, or signing out. */
.pin-sheet__exits {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-lg);
  margin-top: var(--space-md);
}

.pin-exit {
  background: none;
  border: none;
  padding: var(--space-xs);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--color-text-muted);
  text-decoration: underline;
  cursor: pointer;
}
.pin-exit:hover { color: var(--color-text); }

.pin-sheet__note {
  max-width: 30ch;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.45;
  color: var(--color-text-muted);
}

/* ── Parent-area lock (js/parent-guard.js) ────────────────────────────────── */
/* The guard adds .piggy-locked to <html> synchronously, before the page paints,
   so protected content never flashes. visibility:hidden also takes the content
   out of hit-testing AND out of the tab order, so nothing behind the sheet is
   reachable by tap, click or keyboard. The sheet opts itself back in. */
html.piggy-locked { overflow: hidden; }
html.piggy-locked body { visibility: hidden; overflow: hidden; }
html.piggy-locked body .pin-overlay { visibility: visible; }

/* Fallback block inside a PIN sheet (e.g. "no parent PIN set yet" + Sign out). */
.pin-sheet__fallback {
  width: 100%;
  padding: 0 var(--space-md);
  display: flex;
  flex-direction: column;
  align-items: center;
}
