/* ============================================================
   css/base.css — Global component styles
   (Theme variable blocks live in themes/{name}/theme.css)
   ============================================================ */

/* ── Base Reset & Transitions ─────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  transition:
    background-color 0.35s ease,
    color 0.35s ease;
  min-height: 100vh;
}

/* ================================================================
   GLOBAL COMPONENT STYLES (use CSS variables from theme files)
   ================================================================ */

body {
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-family);
}

/* ── Navbar ──────────────────────────────────────────────── */
.portfolio-navbar {
  background: var(--bg-navbar) !important;
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  z-index: 1040;
  transition:
    background 0.35s ease,
    border-color 0.35s ease;
}

.brand-icon {
  font-size: 1.4rem;
  color: var(--accent);
  transition: color 0.35s ease;
}
.brand-text {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-logo);
  letter-spacing: -0.02em;
  transition: color 0.35s ease;
}
.brand-accent {
  color: var(--accent);
}

.chart-count-badge {
  background: var(--badge-bg);
  color: var(--badge-color);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.3em 0.75em;
  border-radius: 50px;
  letter-spacing: 0.02em;
  transition:
    background 0.35s ease,
    color 0.35s ease;
}

/* ── Theme Dropdown ──────────────────────────────────────── */
.theme-btn {
  background: var(--theme-btn-bg);
  color: var(--theme-btn-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.42rem 0.9rem;
  transition: all 0.2s ease;
}
.theme-btn:hover,
.theme-btn:focus {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.theme-btn::after {
  margin-left: 0.4em;
}

.theme-menu {
  background: var(--dropdown-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  padding: 0.5rem;
  min-width: 260px;
  max-height: 420px;
  overflow-y: auto;
  overflow-x: hidden;
  transition: background 0.35s ease;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}
.theme-menu::-webkit-scrollbar {
  width: 5px;
}
.theme-menu::-webkit-scrollbar-track {
  background: transparent;
}
.theme-menu::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}
.theme-menu .dropdown-header {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 0.4rem 0.75rem;
}
.theme-menu .dropdown-divider {
  border-color: var(--border-color);
  margin: 0.4rem 0;
}

.theme-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  color: var(--dropdown-text);
  transition: background 0.15s ease;
  border: none;
  width: 100%;
  text-align: left;
  background: transparent;
}
.theme-item:hover,
.theme-item:focus {
  background: var(--dropdown-hover);
  outline: none;
}
.theme-item.active-theme {
  background: var(--cat-pill-active-bg);
  color: var(--cat-pill-active-color);
}

.theme-item-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--dropdown-text);
  transition: color 0.2s;
}
.theme-item.active-theme .theme-item-name {
  color: inherit;
}
.theme-item-desc {
  font-size: 0.73rem;
  color: var(--text-muted);
  line-height: 1.3;
  transition: color 0.2s;
}

/* Theme swatches (base size — individual colors in theme.css) */
.theme-swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.4);
  display: inline-block;
}
#activeThemeSwatch {
  width: 14px;
  height: 14px;
}

/* ── Hero Section ────────────────────────────────────────── */
.portfolio-hero {
  background: var(--bg-hero);
  border-bottom: 1px solid var(--border-color);
  transition: background 0.35s ease;
}
.hero-eyebrow {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--hero-eyebrow);
  transition: color 0.35s ease;
}
.hero-title {
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 800;
  line-height: 1.15;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  transition: color 0.35s ease;
}
.hero-accent {
  color: var(--hero-accent);
  transition: color 0.35s ease;
}
.hero-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.7;
  max-width: 520px;
  transition: color 0.35s ease;
}
.hero-tag {
  display: inline-flex;
  align-items: center;
  background: var(--hero-tag-bg);
  color: var(--hero-tag-color);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3em 0.8em;
  border-radius: 50px;
  transition:
    background 0.35s ease,
    color 0.35s ease;
}
.hero-chart-preview {
  width: 100%;
  max-width: 420px;
  height: 260px;
  border-radius: 12px;
  overflow: hidden;
}

/* ── Category Filter Bar ─────────────────────────────────── */
.category-bar-wrapper {
  background: var(--bg-page);
  border-bottom: 1px solid var(--border-color);
  transition: background 0.35s ease;
}
.category-bar {
  gap: 0.5rem;
  flex-wrap: nowrap;
  scrollbar-width: none;
}
.category-bar::-webkit-scrollbar {
  display: none;
}

.cat-pill {
  background: var(--cat-pill-bg);
  color: var(--cat-pill-color);
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 50px;
  padding: 0.32rem 0.9rem;
  border: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition:
    background 0.2s ease,
    color 0.2s ease;
}
.cat-pill:hover {
  filter: brightness(1.05);
}
.cat-pill.active {
  background: var(--cat-pill-active-bg) !important;
  color: var(--cat-pill-active-color) !important;
}
.cat-count {
  font-size: 0.7rem;
  opacity: 0.7;
}

/* Sticky below sticky nav */
.sticky-below-nav {
  top: 57px;
  z-index: 1030;
}

/* ── Section Labels ──────────────────────────────────────── */
.section-label {
  display: inline-flex;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--section-icon-color);
  background: var(--bg-section-label);
  padding: 0.4em 1em;
  border-radius: 6px;
  transition:
    background 0.35s ease,
    color 0.35s ease;
}

/* ── Chart Cards ─────────────────────────────────────────── */
.chart-card {
  background: var(--bg-card);
  border-radius: var(--card-radius);
  border: var(--card-border-width) var(--card-border-style) var(--border-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  height: 100%;
  display: flex;
  flex-direction: column;
  transition:
    box-shadow 0.25s ease,
    transform 0.25s ease,
    background 0.35s ease,
    border-color 0.35s ease;
}
.chart-card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
}

.chart-card-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 1rem 1.1rem 0.6rem;
}
.chart-category-pill {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--pill-bg);
  color: var(--pill-color);
  padding: 0.2em 0.65em;
  border-radius: 50px;
  margin-bottom: 0.4rem;
  transition:
    background 0.35s ease,
    color 0.35s ease;
}
.chart-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
  letter-spacing: -0.01em;
  transition: color 0.35s ease;
}
.chart-card-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.4;
  transition: color 0.35s ease;
}

/* ── Chart Container ─────────────────────────────────────── */
.chart-container {
  flex: 1;
  min-height: 310px;
  height: 340px;
  max-height: 420px;
  padding: 0 0.5rem 0.75rem;
  position: relative;
  overflow: hidden;
}
.chart-container .js-plotly-plot {
  width: 100% !important;
  height: 100% !important;
}

/* ── Footer ──────────────────────────────────────────────── */
.portfolio-footer {
  background: var(--bg-footer);
  border-top: 1px solid var(--border-color);
  transition: background 0.35s ease;
}
.footer-text {
  font-size: 0.88rem;
  color: var(--text-secondary);
  font-weight: 600;
}
.footer-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ── Theme Transition Fade ───────────────────────────────── */
.chart-card,
.portfolio-navbar,
.portfolio-hero,
.portfolio-footer,
.category-bar-wrapper {
  transition:
    background 0.35s ease,
    background-color 0.35s ease,
    border-color 0.35s ease,
    box-shadow 0.35s ease,
    color 0.35s ease;
}

/* ── Plotly modebar ──────────────────────────────────────── */
.modebar-container {
  z-index: 1 !important;
}

/* ── Filter Panel ────────────────────────────────────────── */
.filter-panel-wrapper {
  background: var(--bg-hero);
  border-bottom: 1px solid var(--border-color);
  padding: 0.65rem 0;
}
.filter-panel-wrapper .container-xxl {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
}
.filter-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem 0.4rem;
}
.filter-group-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-right: 0.15rem;
  white-space: nowrap;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.72rem;
  border-radius: 50px;
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: var(--cat-pill-bg);
  color: var(--cat-pill-color);
  transition:
    background 0.18s,
    color 0.18s,
    border-color 0.18s;
  line-height: 1.4;
  white-space: nowrap;
}
.filter-chip:hover {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}
.filter-chip.active {
  background: var(--cat-pill-active-bg);
  color: var(--cat-pill-active-color);
  border-color: transparent;
  font-weight: 600;
}
.filter-reset-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.8rem;
  border-radius: 50px;
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  transition:
    background 0.18s,
    color 0.18s;
  margin-left: auto;
}
.filter-reset-btn:hover {
  background: var(--border-color);
  color: var(--text-body);
}

/* ── Drilldown back button ───────────────────────────────── */
.drilldown-back-btn {
  display: none;
  align-items: center;
  gap: 0.25rem;
  padding: 0.18rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  margin-left: auto;
  transition: opacity 0.15s;
  line-height: 1.5;
}
.drilldown-back-btn:hover {
  opacity: 0.82;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 576px) {
  .chart-container {
    height: 290px;
    min-height: 270px;
  }
  .hero-title {
    font-size: 1.8rem;
  }
  .hero-subtitle {
    font-size: 0.9rem;
  }
  .portfolio-navbar .brand-text {
    font-size: 1rem;
  }
  .filter-panel-wrapper .container-xxl {
    gap: 0.5rem 0.75rem;
  }
  .filter-chip,
  .filter-reset-btn {
    font-size: 0.72rem;
    padding: 0.18rem 0.58rem;
  }
}

@media (max-width: 768px) {
  .category-bar-wrapper {
    top: 56px;
  }
}

/* ── Library Compatibility Section ──────────────────────────────────── */
.compat-section {
  padding: 2rem 0 5rem;
}
.compat-heading {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}
.compat-intro {
  color: var(--text-muted);
  font-size: 0.9rem;
  max-width: 720px;
  margin-bottom: 1rem;
}
.compat-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.85rem;
}
.compat-legend span {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.compat-table {
  font-size: 0.83rem;
  border-color: var(--border-subtle);
}
.compat-table th {
  font-weight: 600;
  white-space: nowrap;
  color: var(--text-primary);
  background: var(--card-bg);
}
.compat-table td {
  vertical-align: middle;
}
.cb-native {
  color: #198754;
  font-weight: 500;
}
.cb-plugin {
  color: #fd7e14;
  font-weight: 500;
}
.cb-partial {
  color: #0d6efd;
  font-weight: 500;
}
.cb-none {
  color: #6c757d;
}

/* ── N/A overlay for unsupported chart types on library pages ── */
.chart-container {
  position: relative;
}
.chart-na-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  background: var(--bg-card);
  opacity: 0.8;
  border-radius: var(--radius, 0.75rem);
  font-size: 0.85rem;
  gap: 0.4rem;
  pointer-events: none;
  z-index: 2;
}
.chart-na-overlay i {
  font-size: 1.6rem;
  opacity: 0.5;
}
