/* === Font Faces === */
@font-face {
  font-family: 'Inter';
  src: url('../assets/fonts/InterVariable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Inter';
  src: url('../assets/fonts/InterVariable-Italic.woff2') format('woff2');
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'JetBrains Mono';
  src: url('../assets/fonts/JetBrainsMono-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* === CSS Custom Properties === */
:root {
  --brand-green: #56da77;
  --brand-green-dark: #3ec05f;
  --brand-green-light: #6ef58b;

  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-muted: #706860;

  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-dark: #111827;

  --border-color: #e5e7eb;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);

  --nav-height: 52px;
  --panel-width: 340px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

  /* AI score colors */
  --score-low: #56da77;
  --score-mid: #f59e0b;
  --score-high: #ef4444;
  --score-critical: #991b1b;
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-weight: 400;
  color: var(--text-primary);
  background: var(--bg-primary);
  line-height: 1.5;
  overflow-x: hidden;
}

/* === Navigation === */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 15px;
  flex-shrink: 0;
}

.nav-logo img {
  width: 28px;
  height: 28px;
}

.nav-spacer {
  flex: 1;
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.nav-btn:hover {
  background: var(--bg-secondary);
  border-color: #d1d5db;
}

.nav-btn.active {
  background: var(--brand-green);
  border-color: var(--brand-green);
  color: var(--text-primary);
}

.nav-btn.toggle-2030 {
  font-family: var(--font-mono);
  font-size: 12px;
}

.nav-btn.toggle-2030.active {
  background: var(--bg-dark);
  border-color: var(--bg-dark);
  color: #fff;
}

.nav-btn.toggle-2030.pulse-hint {
  animation: exposurePulse 1.8s ease-in-out 3;
}

@keyframes exposurePulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(86, 218, 119, 0);
    background: var(--bg-primary);
    border-color: var(--border-color);
  }
  50% {
    box-shadow: 0 0 14px 5px rgba(86, 218, 119, 0.45);
    background: rgba(86, 218, 119, 0.15);
    border-color: var(--brand-green);
  }
}

.nav-divider {
  width: 1px;
  height: 24px;
  background: var(--border-color);
  margin: 0 8px;
}

/* Legend */
.nav-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  color: var(--text-muted);
}

.nav-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.legend-swatch {
  width: 12px;
  height: 10px;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.legend-swatch.lit {
  background: #E8B84B;
}

.legend-swatch.dark {
  background: #1E1A16;
}

/* === Scroll Container === */
.skyline-container {
  position: relative;
  width: 100%;
  height: calc(100vh - var(--nav-height));
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.skyline-container canvas {
  display: block;
}

/* Scroll indicators */
.scroll-indicator {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-secondary);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.scroll-indicator.visible {
  opacity: 1;
  pointer-events: auto;
}

.scroll-indicator.left {
  left: 12px;
}

.scroll-indicator.right {
  right: 12px;
}

.scroll-indicator:hover {
  background: #fff;
  color: var(--text-primary);
}

/* === Detail Panel === */
.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.1);
  z-index: 199;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.panel-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.panel {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--panel-width);
  height: 100vh;
  background: var(--bg-primary);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.1);
  z-index: 200;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel.open {
  transform: translateX(0);
}

.panel-header {
  background: var(--bg-dark);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.panel-header h2 {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
}

.panel-header .subtitle {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 2px;
}

.panel-close {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.panel-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* AI Score Section */
.panel-score {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.score-circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.score-bar-wrap {
  flex: 1;
}

.score-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.score-bar {
  height: 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* Stats */
.panel-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 12px;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 18px;
  font-weight: 600;
  margin-top: 2px;
}

.stat-value.mono {
  font-family: var(--font-mono);
}

/* Subcategories */
.panel-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sub-list {
  list-style: none;
  margin-bottom: 20px;
}

.sub-item {
  padding: 8px 0;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sub-item:last-child {
  border-bottom: none;
}

.sub-bar {
  width: 40px;
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}

.sub-bar-fill {
  height: 100%;
  border-radius: 3px;
}

.sub-info {
  flex: 1;
  min-width: 0;
}

.sub-title {
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sub-meta {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.sub-score {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

/* Rationale */
.panel-rationale {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 20px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* Source link */
.panel-source {
  font-size: 12px;
  color: var(--text-muted);
}

.panel-source a {
  color: var(--brand-green-dark);
  text-decoration: none;
}

.panel-source a:hover {
  text-decoration: underline;
}

/* ThinkTower panel */
.panel-thinktower {
  text-align: center;
}

.panel-thinktower .tt-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
}

.panel-thinktower h3 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.panel-thinktower p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
}

.panel-thinktower .tt-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 20px 0 8px;
}

.panel-thinktower .tt-section-title:first-child {
  margin-top: 0;
}

.panel-thinktower .tt-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--brand-green);
  color: var(--text-primary);
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.15s ease;
}

.panel-thinktower .tt-cta:hover {
  background: var(--brand-green-dark);
}

.panel-thinktower .tt-legend {
  text-align: left;
  margin: 12px 0;
}

.panel-thinktower .tt-legend dt {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  margin-top: 10px;
}

.panel-thinktower .tt-legend dd {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 2px 0 0 0;
}

.panel-thinktower .tt-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  font-size: 13px;
  color: var(--text-muted);
}

.panel-thinktower .tt-footer a {
  color: var(--brand-green-dark);
  text-decoration: none;
}

.panel-thinktower .tt-footer a:hover {
  text-decoration: underline;
}

/* === Landing Page === */
.landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
}

.landing-logo {
  width: 80px;
  height: 80px;
  margin-bottom: 32px;
}

.landing h1 {
  font-size: 42px;
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: 12px;
  max-width: 600px;
}

.landing h1 span {
  color: var(--brand-green);
}

.landing .subtitle {
  font-size: 18px;
  color: var(--text-secondary);
  max-width: 520px;
  line-height: 1.6;
  margin-bottom: 40px;
}

.landing-buttons {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.landing-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 16px;
  transition: all 0.15s ease;
}

.landing-btn.primary {
  background: var(--brand-green);
  color: var(--text-primary);
}

.landing-btn.primary:hover {
  background: var(--brand-green-dark);
}

.landing-btn.secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.landing-btn.secondary:hover {
  background: #f3f4f6;
}

.landing-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

.landing-footer a {
  color: var(--brand-green-dark);
  text-decoration: none;
}

.landing-footer a:hover {
  text-decoration: underline;
}

.landing-description {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 460px;
  line-height: 1.7;
  margin-bottom: 48px;
}

/* === Nav Language Flag === */
.nav-lang {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  background: var(--bg-primary);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  padding: 0;
}

.nav-lang:hover {
  background: var(--bg-secondary);
  border-color: #d1d5db;
  transform: scale(1.08);
}

/* === Guide Panel === */
.guide-btn {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  width: 32px;
  padding: 6px 0;
  justify-content: center;
}

.guide-panel {
  position: fixed;
  top: var(--nav-height);
  left: 0;
  right: 0;
  z-index: 90;
  background: #fff;
  border-bottom: 2px solid var(--brand-green);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.10);
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.2s ease;
}

.guide-panel.open {
  max-height: calc(100vh - var(--nav-height) - 20px);
  opacity: 1;
  overflow-y: auto;
}

.guide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px 0;
}

.guide-title {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.guide-close {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: #fff;
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.guide-close:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-color: #d1d5db;
}

.guide-content {
  padding: 14px 32px 24px;
}

.guide-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.guide-card {
  flex: 1 1 0%;
  min-width: 160px;
  max-width: 25%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #f8faf9;
  border: 1px solid #e8ece9;
  border-radius: 10px;
}

.guide-card-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  color: var(--brand-green-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-radius: 6px;
  border: 1px solid #e8ece9;
}

.guide-card-icon svg {
  display: block;
  width: 18px;
  height: 18px;
}

.guide-card-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.guide-card-text strong {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.guide-card-text span {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.3;
}

.legend-swatch-inline {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 2px;
}
.legend-swatch-inline.lit { background: #F5D77A; }
.legend-swatch-inline.dark { background: #1E1A16; }

.guide-group-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 12px 0 6px 4px;
}
.guide-group-label:first-child {
  margin-top: 0;
}

.guide-footnote {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 12px 0 0;
  padding: 0 4px;
}

.guide-sources {
  margin: 4px 0 16px 4px;
}
.guide-sources dt {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 8px;
}
.guide-sources dt:first-child {
  margin-top: 0;
}
.guide-sources dd {
  font-size: 13px;
  color: var(--text-muted);
  margin: 2px 0 0 0;
  line-height: 1.5;
}
.guide-sources a {
  color: var(--brand-green-dark);
  text-decoration: none;
  transition: color 0.15s ease;
}
.guide-sources a:hover {
  color: var(--brand-green);
  text-decoration: underline;
}
.guide-sources a:active {
  color: #2a9d48;
}

/* === Treemap === */
.treemap-svg {
  display: block;
}

.treemap-tooltip {
  position: fixed;
  z-index: 300;
  display: none;
  padding: 12px 16px;
  background: rgba(20, 20, 35, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: #ccc;
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  max-width: 320px;
}

.treemap-tooltip .tt-title {
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
  line-height: 1.3;
}

.treemap-tooltip .tt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.treemap-tooltip .tt-table td {
  padding: 2px 0;
  vertical-align: top;
}

.treemap-tooltip .tt-table td:first-child {
  color: #999;
  padding-right: 16px;
  white-space: nowrap;
}

.treemap-tooltip .tt-table td:last-child {
  color: #eee;
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: right;
}

.treemap-tooltip .tt-score-bar {
  margin-bottom: 10px;
}

.treemap-tooltip .tt-score-label {
  font-size: 13px;
  font-weight: 600;
}

.treemap-tooltip .tt-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}

.treemap-tooltip .tt-bar-fill {
  height: 100%;
  border-radius: 2px;
}

/* Panel subcategory tooltip — same style as treemap tooltip */
.panel-sub-tooltip {
  position: fixed;
  z-index: 300;
  display: none;
  padding: 12px 16px;
  background: rgba(20, 20, 35, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: #ccc;
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  max-width: 360px;
}

.panel-sub-tooltip .tt-title {
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
  line-height: 1.3;
}

.panel-sub-tooltip .tt-score-bar { margin-bottom: 10px; }
.panel-sub-tooltip .tt-score-label { font-size: 13px; font-weight: 600; }
.panel-sub-tooltip .tt-bar { height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px; margin-top: 4px; overflow: hidden; }
.panel-sub-tooltip .tt-bar-fill { height: 100%; border-radius: 2px; }

.panel-sub-tooltip .tt-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.panel-sub-tooltip .tt-table td { padding: 2px 0; vertical-align: top; }
.panel-sub-tooltip .tt-table td:first-child { color: #999; padding-right: 16px; white-space: nowrap; }
.panel-sub-tooltip .tt-table td:last-child { color: #eee; font-family: var(--font-mono); font-size: 12px; text-align: right; }

.panel-sub-tooltip .tt-rationale {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 12px;
  line-height: 1.5;
  color: #aaa;
  white-space: normal;
  max-width: 360px;
}

/* Highlight sub-item on hover */
.sub-item[data-sub-idx] {
  cursor: pointer;
  transition: background 0.1s ease;
}

.sub-item[data-sub-idx]:hover {
  background: var(--bg-secondary);
}

.treemap-tooltip .tt-rationale {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 12px;
  line-height: 1.5;
  color: #aaa;
  white-space: normal;
  max-width: 360px;
}

/* === Responsive === */
@media (max-width: 768px) {
  .panel {
    width: 100%;
  }

  .nav-legend {
    display: none;
  }

  .nav-btn {
    padding: 5px 8px;
    font-size: 12px;
  }

  .guide-card {
    min-width: calc(33% - 12px);
  }

  .guide-panel.open {
    max-height: calc(100vh - var(--nav-height) - 20px);
  }

  .guide-btn {
    width: 28px;
    font-size: 12px;
  }

  .landing h1 {
    font-size: 32px;
  }

  .landing .subtitle {
    font-size: 16px;
  }

  .scroll-indicator {
    width: 30px;
    height: 30px;
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .nav {
    padding: 0 10px;
    gap: 8px;
  }

  .nav-divider {
    display: none;
  }

  .landing h1 {
    font-size: 28px;
  }

  .guide-card {
    min-width: 100%;
  }

  .guide-panel.open {
    max-height: calc(100vh - var(--nav-height) - 20px);
  }

  .guide-content {
    padding: 10px 16px 16px;
  }

  .guide-header {
    padding: 12px 16px 0;
  }
}
