/* style.css — Cartridge Curves Design Tokens + Components */

/* ============================================
   TYPE SCALE (fluid)
   ============================================ */
:root {
  --text-xs:   clamp(0.75rem,  0.7rem  + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.8rem  + 0.35vw, 1rem);
  --text-base: clamp(1rem,     0.9rem  + 0.5vw,  1.125rem);
  --text-lg:   clamp(1.125rem, 0.95rem + 0.85vw, 1.5rem);
  --text-xl:   clamp(1.5rem,   1rem    + 1.5vw,  2.25rem);
  --text-2xl:  clamp(2rem,     1.2rem  + 2.5vw,  3.5rem);
  --text-3xl:  clamp(2.5rem,   1rem    + 4vw,    5rem);

  /* SPACING (4px grid) */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* FONTS */
  --font-display: 'Libre Baskerville', 'Georgia', serif;
  --font-body: 'DM Sans', 'Helvetica Neue', sans-serif;

  /* RADIUS */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* TRANSITION */
  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  /* CONTENT WIDTHS */
  --content-narrow: 640px;
  --content-default: 960px;
  --content-wide: 1200px;
  --content-full: 100%;
}

/* ============================================
   DARK MODE (DEFAULT)
   ============================================ */
:root, [data-theme="dark"] {
  --color-bg:             #121110;
  --color-surface:        #1a1918;
  --color-surface-2:      #201f1d;
  --color-surface-offset: #1d1c1a;
  --color-surface-offset-2: #252422;
  --color-surface-dynamic: #2d2c2a;
  --color-divider:        #2a2928;
  --color-border:         #3a3937;

  --color-text:           #d4d3d0;
  --color-text-muted:     #8a8985;
  --color-text-faint:     #5a5957;
  --color-text-inverse:   #1a1918;

  /* Primary Accent — Teal */
  --color-primary:        #4f98a3;
  --color-primary-hover:  #6ab0ba;
  --color-primary-active: #1a626b;
  --color-primary-highlight: #1f3033;

  /* Gold accent for active/selected */
  --color-gold:           #c9a84c;
  --color-gold-hover:     #dabb60;
  --color-gold-active:    #a88b3a;
  --color-gold-highlight: #2e2a1e;

  /* Semantic */
  --color-success:        #6daa45;
  --color-error:          #d163a7;
  --color-warning:        #bb653b;

  /* Shadows */
  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.25);
  --shadow-md: 0 4px 12px oklch(0 0 0 / 0.35);
  --shadow-lg: 0 12px 32px oklch(0 0 0 / 0.45);
}

/* ============================================
   LIGHT MODE
   ============================================ */
[data-theme="light"] {
  --color-bg:             #f5f3ef;
  --color-surface:        #faf9f6;
  --color-surface-2:      #ffffff;
  --color-surface-offset: #edeae5;
  --color-surface-offset-2: #e6e3de;
  --color-surface-dynamic: #dbd8d3;
  --color-divider:        #d4d1ca;
  --color-border:         #c8c5be;

  --color-text:           #1c1a16;
  --color-text-muted:     #6b6a66;
  --color-text-faint:     #a5a4a0;
  --color-text-inverse:   #f5f3ef;

  --color-primary:        #01696f;
  --color-primary-hover:  #0c4e54;
  --color-primary-active: #0f3638;
  --color-primary-highlight: #cedcd8;

  --color-gold:           #9a7b20;
  --color-gold-hover:     #7d6318;
  --color-gold-active:    #604c12;
  --color-gold-highlight: #ede7d2;

  --color-success:        #437a22;
  --color-error:          #a12c7b;
  --color-warning:        #964219;

  --shadow-sm: 0 1px 2px oklch(0.2 0.01 80 / 0.06);
  --shadow-md: 0 4px 12px oklch(0.2 0.01 80 / 0.08);
  --shadow-lg: 0 12px 32px oklch(0.2 0.01 80 / 0.12);
}

/* ============================================
   LAYOUT
   ============================================ */
.container {
  max-width: var(--content-wide);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

.container--narrow {
  max-width: var(--content-default);
}

/* ============================================
   SKIP LINK
   ============================================ */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  padding: var(--space-2) var(--space-4);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-radius: var(--radius-md);
  z-index: 1000;
  font-size: var(--text-sm);
  text-decoration: none;
}
.skip-link:focus {
  top: var(--space-2);
}

/* ============================================
   HEADER / NAV
   ============================================ */
.site-header {
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--color-divider);
  background: var(--color-bg);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: oklch(from var(--color-bg) l c h / 0.9);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.site-logo {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.site-logo span {
  color: var(--color-primary);
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  transition: color var(--transition-interactive),
              background var(--transition-interactive);
}
.theme-toggle:hover {
  color: var(--color-text);
  background: var(--color-surface-dynamic);
}

/* ============================================
   HERO
   ============================================ */
.hero {
  padding: clamp(var(--space-12), 6vw, var(--space-20)) 0;
  text-align: center;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-3);
  letter-spacing: -0.02em;
}

.hero .subtitle {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  max-width: 48ch;
  margin-inline: auto;
  line-height: 1.5;
}

/* ============================================
   BRAND TABS
   ============================================ */
.brand-tabs {
  display: flex;
  gap: var(--space-2);
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: var(--space-6);
}

.brand-tab {
  padding: var(--space-2) var(--space-5);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  transition: all var(--transition-interactive);
  min-height: 44px;
  display: flex;
  align-items: center;
}
.brand-tab:hover {
  color: var(--color-text);
  border-color: var(--color-text-muted);
  background: var(--color-surface-dynamic);
}
.brand-tab.active {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background: var(--color-primary-highlight);
  font-weight: 600;
}

/* ============================================
   CHART SECTION
   ============================================ */
.chart-section {
  padding: 0 0 var(--space-8);
}

.chart-wrapper {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
  position: relative;
}

.chart-container {
  position: relative;
  width: 100%;
  height: 450px;
}

@media (max-width: 768px) {
  .chart-container {
    height: 300px;
  }
  .chart-wrapper {
    padding: var(--space-4);
  }
}

.chart-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  margin-bottom: var(--space-4);
  color: var(--color-text);
}

.chart-subtitle {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-4);
}

/* ============================================
   CARTRIDGE CHIPS (toggles)
   ============================================ */
.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: center;
}

.cartridge-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 500;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  transition: all var(--transition-interactive);
  min-height: 40px;
  cursor: pointer;
}

.cartridge-chip .chip-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.cartridge-chip:hover {
  border-color: var(--color-text-muted);
  color: var(--color-text);
  background: var(--color-surface-dynamic);
}

.cartridge-chip.active {
  border-color: var(--color-gold);
  background: var(--color-gold-highlight);
  color: var(--color-text);
}

.cartridge-chip.active .chip-dot {
  box-shadow: 0 0 0 2px var(--color-gold);
}

/* ============================================
   COMPARISON TABLE
   ============================================ */
.comparison-section {
  padding: var(--space-8) 0;
}

.section-heading {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-6);
  letter-spacing: -0.01em;
}

.comparison-empty {
  text-align: center;
  padding: var(--space-10) var(--space-4);
  color: var(--color-text-muted);
}

.comparison-empty p {
  max-width: 40ch;
  margin-inline: auto;
}

.comparison-empty .icon-placeholder {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-4);
  color: var(--color-text-faint);
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.comparison-table {
  min-width: 700px;
  font-size: var(--text-sm);
}

.comparison-table th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-offset);
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  border-bottom: 1px solid var(--color-divider);
}

.comparison-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-divider);
  color: var(--color-text);
  vertical-align: top;
}

.comparison-table tr:last-child td {
  border-bottom: none;
}

.comparison-table .model-name {
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
}

.comparison-table .sound-desc {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  max-width: 24ch;
  line-height: 1.4;
}

/* ============================================
   CARTRIDGE DETAIL CARDS
   ============================================ */
.cards-section {
  padding: var(--space-8) 0 var(--space-16);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  gap: var(--space-4);
}

.cartridge-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: box-shadow var(--transition-interactive),
              border-color var(--transition-interactive);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.cartridge-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-text-faint);
}

.cartridge-card.active {
  border-color: var(--color-gold);
  box-shadow: 0 0 0 1px var(--color-gold), var(--shadow-md);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
}

.card-brand {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-primary);
  font-weight: 600;
}

.card-model {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
}

.card-price {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-gold);
  white-space: nowrap;
}

.card-specs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.spec-item {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.spec-item .spec-label {
  color: var(--color-text-faint);
  display: block;
  margin-bottom: 2px;
}

.spec-item .spec-value {
  color: var(--color-text);
  font-weight: 500;
}

.card-description {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* Tonal Profile Bars */
.tonal-profile {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.tonal-bar-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.tonal-label {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  width: 80px;
  flex-shrink: 0;
  text-align: right;
}

.tonal-bar-track {
  flex: 1;
  height: 6px;
  background: var(--color-surface-dynamic);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.tonal-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  transition: width 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

.tonal-bar-fill.bass { background: #5591c7; }
.tonal-bar-fill.midrange { background: #6daa45; }
.tonal-bar-fill.treble { background: #e8af34; }
.tonal-bar-fill.soundstage { background: #a86fdf; }

.tonal-value {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  width: 28px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ============================================
   SOUND SIGNATURE LEGEND
   ============================================ */
.legend-section {
  padding: var(--space-8) 0;
  border-top: 1px solid var(--color-divider);
}

.legend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
  gap: var(--space-4);
}

.legend-item {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.legend-name {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.legend-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
  line-height: 1.4;
}

.legend-curve {
  height: 40px;
  position: relative;
}

.legend-curve svg {
  width: 100%;
  height: 100%;
}

.legend-curve svg path {
  fill: none;
  stroke: var(--color-primary);
  stroke-width: 2;
  opacity: 0.7;
}

.legend-curve svg .ref-line {
  stroke: var(--color-text-faint);
  stroke-width: 1;
  stroke-dasharray: 4 4;
  opacity: 0.4;
}

/* ============================================
   FOOTER
   ============================================ */
.site-footer {
  padding: var(--space-8) 0;
  border-top: 1px solid var(--color-divider);
  text-align: center;
  color: var(--color-text-faint);
  font-size: var(--text-xs);
}

/* ============================================
   SCROLL REVEAL ANIMATION
   ============================================ */
.fade-in {
  opacity: 1;
}

@supports (animation-timeline: scroll()) {
  .fade-in {
    opacity: 0;
    animation: reveal-fade linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 100%;
  }
}

@keyframes reveal-fade {
  to { opacity: 1; }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .hero {
    padding: var(--space-8) 0;
  }
  .hero h1 {
    font-size: var(--text-xl);
  }
  .card-grid {
    grid-template-columns: 1fr;
  }
  .brand-tabs {
    gap: var(--space-1);
  }
  .brand-tab {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
  }
  .cartridge-chip {
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
    min-height: 36px;
  }
  .section-heading {
    font-size: var(--text-lg);
  }
}
