/* =========================
   1) COLOR VARIABLES
   ========================= */
:root {
  --background-color: #EDEDED;  /* light grey color */
  --text-color: #111111;        /* Primary text (dark) */
  --accent-color: #000000;      /* Accent (solid black) */
  --hover-bg-color: #f2f2f2;    /* Subtle hover background */

  /* Graph-specific variables */
  --graph-color-primary: var(--accent-color);
  --graph-color-secondary: var(--text-color);
  --graph-color-background: var(--background-color);
  --graph-font: 'BerkeleyMono', monospace;
  --graph-font-size: 0.875rem;
  --graph-spacing: 1rem;
}

@font-face {
  font-family: 'BerkeleyMono';
  src: url('/fonts/BerkeleyMono-Regular.woff2') format('woff2'), /* Use WOFF2 for modern browsers */
       url('/fonts/BerkeleyMono-Regular.woff') format('woff');  /* Fallback for older browsers */
  font-weight: normal;
  font-style: normal;
  font-display: swap; /* Avoid FOIT and improve first paint */
}

/* =========================
   2) RESET & GLOBAL STYLES
   ========================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  font-family: 'BerkeleyMono', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-color);
  background-color: var(--background-color);
  min-height: 100vh; /* Ensure body fills the screen */
}

a {
  color: inherit;
  text-decoration: none;
}

/* =========================
   3) HEADER & NAVIGATION
   ========================= */
header {
  background-color: var(--background-color);
}

.layout {
  min-height: 100vh;
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar-brand a {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.nav-menu {
  display: flex;
  gap: 1.5rem;
  font-size: 0.9rem;
}

.navbar-brand img {
  display: block;
  height: 1.6rem;
  width: auto;
}

@media (max-width: 768px) {
  .layout {
    display: block;
    padding: 1.5rem;
  }

  header {
    position: static;
    margin-bottom: 1.5rem;
  }

  .navbar {
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
  }

  .nav-menu {
    width: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
  }

  .nav-menu a {
    text-decoration: underline;
  }

  main {
    max-width: 65ch;
    margin: 0 auto;
    padding-top: 1.25rem;
  }
}

@media (min-width: 769px) {
  .layout {
    display: grid;
    grid-template-columns:
      minmax(160px, 220px)
      minmax(46ch, 70ch)
      minmax(160px, 1fr);
    column-gap: 3rem;
    align-items: flex-start;
    padding: 4rem 0;
    max-width: 1200px;
    margin: 0 auto;
  }

  header {
    grid-column: 1;
    position: sticky;
    top: 4rem;
    align-self: flex-start;
    z-index: 1;
  }

  main {
    grid-column: 2;
    max-width: 65ch;
    padding-top: 3.5rem;
  }

  .navbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .navbar-brand {
    margin-bottom: 1.5rem;
  }

  .navbar-brand img {
    height: 1.8rem;
  }

  .nav-menu {
    flex-direction: column;
    gap: 0.50rem;
  }

  .nav-menu a {
    padding: 0;
  }
}

h1, h2, h3 {
  margin-bottom: 1rem;
}

p {
  margin-bottom: 1rem; /* 1rem bottom margin for paragraphs */
  line-height: 1.5; /* Explicit line-height for paragraphs */
}

li {
  padding-left:1.5rem;
  margin-left: 2rem;
  text-indent: -0.5rem;
}

li::marker {
  content:">";
  color: var(--text-color);
}

/* =========================
   7) FOOTER
   ========================= */
footer {
  text-align: center;
  padding: 1rem;
  border-top: 1px solid var(--accent-color);
  font-size: 0.9rem;
}

/* =========================
   8) GRAPH STYLES
   ========================= */
.graph {
  width: 100%;
  max-width: 100%;
  margin: var(--graph-spacing) 0;
  font-family: var(--graph-font);
}

.graph svg {
  width: 100%;
  height: auto;
  display: block;
}

[data-graph] {
  display: block;
  width: 100%;
}

/* Bar Chart Styles */
.graph-bar .bar {
  fill: var(--graph-color-primary);
  transition: opacity 0.2s ease;
}

.graph-bar .bar:hover {
  opacity: 0.8;
}

.graph-bar .label {
  fill: var(--graph-color-secondary);
  font-size: var(--graph-font-size);
  text-anchor: middle;
}

.graph-bar .value {
  fill: var(--graph-color-secondary);
  font-size: calc(var(--graph-font-size) * 0.875);
  text-anchor: middle;
}

/* Line Chart Styles */
.graph-line .line {
  fill: none;
  stroke: var(--graph-color-primary);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.graph-line .point {
  fill: var(--graph-color-primary);
  stroke: var(--graph-color-background);
  stroke-width: 2;
}

.graph-line .label {
  fill: var(--graph-color-secondary);
  font-size: var(--graph-font-size);
  text-anchor: middle;
}

.graph-line .legend-label {
  fill: var(--graph-color-secondary);
  font-size: calc(var(--graph-font-size) * 0.9);
}

.graph-line .legend-swatch {
  stroke: none;
  rx: 2;
  ry: 2;
}

/* Common Graph Elements */
.graph-title {
  fill: var(--graph-color-secondary);
  font-size: calc(var(--graph-font-size) * 1.125);
  font-weight: 600;
  text-anchor: middle;
}

.grid-line {
  stroke: var(--graph-color-secondary);
  stroke-width: 0.5;
  opacity: 0.2;
}

.empty-state {
  fill: var(--graph-color-secondary);
  font-size: var(--graph-font-size);
  opacity: 0.6;
}

/* Error State */
.graph-error {
  font-family: var(--graph-font);
  font-size: var(--graph-font-size);
  color: #d32f2f;
  padding: 1rem;
  border: 1px solid #d32f2f;
  border-radius: 4px;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .graph {
    --graph-font-size: 0.75rem;
  }
}

@media (max-width: 480px) {
  .graph {
    --graph-font-size: 0.625rem;
  }
}

/* Print Styles */
@media print {
  .graph svg {
    max-height: 300px;
  }

  .graph-bar .bar,
  .graph-line .line {
    stroke: #000 !important;
    fill: #000 !important;
  }
}
