/* ============================================================
   The Displacement Curve — Dashboard Styles
   Dark mode, responsive, no frameworks
   ============================================================ */

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

:root {
  --bg-primary: #0d1117;
  --bg-card: #161b22;
  --bg-card-hover: #1c2129;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --accent: #58a6ff;
  --green: #3fb950;
  --red: #f85149;
  --neutral: #8b949e;
  --border: #30363d;
  --border-hover: #484f58;
  --radius: 8px;
  --max-width: 1200px;
  --transition: 0.25s ease;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* --- Layout --- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* --- Header --- */
.site-header {
  padding: 3rem 0 2rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.site-title {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.site-subtitle {
  font-size: 1.125rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto 0.75rem;
}

.last-updated {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* --- Hero Score Section --- */
.hero-score {
  text-align: center;
  padding: 3rem 1rem;
  margin-bottom: 0;
}

.hero-inner {
  max-width: 600px;
  margin: 0 auto;
}

.score-display {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.5rem;
}

.score-number {
  font-size: 6rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.score-label {
  font-size: 1.5rem;
  color: var(--text-secondary);
}

.phase-label {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 0.5rem;
}

.phase-description {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.score-trend {
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

/* --- Section Titles --- */
.section-title {
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 1rem;
  padding-left: 0.5rem;
}

/* --- Timeline Section --- */
.timeline-section {
  padding: 1rem 0;
  margin-bottom: 2rem;
}

.timeline-section canvas {
  width: 100%;
  max-height: 250px;
}

/* --- Signal Cards --- */
.signal-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  padding: 2rem 0;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
  position: relative;
}

.card:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.card.active {
  border-color: var(--accent);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.card-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  flex: 1;
  line-height: 1.3;
}

.card-source {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  background: rgba(139, 148, 158, 0.1);
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.card-body {
  margin-bottom: 1rem;
}

.card-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.25rem;
}

.card-change {
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.75rem;
}

.card-change.positive {
  color: var(--green);
}

.card-change.negative {
  color: var(--red);
}

.card-change.neutral {
  color: var(--neutral);
}

.card-sparkline {
  width: 100%;
  height: 60px;
  position: relative;
}

.card-sparkline canvas {
  width: 100% !important;
  height: 60px !important;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.card-expand-hint {
  opacity: 0;
  transition: opacity var(--transition);
}

.card:hover .card-expand-hint {
  opacity: 1;
}

/* --- Expanded Chart --- */
.expanded-chart-section {
  padding: 0 0 2rem;
  animation: slideDown 0.3s ease;
}

.expanded-chart-section[hidden] {
  display: none;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-1rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.expanded-chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.expanded-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.expanded-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

.expanded-close {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 1.5rem;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
  line-height: 1;
}

.expanded-close:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

.expanded-chart-wrapper {
  position: relative;
  width: 100%;
  height: 400px;
}

.expanded-chart-wrapper canvas {
  width: 100% !important;
  height: 100% !important;
}

/* --- Data Unavailable State --- */
.card-unavailable {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  color: var(--text-secondary);
  font-size: 0.875rem;
  text-align: center;
}

/* --- Footer --- */
.site-footer {
  margin-top: auto;
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.site-footer p {
  margin-bottom: 0.5rem;
}

.site-footer p:last-child {
  margin-bottom: 0;
}

.footer-sep {
  margin: 0 0.5rem;
  opacity: 0.5;
}

.footer-privacy {
  font-style: italic;
  opacity: 0.7;
  margin-top: 0.25rem;
}

/* --- Responsive --- */
@media (max-width: 960px) {
  .signal-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .signal-cards {
    grid-template-columns: 1fr;
  }

  .site-header {
    padding: 2rem 0 1.5rem;
  }

  .site-title {
    font-size: 1.75rem;
  }

  .site-subtitle {
    font-size: 1rem;
  }

  .card-value {
    font-size: 1.5rem;
  }

  .expanded-chart-wrapper {
    height: 300px;
  }

  .score-number {
    font-size: 4rem;
  }

  .score-label {
    font-size: 1.125rem;
  }

  .hero-score {
    padding: 2rem 1rem;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 1rem;
  }

  .site-title {
    font-size: 1.5rem;
  }

  .card {
    padding: 1rem;
  }
}

/* --- Print Styles --- */
@media print {
  :root {
    --bg-primary: #ffffff;
    --bg-card: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #555555;
    --border: #cccccc;
  }

  body {
    background: white;
    color: #1a1a1a;
  }

  .card {
    break-inside: avoid;
    border: 1px solid #ccc;
    box-shadow: none;
  }

  .card:hover {
    transform: none;
    background: white;
  }

  .card-expand-hint {
    display: none;
  }

  .expanded-close {
    display: none;
  }

  a {
    color: #1a1a1a;
    text-decoration: underline;
  }

  .site-header {
    border-bottom-color: #ccc;
  }

  .site-footer {
    border-top-color: #ccc;
  }
}
