@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700&family=JetBrains+Mono:wght@400;500;700&display=swap');

/* ── Design Tokens (matched to statreflector.com) ── */
:root {
  --bg-primary: #08080d;
  --bg-secondary: #0e0e16;
  --bg-card: #111119;
  --bg-card-hover: #16161f;
  --bg-elevated: #1a1a26;
  --border-subtle: rgba(255, 255, 255, .06);
  --border-medium: rgba(255, 255, 255, .1);
  --border-strong: rgba(255, 255, 255, .15);
  --text-primary: #e8e8ee;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --text-faint: #4b5563;
  --red: #dc2626;
  --red-dim: rgba(220, 38, 38, .12);
  --amber: #f59e0b;
  --amber-dim: rgba(245, 158, 11, .12);
  --blue: #3b82f6;
  --blue-dim: rgba(59, 130, 246, .12);
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, .12);
  --purple: #8b5cf6;
  --purple-dim: rgba(139, 92, 246, .12);
  --cyan: #06b6d4;
  --cyan-dim: rgba(6, 182, 212, .12);
  --font-body: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", monospace;
  --max-width: 1120px;
  --content-padding: 24px;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: rgba(59, 130, 246, .3); color: #fff; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: #2a2a3a; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a4a; }

/* ── Layout ── */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 var(--content-padding); }

/* ── Header / Nav ── */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(8, 8, 13, .85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
}

.site-header .container {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}

.logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 1.15rem; color: var(--text-primary);
  text-decoration: none;
}

.logo svg { width: 28px; height: 28px; }

.logo:hover { text-decoration: none; }

nav { display: flex; align-items: center; gap: 8px; }

nav a {
  padding: 6px 14px; border-radius: 8px;
  font-size: .875rem; font-weight: 500;
  color: var(--text-secondary);
  transition: color .15s, background .15s;
}

nav a:hover { color: var(--text-primary); background: var(--bg-card); text-decoration: none; }
nav a.active { color: var(--text-primary); background: var(--bg-card); }

/* ── Hero ── */
.hero {
  padding: 80px 0 60px;
  text-align: center;
}

.hero h1 {
  font-size: 2.8rem; font-weight: 700;
  line-height: 1.15; letter-spacing: -.02em;
  margin-bottom: 16px;
}

.hero h1 .accent { color: var(--blue); }

.hero .subtitle {
  font-size: 1.15rem; color: var(--text-secondary);
  max-width: 640px; margin: 0 auto 40px;
  line-height: 1.7;
}

/* ── URL Input / Analyze Section ── */
.analyze-box {
  max-width: 720px; margin: 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: 16px;
  padding: 32px;
}

.analyze-box label {
  display: block; font-size: .875rem; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 10px;
  text-transform: uppercase; letter-spacing: .05em;
}

.input-row {
  display: flex; gap: 12px;
}

.input-row input {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: 10px;
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: .9rem;
  color: var(--text-primary);
  transition: border-color .2s;
}

.input-row input::placeholder { color: var(--text-faint); }
.input-row input:focus { outline: none; border-color: var(--blue); }

.btn-primary {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 28px;
  background: var(--blue);
  color: #fff;
  font-weight: 600; font-size: .9rem;
  border-radius: 10px;
  border: none; cursor: pointer;
  transition: background .15s, transform .1s;
}

.btn-primary:hover { background: #2563eb; }
.btn-primary:active { transform: scale(.97); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary .spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.analyze-hint {
  margin-top: 12px; font-size: .8rem; color: var(--text-muted);
}

/* ── Error message ── */
.error-msg {
  margin-top: 16px; padding: 12px 16px;
  background: var(--red-dim); border: 1px solid rgba(220,38,38,.3);
  border-radius: 10px; color: var(--red);
  font-size: .875rem;
}

/* ── Results ── */
.results-section {
  margin-top: 40px;
  animation: fadeInUp .4s var(--ease-out);
}

@keyframes fadeInUp {
  0% { opacity: 0; transform: translateY(24px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* Score card */
.score-card {
  display: flex; align-items: center; gap: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: 16px; padding: 32px;
  margin-bottom: 24px;
}

.score-ring {
  position: relative; flex-shrink: 0;
  width: 120px; height: 120px;
}

.score-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }

.score-ring .track { fill: none; stroke: var(--bg-elevated); stroke-width: 8; }
.score-ring .fill { fill: none; stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset .8s var(--ease-out); }

.score-ring .score-value {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-size: 2rem; font-weight: 700;
}

.score-ring .score-label {
  font-size: .7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em;
  margin-top: 2px;
}

.score-meta h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: 4px; }
.score-meta .confidence { font-size: .875rem; color: var(--text-muted); }

/* Rating colors */
.rating-low { color: var(--green); }
.rating-low .fill { stroke: var(--green); }
.rating-mild { color: var(--cyan); }
.rating-mild .fill { stroke: var(--cyan); }
.rating-moderate { color: var(--amber); }
.rating-moderate .fill { stroke: var(--amber); }
.rating-high { color: var(--red); }
.rating-high .fill { stroke: var(--red); }
.rating-very_high { color: #ef4444; }
.rating-very_high .fill { stroke: #ef4444; }

/* ── Dimension Grid ── */
.dimensions-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px; margin-bottom: 32px;
}

.dim-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px; padding: 24px;
  transition: border-color .2s;
}

.dim-card:hover { border-color: var(--border-medium); }

.dim-card .dim-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}

.dim-card .dim-name {
  font-size: .9rem; font-weight: 600;
}

.dim-card .dim-score {
  font-family: var(--font-mono); font-size: .85rem; font-weight: 600;
  padding: 3px 10px; border-radius: 6px;
}

.dim-card .dim-bar {
  height: 4px; background: var(--bg-elevated);
  border-radius: 2px; margin-bottom: 12px; overflow: hidden;
}

.dim-card .dim-bar-fill {
  height: 100%; border-radius: 2px;
  transition: width .6s var(--ease-out);
}

.dim-card .dim-summary {
  font-size: .825rem; color: var(--text-secondary); line-height: 1.55;
}

/* ── Signals ── */
.signals-row {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px;
}

.signal-chip {
  font-size: .72rem; font-weight: 500;
  padding: 3px 8px; border-radius: 5px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

/* ── Findings ── */
.findings-section { margin-bottom: 32px; }

.section-title {
  font-size: 1.15rem; font-weight: 700;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}

.finding-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px; padding: 20px;
  margin-bottom: 12px;
}

.finding-card .finding-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px;
}

.finding-priority {
  font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  padding: 2px 8px; border-radius: 4px;
}

.finding-priority.high { background: var(--red-dim); color: var(--red); }
.finding-priority.medium { background: var(--amber-dim); color: var(--amber); }
.finding-priority.low { background: var(--blue-dim); color: var(--blue); }

.finding-category { font-size: .8rem; color: var(--text-muted); }

.finding-desc { font-size: .875rem; color: var(--text-secondary); line-height: 1.6; margin-bottom: 8px; }

.finding-excerpt {
  font-family: var(--font-mono); font-size: .78rem;
  background: var(--bg-secondary);
  border-left: 3px solid var(--border-strong);
  padding: 8px 12px; border-radius: 0 6px 6px 0;
  color: var(--text-muted); margin-bottom: 6px;
  overflow-x: auto;
}

.finding-fix {
  font-size: .8rem; color: var(--green);
  margin-top: 6px;
}

.finding-fix::before { content: '→ '; }

/* ── Suggestions ── */
.suggestions-section { margin-bottom: 32px; }

.suggestion-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  margin-bottom: 8px;
}

.suggestion-item .sugg-priority {
  flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%; margin-top: 7px;
}

.sugg-priority.high { background: var(--red); }
.sugg-priority.medium { background: var(--amber); }
.sugg-priority.low { background: var(--blue); }

.suggestion-item .sugg-text { font-size: .85rem; color: var(--text-secondary); line-height: 1.55; }
.suggestion-item .sugg-impact { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }

/* ── Artifacts ── */
.artifacts-section {
  margin-bottom: 32px;
}

.artifacts-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.artifact-item {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px; padding: 16px;
}

.artifact-item .artifact-label {
  font-size: .72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); margin-bottom: 4px;
}

.artifact-item .artifact-value {
  font-size: 1rem; font-weight: 600;
  word-break: break-all;
}

/* ── Methodology / About Pages ── */
.page-content {
  padding: 60px 0 80px;
}

.page-content h1 {
  font-size: 2.2rem; font-weight: 700;
  line-height: 1.2; margin-bottom: 12px;
}

.page-content h1 .accent { color: var(--blue); }

.page-content .page-subtitle {
  font-size: 1.05rem; color: var(--text-secondary);
  margin-bottom: 48px; max-width: 640px;
}

.page-content h2 {
  font-size: 1.35rem; font-weight: 700;
  margin: 40px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.page-content h3 {
  font-size: 1.05rem; font-weight: 600;
  margin: 24px 0 8px;
  color: var(--text-primary);
}

.page-content p {
  font-size: .925rem; color: var(--text-secondary);
  line-height: 1.75; margin-bottom: 16px;
  max-width: 720px;
}

.page-content ul, .page-content ol {
  margin-bottom: 16px; padding-left: 24px;
}

.page-content li {
  font-size: .9rem; color: var(--text-secondary);
  line-height: 1.7; margin-bottom: 6px;
}

.page-content code {
  font-family: var(--font-mono);
  font-size: .82rem;
  background: var(--bg-elevated);
  padding: 2px 7px; border-radius: 5px;
  color: var(--cyan);
}

.page-content pre {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 20px;
  overflow-x: auto;
  margin-bottom: 20px;
}

.page-content pre code {
  background: none; padding: 0;
  font-size: .82rem; line-height: 1.6;
  color: var(--text-secondary);
}

/* Dimension cards on methodology page */
.method-dimension {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px; padding: 24px;
  margin-bottom: 16px;
}

.method-dimension .dim-title {
  font-size: 1rem; font-weight: 600;
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px;
}

.method-dimension .dim-weight {
  font-family: var(--font-mono);
  font-size: .75rem; font-weight: 600;
  padding: 2px 8px; border-radius: 5px;
  background: var(--blue-dim); color: var(--blue);
}

.method-dimension .dim-desc {
  font-size: .85rem; color: var(--text-secondary); line-height: 1.65;
  margin-bottom: 10px;
}

.method-dimension .signal-list {
  display: flex; flex-wrap: wrap; gap: 6px;
}

/* API doc specific */
.endpoint-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px; padding: 24px;
  margin-bottom: 20px;
}

.endpoint-card .method-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: .75rem; font-weight: 700;
  padding: 3px 10px; border-radius: 5px;
  margin-right: 8px;
}

.method-badge.get { background: var(--green-dim); color: var(--green); }
.method-badge.post { background: var(--blue-dim); color: var(--blue); }

.endpoint-card .endpoint-path {
  font-family: var(--font-mono);
  font-size: .95rem; font-weight: 500;
}

.endpoint-card .endpoint-desc {
  font-size: .875rem; color: var(--text-secondary);
  margin: 10px 0;
}

/* ── Footer ── */
.site-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 40px 0;
  margin-top: 60px;
}

.footer-inner {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 16px;
}

.footer-brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: .9rem;
}

.footer-brand svg { width: 20px; height: 20px; }

.footer-text { font-size: .8rem; color: var(--text-muted); }

.footer-links { display: flex; gap: 16px; }

.footer-links a {
  font-size: .825rem; color: var(--text-muted);
  transition: color .15s;
}

.footer-links a:hover { color: var(--text-primary); text-decoration: none; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .hero h1 { font-size: 2rem; }
  .input-row { flex-direction: column; }
  .score-card { flex-direction: column; text-align: center; gap: 20px; }
  .dimensions-grid { grid-template-columns: 1fr; }
  .footer-inner { flex-direction: column; text-align: center; }
}

@media (max-width: 480px) {
  .hero { padding: 50px 0 40px; }
  .hero h1 { font-size: 1.6rem; }
  .analyze-box { padding: 20px; }
}

/* ── Tabs ── */
.tabs {
  display: flex; gap: 4px; margin-bottom: 24px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0;
}

.tab-btn {
  padding: 10px 20px;
  font-size: .875rem; font-weight: 500;
  color: var(--text-muted);
  background: none; border: none; cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}

.tab-btn:hover { color: var(--text-secondary); }
.tab-btn.active { color: var(--text-primary); border-bottom-color: var(--blue); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── JSON viewer ── */
.json-viewer {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 10px; padding: 20px;
  max-height: 500px; overflow: auto;
}

.json-viewer pre {
  font-family: var(--font-mono);
  font-size: .78rem; line-height: 1.5;
  color: var(--text-secondary);
  margin: 0;
}

/* Sister project link */
.sister-link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  font-size: .825rem; color: var(--text-secondary);
  transition: border-color .2s, color .2s;
}

.sister-link:hover { border-color: var(--border-medium); color: var(--text-primary); text-decoration: none; }

/* ── Results (app.js dynamic rendering) ── */
#results-container {
  margin-top: 40px;
  animation: fadeInUp .4s var(--ease-out);
}

.score-visual {
  flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}

.score-visual .score-ring {
  width: 120px; height: 120px;
}

.score-label { text-align: center; }

.rating-badge {
  display: inline-block;
  font-size: .75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  padding: 4px 14px; border-radius: 6px;
}

.score-details h2 {
  font-size: 1.35rem; font-weight: 700; margin-bottom: 6px;
}

.score-desc {
  font-size: .9rem; color: var(--text-secondary); line-height: 1.6;
}

/* Tabs (app.js uses .tab / .tab-content) */
.tab {
  padding: 10px 20px;
  font-family: var(--font-body);
  font-size: .875rem; font-weight: 500;
  color: var(--text-muted);
  background: none; border: none; cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}

.tab:hover { color: var(--text-secondary); }
.tab.active { color: var(--text-primary); border-bottom-color: var(--blue); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Dimension card overrides for dynamic render */
.dim-icon {
  flex-shrink: 0;
  width: 22px; height: 22px;
  color: var(--text-muted);
}

.dim-icon svg { width: 100%; height: 100%; }

.dim-title-row {
  flex: 1; min-width: 0;
}

.dim-title-row h3 {
  font-size: .9rem; font-weight: 600; margin: 0;
}

.dim-card .dim-weight {
  font-family: var(--font-mono);
  font-size: .7rem; color: var(--text-muted);
}

.dim-card .dim-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
}

/* Signals inside dimension cards */
.dim-signals {
  margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}

.signal-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.signal-item:last-child { border-bottom: none; }

.signal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 4px;
}

.signal-type {
  font-size: .8rem; font-weight: 600; color: var(--text-primary);
}

.signal-severity {
  font-family: var(--font-mono);
  font-size: .78rem; font-weight: 600;
}

.signal-desc {
  font-size: .78rem; color: var(--text-muted); line-height: 1.5;
}

.signal-count {
  font-size: .72rem; color: var(--text-faint); margin-top: 4px; display: inline-block;
}

/* Excerpts */
.excerpts { margin-top: 8px; }

.excerpt-item {
  font-family: var(--font-mono);
  font-size: .75rem;
  background: var(--bg-secondary);
  border-left: 3px solid var(--border-strong);
  padding: 6px 10px; border-radius: 0 6px 6px 0;
  margin-bottom: 4px;
}

.excerpt-text { color: var(--amber); }

.excerpt-context {
  display: block;
  color: var(--text-muted); font-style: italic;
  margin-top: 2px;
}

.excerpt-more { font-size: .72rem; color: var(--text-faint); margin-top: 4px; display: block; }

/* Priority badges */
.priority-badge {
  font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  padding: 2px 8px; border-radius: 4px;
}

.priority-high { background: var(--red-dim); color: var(--red); }
.priority-medium { background: var(--amber-dim); color: var(--amber); }
.priority-low { background: var(--blue-dim); color: var(--blue); }

/* Findings list */
.findings-list, .suggestions-list { }

/* Suggestion overrides for dynamic render */
.suggestion-item {
  flex-direction: column; gap: 6px;
}

.suggestion-header {
  display: flex; align-items: center; gap: 10px;
}

.suggestion-category { font-size: .8rem; color: var(--text-muted); }

.suggestion-action {
  font-size: .85rem; color: var(--text-secondary); line-height: 1.5;
  margin: 0;
}

.suggestion-impact {
  font-size: .78rem; color: var(--text-muted); font-style: italic;
  margin: 0;
}

/* Artifact card (dynamic render) */
.artifact-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px; padding: 16px;
}

.artifact-card h4 {
  font-size: .72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); margin-bottom: 4px;
}

.artifact-card .artifact-value {
  font-size: .95rem; font-weight: 600; word-break: break-all;
  margin: 0;
}

.artifact-card .artifact-value a { word-break: break-all; }

.artifact-section {
  margin-top: 20px;
}

.artifact-section h4 {
  font-size: .85rem; font-weight: 600;
  margin-bottom: 8px;
}

.artifact-list {
  list-style: none; padding: 0;
}

.artifact-list li {
  font-size: .825rem; color: var(--text-secondary);
  padding: 4px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.artifact-list li:last-child { border-bottom: none; }

.artifact-list li a { word-break: break-all; }

.more-indicator { color: var(--text-muted) !important; font-style: italic; }

/* Empty state text */
.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: .9rem;
  padding: 40px 0;
}
