/* Kidion Parent Dashboard — design tokens & primitives */

:root {
  /* Surfaces — cool neutrals, very low chroma */
  --bg:           oklch(0.985 0.003 255);
  --surface:      #ffffff;
  --surface-2:    oklch(0.972 0.004 255);
  --surface-3:    oklch(0.955 0.005 255);

  /* Borders / dividers */
  --border:        oklch(0.92 0.006 255);
  --border-strong: oklch(0.86 0.010 255);

  /* Ink */
  --text:    oklch(0.22 0.015 260);
  --text-2:  oklch(0.46 0.012 260);
  --text-3:  oklch(0.62 0.010 260);
  --text-4:  oklch(0.74 0.008 260);

  /* Single accent — confident indigo */
  --accent:        oklch(0.52 0.17 268);
  --accent-ink:    oklch(0.34 0.16 268);
  --accent-soft:   oklch(0.96 0.030 268);
  --accent-softer: oklch(0.985 0.014 268);
  --accent-border: oklch(0.88 0.045 268);

  /* Semantic — kept low-chroma, used very sparingly */
  --warm:        oklch(0.66 0.15 48);   /* streak fire */
  --warm-soft:   oklch(0.96 0.030 65);
  --gold:        oklch(0.74 0.12 82);   /* star earnings */
  --gold-soft:   oklch(0.96 0.038 90);
  --gem:         oklch(0.55 0.15 295);  /* crystals (parent) */
  --gem-soft:    oklch(0.96 0.025 295);

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --shadow-sm: 0 1px 2px rgba(15, 18, 35, 0.04);
  --shadow-md: 0 1px 3px rgba(15, 18, 35, 0.04), 0 8px 24px -8px rgba(15, 18, 35, 0.08);

  --font: "Geist", ui-sans-serif, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", monospace;
}

.kd {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-feature-settings: "ss01", "ss03", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.4;
  letter-spacing: 0;
}
.kd * { box-sizing: border-box; }
.kd button { font-family: inherit; cursor: pointer; }

/* ===================== Top bar ===================== */
.kd-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.kd-brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 17px;
  letter-spacing: 0;
}
.kd-brand-mark {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(140deg, oklch(0.62 0.17 268), oklch(0.45 0.18 282));
  display: grid; place-items: center;
  color: white; font-weight: 700; font-size: 13px;
  letter-spacing: 0;
  box-shadow: inset 0 -3px 6px rgba(0,0,0,0.12), 0 1px 2px rgba(40,30,90,0.18);
}
.kd-topbar-right { display: flex; align-items: center; gap: 10px; }

.kd-balance {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px 6px 8px;
  background: var(--gem-soft);
  border: 1px solid color-mix(in oklch, var(--gem) 18%, transparent);
  border-radius: 999px;
  font-size: 13px; font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.kd-balance-icon { font-size: 12px; line-height: 1; }
.kd-balance-label { color: var(--text-2); font-weight: 500; font-size: 12px; }

.kd-avatar-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  display: grid; place-items: center;
  font-size: 14px; color: var(--text-2);
}

/* ===================== Page chrome ===================== */
.kd-page {
  padding: 24px 20px 32px;
}
.kd-h1 {
  margin: 0 0 4px;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.15;
}
.kd-h1-sub {
  margin: 0 0 24px;
  color: var(--text-2);
  font-size: 14.5px;
  line-height: 1.5;
  max-width: 36ch;
}
.kd-section-eyebrow {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-3);
  margin: 0 0 10px;
}

/* ===================== Invite (empty-state) block ===================== */
.kd-invite {
  position: relative;
  border-radius: var(--radius-lg);
  padding: 26px 22px 22px;
  background:
    radial-gradient(120% 100% at 100% 0%, oklch(0.93 0.085 268) 0%, transparent 60%),
    radial-gradient(120% 120% at 0% 100%, oklch(0.94 0.06 295) 0%, transparent 55%),
    var(--accent-soft);
  border: 1px solid var(--accent-border);
  overflow: hidden;
  isolation: isolate;
}
.kd-invite-orb {
  position: absolute; top: -28px; right: -22px;
  width: 130px; height: 130px; border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, white 0%, oklch(0.92 0.10 268) 40%, oklch(0.78 0.16 282) 100%);
  opacity: 0.55; z-index: -1; filter: blur(2px);
}
.kd-invite-title {
  margin: 0 0 8px;
  font-size: 18px; font-weight: 600;
  letter-spacing: 0;
  color: var(--accent-ink);
  max-width: 22ch;
  line-height: 1.25;
}
.kd-invite-body {
  margin: 0 0 18px;
  font-size: 13.5px; color: var(--text);
  line-height: 1.5;
  max-width: 36ch;
}

/* ===================== Buttons ===================== */
.kd-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  height: 40px; padding: 0 16px;
  border-radius: 10px;
  font-size: 14px; font-weight: 500;
  letter-spacing: 0;
  border: 1px solid transparent;
  transition: background .12s, border-color .12s, box-shadow .12s;
  white-space: nowrap;
}
.kd-btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 1px 0 rgba(255,255,255,0.18) inset, 0 1px 2px rgba(40, 35, 100, 0.18);
}
.kd-btn-primary:hover { background: var(--accent-ink); }
.kd-btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.kd-btn-ghost:hover { background: var(--surface-2); }
.kd-btn-tint {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-color: transparent;
}
.kd-btn-tint:hover { background: color-mix(in oklch, var(--accent-soft) 70%, var(--accent) 8%); }
.kd-btn-block { width: 100%; }

/* ===================== Streak banner ===================== */
.kd-streak {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px 12px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}
.kd-streak-bar {
  width: 4px; align-self: stretch;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--warm), oklch(0.74 0.16 28));
  flex: 0 0 4px;
}
.kd-streak-body {
  font-size: 13.5px; line-height: 1.45;
  color: var(--text);
}
.kd-streak-body strong { font-weight: 600; }
.kd-streak-body .kd-streak-num { font-variant-numeric: tabular-nums; }
.kd-streak-fire { color: var(--warm); margin-left: 2px; }
.kd-streak-star { color: var(--gold); }

/* ===================== Kid cards ===================== */
.kd-cards { display: flex; flex-direction: column; gap: 12px; }

.kd-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.kd-card-top {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 14px;
}
.kd-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  font-size: 30px; line-height: 1;
  flex: 0 0 56px;
}
.kd-card-name {
  margin: 0; font-size: 17px; font-weight: 600;
  letter-spacing: 0;
  line-height: 1.2;
}
.kd-card-meta {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-3);
}

.kd-stats {
  display: flex; gap: 8px;
  margin-bottom: 14px;
}
.kd-stat {
  flex: 1;
  display: flex; flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in oklch, var(--border) 60%, transparent);
}
.kd-stat-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  font-weight: 500;
}
.kd-stat-value {
  font-size: 16px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  display: inline-flex; align-items: baseline; gap: 4px;
}
.kd-stat-value .kd-stat-icon {
  font-size: 13px;
  position: relative; top: -1px;
}

.kd-card-actions {
  display: flex; gap: 8px;
}
.kd-card-actions .kd-btn { flex: 1; height: 38px; font-size: 13.5px; }

/* New / unvisited card hint */
.kd-hint {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500;
  color: var(--accent-ink);
  margin-top: 10px;
  padding: 6px 10px 6px 8px;
  background: var(--accent-soft);
  border-radius: 999px;
  width: fit-content;
}
.kd-hint-arrow {
  display: inline-block;
  animation: kd-arrow 1.4s ease-in-out infinite;
}
@keyframes kd-arrow {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(-3px); }
}

/* Add kid CTA (dashed) */
.kd-add {
  width: 100%;
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--text-2);
  border-radius: var(--radius-lg);
  padding: 16px;
  font-size: 14px; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  transition: background .12s, border-color .12s, color .12s;
  margin-top: 4px;
}
.kd-add:hover {
  background: var(--accent-softer);
  border-color: var(--accent-border);
  color: var(--accent-ink);
}
.kd-add-plus {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface-2);
  display: inline-grid; place-items: center;
  font-size: 14px; font-weight: 500;
  color: var(--text-2);
}

/* ===================== Referral block ===================== */
.kd-referral {
  margin-top: 28px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.kd-referral-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 4px;
}
.kd-referral-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--gem-soft);
  display: grid; place-items: center;
  font-size: 15px;
}
.kd-referral-title {
  margin: 0; font-size: 15px; font-weight: 600;
  letter-spacing: 0;
}
.kd-referral-body {
  margin: 2px 0 14px;
  font-size: 13px; color: var(--text-2);
  line-height: 1.5;
}
.kd-link-field {
  display: flex; align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-2);
}
.kd-link-input {
  flex: 1; min-width: 0;
  padding: 0 12px;
  border: 0; background: transparent;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-2);
  outline: none;
  letter-spacing: 0;
}
.kd-link-copy {
  border: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 0 14px;
  font-size: 13px; font-weight: 500;
  color: var(--text);
  display: inline-flex; align-items: center; gap: 6px;
}
.kd-link-copy:hover { background: var(--surface-3); }

/* ===================== Tone variations ===================== */
/* Tone B — balanced: accent appears on streak, avatars get color */
.kd.tone-balanced .kd-card-top { gap: 14px; }
.kd.tone-balanced .kd-avatar {
  background: var(--accent-softer);
  border-color: var(--accent-border);
}
.kd.tone-balanced .kd-streak {
  background: var(--accent-softer);
  border-color: var(--accent-border);
}
.kd.tone-balanced .kd-streak-bar {
  background: var(--accent);
}
.kd.tone-balanced .kd-stat { background: var(--accent-softer); border-color: transparent; }

/* Tone C — warmer: hero card has accent tint, larger emoji, friendlier */
.kd.tone-warm .kd-h1 { font-size: 28px; }
.kd.tone-warm .kd-cards .kd-card:first-of-type {
  background:
    linear-gradient(160deg, var(--accent-softer), white 70%);
  border-color: var(--accent-border);
}
.kd.tone-warm .kd-avatar {
  font-size: 34px;
  background: white;
  border-color: var(--accent-border);
  box-shadow: 0 1px 2px rgba(40, 35, 100, 0.06);
}
.kd.tone-warm .kd-streak {
  background:
    linear-gradient(100deg, oklch(0.97 0.04 50), white 80%);
  border-color: oklch(0.90 0.06 50);
}
.kd.tone-warm .kd-stat { background: white; border-color: var(--border); }
.kd.tone-warm .kd-add { padding: 18px; }

/* ===================== Desktop layout ===================== */
.kd.is-desktop .kd-page {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 28px;
  padding: 32px 40px 40px;
  max-width: 1100px;
  margin: 0 auto;
}
.kd.is-desktop .kd-main { min-width: 0; }
.kd.is-desktop .kd-aside { display: flex; flex-direction: column; gap: 16px; }
.kd.is-desktop .kd-h1 { font-size: 30px; }
.kd.is-desktop .kd-cards { gap: 14px; }
.kd.is-desktop .kd-card { padding: 20px; }
.kd.is-desktop .kd-card-actions .kd-btn { height: 40px; font-size: 14px; }
.kd.is-desktop .kd-referral { margin-top: 0; }
.kd.is-desktop .kd-topbar { padding: 16px 40px; }

/* Aside crystal balance block (desktop only) */
.kd-balance-card {
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.kd-balance-card-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-3);
  margin: 0 0 4px;
}
.kd-balance-card-value {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 26px; font-weight: 600;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  margin: 0;
}
.kd-balance-card-icon { font-size: 20px; }
.kd-balance-card-sub {
  font-size: 12.5px; color: var(--text-2);
  margin: 6px 0 0;
}

/* Two-up cards on desktop when >1 kid */
.kd.is-desktop .kd-cards.is-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.kd.is-desktop .kd-cards.is-grid .kd-add {
  grid-column: 1 / -1;
}
