/* My GraceRoot Journey — student hub (/portal) and course dashboard (/portal/course/:slug).
   Light theme keeps the GraceRoot olive / gold / cream palette; dark theme is opt-in via the
   toggle at the top of the dashboard (public/js/theme.js). Colours meet WCAG 2.1 AA in both. */

:root {
  --j-bg: #faf6f1;
  --j-surface: #ffffff;
  --j-surface-2: #f3eee5;
  --j-ink: #2c2c2c;
  --j-muted: #5f6358;
  --j-heading: #3d4a3a;
  --j-accent: #8a6a2a;          /* gold text on light: 5.1:1 on white */
  --j-gold: #c8a45e;
  --j-line: rgba(61, 74, 58, 0.14);
  --j-btn: #3d4a3a;
  --j-btn-ink: #ffffff;
  --j-btn-2: transparent;
  --j-track: #e8d5c4;
  --j-fill: linear-gradient(90deg, #7a8b6f, #c8a45e);
  --j-ok: #1f6b3a;
  --j-ok-bg: #e8f4ec;
  --j-warn-bg: #fbf3df;
  --j-warn-ink: #6b5212;
  --j-shadow: 0 2px 12px rgba(61, 74, 58, 0.06);
  --j-focus: #8a6a2a;
  color-scheme: light;
}

[data-theme="dark"] {
  --j-bg: #141813;
  --j-surface: #1d231c;
  --j-surface-2: #262e24;
  --j-ink: #ece8df;
  --j-muted: #b5b9ad;
  --j-heading: #e3d6b4;
  --j-accent: #e2c27f;
  --j-gold: #d6b46c;
  --j-line: rgba(236, 232, 223, 0.14);
  --j-btn: #d6b46c;
  --j-btn-ink: #1b1a14;
  --j-track: #3a4237;
  --j-fill: linear-gradient(90deg, #9fb592, #d6b46c);
  --j-ok: #8fd3a5;
  --j-ok-bg: #1f3326;
  --j-warn-bg: #3a3220;
  --j-warn-ink: #f1dca7;
  --j-shadow: 0 2px 14px rgba(0, 0, 0, 0.35);
  --j-focus: #e2c27f;
  color-scheme: dark;

  /* existing portal.html variables, so its older sections follow the theme too */
  --warm-cream: #141813;
  --deep-olive: #e3d6b4;
  --warm-brown: #e2c27f;
  --text-dark: #ece8df;
  --text-muted: #b5b9ad;
  --blush: #3a4237;
  --border: rgba(236, 232, 223, 0.14);
  --card-shadow: 0 2px 14px rgba(0, 0, 0, 0.35);
}

/* Older portal.html blocks with hard-coded light colours */
[data-theme="dark"] body { background: var(--j-bg); color: var(--j-ink); }
[data-theme="dark"] body > nav { background: rgba(20, 24, 19, 0.95) !important; }
[data-theme="dark"] .logo span { color: var(--j-heading); }
[data-theme="dark"] .course-card,
[data-theme="dark"] .cert-card,
[data-theme="dark"] .account-section,
[data-theme="dark"] #section-messages .m-thread,
[data-theme="dark"] #section-messages .convo-wrap,
[data-theme="dark"] #section-messages .compose-card { background: var(--j-surface) !important; color: var(--j-ink); }
[data-theme="dark"] #section-messages .b.staff { background: var(--j-surface-2) !important; color: var(--j-ink); }
[data-theme="dark"] input, [data-theme="dark"] textarea, [data-theme="dark"] select { background: var(--j-surface-2) !important; color: var(--j-ink) !important; border-color: var(--j-line) !important; }
[data-theme="dark"] .submit-btn, [data-theme="dark"] .account-btn, [data-theme="dark"] .cert-download,
[data-theme="dark"] .nav-btn, [data-theme="dark"] #section-messages .msg-new-btn,
[data-theme="dark"] .auth-tab.active { background: var(--j-btn) !important; color: var(--j-btn-ink) !important; }
[data-theme="dark"] .account-btn[style*="8b1e1e"] { background: #e07a6e !important; color: #1b1a14 !important; }
[data-theme="dark"] .error-msg { background: #3a1f1f; border-color: #7a3535; color: #f3b9b0; }
[data-theme="dark"] .success-msg { background: var(--j-ok-bg); border-color: #2f5a3d; color: var(--j-ok); }

body { background: var(--j-bg); color: var(--j-ink); }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--j-focus); outline-offset: 2px; border-radius: 4px; }
.j-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Top bar ─────────────────────────────────────────────────────────── */
.j-top { max-width: 1180px; margin: 0 auto; padding: 6rem 1.5rem 1.25rem; display: flex; gap: 1rem; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; }
.j-top h1 { font-family: 'Playfair Display', Georgia, serif; color: var(--j-heading); font-size: clamp(1.6rem, 3.2vw, 2.2rem); line-height: 1.2; margin: 0; }
.j-top p { color: var(--j-muted); margin: 0.3rem 0 0; font-size: 0.95rem; }
.j-top-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.j-chip-btn { display: inline-flex; align-items: center; gap: 0.4rem; background: var(--j-surface); color: var(--j-ink); border: 1px solid var(--j-line); border-radius: 999px; padding: 0.5rem 0.95rem; font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer; text-decoration: none; min-height: 40px; }
.j-chip-btn:hover { border-color: var(--j-gold); }
.j-chip-btn [data-theme-icon] { font-size: 1rem; line-height: 1; }

/* ── Layout ──────────────────────────────────────────────────────────── */
.j-layout { max-width: 1180px; margin: 0 auto; padding: 0 1.5rem 4rem; display: grid; grid-template-columns: 220px 1fr; gap: 1.75rem; align-items: start; }
.j-side { position: sticky; top: 5.5rem; display: flex; flex-direction: column; justify-content: flex-start; align-items: stretch; gap: 0.15rem; width: auto; padding: 0; background: none; border: 0; backdrop-filter: none; z-index: auto; }
.j-side .j-side-group { text-align: left; }
.j-side button { text-align: left; background: none; border: 0; border-radius: 10px; padding: 0.6rem 0.8rem; font: inherit; font-size: 0.9rem; color: var(--j-muted); cursor: pointer; display: flex; justify-content: flex-start; gap: 0.5rem; align-items: center; min-height: 40px; width: 100%; }
.j-side button .j-badge { margin-left: auto; }
.j-side button:hover { background: var(--j-surface-2); color: var(--j-ink); }
.j-side button[aria-current="page"] { background: var(--j-surface); color: var(--j-heading); font-weight: 700; box-shadow: var(--j-shadow); border-left: 3px solid var(--j-gold); }
.j-side .j-side-group { font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--j-muted); margin: 0.9rem 0.8rem 0.2rem; }
.j-badge { background: #b4442e; color: #fff; font-size: 0.68rem; font-weight: 700; padding: 0.05rem 0.45rem; border-radius: 999px; }
@media (max-width: 860px) {
  .j-layout { grid-template-columns: 1fr; }
  .j-side { position: static; flex-direction: row; overflow-x: auto; gap: 0.35rem; padding-bottom: 0.4rem; }
  .j-side .j-side-group { display: none; }
  .j-side button { white-space: nowrap; border: 1px solid var(--j-line); }
  .j-side button[aria-current="page"] { border-left-width: 1px; border-color: var(--j-gold); }
  .j-top { padding-top: 5.5rem; }
}

.j-section { display: none; }
.j-section.active { display: block; }
.j-section > h2 { font-family: 'Playfair Display', Georgia, serif; color: var(--j-heading); font-size: 1.45rem; margin: 0 0 0.25rem; }
.j-section > .j-lede { color: var(--j-muted); margin: 0 0 1.25rem; font-size: 0.92rem; }

/* ── Cards & tiles ───────────────────────────────────────────────────── */
.j-card { background: var(--j-surface); border: 1px solid var(--j-line); border-radius: 14px; padding: 1.25rem 1.35rem; box-shadow: var(--j-shadow); }
.j-card h3 { font-family: 'Playfair Display', Georgia, serif; color: var(--j-heading); font-size: 1.08rem; margin: 0 0 0.2rem; }
.j-card .j-sub { color: var(--j-muted); font-size: 0.85rem; margin: 0 0 0.75rem; }
.j-grid { display: grid; gap: 1rem; }
.j-grid.two { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.j-grid.three { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.j-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.85rem; margin-bottom: 1.25rem; }
.j-stat { background: var(--j-surface); border: 1px solid var(--j-line); border-radius: 14px; padding: 1rem 1.1rem; box-shadow: var(--j-shadow); }
.j-stat b { display: block; font-family: 'Playfair Display', Georgia, serif; font-size: 1.9rem; color: var(--j-heading); line-height: 1.1; }
.j-stat span { color: var(--j-muted); font-size: 0.82rem; }
.j-eyebrow { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--j-accent); margin: 0 0 0.35rem; }

.j-continue { display: grid; grid-template-columns: 1fr auto; gap: 1rem; align-items: center; margin-bottom: 1.25rem; border-left: 4px solid var(--j-gold); }
.j-continue h3 { font-size: 1.3rem; }
@media (max-width: 560px) { .j-continue { grid-template-columns: 1fr; } }

.j-progress { height: 8px; background: var(--j-track); border-radius: 999px; overflow: hidden; margin: 0.6rem 0 0.35rem; }
.j-progress > i { display: block; height: 100%; background: var(--j-fill); border-radius: 999px; }
.j-meta { display: flex; justify-content: space-between; gap: 0.5rem; color: var(--j-muted); font-size: 0.8rem; flex-wrap: wrap; }

.j-btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; background: var(--j-btn); color: var(--j-btn-ink); border: 1px solid var(--j-btn); border-radius: 10px; padding: 0.65rem 1.15rem; font: inherit; font-size: 0.9rem; font-weight: 700; text-decoration: none; cursor: pointer; min-height: 44px; }
.j-btn.ghost { background: transparent; color: var(--j-heading); border-color: var(--j-line); }
.j-btn.ghost:hover { border-color: var(--j-gold); }
.j-btn.small { padding: 0.4rem 0.8rem; font-size: 0.82rem; min-height: 36px; }
.j-btn[disabled] { opacity: 0.55; cursor: default; }
.j-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.85rem; }

.j-list { list-style: none; margin: 0; padding: 0; }
.j-list li { display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.5rem 0; border-bottom: 1px solid var(--j-line); font-size: 0.9rem; }
.j-list li:last-child { border-bottom: 0; }
.j-list .j-dot { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; margin-top: 0.45rem; background: var(--j-gold); }
.j-list a { color: var(--j-heading); font-weight: 600; }

.j-quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0.6rem; }
.j-quick button, .j-quick a { background: var(--j-surface-2); border: 1px solid var(--j-line); border-radius: 12px; padding: 0.85rem 0.6rem; text-align: center; font: inherit; font-size: 0.85rem; font-weight: 600; color: var(--j-heading); cursor: pointer; text-decoration: none; }
.j-quick button:hover, .j-quick a:hover { border-color: var(--j-gold); }
.j-quick .j-ico { display: block; font-size: 1.25rem; margin-bottom: 0.2rem; }

.j-reflect { background: var(--j-warn-bg); color: var(--j-warn-ink); border: 1px solid var(--j-line); }
.j-reflect h3 { color: var(--j-warn-ink); }
.j-reflect blockquote { margin: 0.4rem 0 0; font-family: 'Playfair Display', Georgia, serif; font-size: 1.1rem; line-height: 1.5; }

.j-banner { background: var(--j-ok-bg); color: var(--j-ok); border: 1px solid var(--j-line); border-radius: 12px; padding: 0.8rem 1rem; margin-bottom: 1rem; font-weight: 600; font-size: 0.9rem; }
.j-banner.warn { background: var(--j-warn-bg); color: var(--j-warn-ink); }
.j-empty { text-align: center; color: var(--j-muted); padding: 2rem 1rem; }
.j-empty h3 { color: var(--j-heading); }

/* course cards */
.j-filters { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.j-filters button { background: var(--j-surface); border: 1px solid var(--j-line); color: var(--j-muted); border-radius: 999px; padding: 0.4rem 0.9rem; font: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer; min-height: 36px; }
.j-filters button[aria-pressed="true"] { background: var(--j-btn); border-color: var(--j-btn); color: var(--j-btn-ink); }
.j-course { display: flex; flex-direction: column; }
.j-course .j-actions { margin-top: auto; padding-top: 0.85rem; }
.j-pill { display: inline-block; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; padding: 0.2rem 0.55rem; border-radius: 999px; background: var(--j-surface-2); color: var(--j-muted); }
.j-pill.completed { background: var(--j-ok-bg); color: var(--j-ok); }
.j-pill.in-progress { background: var(--j-warn-bg); color: var(--j-warn-ink); }
.j-pill.up-next { background: var(--j-btn); color: var(--j-btn-ink); }
.j-pill.locked, .j-pill.inactive { background: var(--j-surface-2); color: var(--j-muted); }

/* growth plan + journal */
.j-checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0.5rem; margin: 0.5rem 0 1rem; }
.j-checks label { display: flex; gap: 0.6rem; align-items: center; background: var(--j-surface-2); border: 1px solid var(--j-line); border-radius: 10px; padding: 0.65rem 0.8rem; cursor: pointer; font-size: 0.9rem; }
.j-checks input { width: 18px; height: 18px; accent-color: var(--j-gold); }
.j-field { display: block; margin: 0 0 0.85rem; }
.j-field > span { display: block; font-size: 0.8rem; font-weight: 700; color: var(--j-heading); margin-bottom: 0.3rem; }
.j-field textarea, .j-field select, .j-field input[type="text"] { width: 100%; font: inherit; font-size: 0.92rem; padding: 0.65rem 0.75rem; border-radius: 10px; border: 1.5px solid var(--j-line); background: var(--j-surface); color: var(--j-ink); }
.j-field textarea { min-height: 130px; resize: vertical; line-height: 1.6; }
.j-hint { color: var(--j-muted); font-size: 0.8rem; margin: 0.25rem 0 0; }
.j-private { display: flex; gap: 0.6rem; align-items: flex-start; background: var(--j-surface-2); border-radius: 12px; padding: 0.8rem 1rem; font-size: 0.85rem; color: var(--j-muted); margin-bottom: 1rem; }
.j-entry { padding: 1rem 0; border-bottom: 1px solid var(--j-line); }
.j-entry:last-child { border-bottom: 0; }
.j-entry-head { display: flex; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; align-items: baseline; }
.j-entry-head strong { color: var(--j-heading); }
.j-entry-head small { color: var(--j-muted); }
.j-entry p { white-space: pre-wrap; margin: 0.4rem 0 0; font-size: 0.92rem; }
.j-entry .j-actions { margin-top: 0.5rem; }

/* roadmap */
.j-roadmap { list-style: none; margin: 0; padding: 0; counter-reset: none; }
.j-roadmap li { display: grid; grid-template-columns: 2.2rem 1fr auto; gap: 0.75rem; align-items: start; padding: 0.85rem 0; border-bottom: 1px solid var(--j-line); }
.j-roadmap li:last-child { border-bottom: 0; }
.j-roadmap .j-num { width: 2.2rem; height: 2.2rem; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 0.85rem; background: var(--j-surface-2); color: var(--j-muted); border: 1px solid var(--j-line); }
.j-roadmap li.completed .j-num { background: var(--j-ok-bg); color: var(--j-ok); }
.j-roadmap li.up-next .j-num { background: var(--j-btn); color: var(--j-btn-ink); border-color: var(--j-btn); }
.j-roadmap strong { color: var(--j-heading); display: block; }
.j-roadmap p { margin: 0.15rem 0 0; color: var(--j-muted); font-size: 0.85rem; }
.j-reqs li .j-dot.done { background: var(--j-ok); }
.j-reqs li .j-dot.todo { background: transparent; border: 2px solid var(--j-gold); }
.j-reqs li .j-dot.unknown { background: var(--j-track); }

/* take a break */
.j-modal-back { position: fixed; inset: 0; background: rgba(10, 12, 10, 0.55); display: none; align-items: center; justify-content: center; padding: 1rem; z-index: 9000; }
.j-modal-back.open { display: flex; }
.j-modal { background: var(--j-surface); color: var(--j-ink); border-radius: 16px; max-width: 520px; width: 100%; padding: 1.5rem 1.6rem; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); max-height: 90vh; overflow-y: auto; }
.j-modal h2 { font-family: 'Playfair Display', Georgia, serif; color: var(--j-heading); margin: 0 0 0.4rem; font-size: 1.4rem; }
.j-modal ol { padding-left: 1.2rem; margin: 0.6rem 0; }
.j-modal li { margin: 0.25rem 0; }
.j-breathe { width: 84px; height: 84px; border-radius: 50%; margin: 0.75rem auto; background: radial-gradient(circle, var(--j-gold), transparent 70%); animation: j-breathe 10s ease-in-out infinite; }
@keyframes j-breathe { 0%, 100% { transform: scale(0.7); opacity: 0.6; } 40% { transform: scale(1.15); opacity: 1; } 60% { transform: scale(1.15); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .j-breathe { animation: none; } .j-progress > i { transition: none; } }
.j-crisis { font-size: 0.82rem; color: var(--j-muted); border-top: 1px solid var(--j-line); margin-top: 1rem; padding-top: 0.8rem; }

.j-loading { color: var(--j-muted); padding: 2rem 0; text-align: center; }

/* Older portal sections placed inside the new layout */
.j-section .section-header { padding: 0 0 1rem; max-width: none; margin: 0; }
.j-section .cert-grid, .j-section .account-container { padding: 0; max-width: none; margin: 0; }
.j-section .account-container { max-width: 640px; }
.j-layout footer { grid-column: 1 / -1; text-align: center; color: var(--j-muted); font-size: 0.8rem; padding-top: 2rem; }
.j-layout footer a { color: var(--j-heading); }
