/* Margam — layout + components.
   Built on the tokens in theme.css. */

html, body { margin: 0; padding: 0; min-height: 100%; }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============ INPUTS ============ */
input, select, textarea {
  font-family: inherit;
  font-size: var(--t-base);
  padding: 9px 12px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-3);
  background: var(--surface);
  color: var(--text);
  width: 100%;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--text-4); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
textarea { resize: vertical; min-height: 80px; }

label {
  display: block;
  font-size: var(--t-sm);
  color: var(--text-2);
  font-weight: 500;
  margin-bottom: 6px;
}
label .hint {
  color: var(--text-3);
  font-weight: 400;
  font-size: var(--t-xs);
}

button {
  cursor: pointer;
  padding: 9px 16px;
  border-radius: var(--r-3);
  font-size: var(--t-md);
  transition: background var(--dur-fast) var(--ease);
}

.skip-link {
  position: absolute;
  left: -9999px;
}
.skip-link:focus {
  left: 8px; top: 8px;
  background: var(--brand);
  color: var(--brand-fg);
  padding: 8px 12px;
  z-index: 1000;
  border-radius: var(--r-3);
}

/* ============ HEADER ============ */
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-7);
  gap: var(--sp-5);
}
.brand { display: flex; align-items: center; gap: var(--sp-3); text-decoration: none; color: inherit; }
.brand:hover { text-decoration: none; }

.header-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.header-actions-slot {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.link-button {
  background: transparent;
  color: var(--text-2);
  border-color: var(--border-2);
}
.link-button:hover { background: var(--surface-2); color: var(--text); }

/* On the dark maroon chapter card, the link-button needs a light treatment */
.chapter-card .link-button {
  background: rgba(255, 255, 255, 0.10);
  color: var(--gold-2);
  border-color: rgba(255, 255, 255, 0.25);
}
.chapter-card .link-button:hover {
  background: rgba(255, 255, 255, 0.20);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.45);
}

.header-select {
  background: var(--surface);
  border: 1px solid var(--border-2);
  color: var(--text);
  font-size: var(--t-md);
  padding: 6px 28px 6px 10px;
  border-radius: var(--r-3);
  max-width: 220px;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='%235A4A3F' d='M2 4l4 4 4-4z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.header-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--brand);
  color: var(--brand-fg);
  font-size: var(--t-md);
  font-weight: 700;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: transform var(--dur-fast) var(--ease);
}
.header-avatar:hover { transform: scale(1.05); }

.account-menu {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-4);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 1000;
  min-width: 190px;
  display: flex;
  flex-direction: column;
}
.account-menu a, .account-menu button {
  display: block;
  text-align: left;
  width: 100%;
  background: transparent;
  border: none;
  padding: 9px 14px;
  font-size: var(--t-md);
  color: var(--text);
  border-radius: var(--r-2);
  cursor: pointer;
  text-decoration: none;
}
.account-menu a:hover, .account-menu button:hover {
  background: var(--surface-2);
  text-decoration: none;
}
.account-menu button[data-act="signout"] { color: var(--danger); }

.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border-2);
  border-radius: var(--r-3);
  width: 36px; height: 36px;
  padding: 0;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
}
.nav-toggle span {
  display: block;
  width: 16px;
  height: 1.5px;
  background: var(--text);
  border-radius: 2px;
  transition: transform var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
}
body.nav-open .nav-toggle span:nth-child(1) { transform: translateY(5px) rotate(45deg); }
body.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
body.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-5px) rotate(-45deg); }

/* ============ LAYOUT ============ */
.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 60px - 50px);
}

.side-nav {
  padding: var(--sp-4) 0;
}
.side-nav ul { list-style: none; padding: 0; margin: 0; }
.side-nav li { margin: 0; }
.side-nav a {
  display: block;
  padding: 7px var(--sp-5) 7px var(--sp-5);
  font-size: var(--t-md);
  font-weight: 500;
  transition: background var(--dur-fast) var(--ease);
}
.nav-group {
  font-size: 0.68rem;
  color: var(--text-3);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: var(--sp-5) var(--sp-5) var(--sp-2);
  font-weight: 600;
  list-style: none;
}
.nav-group:first-child { padding-top: var(--sp-2); }

body.local-mode .cloud-only { display: none !important; }
body.cloud-mode:not(.has-events) .parent-only { display: none !important; }
body.cloud-mode:not(.has-schools) .school-only { display: none !important; }
body.cloud-mode:not(.has-many-events) .multi-event-only { display: none !important; }
body.cloud-mode:not(.has-events) .nav-group.parent-only,
body.cloud-mode:not(.has-schools) .nav-group.school-only { display: none !important; }

.view {
  padding: var(--sp-8) clamp(var(--sp-5), 4vw, var(--sp-12)) var(--sp-12);
  max-width: 1180px;
}

.view h2 {
  font-size: var(--t-4xl);
  margin: 0 0 var(--sp-2);
  letter-spacing: -0.018em;
}
.view .view-subtitle {
  color: var(--text-2);
  margin: 0 0 var(--sp-7);
  font-size: var(--t-lg);
  line-height: var(--lh-snug);
  max-width: 68ch;
}

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-bottom: var(--sp-7);
}
.view-header .view-header-left h2 { margin-bottom: var(--sp-1); }
.view-header .view-header-left .view-subtitle { margin: 0; }
.view-header .view-header-actions { display: flex; gap: var(--sp-2); flex-shrink: 0; }

/* Section-level h3 inside a view or modal gets natural bottom margin
   (theme.css sets h3 margin: 0 globally; restore breathing room here) */
.view > section > h3,
.view > div > h3,
.view section h3:first-child,
.modal-card form > div > h3 {
  margin-bottom: var(--sp-3);
}
.section-header {
  margin: var(--sp-7) 0 var(--sp-3);
  font-size: var(--t-xl);
}
.section-subhead {
  color: var(--text-3);
  font-size: var(--t-sm);
  margin: -8px 0 var(--sp-4);
  font-style: italic;
}

/* ============ CARDS ============ */
.card {
  padding: var(--sp-6);
  margin-bottom: var(--sp-4);
}

.card h3 {
  margin: 0 0 var(--sp-3);
  font-size: var(--t-xl);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--sp-4);
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-4);
  padding: var(--sp-5);
  box-shadow: var(--shadow-xs);
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-base) var(--ease), border-color var(--dur-fast) var(--ease);
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-2);
}

.stat-label {
  color: var(--text-3);
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0;
  font-weight: 600;
}

.stat-value {
  font-family: var(--font);
  font-size: var(--t-3xl);
  color: var(--text);
  margin: var(--sp-2) 0 0;
  line-height: 1.1;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.stat-sub {
  color: var(--text-3);
  font-size: var(--t-sm);
  margin-top: var(--sp-1);
}

/* ============ PROGRESS BARS ============ */
.progress {
  width: 100%;
  height: 6px;
  background: var(--surface-3);
  border-radius: var(--r-full);
  overflow: hidden;
  margin-top: var(--sp-2);
}
.progress > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: var(--r-full);
  transition: width var(--dur-slow) var(--ease);
}

.stack-bar {
  width: 100%;
  height: 12px;
  background: var(--surface-3);
  border-radius: var(--r-full);
  overflow: hidden;
  display: flex;
  margin-top: var(--sp-2);
}
.stack-bar span { display: block; height: 100%; }
.stack-bar .seg-planned   { background: var(--gold-2); }
.stack-bar .seg-committed { background: var(--accent); }
.stack-bar .seg-spent     { background: var(--brand); }

.legend {
  display: flex;
  gap: var(--sp-3);
  flex-wrap: wrap;
  font-size: var(--t-xs);
  color: var(--text-3);
  margin-top: var(--sp-2);
}
.legend span::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 2px;
  margin-right: 5px;
  vertical-align: middle;
}
.legend .l-planned::before   { background: var(--gold-2); }
.legend .l-committed::before { background: var(--accent); }
.legend .l-spent::before     { background: var(--brand); }
.legend .l-remaining::before { background: var(--surface-3); border: 1px solid var(--border); }

/* ============ FORMS ============ */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.form-actions {
  display: flex;
  gap: var(--sp-2);
  justify-content: flex-end;
  margin-top: var(--sp-4);
}
.btn-block { width: 100%; padding: 11px 16px; font-size: var(--t-lg); font-weight: 600; }
.code-input {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-family: var(--font-mono);
  text-align: center;
  font-size: var(--t-lg);
  padding: 12px;
}

/* ============ TABLES ============ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--r-4);
  overflow: hidden;
  border: 1px solid var(--border);
  font-size: var(--t-md);
}
.data-table th, .data-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.data-table th {
  background: var(--surface-2);
  color: var(--text-2);
  font-weight: 600;
  font-size: var(--t-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--hover); }
.data-table input, .data-table select, .data-table textarea {
  font-size: var(--t-sm);
  padding: 5px 8px;
  min-width: 0;
}
.row-actions { display: flex; gap: var(--sp-1); }

/* ============ TABS ============ */
.tabs {
  display: flex;
  gap: 0;
  overflow-x: auto;
  overflow-y: hidden;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-5);
  scrollbar-width: thin;
  scrollbar-color: var(--border-2) transparent;
}
.tabs::-webkit-scrollbar { height: 3px; }
.tabs::-webkit-scrollbar-track { background: transparent; }
.tabs::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }

.tab {
  background: transparent;
  border: none;
  padding: 10px 14px;
  color: var(--text-3);
  font-weight: 500;
  font-size: var(--t-md);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: 0;
  flex-shrink: 0;
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); border-bottom-color: var(--accent); font-weight: 600; }

/* ============ TIMELINE ============ */
.timeline-list {
  position: relative;
  padding-left: var(--sp-6);
  margin: 0;
  list-style: none;
}
.timeline-list::before {
  content: "";
  position: absolute;
  top: var(--sp-2);
  bottom: var(--sp-2);
  left: 7px;
  width: 2px;
  background: var(--border-2);
  border-radius: 1px;
}
.timeline-list li {
  position: relative;
  margin-bottom: var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-3);
  padding: var(--sp-3) var(--sp-4);
  box-shadow: var(--shadow-xs);
}
.timeline-list li::before {
  content: "";
  position: absolute;
  left: calc(var(--sp-6) * -1 + 1px);
  top: 18px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
}
.timeline-list li.done::before { background: var(--success); border-color: var(--success); }
.timeline-list .ms-head {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  align-items: baseline;
  flex-wrap: wrap;
}
.timeline-list .ms-title { font-weight: 600; color: var(--text); font-size: var(--t-base); }
.timeline-list .ms-due {
  color: var(--text-3);
  font-size: var(--t-xs);
  font-weight: 500;
}
.timeline-list .ms-notes { color: var(--text-2); font-size: var(--t-sm); margin: 6px 0 0; line-height: var(--lh-normal); }

/* ============ CHECKLIST (inline) ============ */
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-3);
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.checklist li:last-child { border-bottom: none; }
.checklist li.done .task-text { text-decoration: line-through; color: var(--text-3); }
.checklist input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  margin: 0;
}
.task-text { font-size: var(--t-base); }
.task-meta { font-size: var(--t-xs); color: var(--text-3); margin-top: 2px; }

.filter-bar {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: var(--sp-4);
}
.filter-bar input, .filter-bar select {
  width: auto;
  min-width: 200px;
}

.empty-state {
  text-align: center;
  padding: var(--sp-12) var(--sp-5);
  color: var(--text-3);
  background: var(--surface);
  border: 1px dashed var(--border-2);
  border-radius: var(--r-4);
}

/* ============ MODAL ============ */
.modal-root {
  position: fixed;
  inset: 0;
  background: rgba(31, 24, 20, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--sp-5);
  animation: fadeIn var(--dur-base) var(--ease);
}
.modal-root[hidden] { display: none; }
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-5);
  max-width: 540px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: var(--sp-8) var(--sp-8) var(--sp-6);
  box-shadow: var(--shadow-xl);
  animation: scaleIn var(--dur-base) var(--ease);
}
.modal-card h2 { margin: 0 0 var(--sp-2); font-size: var(--t-2xl); }
.modal-card h3 { margin: 0 0 var(--sp-3); font-size: var(--t-xl); }
.modal-card > p { color: var(--text-2); line-height: var(--lh-normal); margin: 0 0 var(--sp-4); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* ============ FOOTER ============ */
.site-footer {
  background: var(--bg);
  color: var(--text-3);
  text-align: center;
  padding: var(--sp-5) var(--sp-5);
  font-size: var(--t-sm);
  border-top: 1px solid var(--border);
}

/* ============ DASHBOARD HERO / CHAPTER CARD (deprecated, kept for compat) ============ */
.dashboard-hero {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  color: var(--brand-fg);
  border-radius: var(--r-5);
  padding: var(--sp-7) var(--sp-8);
  margin-bottom: var(--sp-6);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--sp-6);
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}
.dashboard-hero h2 { color: var(--brand-fg); margin: 0 0 var(--sp-2); }
.dashboard-hero p { margin: 0; color: var(--gold-2); }
.dashboard-hero .hero-motif { width: 96px; height: 96px; color: var(--gold); opacity: 0.7; }

.countdown-box {
  display: flex;
  gap: var(--sp-3);
  margin-top: var(--sp-4);
}
.countdown-unit {
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--r-3);
  padding: 10px 16px;
  text-align: center;
  min-width: 72px;
}
.countdown-unit b {
  display: block;
  font-size: var(--t-3xl);
  color: var(--brand-fg);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
}
.countdown-unit small {
  color: var(--gold-2);
  font-size: var(--t-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 4px;
  display: block;
}

/* ============ TODAY VIEW ============ */
.today-greeting {
  font-size: var(--t-3xl);
  color: var(--text);
  margin: 0 0 var(--sp-2);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.018em;
}
.today-greeting em { color: var(--accent); font-style: normal; }
.today-sub {
  color: var(--text-2);
  margin: 0 0 var(--sp-7);
  font-size: var(--t-lg);
  line-height: var(--lh-snug);
  max-width: 68ch;
}

.chapter-card {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  color: var(--brand-fg);
  border-radius: var(--r-5);
  padding: var(--sp-8) var(--sp-8);
  margin-bottom: var(--sp-6);
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}
.chapter-card::before {
  content: "";
  position: absolute;
  top: -40%;
  right: -10%;
  width: 60%;
  height: 200%;
  background: radial-gradient(ellipse at center, rgba(196, 164, 90, 0.20), transparent 60%);
  pointer-events: none;
}
.chapter-card .chapter-eyebrow {
  color: var(--gold-2);
  font-size: var(--t-xs);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin: 0;
  font-weight: 600;
}
.chapter-card .chapter-name {
  font-family: var(--font);
  font-size: var(--t-4xl);
  margin: var(--sp-2) 0 var(--sp-1);
  color: var(--brand-fg);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.022em;
  position: relative;
}
.chapter-card .chapter-translation {
  color: var(--gold-2);
  margin: 0;
  font-family: var(--font);
  font-size: var(--t-md);
  font-style: italic;
  position: relative;
}
.chapter-card .chapter-tagline {
  margin: var(--sp-4) 0 0;
  font-size: var(--t-base);
  color: var(--brand-fg);
  opacity: 0.9;
  max-width: 56ch;
  line-height: var(--lh-normal);
  position: relative;
}
.chapter-card .chapter-meta {
  display: flex;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-top: var(--sp-5);
  align-items: center;
  position: relative;
}
.chapter-card .chapter-meta .pill {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: var(--brand-fg);
  padding: 5px 12px;
  border-radius: var(--r-full);
  font-size: var(--t-sm);
}

/* Focus cards */
.focus-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-4);
  padding: var(--sp-4) var(--sp-5);
  margin-bottom: var(--sp-3);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--dur-base) var(--ease), transform var(--dur-fast) var(--ease);
}
.focus-card:hover { box-shadow: var(--shadow-md); transform: translateX(2px); }
.focus-card .focus-eyebrow {
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: var(--t-xs);
  margin: 0 0 var(--sp-1);
  font-weight: 600;
}
.focus-card .focus-title {
  margin: 0;
  color: var(--text);
  font-size: var(--t-lg);
  font-weight: 600;
}
.focus-card .focus-meta {
  color: var(--text-2);
  font-size: var(--t-sm);
  margin: 4px 0 0;
  line-height: var(--lh-normal);
}

/* Wisdom + Reflection (keep serif for emotional weight) */
.wisdom-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: var(--r-4);
  padding: var(--sp-6);
  font-family: var(--font-serif);
  font-size: var(--t-lg);
  font-style: italic;
  color: var(--text);
  line-height: var(--lh-relaxed);
  position: relative;
}
.wisdom-card::before {
  content: '\201C';
  position: absolute;
  top: -8px;
  left: 14px;
  font-size: 3rem;
  color: var(--gold);
  font-family: var(--font-serif);
  line-height: 1;
}
.wisdom-card .wisdom-attribution {
  display: block;
  margin-top: var(--sp-3);
  font-size: var(--t-xs);
  font-style: normal;
  color: var(--text-3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-family: var(--font);
}

.reflection-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-4);
  padding: var(--sp-6);
  box-shadow: var(--shadow-xs);
}
.reflection-card .reflection-eyebrow {
  color: var(--accent);
  font-size: var(--t-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0 0 var(--sp-2);
  font-weight: 600;
}
.reflection-card .reflection-prompt {
  font-family: var(--font-serif);
  font-size: var(--t-2xl);
  color: var(--text);
  margin: 0 0 var(--sp-4);
  line-height: 1.3;
  font-style: italic;
}

/* ============ JOURNEY MAP ============ */
/* Layout math:
   - .journey-map gets padding-left: 36px so li content starts at x=36
   - Vertical line at left: 17px (center at x=18 since line is 2px wide)
   - Dot 16x16 centered at x=18 → from li, dot left = 18 - 8 - 36 = -26px */
.journey-map {
  position: relative;
  padding-left: 36px;
  margin: var(--sp-6) 0;
  list-style: none;
}
.journey-map::before {
  content: "";
  position: absolute;
  top: 14px;
  bottom: 14px;
  left: 17px;
  width: 2px;
  background: linear-gradient(180deg, var(--gold-2), var(--accent), var(--brand));
  border-radius: 1px;
}
.journey-map > li {
  position: relative;
  margin-bottom: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-4);
  padding: var(--sp-5) var(--sp-6);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--dur-base) var(--ease);
}
.journey-map > li:hover { box-shadow: var(--shadow-md); }
.journey-map > li::before {
  content: "";
  position: absolute;
  left: -26px;
  top: 22px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border-3);
  box-sizing: border-box;
}
.journey-map > li.current::before {
  background: var(--accent);
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--accent-bg);
}
.journey-map > li.past::before { background: var(--brand); border-color: var(--brand); }
.journey-map > li.future { opacity: 0.75; }
.journey-map .ch-head {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  align-items: baseline;
  flex-wrap: wrap;
}
.journey-map .ch-name {
  font-size: var(--t-2xl);
  color: var(--brand);
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.journey-map .ch-translation {
  font-style: italic;
  color: var(--text-3);
  font-size: var(--t-md);
  font-weight: 400;
}
.journey-map .ch-period {
  font-size: var(--t-xs);
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.journey-map .ch-tagline {
  color: var(--text-2);
  margin: var(--sp-2) 0 var(--sp-3);
  font-size: var(--t-md);
  line-height: var(--lh-normal);
}
.journey-map details { margin-top: var(--sp-2); }
.journey-map summary {
  cursor: pointer;
  color: var(--brand);
  font-weight: 600;
  font-size: var(--t-sm);
  padding: var(--sp-1) 0;
  outline: none;
}
.journey-map summary:hover { text-decoration: underline; }
.journey-map .ch-section { margin: var(--sp-3) 0 0; color: var(--text); line-height: var(--lh-normal); }
.journey-map .ch-section h4 {
  margin: var(--sp-3) 0 var(--sp-1);
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  font-weight: 600;
}

/* ============ JOURNAL ============ */
.journal-entry {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-4);
  padding: var(--sp-5) var(--sp-6);
  margin-bottom: var(--sp-3);
  box-shadow: var(--shadow-xs);
}
.journal-entry .je-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--sp-3);
  color: var(--text-3);
  font-size: var(--t-xs);
  margin-bottom: var(--sp-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.journal-entry .je-prompt {
  font-family: var(--font-serif);
  color: var(--brand);
  font-style: italic;
  font-size: var(--t-lg);
  margin: 0 0 var(--sp-2);
}
.journal-entry .je-body {
  white-space: pre-wrap;
  color: var(--text);
  margin: 0;
  font-size: var(--t-base);
  line-height: var(--lh-relaxed);
}
.journal-entry .je-actions { display: flex; gap: var(--sp-2); margin-top: var(--sp-3); }

/* ============ ONBOARDING CARDS ============ */
.onboard-primary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}
.onboard-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-4);
  padding: var(--sp-6);
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.onboard-card.primary {
  border-top: 3px solid var(--accent);
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
  box-shadow: var(--shadow-md);
}
.onboard-card h3 { margin: 0; font-size: var(--t-xl); color: var(--brand); }
.onboard-card p { margin: 0 0 var(--sp-2); color: var(--text-2); line-height: var(--lh-normal); font-size: var(--t-md); }
.onboard-card button { align-self: flex-start; }
.onboard-secondary { margin-top: var(--sp-2); }
.onboard-secondary summary {
  cursor: pointer;
  color: var(--text-3);
  font-size: var(--t-md);
  padding: var(--sp-2) 0;
}
.onboard-secondary summary:hover { color: var(--brand); }

/* Parent-form school code section gets visual emphasis */
.parent-form-section {
  background: var(--accent-bg);
  border-radius: var(--r-4);
  padding: var(--sp-4) var(--sp-5);
  margin-bottom: var(--sp-2);
}

/* ============ TOAST ============ */
.toast-root {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
}
.toast {
  background: var(--text);
  color: var(--surface);
  padding: 11px 22px;
  border-radius: var(--r-full);
  font-size: var(--t-md);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity var(--dur-base) var(--ease), transform var(--dur-base) var(--ease);
  pointer-events: auto;
  max-width: 90vw;
}
.toast.on { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--success); }
.toast-danger  { background: var(--danger); }

/* ============ SPINNER ============ */
.spinner-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-10) var(--sp-3);
  gap: var(--sp-3);
}
.spinner {
  width: 28px; height: 28px;
  border: 2.5px solid var(--surface-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner-label { margin: 0; color: var(--text-3); font-size: var(--t-md); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ VIEW TRANSITIONS ============ */
.view-enter { animation: viewEnter var(--dur-slow) var(--ease); }
@keyframes viewEnter {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .view-enter, .modal-card, .modal-root { animation: none !important; }
  .spinner { animation: none; border-top-color: var(--accent); }
  .toast { transition: none; }
}

/* ============ AUTH SCREEN ============ */
.auth-screen {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg);
}
.auth-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle 700px at 88% 8%, var(--gold-bg), transparent 55%),
    radial-gradient(circle 600px at 12% 90%, var(--accent-bg), transparent 55%);
  opacity: 0.7;
}
.auth-container {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: var(--sp-16) var(--sp-6) var(--sp-12);
}

/* Auth Hero */
.auth-hero {
  text-align: center;
  margin-bottom: var(--sp-12);
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}
.auth-logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px; height: 72px;
  border-radius: var(--r-5);
  background: var(--brand);
  box-shadow: var(--shadow-lg);
  margin-bottom: var(--sp-4);
  position: relative;
}
.auth-logo-mark::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--r-5);
  background: linear-gradient(180deg, rgba(255,255,255,0.10), transparent);
  pointer-events: none;
}
.auth-logo-mark svg { width: 44px; height: 44px; color: var(--gold); }
.auth-wordmark {
  font-family: var(--font-serif);
  font-size: var(--t-5xl);
  margin: 0 0 var(--sp-3);
  color: var(--brand);
  letter-spacing: -0.02em;
  font-weight: 600;
  line-height: 1;
}
.auth-hero .auth-tagline {
  font-size: var(--t-2xl);
  color: var(--text);
  margin: 0 0 var(--sp-3);
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.015em;
}
.auth-blurb {
  color: var(--text-2);
  font-size: var(--t-lg);
  margin: 0 auto;
  line-height: var(--lh-normal);
  max-width: 56ch;
}

.auth-ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  margin: var(--sp-10) auto var(--sp-8);
  max-width: 200px;
}
.auth-ornament-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold) 50%, transparent);
}
.auth-ornament-dot { color: var(--gold); font-size: var(--t-sm); }

/* Path cards as 3-column grid */
.auth-paths-title {
  text-align: center;
  font-size: var(--t-xl);
  font-weight: 500;
  color: var(--text-2);
  margin: 0 0 var(--sp-6);
}
.auth-paths {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-4);
  max-width: 1000px;
  margin: 0 auto;
}
.path-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-5);
  padding: var(--sp-7) var(--sp-6) var(--sp-6);
  text-align: left;
  cursor: pointer;
  width: 100%;
  font-family: inherit;
  box-shadow: var(--shadow-sm);
  position: relative;
  transition: transform var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease), border-color var(--dur-fast) var(--ease);
  display: flex;
  flex-direction: column;
}
.path-card:hover, .path-card:focus-visible {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
  outline: none;
}
.path-card-primary {
  border-top: 3px solid var(--accent);
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
}

.path-icon {
  width: 48px; height: 48px;
  border-radius: var(--r-4);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand);
  flex-shrink: 0;
  margin-bottom: var(--sp-4);
  transition: transform var(--dur-base) var(--ease);
}
.path-icon svg { width: 26px; height: 26px; }
.path-card-primary .path-icon { background: var(--brand); color: var(--gold-2); }
.path-card:hover .path-icon { transform: scale(1.06); }

.path-tag {
  display: inline-block;
  background: var(--accent);
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--r-full);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: var(--sp-2);
}
.path-text { flex: 1; min-width: 0; }
.path-text h3 {
  margin: 0 0 var(--sp-2);
  color: var(--text);
  font-size: var(--t-xl);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.path-text p {
  margin: 0 0 var(--sp-5);
  color: var(--text-2);
  font-size: var(--t-md);
  line-height: var(--lh-normal);
}
.path-arrow {
  color: var(--accent);
  font-weight: 500;
  font-size: var(--t-md);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: auto;
}
.path-arrow::after { content: "→"; transition: transform var(--dur-base) var(--ease); }
.path-card:hover .path-arrow::after { transform: translateX(4px); }

.auth-footer {
  text-align: center;
  margin-top: var(--sp-12);
  color: var(--text-3);
  font-size: var(--t-md);
}
.auth-footer p { margin: 0 0 var(--sp-2); }
.auth-footer-trust {
  font-family: var(--font-serif);
  font-style: italic;
  opacity: 0.85;
  font-size: var(--t-md);
}
.link-inline {
  background: transparent;
  border: none;
  color: var(--brand);
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  font-size: inherit;
  font-family: inherit;
}
.link-inline:hover { text-decoration: underline; text-underline-offset: 2px; }
.hint { color: var(--text-3); font-weight: 400; font-size: var(--t-xs); }

/* Auth form (signup / signin) */
.auth-form-wrap {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--sp-8) var(--sp-4);
}
.auth-form-card {
  background: var(--surface);
  border-radius: var(--r-5);
  padding: var(--sp-10) var(--sp-10) var(--sp-7);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  max-width: 440px;
  width: 100%;
  position: relative;
  text-align: center;
}
.auth-back {
  position: absolute;
  top: var(--sp-3);
  left: var(--sp-3);
  background: transparent;
  border: none;
  color: var(--text-3);
  font-size: var(--t-sm);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--r-2);
  font-family: inherit;
}
.auth-back:hover { color: var(--brand); background: var(--surface-2); }
.auth-form-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px; height: 56px;
  margin: var(--sp-3) auto var(--sp-4);
  border-radius: var(--r-4);
  background: var(--surface-2);
  color: var(--brand);
}
.auth-form-icon svg { width: 28px; height: 28px; }
.auth-form-card h2 {
  margin: 0 0 var(--sp-1);
  font-size: var(--t-2xl);
  color: var(--text);
}
.auth-sub {
  color: var(--text-2);
  margin: 0 0 var(--sp-6);
  font-size: var(--t-md);
}
.auth-form-card form { text-align: left; }
.auth-help {
  color: var(--text-3);
  font-size: var(--t-sm);
  margin: var(--sp-4) 0 0;
  text-align: center;
}

/* Invite code box */
.invite-code-box {
  font-family: var(--font-mono);
  font-size: var(--t-2xl);
  font-weight: 600;
  letter-spacing: 0.16em;
  background: var(--surface-2);
  border: 1px dashed var(--border-3);
  border-radius: var(--r-4);
  padding: var(--sp-4) var(--sp-5);
  text-align: center;
  margin: var(--sp-4) 0;
  color: var(--brand);
  user-select: all;
}

/* ============ TOUR BANNER + INVITE NUDGE ============ */
.tour-banner {
  background: var(--surface-2);
  border: 1px solid var(--gold-2);
  border-radius: var(--r-4);
  padding: var(--sp-5) var(--sp-6) var(--sp-4);
  margin-bottom: var(--sp-5);
  position: relative;
}
.tour-banner h3 { margin: 0 0 var(--sp-2); font-size: var(--t-lg); color: var(--brand); }
.tour-banner p { margin: 0 0 var(--sp-2); color: var(--text-2); line-height: var(--lh-normal); font-size: var(--t-md); }
.tour-banner ol { margin: var(--sp-2) 0 var(--sp-3); padding-left: 22px; color: var(--text); line-height: 1.7; font-size: var(--t-md); }
.tour-banner ol li { margin-bottom: 4px; }
.tour-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: transparent;
  border: none;
  color: var(--text-3);
  font-size: var(--t-2xl);
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 50%;
}
.tour-close:hover { background: var(--surface); color: var(--brand); }

.invite-nudge {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-4);
  padding: var(--sp-4) var(--sp-5);
  margin-bottom: var(--sp-5);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-4);
  flex-wrap: wrap;
  box-shadow: var(--shadow-xs);
}
.invite-nudge-body h4 { margin: 0 0 var(--sp-1); color: var(--brand); font-size: var(--t-md); font-weight: 600; }
.invite-nudge-body p { margin: 0; color: var(--text-2); font-size: var(--t-sm); }
.invite-nudge-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

/* ============ ACCORDION (Tasks page) ============ */
.accordion { display: flex; flex-direction: column; gap: var(--sp-3); }
.acc-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-4);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.acc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  background: transparent;
  border: none;
  cursor: pointer;
  width: 100%;
  font-family: inherit;
  text-align: left;
  transition: background var(--dur-fast) var(--ease);
}
.acc-header:hover { background: var(--surface-2); }
.acc-header[aria-expanded="true"] { background: var(--surface-2); border-bottom: 1px solid var(--border); }
.acc-header h3 {
  margin: 0;
  font-size: var(--t-lg);
  color: var(--text);
  font-weight: 600;
}
.acc-header-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-shrink: 0;
  color: var(--text-3);
  font-size: var(--t-sm);
}
.acc-progress-mini {
  width: 80px; height: 4px;
  background: var(--surface-3);
  border-radius: var(--r-full);
  overflow: hidden;
}
.acc-progress-mini > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: var(--r-full);
  transition: width var(--dur-slow) var(--ease);
}
.acc-chevron {
  width: 16px; height: 16px;
  color: var(--text-3);
  transition: transform var(--dur-base) var(--ease);
}
.acc-header[aria-expanded="true"] .acc-chevron { transform: rotate(180deg); }
.acc-body { padding: var(--sp-3) var(--sp-5) var(--sp-5); }
.acc-body[hidden] { display: none; }

/* ============ MOBILE ============ */
@media (max-width: 820px) {
  .nav-toggle { display: inline-flex; }
  .layout { grid-template-columns: 1fr; }
  .side-nav {
    position: fixed;
    top: 0; left: -260px; bottom: 0;
    width: 240px;
    z-index: 900;
    border-right: 1px solid var(--border);
    transition: left var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
    overflow-y: auto;
    padding: var(--sp-6) 0 var(--sp-5);
    background: var(--surface);
  }
  body.nav-open .side-nav { left: 0; box-shadow: var(--shadow-xl); }
  body.nav-open::after {
    content: "";
    position: fixed; inset: 0;
    background: rgba(31, 24, 20, 0.40);
    z-index: 800;
  }
  .nav-group { padding: var(--sp-3) var(--sp-5) var(--sp-1); }
  .masthead { padding: var(--sp-3) var(--sp-4); gap: var(--sp-2); }
  .brand-tagline { display: none; }
  .brand-name { font-size: var(--t-xl); }
  .brand-mark { width: 32px; height: 32px; }
  .event-name { font-size: var(--t-sm); max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .header-select { max-width: 130px; font-size: var(--t-sm); padding-right: 24px; }
  .view { padding: var(--sp-6) var(--sp-4) var(--sp-10); }
  .auth-paths { grid-template-columns: 1fr; max-width: 480px; }
  .auth-container { padding: var(--sp-10) var(--sp-4) var(--sp-8); }
  .auth-wordmark { font-size: var(--t-4xl); }
  .auth-hero .auth-tagline { font-size: var(--t-xl); }
  .auth-form-card { padding: var(--sp-8) var(--sp-6) var(--sp-5); }
  .chapter-card { padding: var(--sp-6); }
  .today-greeting { font-size: var(--t-2xl); }
  .data-table { font-size: var(--t-sm); }
  .data-table th, .data-table td { padding: 8px 10px; }
  .form-row { grid-template-columns: 1fr; }
  .view-header { flex-direction: column; }
  .view-header .view-header-actions { width: 100%; }
}

@media (max-width: 480px) {
  .brand-name { font-size: var(--t-lg); }
  .stat-value { font-size: var(--t-2xl); }
  .auth-wordmark { font-size: 2.5rem; }
  .modal-card { padding: var(--sp-6) var(--sp-5); }
}

/* ============ PRINT ============ */
@media print {
  .site-header, .site-footer, .side-nav, .filter-bar, .form-actions, .row-actions, button { display: none !important; }
  body { background: #ffffff; color: #000; }
  .layout { display: block; }
  .view { padding: 0; max-width: none; }
  .card, .stat-card, .data-table { box-shadow: none; border: 1px solid #999; page-break-inside: avoid; }
  h2, h3 { color: #000; }
  .stat-value { color: #000; }
  .timeline-list::before { display: none; }
  .timeline-list { padding-left: 0; }
  .timeline-list li::before { display: none; }
}
