/* ═══════════════════════════════════════
   THE FORGE v2 PROTOTYPE — styles.css
   Visual prototype for Home Surface L1/L2/L3
   ═══════════════════════════════════════ */

/* ─── §1 — Reset & Theme Variables ─── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0f1219;
  --sidebar: #131825;
  --surface: #171c28;
  --surface-hover: #1d2335;
  --input-bg: #131825;
  --border: #252d3f;
  --border-focus: #3b4a6b;
  --text: #e2e8f0;
  --text-dim: #64748b;
  --text-mid: #94a3b8;
  --accent: #818cf8;
  --accent-dim: rgba(129,140,248,0.08);
  --accent-text: #fff;
  --danger: #f87171;
  --danger-dim: rgba(248,113,113,0.1);
  --success: #4ade80;
  --success-dim: rgba(74,222,128,0.1);
  --warning: #fbbf24;
  --warning-dim: rgba(251,191,36,0.1);
  --info: #60a5fa;
  --info-dim: rgba(96,165,250,0.1);
  --conf-mastered: #a78bfa;
  --conf-mastered-dim: rgba(167,139,250,0.1);
  --conf-distinction: #ec4899;
  --conf-distinction-dim: rgba(236,72,153,0.1);
  --radius: 10px;
  --radius-sm: 5px;
  --radius-lg: 14px;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* ─── §2 — Base & Typography ─── */
html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  height: 100%;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

/* ─── §3 — Top Bar ─── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 32px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: var(--accent-text);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
}

.brand-name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-btn {
  background: var(--surface);
  color: var(--text-mid);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  transition: background 150ms, color 150ms;
}

.top-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.top-btn-icon {
  background: var(--surface);
  color: var(--text-mid);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 16px;
  line-height: 1;
  transition: background 150ms, color 150ms;
}

.top-btn-icon:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* ─── §4 — L1: Home Hero ─── */
.home-surface {
  max-width: 840px;
  margin: 0 auto;
  padding: 0 32px;
}

.l1-hero {
  text-align: center;
  padding: 60px 0 40px;
  transition: opacity 300ms ease, max-height 300ms ease;
}

[data-level="l2"] .l1-hero,
[data-level="l3"] .l1-hero {
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  padding: 0;
  pointer-events: none;
}

.greeting {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.stat-line {
  color: var(--text-mid);
  font-size: 15px;
  margin-bottom: 32px;
}

.ask-bar {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  color: var(--text-dim);
  font-size: 15px;
  margin-bottom: 28px;
  text-align: left;
  cursor: text;
  transition: border-color 150ms;
}

.ask-bar:hover {
  border-color: var(--border-focus);
}

.reco-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 48px;
  text-align: left;
}

.reco-label {
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  margin-bottom: 8px;
}

.reco-topic {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
}

.reco-method {
  color: var(--text-mid);
  font-size: 14px;
  margin-bottom: 20px;
}

.reco-start {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 32px;
  font-size: 14px;
  font-weight: 600;
  transition: opacity 150ms;
}

.reco-start:hover {
  opacity: 0.85;
}

/* ─── §5 — Subject Bars ─── */
.subjects-area {
  display: flex;
  gap: 16px;
  padding-bottom: 48px;
  transition: flex-direction 300ms;
}

[data-level="l2"] .subjects-area,
[data-level="l3"] .subjects-area {
  flex-direction: column;
  gap: 12px;
}

.subject-block {
  flex: 1;
  min-width: 0;
}

[data-level="l2"] .subject-block,
[data-level="l3"] .subject-block {
  flex: none;
}

.subject-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  cursor: pointer;
  transition: background 150ms, border-color 150ms;
  user-select: none;
}

.subject-bar:hover {
  background: var(--surface-hover);
  border-color: var(--border-focus);
}

.subject-bar-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.subject-name {
  font-weight: 600;
  font-size: 14px;
}

.subject-pct {
  font-size: 13px;
  font-weight: 600;
}

.subject-progress {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.subject-progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 300ms ease;
}

/* Expanded subject styling */
.subject-block[data-expanded="true"] .subject-bar {
  border-color: var(--border-focus);
  background: var(--surface-hover);
}

/* ─── §6 — L2: Topic List ─── */
.topic-list-panel {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 300ms ease, opacity 300ms ease, padding 300ms ease;
  padding: 0 0;
}

.subject-block[data-expanded="true"] .topic-list-panel {
  max-height: 800px;
  opacity: 1;
  padding: 16px 0 0;
}

[data-level="l3"] .topic-list-panel {
  max-height: 0 !important;
  opacity: 0 !important;
  padding: 0 !important;
}

.sort-control {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  padding: 0 4px;
}

.sort-btn {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  transition: color 150ms, background 150ms, border-color 150ms;
}

.sort-btn:hover {
  color: var(--text);
  background: var(--surface);
}

.sort-btn.active {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: var(--accent);
}

.topic-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 150ms;
  user-select: none;
}

.topic-row:hover {
  background: var(--surface-hover);
}

.topic-name {
  flex: 1;
  min-width: 0;
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topic-confidence {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 110px;
  font-size: 13px;
}

.conf-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.conf-dot-unclassified { background: var(--text-dim); }
.conf-dot-weak { background: var(--danger); }
.conf-dot-developing { background: var(--warning); }
.conf-dot-competent { background: var(--info); }
.conf-dot-solid { background: var(--success); }
.conf-dot-mastered { background: var(--conf-mastered); }
.conf-dot-distinction { background: var(--conf-distinction); }
.conf-dot-honours { background: var(--accent); }

.conf-label-unclassified { color: var(--text-dim); }
.conf-label-weak { color: var(--danger); }
.conf-label-developing { color: var(--warning); }
.conf-label-competent { color: var(--info); }
.conf-label-solid { color: var(--success); }
.conf-label-mastered { color: var(--conf-mastered); }
.conf-label-distinction { color: var(--conf-distinction); }
.conf-label-honours { color: var(--accent); }

.topic-last-studied {
  min-width: 60px;
  font-size: 13px;
  color: var(--text-dim);
}

.topic-last-studied.never {
  color: var(--text-dim);
  font-style: italic;
}

.topic-rec {
  min-width: 90px;
  font-size: 12px;
  color: var(--text-mid);
}

.topic-rec span {
  color: var(--text-dim);
}

.topic-materials {
  min-width: 60px;
  font-size: 13px;
  color: var(--text-dim);
  font-family: 'DM Mono', monospace;
}

.topic-decay {
  min-width: 100px;
  font-size: 12px;
  font-weight: 500;
  text-align: right;
}

.topic-decay.warning {
  color: var(--warning);
}

.topic-decay.danger {
  color: var(--danger);
}

/* ─── §7 — L3: Topic Detail ─── */
.l3-container {
  position: fixed;
  top: 57px;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: 280px 1fr;
  transform: translateX(100%);
  opacity: 0;
  transition: transform 300ms ease, opacity 300ms ease;
  z-index: 50;
  background: var(--bg);
}

[data-level="l3"] .l3-container {
  transform: translateX(0);
  opacity: 1;
}

body[data-sidebar-collapsed="true"] .l3-container {
  grid-template-columns: 0px 1fr;
}

.l3-main {
  overflow-y: auto;
  padding: 32px 48px;
}

.l3-content {
  max-width: 780px;
}

/* ─── §8 — L3: Sidebar ─── */
.l3-sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px 0;
  transition: transform 300ms ease, width 300ms ease;
  width: 280px;
  position: relative;
}

body[data-sidebar-collapsed="true"] .l3-sidebar {
  transform: translateX(-280px);
  width: 0;
  overflow: hidden;
}

.sidebar-toggle {
  position: absolute;
  top: 12px;
  left: 252px;
  background: var(--surface);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background 150ms, color 150ms, left 300ms ease;
  z-index: 60;
}

body[data-sidebar-collapsed="true"] .sidebar-toggle {
  left: 12px;
}

.sidebar-toggle:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.sidebar-subject-header {
  padding: 12px 16px 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 150ms;
}

.sidebar-subject-header:hover {
  color: var(--text-mid);
}

.sidebar-subject-header.active {
  color: var(--text-mid);
}

.sidebar-topic {
  padding: 8px 16px 8px 24px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 150ms, color 150ms;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-topic:hover {
  background: var(--surface);
  color: var(--text);
}

.sidebar-topic.active {
  color: var(--accent);
  background: var(--accent-dim);
  font-weight: 500;
}

.sidebar-collapsed-topics {
  display: none;
}

.sidebar-subject-header.active + .sidebar-collapsed-topics {
  display: block;
}

/* ─── §9 — L3: Main Content ─── */
.l3-header {
  margin-bottom: 24px;
}

.l3-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.l3-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.l3-meta {
  display: flex;
  gap: 20px;
  color: var(--text-dim);
  font-size: 13px;
}

.l3-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.l3-ask-bar {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 24px;
  cursor: text;
  transition: border-color 150ms;
}

.l3-ask-bar:hover {
  border-color: var(--border-focus);
}

.method-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.method-btn {
  background: var(--surface);
  color: var(--text-mid);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  transition: background 150ms, color 150ms, border-color 150ms;
}

.method-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.method-btn.primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.method-btn.primary:hover {
  opacity: 0.85;
}

/* Section cards */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}

.section-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.section-card-title {
  font-size: 14px;
  font-weight: 600;
}

.section-card-actions {
  display: flex;
  gap: 6px;
}

.section-card-btn {
  background: var(--surface-hover);
  color: var(--text-mid);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  transition: background 150ms, color 150ms;
}

.section-card-btn:hover {
  color: var(--text);
}

.section-card-body {
  padding: 16px 18px;
  font-size: 13px;
  color: var(--text-mid);
  line-height: 1.6;
}

.section-card-stat {
  margin-bottom: 4px;
}

.section-card-stat strong {
  color: var(--text);
  font-weight: 500;
}

/* ─── §10 — Badges ─── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 20px;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.badge-unclassified { background: var(--surface); color: var(--text-dim); border: 1px solid var(--border); }
.badge-weak { background: var(--danger-dim); color: var(--danger); }
.badge-developing { background: var(--warning-dim); color: var(--warning); }
.badge-competent { background: var(--info-dim); color: var(--info); }
.badge-solid { background: var(--success-dim); color: var(--success); }
.badge-mastered { background: var(--conf-mastered-dim); color: var(--conf-mastered); }
.badge-distinction { background: var(--conf-distinction-dim); color: var(--conf-distinction); }
.badge-honours { background: var(--accent-dim); color: var(--accent); }

/* ─── §11 — Scrollbar ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-focus); }

/* ─── §12 — Utilities ─── */
.hidden { display: none !important; }
