/* Base styles */
* {
  box-sizing: border-box;
}

/* Accessibility */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  padding: 0.75rem 1rem;
  background: var(--accent-color);
  color: #fff;
  text-decoration: none;
  font-weight: 500;
  z-index: 1000;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:root {
  --text-color: #1a1a1a;
  --text-muted: #666;
  --text-alt: #444;
  --accent-color: #3b82f6;
  --bg-color: #fff;
  --bg-alt: #f5f5f5;
  --border-color: #e5e5e5;
  --border-faint: #eee;
}

@media (prefers-color-scheme: dark) {
  :root {
    --text-color: #f0f0f0;
    --text-muted: #999;
    --text-alt: #ccc;
    --accent-color: #60a5fa;
    --bg-color: #1a1a1a;
    --bg-alt: #2a2a2a;
    --border-color: #333;
    --border-faint: #222;
  }
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.6;
  color: var(--text-color);
  background: var(--bg-color);
  margin: 0;
  padding: 0;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

a {
  color: var(--accent-color);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

a:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* Hero section */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 3rem;
  text-wrap: balance;
  text-align: center;
}

.hero h1 {
  margin: 1rem 0;
  padding: 1rem 0;
  font-variant: small-caps;
  max-width: none;
  font-size: 14vw;
  font-weight: 900;
  line-height: 1;
  color: var(--text-color);
}

@media (min-width: 640px) {
  .hero h1 {
    font-size: 60px;
  }
}

.highlight-header-text {
  color: var(--accent-color);
}

.hero-description {
  max-width: 42em;
  font-size: 1.1rem;
  line-height: 1.7;
  color: var(--text-alt);
  margin: 0;
}

/* Social links */
.social-links {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
  justify-content: center;
}

.simple-link {
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s ease;
}

.simple-link:hover {
  color: var(--accent-color);
  text-decoration: underline;
}

.simple-link:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

.link-separator {
  color: var(--border-faint);
  font-size: 0.8rem;
}

/* Projects section */
.projects-section h2 {
  font-size: 1.5rem;
  margin-bottom: 2rem;
  color: var(--text-color);
  border-bottom: 2px solid var(--accent-color);
  padding-bottom: 0.5rem;
}

.project-item {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border-faint);
}

.project-item:last-child {
  border-bottom: none;
}

.project-image img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border-faint);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.project-content h3 {
  margin: 0 0 0.75rem 0;
  font-size: 1.2rem;
  line-height: 1.3;
}

.project-link {
  color: var(--accent-color);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.project-link:hover {
  text-decoration-thickness: 2px;
}

.project-link:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

.project-description {
  margin: 0 0 0.5rem 0;
  line-height: 1.5;
  color: var(--text-alt);
  font-size: 0.95rem;
}

.project-method {
  margin: 0 0 1rem 0;
  line-height: 1.5;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
}

.project-tech {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tech-tag {
  background: var(--bg-alt);
  color: var(--text-muted);
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 500;
  border: 1px solid var(--border-faint);
}

@media (max-width: 768px) {
  .project-item {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .project-image img {
    height: 160px;
  }
}

/* Article/analysis pages */
article {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

article h1 {
  font-size: 2rem;
  margin-bottom: 1.5rem;
  line-height: 1.2;
}

article h2 {
  font-size: 1.5rem;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

article p {
  margin-bottom: 1rem;
}

article ul, article ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

article li {
  margin-bottom: 0.5rem;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}

th, td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

th {
  font-weight: 600;
  background: var(--bg-alt);
}

/* Charts/visualizations */
.chart-container {
  margin: 2rem 0;
  overflow-x: auto;
}

.chart-container svg {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Form controls */
.control-group {
  margin: 1.5rem 0;
}

.control-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.control-group select {
  padding: 0.5rem 1rem;
  font-size: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-color);
  color: var(--text-color);
  min-width: 200px;
}

/* Scrollable table container */
.table-scroll {
  overflow-y: auto;
  max-height: 500px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

.table-scroll table {
  margin: 0;
}

/* Back link */
.back-link {
  display: inline-block;
  margin-bottom: 1.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.back-link:hover {
  color: var(--accent-color);
}

/* Navigation breadcrumb */
nav.breadcrumb {
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

nav.breadcrumb a {
  color: var(--text-muted);
}

nav.breadcrumb span {
  margin: 0 0.5rem;
}

/* Footer */
.site-footer {
  margin-top: 3rem;
  padding: 2rem 0;
  border-top: 1px solid var(--border-color);
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.site-footer a {
  color: var(--text-muted);
  transition: color 0.2s ease;
}

.site-footer a:hover {
  color: var(--accent-color);
}

/* Accessible chart figures */
.chart-figure {
  margin: 2rem 0;
}

.chart-figure details {
  margin-top: 1rem;
}

.chart-figure summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 0.5rem 0;
  transition: color 0.2s ease;
}

.chart-figure summary:hover {
  color: var(--accent-color);
}

.chart-figure summary:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

.chart-figure details[open] summary {
  margin-bottom: 1rem;
}

.chart-figure .data-table {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

.chart-figure .data-table table {
  margin: 0;
  font-size: 0.85rem;
}

.chart-figure .data-table th {
  position: sticky;
  top: 0;
  background: var(--bg-alt);
}

/* Blog post styles (building-a-home) */
.post-meta {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.post-image {
  max-width: 100%;
  height: auto;
  margin: 1.5rem 0;
  border-radius: 6px;
}

.post-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 1rem;
}

.post-nav a {
  max-width: 45%;
}

.post-nav span {
  visibility: hidden;
}

figure {
  margin: 1.5rem 0;
}

figcaption {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 0.5rem;
}

/* Blog post list (building-a-home index) */
.post-list {
  list-style: none;
  padding: 0;
  margin: 2rem 0;
}

.post-list li {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-faint);
}

.post-list li:last-child {
  border-bottom: none;
}

.post-date {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.post-title {
  font-size: 1.2rem;
  font-weight: 600;
}

.post-excerpt {
  margin: 0.5rem 0 0 0;
  color: var(--text-alt);
  font-size: 0.95rem;
}

/* Classical music analysis styles */
.era-tag {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  margin-left: 0.5rem;
  vertical-align: middle;
}

.era-baroque { background: #e8d4f0; color: #6b3d7a; }
.era-classical { background: #d4e8f0; color: #3d6b7a; }
.era-romantic { background: #f0e4d4; color: #7a5d3d; }
.era-modern { background: #d4f0e4; color: #3d7a5d; }

.work-title {
  font-style: italic;
}

.composer-name {
  font-weight: 500;
}

.highlight-row {
  background-color: var(--bg-alt);
}

.pct-high {
  color: var(--accent-color);
  font-weight: 600;
}

.pct-low {
  color: var(--text-muted);
}

.methodology {
  margin-top: 2rem;
  padding: 1.5rem;
  background: var(--bg-alt);
  border-radius: 6px;
  font-size: 0.9rem;
}

.methodology h3 {
  margin-top: 0;
}

.methodology code {
  background: var(--bg-color);
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  font-size: 0.85em;
}

.story-section {
  margin: 2.5rem 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.story-section:first-of-type {
  border-top: none;
  padding-top: 0;
}

.ratio-highlight {
  font-weight: 600;
  color: var(--accent-color);
}

.chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin: 1.5rem 0;
}

.chart-cell {
  min-width: 0;
}

.chart-cell h4 {
  margin: 0 0 0.5rem 0;
  font-size: 0.95rem;
  color: var(--text-color);
}

.section-intro {
  margin-bottom: 1.5rem;
}

.performer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin: 2rem 0;
}

@media (max-width: 700px) {
  .chart-row {
    grid-template-columns: 1fr;
  }
  .performer-grid {
    grid-template-columns: 1fr;
  }
}
