/*
 * Balance of Power — Model Portal Stylesheet
 *
 * Academic clean aesthetic. NOT the CRT/retro game look.
 * Font: Inter (body), Source Code Pro (code/formulas/function names)
 * Color: navy headers, dark-gray body, white background.
 *
 * Design tokens (colors, fonts) are in shared/tokens.css.
 *
 * Used by: index.html, module.html, function.html
 * Milestone 2 additions: auth forms (.auth-form, .auth-field) are
 * stubbed here and will be populated when auth flows are built.
 */

@import '/shared/tokens.css';

/* ── Reset & Base ───────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: var(--font-size);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  line-height: var(--line-height);
}

/* ── Typography ─────────────────────────────────────────────────────── */
h1, h2, h3, h4 {
  font-weight: 600;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.1rem;
  color: var(--navy);
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--navy);
  display: inline-block;
}

h3 {
  font-size: 0.95rem;
  color: var(--navy);
}

p { margin-bottom: 1rem; }
p:last-child { margin-bottom: 0; }

a { color: var(--navy-light); text-decoration: none; }
a:hover { text-decoration: underline; }

code, .mono {
  font-family: var(--font-code);
}

/* ── Layout ─────────────────────────────────────────────────────────── */
.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 2rem;
}

section {
  margin-bottom: 2.5rem;
}

/* ── Navigation ─────────────────────────────────────────────────────── */
nav {
  background: var(--navy);
  color: #fff;
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

nav .brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #fff;
  text-decoration: none;
}

nav .brand:hover { text-decoration: none; }

nav .brand .sep {
  color: rgba(255, 255, 255, 0.35);
  font-weight: 300;
}

nav .brand .subtitle {
  font-weight: 400;
  opacity: 0.85;
}

nav ul {
  list-style: none;
  display: flex;
  gap: 1.75rem;
}

nav ul a {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.15s;
}

nav ul a:hover {
  color: #fff;
  text-decoration: none;
}

/* ── Breadcrumb ─────────────────────────────────────────────────────── */
.breadcrumb {
  padding: 1rem 0 0;
  font-size: 0.8rem;
  color: var(--text-light);
}

.breadcrumb span { margin: 0 0.35rem; }
.breadcrumb a { color: var(--text-light); }
.breadcrumb a:hover { color: var(--navy); text-decoration: underline; }

/* ── Hero / Page Header ─────────────────────────────────────────────── */
.page-header {
  padding: 2.5rem 0 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2.5rem;
}

.page-header h1 {
  font-size: 1.9rem;
  color: var(--navy);
  margin-bottom: 0.5rem;
}

.page-header p {
  font-size: 0.95rem;
  color: var(--text-mid);
  max-width: 640px;
  margin-bottom: 0;
}

/* ── Module Cards (index.html) ──────────────────────────────────────── */
.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.module-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.4rem 1.5rem;
  transition: box-shadow 0.15s, border-color 0.15s;
  text-decoration: none;
  color: inherit;
  display: block;
}

.module-card:hover {
  box-shadow: 0 2px 12px rgba(27, 42, 74, 0.1);
  border-color: var(--navy-light);
  text-decoration: none;
}

.module-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  gap: 0.75rem;
}

.module-card h3 {
  font-size: 1.05rem;
  color: var(--navy);
  margin-bottom: 0.1rem;
}

.module-card .theorist {
  font-size: 0.8rem;
  color: var(--text-light);
  font-style: italic;
}

.module-card .fn-count {
  font-family: 'Source Code Pro', monospace;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--navy-wash);
  color: var(--navy);
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Function List (module.html) ────────────────────────────────────── */
.fn-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.fn-list-item {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.1rem 1.25rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  text-decoration: none;
  display: block;
  color: inherit;
}

.fn-list-item:hover {
  border-color: var(--navy-light);
  box-shadow: 0 2px 8px rgba(27, 42, 74, 0.08);
  text-decoration: none;
}

.fn-list-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}

.fn-list-item h3 {
  font-family: 'Source Code Pro', monospace;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--navy);
}

.fn-list-item .fn-preview {
  font-size: 0.875rem;
  color: var(--text-mid);
  line-height: 1.65;
}

/* ── Module Page Header ─────────────────────────────────────────────── */
.module-header {
  padding: 2rem 0 1.75rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.module-header h1 {
  font-size: 1.6rem;
  color: var(--navy);
  margin-bottom: 0.25rem;
}

.module-header .theorist-line {
  font-size: 0.9rem;
  color: var(--text-mid);
  font-style: italic;
  margin-bottom: 0;
}

/* ── Function Detail Page ───────────────────────────────────────────── */
.fn-title {
  margin: 1.25rem 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.fn-title h1 {
  font-family: 'Source Code Pro', monospace;
  font-size: 1.55rem;
  font-weight: 600;
  color: var(--navy);
  letter-spacing: -0.02em;
}

/* ── Badges ─────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--navy-wash);
  color: var(--navy);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.7rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  letter-spacing: 0.01em;
}

.badge .dot {
  width: 7px;
  height: 7px;
  background: var(--burgundy);
  border-radius: 50%;
  flex-shrink: 0;
}


/* ── Citation Block ─────────────────────────────────────────────────── */
.citation-block {
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 3px solid var(--navy);
  padding: 1.1rem 1.4rem;
  margin-bottom: 2.5rem;
  border-radius: 0 4px 4px 0;
}

.citation-block p {
  font-size: 0.875rem;
  color: var(--text-mid);
  line-height: 1.75;
  margin-bottom: 0.5rem;
}

.citation-block p:last-child { margin-bottom: 0; }

.citation-block .label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-light);
  margin-bottom: 0.15rem;
}

.citation-block em { font-style: italic; }

/* ── What This Models ───────────────────────────────────────────────── */
.model-desc {
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.8;
}

/* ── Parameters Table ───────────────────────────────────────────────── */
.params-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.params-table thead {
  background: var(--navy);
  color: #fff;
}

.params-table th {
  text-align: left;
  padding: 0.7rem 1rem;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.params-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.65;
}

.params-table tr:last-child td { border-bottom: none; }
.params-table tbody tr:hover { background: #f7f8fb; }

.params-table .param-name {
  font-family: 'Source Code Pro', monospace;
  font-weight: 500;
  color: var(--navy);
  white-space: nowrap;
}

.params-table .param-type {
  font-family: 'Source Code Pro', monospace;
  font-size: 0.8rem;
  color: var(--burgundy);
  white-space: nowrap;
}

.params-table .param-range {
  font-size: 0.8rem;
  color: var(--text-mid);
}

/* ── Returns Box ────────────────────────────────────────────────────── */
.returns-box {
  background: var(--white);
  border: 1px solid var(--border);
  padding: 1rem 1.25rem;
  border-radius: 6px;
  font-size: 0.9rem;
  line-height: 1.75;
}

.returns-box .ret-type {
  font-family: 'Source Code Pro', monospace;
  font-weight: 500;
  color: var(--burgundy);
}

.returns-box .ret-range {
  font-family: 'Source Code Pro', monospace;
  color: var(--text-mid);
  font-size: 0.85rem;
}

/* ── Bulleted List Sections ─────────────────────────────────────────── */
.noted-list {
  list-style: none;
  padding: 0;
}

.noted-list li {
  position: relative;
  padding: 0.4rem 0 0.4rem 1.25rem;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text);
}

.noted-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.65rem;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.assumptions-list {
  border-left: 3px solid var(--navy-light);
  padding-left: 1.25rem;
}

.assumptions-list li::before { background: var(--navy-light); }

.limitations-list {
  border-left: 3px solid var(--amber);
  padding-left: 1.25rem;
}

.limitations-list li::before { background: var(--amber); }

/* ── Source Quote ───────────────────────────────────────────────────── */
.source-quote {
  background: var(--white);
  border-left: 3px solid var(--border);
  padding: 1rem 1.4rem;
  margin-bottom: 1.25rem;
  border-radius: 0 4px 4px 0;
  font-size: 0.9rem;
  line-height: 1.8;
  color: var(--text);
  font-style: italic;
}

.source-quote .page-ref {
  display: block;
  font-style: normal;
  font-size: 0.78rem;
  color: var(--text-light);
  margin-top: 0.5rem;
  font-weight: 500;
}

/* ── Formula Block ──────────────────────────────────────────────────── */
.formula-block {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
}

.formula-block pre {
  font-family: 'Source Code Pro', monospace;
  font-size: 0.82rem;
  line-height: 1.8;
  color: var(--text);
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.formula-block .formula-comment {
  color: var(--text-light);
  font-style: italic;
}

/* ── Empty State ────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-light);
}

.empty-state h2 {
  font-size: 1.1rem;
  color: var(--text-mid);
  border: none;
  display: block;
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-size: 0.9rem;
}

/* ── Loading State ──────────────────────────────────────────────────── */
.loading {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-light);
  font-size: 0.9rem;
}

/* ── Error State ────────────────────────────────────────────────────── */
.error-state {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 1.25rem 1.5rem;
  color: #991b1b;
  font-size: 0.9rem;
  margin: 1.5rem 0;
}

/* ── Milestone 2 stubs (auth forms — not yet implemented) ───────────── */
/* .auth-form { ... }  Add in Milestone 2 */
/* .auth-field { ... } Add in Milestone 2 */

/* ── Footer ─────────────────────────────────────────────────────────── */
footer {
  margin-top: 4rem;
  padding: 1.5rem 0;
  text-align: center;
  background: var(--navy);
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  line-height: 1.6;
}

footer strong { color: #fff; font-weight: 600; }

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .container { padding: 0 1rem; }
  .fn-title h1 { font-size: 1.15rem; }
  .params-table { font-size: 0.8rem; }
  .params-table th, .params-table td { padding: 0.5rem 0.6rem; }
  nav .container { flex-direction: column; height: auto; padding: 0.75rem 1rem; gap: 0.5rem; }
  nav ul { gap: 1rem; }
  .modules-grid { grid-template-columns: 1fr; }
  .page-header h1 { font-size: 1.4rem; }
}

/* ── Calculate Gate (Milestone 2 placeholder) ────────────── */
.calculate-gate {
  margin: 2rem 0;
  padding: 1.5rem 2rem;
  background: #f8f9fa;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  text-align: center;
}

.btn-calculate-locked {
  display: inline-flex;
  align-items: center;
  padding: 0.7rem 1.6rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: #94a3b8;
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  cursor: not-allowed;
  opacity: 0.75;
  letter-spacing: 0.01em;
}

.gate-text {
  margin-top: 0.6rem;
  font-size: 0.8rem;
  color: #94a3b8;
  font-style: italic;
}
