/* EDU Reading Module
 * Design intent: warm, quiet, trustworthy. Not a game.
 * No bouncy animations, no confetti, no rainbow gradients.
 * Strong contrast for readability; dyslexia-friendly fallback available
 * (toggled by child.accommodations.dyslexia_font = true).
 */

:root {
  --ink:        #0f1b24;
  --ink-2:      #2b3a48;
  --muted:      #6a7a88;
  --line:       #dde4ea;
  --bg:         #fbf9f5;
  --card:       #ffffff;
  --accent:     #0b7d8a;      /* teal, not blue */
  --accent-ink: #074a52;
  --warm:       #d96b2c;      /* terracotta, used sparingly */
  --leaf:       #3d7f4e;      /* mastered */
  --amber:      #c98b1a;      /* practicing */
  --radius:     12px;
  --radius-sm:  8px;
  --shadow-sm:  0 1px 2px rgba(15,27,36,.05), 0 1px 1px rgba(15,27,36,.03);
  --shadow:     0 4px 14px rgba(15,27,36,.06), 0 2px 4px rgba(15,27,36,.04);
  --font-body:  ui-serif, Georgia, "Iowan Old Style", "Source Serif Pro", serif;
  --font-ui:    -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--accent); }

h1, h2, h3 { font-family: var(--font-ui); color: var(--ink); letter-spacing: -0.01em; }
h1 { font-size: 2.1rem; line-height: 1.15; font-weight: 700; margin: 0 0 .4rem; }
h2 { font-size: 1.35rem; margin: 1.6rem 0 .6rem; font-weight: 600; }
h3 { font-size: 1.05rem; margin: .8rem 0 .3rem; font-weight: 600; }

.muted { color: var(--muted); }
.small { font-size: .85em; }
.dot { color: var(--line); margin: 0 .3em; }

/* --- nav --- */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
.brand {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  font-family: var(--font-ui);
  text-decoration: none;
  color: var(--ink);
}
.brand-mark {
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--accent-ink);
  font-size: .95rem;
}
.brand-sub { font-size: .85rem; color: var(--muted); }
.nav-links { display: flex; gap: 1.1rem; align-items: center; }
.nav-links a { text-decoration: none; font-family: var(--font-ui); font-size: .92rem; color: var(--ink-2); }
.nav-links a:hover { color: var(--accent); }

.link-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-2);
  font: inherit;
  font-family: var(--font-ui);
  font-size: .92rem;
  padding: 0;
  text-decoration: none;
}
.link-btn:hover { color: var(--accent); }

/* --- container --- */
.container { max-width: 1040px; margin: 0 auto; padding: 32px 28px 80px; }

/* --- buttons --- */
.btn {
  display: inline-block;
  font-family: var(--font-ui);
  font-weight: 500;
  padding: .55rem 1.1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  font-size: .95rem;
  line-height: 1.2;
  transition: background .14s ease, color .14s ease;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-ink); color: #fff; border-color: var(--accent-ink); }
.btn-ghost {
  background: transparent;
  color: var(--ink-2);
  border-color: var(--line);
}
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: .35rem .75rem; font-size: .88rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }

/* --- flash --- */
.flash-stack { max-width: 1040px; margin: 10px auto 0; padding: 0 28px; }
.flash {
  padding: .6rem .9rem;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-family: var(--font-ui);
  font-size: .92rem;
}
.flash-error   { background: #fde8e1; color: #8c3a1d; border: 1px solid #f5cbba; }
.flash-success { background: #e2f0e6; color: #1f5a30; border: 1px solid #c6dfce; }
.flash-info    { background: #e4effa; color: #1d4b73; border: 1px solid #c5dbeb; }

/* --- marketing hero --- */
.hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 60px;
  align-items: center;
  padding: 36px 0 48px;
}
.hero h1 { font-size: 2.6rem; line-height: 1.1; margin-bottom: 1rem; letter-spacing: -.015em; }
.hero .lede { font-size: 1.15rem; color: var(--ink-2); margin-bottom: 1.6rem; max-width: 36em; }
.hero-cta { display: flex; gap: .8rem; flex-wrap: wrap; }

.hero-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.mini-lesson { text-align: center; }
.mini-label { font-family: var(--font-ui); font-size: .8rem; letter-spacing: .1em; color: var(--muted); text-transform: uppercase; }
.mini-graph { font-size: 6rem; font-weight: 400; color: var(--accent-ink); line-height: 1; margin: 10px 0; font-family: var(--font-body); }
.mini-phoneme { font-size: 1.6rem; color: var(--warm); margin: 6px 0; letter-spacing: .05em; }
.mini-words { color: var(--ink-2); font-size: 1rem; letter-spacing: .02em; }

/* --- pillars --- */
.pillars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin: 48px 0;
}
.pillar {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
}
.pillar h3 { margin-top: 0; color: var(--accent-ink); }
.pillar p { color: var(--ink-2); margin: .3rem 0 0; font-size: .96rem; }

.evidence { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 32px; margin-top: 20px; }
.evidence h2 { margin-top: 0; }
.evidence-list { padding-left: 1.2em; }
.evidence-list li { margin: .5em 0; color: var(--ink-2); }

/* --- prose --- */
.prose { max-width: 700px; margin: 0 auto; }
.prose h1 { margin-bottom: 1.5rem; }
.prose p, .prose ul, .prose ol { color: var(--ink-2); }
.prose code { background: #f0f2f5; padding: 1px 6px; border-radius: 4px; font-size: .9em; }

/* --- auth shell --- */
.auth-shell { max-width: 440px; margin: 40px auto; }
.auth-form {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}
.auth-form h1 { margin: 0 0 .4rem; font-size: 1.5rem; }
.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--font-ui);
  font-size: .88rem;
  color: var(--ink-2);
}
.auth-form input[type=text],
.auth-form input[type=email],
.auth-form input[type=password],
.auth-form input[type=number],
.auth-form select {
  padding: .55rem .7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 1rem;
  background: #fff;
  color: var(--ink);
}
.auth-form input:focus, .auth-form select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.auth-form .hint { color: var(--muted); font-size: .8rem; }
.auth-form .qr { text-align: center; margin: 10px 0; }
.auth-form .qr img { max-width: 200px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.auth-form details { font-family: var(--font-ui); font-size: .85rem; color: var(--muted); }
.auth-form details code { background: #f0f2f5; padding: 4px 8px; border-radius: 4px; display: inline-block; margin-top: 4px; }

/* --- page head --- */
.page-head { margin-bottom: 28px; }
.page-head .back-link { font-family: var(--font-ui); font-size: .88rem; color: var(--muted); text-decoration: none; }
.page-head .back-link:hover { color: var(--accent); }
.page-head .meta { margin-top: 4px; color: var(--muted); font-family: var(--font-ui); font-size: .9rem; }

/* --- alerts --- */
.alerts {
  background: #fff8ea;
  border: 1px solid #f3dfa8;
  border-radius: var(--radius);
  padding: 16px 22px;
  margin-bottom: 28px;
}
.alert-list { list-style: none; padding: 0; margin: 0; }
.alert { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 10px 0; border-bottom: 1px solid rgba(243,223,168,.6); }
.alert:last-child { border-bottom: none; }
.alert-type { font-family: var(--font-ui); font-weight: 600; color: var(--ink); }
.alert-details { color: var(--ink-2); font-size: .94rem; }
.severity-watch   .alert-type { color: #8c6d1d; }
.severity-concern .alert-type { color: #8c3a1d; }

/* --- children cards --- */
.children .section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.section-head h2 { margin: 0; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: var(--ink);
  display: block;
  transition: box-shadow .14s ease, transform .14s ease;
}
.card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.child-card .card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.child-name { font-family: var(--font-ui); font-weight: 600; font-size: 1.1rem; color: var(--ink); }
.stage-pill {
  font-family: var(--font-ui);
  font-size: .74rem;
  letter-spacing: .04em;
  background: #e4effa;
  color: #1d4b73;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
}
.child-stat { display: flex; justify-content: space-between; font-family: var(--font-ui); font-size: .9rem; margin: 4px 0; }
.stat-label { color: var(--muted); }
.stat-val { color: var(--ink-2); }

.empty {
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

/* --- today focus card --- */
.today-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 26px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.today-card h2 { margin-top: 0; }
.focus { display: flex; flex-direction: column; gap: 8px; }
.focus-label { font-family: var(--font-ui); font-size: .78rem; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.focus-name { font-family: var(--font-ui); font-weight: 600; font-size: 1.2rem; }
.focus-phoneme { color: var(--warm); font-size: 1.3rem; font-family: var(--font-body); }
.focus-examples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.word-chip {
  background: #f0f2f5;
  color: var(--ink-2);
  padding: 3px 10px;
  border-radius: 999px;
  font-family: var(--font-ui);
  font-size: .88rem;
}

/* --- mastery bars --- */
.mastery-bars { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.mastery-row {
  display: grid;
  grid-template-columns: 140px 1fr 36px;
  gap: 12px;
  align-items: center;
  font-family: var(--font-ui);
  font-size: .9rem;
}
.mastery-label { color: var(--ink-2); }
.mastery-bar { background: #eef1f4; height: 10px; border-radius: 999px; overflow: hidden; }
.mastery-fill { height: 100%; border-radius: 999px; transition: width .4s ease; }
.state-mastered     { background: var(--leaf); }
.state-maintenance  { background: #6b9e7a; }
.state-practicing   { background: var(--amber); }
.state-introduced   { background: #d9b76a; }
.state-needs_reteach { background: #c97a58; }
.state-not_introduced { background: #ccd3d9; }
.mastery-count { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* --- skill chips --- */
.skill-chips { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.skill-chip {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-family: var(--font-ui);
  font-size: .88rem;
  display: flex;
  gap: 8px;
  align-items: center;
}
.chip-name { color: var(--ink); }

/* --- sessions table --- */
.sessions-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-ui);
  font-size: .92rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.sessions-table th, .sessions-table td { padding: 10px 14px; text-align: left; }
.sessions-table th { background: var(--bg); color: var(--muted); font-weight: 500; font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; }
.sessions-table tbody tr { border-top: 1px solid var(--line); }
.status-pill { padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 500; }
.status-completed { background: #e2f0e6; color: #1f5a30; }
.status-in_progress { background: #e4effa; color: #1d4b73; }
.status-abandoned, .status-frustrated_exit { background: #fde8e1; color: #8c3a1d; }

/* --- inline form --- */
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.inline-form select, .inline-form input {
  padding: .4rem .6rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-family: var(--font-ui); font-size: .9rem; background: #fff;
}

/* --- modal --- */
dialog {
  border: none;
  border-radius: var(--radius);
  padding: 28px 32px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(15,27,36,.25);
}
dialog::backdrop { background: rgba(15,27,36,.4); }
.modal-form { display: flex; flex-direction: column; gap: 14px; }
.modal-form h2 { margin: 0 0 .4rem; }
.modal-form label { display: flex; flex-direction: column; gap: 4px; font-family: var(--font-ui); font-size: .88rem; color: var(--ink-2); }
.modal-form input, .modal-form select { padding: .5rem .7rem; border: 1px solid var(--line); border-radius: var(--radius-sm); font: inherit; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* --- settings --- */
.settings { display: flex; flex-direction: column; gap: 24px; max-width: 620px; }
.settings-form, .security-block {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.settings fieldset { border: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--line); padding-bottom: 14px; }
.settings fieldset:last-of-type { border-bottom: none; padding-bottom: 0; }
.settings legend { font-family: var(--font-ui); font-weight: 600; color: var(--ink); padding: 0 0 4px; }
.settings label { font-family: var(--font-ui); font-size: .92rem; color: var(--ink-2); display: flex; flex-direction: column; gap: 3px; }
.settings input[type=text], .settings input[type=email], .settings input[type=number] {
  padding: .5rem .7rem; border: 1px solid var(--line); border-radius: var(--radius-sm); font: inherit; background: #fff;
}
.settings input:disabled { background: var(--bg); color: var(--muted); }
.checkbox-row { flex-direction: row !important; gap: 8px !important; align-items: center; }
.hint { font-size: .8rem; color: var(--muted); }

/* --- empty state --- */
.empty-state { text-align: center; padding: 60px 20px; }

/* --- footer --- */
.foot {
  display: flex;
  justify-content: space-between;
  padding: 18px 28px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: .85rem;
  background: var(--card);
}
.foot a { color: var(--muted); text-decoration: none; }
.foot a:hover { color: var(--accent); }

/* --- responsive --- */
@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; gap: 32px; }
  .hero h1 { font-size: 2rem; }
  .nav { padding: 12px 16px; }
  .container { padding: 20px 16px 60px; }
  .nav-links { gap: .7rem; }
  .mastery-row { grid-template-columns: 100px 1fr 32px; font-size: .85rem; }
  .pillars { margin: 28px 0; }
}

/* --- dyslexia-friendly override: applied when <body class="dys"> --- */
body.dys, body.dys * {
  font-family: "OpenDyslexic", "Comic Neue", "Comic Sans MS", sans-serif !important;
  letter-spacing: .02em;
  line-height: 1.7;
}

/* --- reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* --- page head CTA --- */
.page-head-cta {
  margin-top: .9rem;
}

/* --- weekly report block on child detail --- */
.weekly-report {
  margin-top: 2rem;
  padding: 1.2rem 1.4rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.weekly-report h2 { margin-top: 0; }
.report-narrative {
  font-size: 1.05rem;
  color: var(--ink);
  margin: .4rem 0 .8rem;
}
.report-tip {
  margin: .8rem 0;
  padding: .9rem 1rem;
  background: #f4f8fa;
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
}
.report-tip .tip-title {
  font-weight: 600;
  color: var(--accent-ink);
  margin-bottom: .25em;
}
.report-tip .tip-body { color: var(--ink-2); }
