/* S-3 Leadership Platform — design system.
   Palette aims for the "managerial / mature" feel of S-3:
   - Paper cream background (continuity with S-1 / S-2)
   - Deep forest green as primary (calm, grounded, leadership)
   - Burgundy as accent (mature, considered)
   - Slate blue for muted ink
   - Sand for surfaces / cards
   Serif display headings; clean sans for body.
*/

:root {
  --ink:      #1c2a26;            /* near-black with green undertone */
  --ink-soft: #4a5953;
  --ink-mute: #7c8a85;
  --paper:    #f6f1e6;            /* cream — same family as S-1/S-2 */
  --surface:  #fdfaf2;            /* sand / lifted card */
  --surface-2:#efe8d6;            /* recessed */
  --primary:  #1f4d3a;            /* deep forest green */
  --primary-2:#2c6d54;            /* lighter green for hovers */
  --primary-soft:#dae8df;         /* tinted background */
  --accent:   #8c2a2a;            /* burgundy */
  --accent-soft:#f3dcd6;
  --gold:     #b08a3e;            /* aged brass — for badges & highlights */
  --gold-soft:#f1e5c4;
  --line:     #d9cfb6;            /* paper-tone divider */
  --line-soft:#e7ddc4;
  --good:     #2b6a4a;
  --warn:     #b08a3e;
  --bad:      #8c2a2a;
  --shadow:   0 1px 0 rgba(28,42,38,0.04), 0 8px 24px rgba(28,42,38,0.06);
  --shadow-lg:0 20px 60px -20px rgba(28,42,38,0.20);
  --radius:   10px;
  --radius-sm: 6px;
  --maxw:     1180px;
  --font-display: 'Cormorant Garamond', 'Garamond', 'Georgia', serif;
  --font-body:    'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* ─── RESET & BASE ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
  font-size: 15px;
  min-height: 100vh;
  /* subtle paper grain */
  background-image:
    radial-gradient(circle at 10% 20%, rgba(28,77,58,0.025) 0, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(140,42,42,0.022) 0, transparent 40%);
}

h1, h2, h3, h4 { font-family: var(--font-display); color: var(--ink); font-weight: 600; line-height: 1.2; }
h1 { font-size: 2.1rem; margin: 0 0 0.4em; letter-spacing: -0.01em; }
h2 { font-size: 1.5rem; margin: 1.8em 0 0.5em; }
h3 { font-size: 1.18rem; margin: 1.4em 0 0.4em; }
h4 { font-size: 1rem; margin: 1.2em 0 0.4em; font-family: var(--font-body); font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: var(--ink-soft); font-size: 0.78rem; }
p { margin: 0.6em 0; }
a { color: var(--primary); text-decoration: none; border-bottom: 1px solid transparent; transition: border-color 0.15s; }
a:hover { border-bottom-color: currentColor; }

em { font-style: italic; color: var(--accent); font-family: var(--font-display); }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.5em 0; }
code, pre { font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Monaco, Consolas, monospace; font-size: 0.92em; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; }

/* ─── LOGIN / REGISTRATION PAGE ───────────────────────────────────────── */
body.auth-page { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
@media (max-width: 880px) { body.auth-page { grid-template-columns: 1fr; } }

.auth-hero {
  background: linear-gradient(135deg, #18402f 0%, #1f4d3a 50%, #2c6d54 100%);
  color: #f4ecd7;
  padding: 4rem 3rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-hero::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 80% 15%, rgba(176,138,62,0.18) 0, transparent 35%),
    radial-gradient(circle at 15% 80%, rgba(140,42,42,0.15) 0, transparent 40%);
  pointer-events: none;
}
.auth-hero > * { position: relative; z-index: 1; }
.auth-hero .brand-line { font-family: var(--font-body); font-size: 0.8rem; letter-spacing: 0.22em; text-transform: uppercase; opacity: 0.72; }
.auth-hero h1 {
  font-family: var(--font-display);
  color: #f6efd9;
  font-size: clamp(2.4rem, 4vw, 3.6rem);
  line-height: 1.05;
  margin: 1rem 0;
  font-weight: 500;
}
.auth-hero h1 em { color: #d6b772; font-style: italic; }
.auth-hero p { max-width: 36ch; opacity: 0.85; }
.auth-hero .credits { font-size: 0.78rem; opacity: 0.55; letter-spacing: 0.04em; }
.auth-hero .badge {
  display: inline-block; padding: 6px 14px; border: 1px solid rgba(214,183,114,0.35);
  border-radius: 999px; font-size: 0.72rem; letter-spacing: 0.15em; text-transform: uppercase;
  color: #d6b772; margin-bottom: 1rem;
}

.auth-side {
  background: var(--paper);
  padding: 4rem 3rem;
  display: flex; flex-direction: column; justify-content: center;
}
.auth-card { max-width: 420px; width: 100%; margin: 0 auto; }
.auth-tabs { display: flex; gap: 0; margin-bottom: 1.4rem; border-bottom: 1px solid var(--line); }
.auth-tab {
  flex: 1; padding: 12px 6px; text-align: center; cursor: pointer; background: none; border: 0;
  font-family: var(--font-body); font-size: 0.92rem; color: var(--ink-mute);
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all 0.15s;
}
.auth-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.form-row { margin-bottom: 0.9rem; }
.form-row label { display: block; font-size: 0.78rem; font-weight: 600; color: var(--ink-soft); margin-bottom: 4px; letter-spacing: 0.03em; }
.form-row .hint { font-size: 0.72rem; color: var(--ink-mute); font-weight: 400; letter-spacing: 0; }
input, select, textarea {
  width: 100%; font-family: var(--font-body); font-size: 0.95rem; color: var(--ink);
  padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31,77,58,0.10); }
textarea { resize: vertical; min-height: 80px; font-family: var(--font-body); line-height: 1.5; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
@media (max-width: 540px) { .form-grid-2 { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-body); font-weight: 600; font-size: 0.92rem;
  padding: 10px 22px; border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; transition: all 0.15s;
  background: var(--primary); color: #f6efd9;
  letter-spacing: 0.01em;
}
.btn:hover { background: var(--primary-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--primary); border-color: var(--line); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-accent { background: var(--accent); }
.btn-accent:hover { background: #6f2222; }
.btn-sm { padding: 5px 12px; font-size: 0.82rem; }
.btn-danger { background: transparent; color: var(--bad); border-color: var(--accent-soft); }
.btn-danger:hover { background: var(--accent-soft); }

.error {
  background: var(--accent-soft); color: var(--accent); padding: 9px 12px;
  border-radius: var(--radius-sm); font-size: 0.88rem; margin-bottom: 0.8rem;
}

/* ─── APP SHELL ────────────────────────────────────────────────────────── */
body.app-page { background: var(--paper); }
#app-shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
@media (max-width: 880px) { #app-shell { grid-template-columns: 1fr; } .sidebar { display: none; } }

.sidebar {
  background: linear-gradient(180deg, #18402f 0%, #1f4d3a 100%);
  color: #d6cfb8;
  padding: 1.6rem 0;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { padding: 0 1.6rem 1.6rem; border-bottom: 1px solid rgba(214,183,114,0.18); }
.brand-sub { font-size: 0.68rem; letter-spacing: 0.22em; text-transform: uppercase; opacity: 0.7; margin-bottom: 4px; }
.brand-head { font-family: var(--font-display); font-size: 1.5rem; line-height: 1.1; color: #f4ecd7; font-weight: 500; }
.brand-head em { color: #d6b772; font-style: italic; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 1rem 0; }
.nav-group { padding: 0 1.6rem; margin-top: 1.2rem; }
.nav-group-title { font-size: 0.68rem; letter-spacing: 0.18em; text-transform: uppercase; opacity: 0.55; margin-bottom: 6px; }
.nav-item {
  display: block; padding: 7px 1.6rem; color: #d6cfb8;
  font-size: 0.92rem; cursor: pointer; border-left: 3px solid transparent; transition: all 0.15s;
}
.nav-item:hover { background: rgba(214,183,114,0.08); color: #f4ecd7; }
.nav-item.active { background: rgba(214,183,114,0.12); color: #f4ecd7; border-left-color: #d6b772; font-weight: 600; }

.sidebar-foot { padding: 1rem 1.6rem; border-top: 1px solid rgba(214,183,114,0.18); font-size: 0.85rem; }
.sidebar-foot .me-name { color: #f4ecd7; font-weight: 600; }
.sidebar-foot .me-role { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.65; margin-bottom: 6px; }
.sidebar-foot .signout { display: block; margin-top: 8px; color: #d6b772; cursor: pointer; font-size: 0.85rem; }
.sidebar-foot .signout:hover { color: #f0d894; }

.main { padding: 2rem 2.5rem 4rem; max-width: 100%; overflow-x: hidden; }
@media (max-width: 880px) { .main { padding: 1.4rem; } }

.page-head { margin-bottom: 1.8rem; }
.page-head .crumb { font-size: 0.74rem; letter-spacing: 0.15em; text-transform: uppercase; color: var(--ink-mute); margin-bottom: 0.4rem; }
.page-head h1 { margin: 0; }
.page-head p.subtitle { color: var(--ink-soft); max-width: 70ch; margin-top: 0.4rem; }

/* ─── CARDS / PANELS ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
  margin-bottom: 1.2rem;
  box-shadow: var(--shadow);
}
.card h2 { margin-top: 0; }
.card h3:first-child { margin-top: 0; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem;
}
.stat-label { font-size: 0.74rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-mute); margin-bottom: 4px; }
.stat-value { font-family: var(--font-display); font-size: 1.9rem; color: var(--primary); line-height: 1; font-weight: 600; }
.stat-sub { color: var(--ink-soft); font-size: 0.85rem; margin-top: 4px; }

.module-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.4rem; cursor: pointer; transition: all 0.15s;
  position: relative;
}
.module-card:hover { border-color: var(--primary); transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.module-card .module-num {
  font-family: var(--font-display); font-size: 0.85rem; letter-spacing: 0.18em;
  color: var(--gold); text-transform: uppercase; margin-bottom: 0.3rem;
}
.module-card h3 { margin: 0 0 0.4rem; }
.module-card p { font-size: 0.88rem; color: var(--ink-soft); margin: 0 0 0.6rem; }
.module-card .module-meta {
  display: flex; gap: 1rem; font-size: 0.78rem; color: var(--ink-mute);
  border-top: 1px solid var(--line-soft); padding-top: 0.6rem; margin-top: 0.6rem;
}
.module-card .pill {
  position: absolute; top: 1.4rem; right: 1.4rem;
  background: var(--primary-soft); color: var(--primary);
  font-size: 0.7rem; padding: 3px 10px; border-radius: 999px;
  letter-spacing: 0.06em;
}
.module-card .pill.done { background: var(--gold-soft); color: var(--gold); }

/* ─── MODULE READING PAGE ─────────────────────────────────────────────── */
.lesson { max-width: 75ch; margin: 0 auto; }
.lesson .module-header { margin-bottom: 2rem; padding-bottom: 1.2rem; border-bottom: 2px solid var(--line); }
.lesson .module-header .module-num { font-family: var(--font-display); font-size: 0.95rem; letter-spacing: 0.2em; color: var(--gold); text-transform: uppercase; }
.lesson h2 { color: var(--primary); }
.lesson h3 { color: var(--ink); }
.lesson ul, .lesson ol { padding-left: 1.4em; }
.lesson li { margin: 0.3em 0; }
.lesson .keypoint {
  background: var(--gold-soft); border-left: 4px solid var(--gold);
  padding: 0.9rem 1.1rem; margin: 1.2em 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.lesson .keypoint .keypoint-label { font-size: 0.72rem; letter-spacing: 0.15em; text-transform: uppercase; color: var(--gold); font-weight: 600; margin-bottom: 4px; }
.lesson .quote {
  font-family: var(--font-display); font-style: italic; font-size: 1.18rem;
  border-left: 3px solid var(--accent); padding: 0.4em 0 0.4em 1.2em;
  color: var(--ink-soft); margin: 1.2em 0;
}
.lesson table { border-collapse: collapse; width: 100%; margin: 1em 0; font-size: 0.9rem; }
.lesson th { background: var(--surface-2); text-align: left; padding: 8px 12px; border: 1px solid var(--line); }
.lesson td { padding: 8px 12px; border: 1px solid var(--line); vertical-align: top; }

/* ─── MCQ / QUIZ ──────────────────────────────────────────────────────── */
.mcq-question { margin: 1.4rem 0; padding: 1.2rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.mcq-question .qnum { font-size: 0.74rem; color: var(--gold); letter-spacing: 0.18em; text-transform: uppercase; margin-bottom: 4px; }
.mcq-question .qtext { font-weight: 600; margin-bottom: 0.8rem; color: var(--ink); }
.mcq-options { display: flex; flex-direction: column; gap: 6px; }
.mcq-opt {
  padding: 9px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  cursor: pointer; transition: all 0.15s; background: var(--paper); font-size: 0.92rem;
}
.mcq-opt:hover { border-color: var(--primary); }
.mcq-opt.selected { border-color: var(--primary); background: var(--primary-soft); font-weight: 500; }
.mcq-opt.correct { border-color: var(--good); background: #dfeee5; }
.mcq-opt.incorrect { border-color: var(--bad); background: var(--accent-soft); }
.mcq-explain { margin-top: 0.6rem; font-size: 0.86rem; color: var(--ink-soft); padding: 8px 12px; border-left: 3px solid var(--primary); background: var(--primary-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.score-banner {
  background: var(--primary); color: #f4ecd7; padding: 1.2rem 1.5rem;
  border-radius: var(--radius); display: flex; justify-content: space-between; align-items: center;
}
.score-banner .big { font-family: var(--font-display); font-size: 2.6rem; line-height: 1; }
.score-banner .label { font-size: 0.78rem; letter-spacing: 0.15em; text-transform: uppercase; opacity: 0.75; }

/* ─── SELF-ASSESSMENT (likert + bar charts) ───────────────────────────── */
.likert-table { width: 100%; border-collapse: collapse; }
.likert-table td { padding: 10px 8px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.likert-table td.qtext { font-size: 0.93rem; }
.likert-table td.qtag { font-size: 0.74rem; color: var(--gold); letter-spacing: 0.1em; text-transform: uppercase; width: 110px; text-align: right; }
.likert-row-scale { display: flex; gap: 4px; justify-content: flex-end; }
.likert-row-scale button {
  width: 30px; height: 30px; border: 1px solid var(--line); background: var(--paper);
  border-radius: 50%; cursor: pointer; font-family: var(--font-body); font-size: 0.85rem; color: var(--ink-soft);
  transition: all 0.12s;
}
.likert-row-scale button:hover { border-color: var(--primary); }
.likert-row-scale button.on { background: var(--primary); color: #f4ecd7; border-color: var(--primary); }

.bar-chart { display: flex; flex-direction: column; gap: 10px; margin: 1rem 0; }
.bar-row { display: grid; grid-template-columns: 160px 1fr 80px; align-items: center; gap: 10px; }
.bar-row .bar-label { font-size: 0.88rem; font-weight: 600; }
.bar-row .bar-track { background: var(--line-soft); height: 18px; border-radius: 999px; overflow: hidden; }
.bar-row .bar-fill { background: linear-gradient(90deg, var(--primary), var(--primary-2)); height: 100%; border-radius: 999px; transition: width 0.5s; }
.bar-row .bar-fill.accent { background: linear-gradient(90deg, var(--accent), #b04545); }
.bar-row .bar-fill.gold   { background: linear-gradient(90deg, var(--gold), #d6b772); }
.bar-row .bar-value { text-align: right; font-family: var(--font-display); font-size: 1.05rem; color: var(--primary); }

.interpret-card {
  background: var(--primary-soft); border-left: 4px solid var(--primary);
  padding: 1rem 1.2rem; margin: 1rem 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.interpret-card .label { font-size: 0.74rem; letter-spacing: 0.15em; text-transform: uppercase; color: var(--primary); font-weight: 600; }

/* ─── TEAM WORKSPACE ──────────────────────────────────────────────────── */
.team-banner {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #f4ecd7; padding: 1.4rem 1.6rem; border-radius: var(--radius);
  margin-bottom: 1.4rem;
}
.team-banner h2 { color: #f4ecd7; margin: 0; }
.team-banner .sub { font-size: 0.85rem; opacity: 0.8; }
.team-banner .members { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 0.7rem; }
.team-banner .members .chip {
  background: rgba(214,183,114,0.18); color: #f4ecd7; padding: 4px 11px;
  border-radius: 999px; font-size: 0.78rem;
}
.status-pill { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; }
.status-pill.draft     { background: var(--surface-2); color: var(--ink-soft); }
.status-pill.submitted { background: var(--gold-soft); color: var(--gold); }
.status-pill.approved  { background: #dfeee5; color: var(--good); }

.standup-week {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 0.9rem 1.1rem; margin-bottom: 0.8rem;
}
.standup-week .author-line { font-size: 0.78rem; color: var(--ink-mute); margin-bottom: 4px; }
.standup-week h4 { margin: 0.6rem 0 2px; color: var(--primary); font-size: 0.72rem; letter-spacing: 0.15em; }

/* ─── TABLES (lists, gradebook) ───────────────────────────────────────── */
.dt { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.dt th, .dt td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line-soft); font-size: 0.92rem; }
.dt th { background: var(--surface-2); font-weight: 600; font-size: 0.78rem; letter-spacing: 0.08em; color: var(--ink-soft); text-transform: uppercase; }
.dt tr:last-child td { border-bottom: 0; }
.dt tr:hover td { background: var(--paper); }
.dt .num { text-align: right; font-variant-numeric: tabular-nums; }
.dt .actions { text-align: right; white-space: nowrap; }

/* ─── TOAST ───────────────────────────────────────────────────────────── */
#toast-host { position: fixed; bottom: 1.5rem; right: 1.5rem; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
.toast { background: var(--ink); color: #f4ecd7; padding: 10px 16px; border-radius: var(--radius-sm); font-size: 0.88rem; box-shadow: var(--shadow-lg); animation: toast-in 0.2s ease-out; }
.toast.error { background: var(--accent); }
.toast.success { background: var(--good); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ─── MODAL ───────────────────────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(28,42,38,0.4); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 1rem; }
.modal { background: var(--surface); border-radius: var(--radius); padding: 1.6rem; max-width: 540px; width: 100%; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal h3 { margin-top: 0; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--line); }

/* ─── UTILITY ─────────────────────────────────────────────────────────── */
.row { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.6rem; } .mb-2 { margin-bottom: 1rem; }
.muted { color: var(--ink-mute); font-size: 0.88rem; }
.tag { display: inline-block; font-size: 0.7rem; padding: 2px 8px; border-radius: 999px; letter-spacing: 0.08em; }
.tag.green { background: var(--primary-soft); color: var(--primary); }
.tag.gold  { background: var(--gold-soft);  color: var(--gold); }
.tag.red   { background: var(--accent-soft); color: var(--bad); }

.hidden { display: none !important; }

/* responsive small-screen */
@media (max-width: 700px) {
  .bar-row { grid-template-columns: 100px 1fr 60px; gap: 6px; }
  .likert-table td.qtag { display: none; }
  .form-grid-2 { grid-template-columns: 1fr; }
}
