/*!
 * @fileoverview Styles for the company-comparison module (js/company-compare.js).
 *   Self-contained token set scoped to `.cc-root` (light default, dark via
 *   prefers-color-scheme + [data-theme], matching the pattern css/timeline.css
 *   uses for `.tt-tl`) so this module works standalone in
 *   dev/company-compare-demo.html without css/app.css or css/timeline.css
 *   loaded. When mounted in the real app both token sets simply coexist
 *   (distinct `--cc-*` custom properties, no collision with `--tt-*`).
 * @module css/company-compare
 */

/* ---------------------------------------------------------------------
   Tokens — light (default), dark (prefers-color-scheme + [data-theme]).
   Chart chrome matches the dataviz skill's reference palette. The phase
   ramp duplicates css/timeline.css's validated 8-step ordinal blue ramp
   (company strips colour bars by phase "exactly as the main Gantt does").
   The categorical company palette (6 slots + neutral "other") and the
   5-step sequential ramp are validated with the dataviz skill's
   validate_palette.js — see the build report for the exact invocations.
   --------------------------------------------------------------------- */
.cc-root {
  color-scheme: light;
  --cc-surface: #fcfcfb;
  --cc-page: #f9f9f7;
  --cc-ink: #0b0b0b;
  --cc-ink-secondary: #52514e;
  --cc-ink-muted: #898781;
  --cc-grid: #e1e0d9;
  --cc-border: rgba(11, 11, 11, 0.1);
  --cc-tooltip-bg: #0b0b0b;
  --cc-tooltip-ink: #fcfcfb;
  --cc-focus-ring: #52514e;
  --cc-accent: #0d3666;
  --cc-accent-soft: #e7edf5;

  --cc-phase-0: #8fb0db;
  --cc-phase-1: #719ad1;
  --cc-phase-2: #5585c3;
  --cc-phase-3: #3b70b3;
  --cc-phase-4: #275b9d;
  --cc-phase-5: #184882;
  --cc-phase-6: #0d3666;
  --cc-phase-7: #05244a;

  --cc-series-1: #2a78d6; /* blue */
  --cc-series-2: #eb6834; /* orange */
  --cc-series-3: #1baf7a; /* aqua */
  --cc-series-4: #eda100; /* yellow */
  --cc-series-5: #e87ba4; /* magenta */
  --cc-series-6: #008300; /* green */
  --cc-series-other: #898781;

  --cc-seq-1: #86b6ef;
  --cc-seq-2: #5598e7;
  --cc-seq-3: #2a78d6;
  --cc-seq-4: #1c5cab;
  --cc-seq-5: #104281;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .cc-root {
    color-scheme: dark;
    --cc-surface: #1a1a19;
    --cc-page: #0d0d0d;
    --cc-ink: #ffffff;
    --cc-ink-secondary: #c3c2b7;
    --cc-ink-muted: #898781;
    --cc-grid: #2c2c2a;
    --cc-border: rgba(255, 255, 255, 0.1);
    --cc-tooltip-bg: #ffffff;
    --cc-tooltip-ink: #1a1a19;
    --cc-focus-ring: #c3c2b7;
    --cc-accent: #90b5e6;
    --cc-accent-soft: #22334a;

    --cc-phase-0: #c7e0ff;
    --cc-phase-1: #aacbf6;
    --cc-phase-2: #90b5e6;
    --cc-phase-3: #78a0d5;
    --cc-phase-4: #648bbf;
    --cc-phase-5: #5477a5;
    --cc-phase-6: #46648b;
    --cc-phase-7: #395170;

    --cc-series-1: #3987e5;
    --cc-series-2: #d95926;
    --cc-series-3: #199e70;
    --cc-series-4: #c98500;
    --cc-series-5: #d55181;
    --cc-series-6: #008300;
    --cc-series-other: #898781;

    --cc-seq-1: #184f95;
    --cc-seq-2: #256abf;
    --cc-seq-3: #3987e5;
    --cc-seq-4: #6da7ec;
    --cc-seq-5: #b7d3f6;
  }
}

:root[data-theme='dark'] .cc-root {
  color-scheme: dark;
  --cc-surface: #1a1a19;
  --cc-page: #0d0d0d;
  --cc-ink: #ffffff;
  --cc-ink-secondary: #c3c2b7;
  --cc-ink-muted: #898781;
  --cc-grid: #2c2c2a;
  --cc-border: rgba(255, 255, 255, 0.1);
  --cc-tooltip-bg: #ffffff;
  --cc-tooltip-ink: #1a1a19;
  --cc-focus-ring: #c3c2b7;
  --cc-accent: #90b5e6;
  --cc-accent-soft: #22334a;

  --cc-phase-0: #c7e0ff;
  --cc-phase-1: #aacbf6;
  --cc-phase-2: #90b5e6;
  --cc-phase-3: #78a0d5;
  --cc-phase-4: #648bbf;
  --cc-phase-5: #5477a5;
  --cc-phase-6: #46648b;
  --cc-phase-7: #395170;

  --cc-series-1: #3987e5;
  --cc-series-2: #d95926;
  --cc-series-3: #199e70;
  --cc-series-4: #c98500;
  --cc-series-5: #d55181;
  --cc-series-6: #008300;
  --cc-series-other: #898781;

  --cc-seq-1: #184f95;
  --cc-seq-2: #256abf;
  --cc-seq-3: #3987e5;
  --cc-seq-4: #6da7ec;
  --cc-seq-5: #b7d3f6;
}

/* ---------------------------------------------------------------------
   Root & layout
   --------------------------------------------------------------------- */
.cc-root {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--cc-surface);
  color: var(--cc-ink);
  font: 13px/1.4 system-ui, -apple-system, 'Segoe UI', sans-serif;
  box-sizing: border-box;
}
.cc-root *,
.cc-root *::before,
.cc-root *::after {
  box-sizing: border-box;
}
.cc-root [hidden] {
  display: none !important;
}
.cc-root :focus-visible {
  outline: 2px solid var(--cc-focus-ring);
  outline-offset: 2px;
}

.cc-empty,
.cc-empty-inline {
  color: var(--cc-ink-secondary);
  font-size: 13px;
  padding: 12px 0;
}

.cc-body {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.cc-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.cc-section-title {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--cc-ink-secondary);
}
.cc-caption {
  margin: 0;
  font-size: 11px;
  color: var(--cc-ink-muted);
  line-height: 1.5;
}
.cc-section-body {
  min-width: 0;
}

/* ---------------------------------------------------------------------
   Legend (shared across sections — colour identity stays constant)
   --------------------------------------------------------------------- */
.cc-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  padding: 8px 10px;
  border: 1px solid var(--cc-border);
  border-radius: 8px;
  background: var(--cc-page);
}
.cc-legend-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--cc-ink-muted);
}
.cc-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--cc-ink);
  cursor: pointer;
  border-radius: 4px;
  padding: 2px 4px;
}
.cc-legend-item:hover {
  background: var(--cc-grid);
}
.cc-legend-item.cc-dim {
  opacity: 0.55;
}
.cc-legend-swatch,
.cc-swatch-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}
.cc-swatch-dot {
  margin-right: 6px;
}

/* ---------------------------------------------------------------------
   Tables (shared skeleton — matrix / comparison / calendar / strips-table)
   --------------------------------------------------------------------- */
.cc-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--cc-border);
  border-radius: 8px;
}
.cc-matrix-table,
.cc-comparison-table,
.cc-calendar-table,
.cc-strips-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.cc-matrix-table th,
.cc-matrix-table td,
.cc-comparison-table th,
.cc-comparison-table td,
.cc-calendar-table th,
.cc-calendar-table td,
.cc-strips-table th,
.cc-strips-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--cc-border);
  text-align: right;
  white-space: nowrap;
}
.cc-matrix-table th:first-child,
.cc-matrix-table td:first-child,
.cc-comparison-table th:first-child,
.cc-comparison-table td:first-child,
.cc-calendar-table th:first-child,
.cc-calendar-table td:first-child,
.cc-strips-table th:first-child,
.cc-strips-table td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--cc-surface);
}
.cc-strips-table td:nth-child(3) {
  text-align: left;
  white-space: normal;
  max-width: 320px;
}
.cc-num {
  text-align: right;
}
.cc-total {
  font-weight: 700;
}
.cc-row-name {
  display: flex;
  align-items: center;
  font-weight: 600;
  text-align: left !important;
}
.cc-matrix-table tbody tr,
.cc-comparison-table tbody tr,
.cc-strips-table tbody tr {
  cursor: pointer;
}
.cc-matrix-table tbody tr:hover,
.cc-comparison-table tbody tr:hover,
.cc-strips-table tbody tr:hover {
  background: var(--cc-page);
}
.cc-row-focus {
  box-shadow: inset 3px 0 0 var(--cc-accent);
}
.cc-row-focus .cc-row-name,
.cc-row-focus td:first-child {
  background: var(--cc-accent-soft);
}
.cc-dim {
  opacity: 0.55;
}
.cc-cell {
  border-radius: 3px;
}
.cc-cell-filled {
  color: var(--cc-ink);
}

.cc-table-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 6px;
}
.cc-sort-btn {
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
  white-space: nowrap;
}
.cc-sort-btn:hover {
  text-decoration: underline;
}

.cc-btn {
  font: inherit;
  font-size: 12px;
  color: var(--cc-ink);
  background: var(--cc-surface);
  border: 1px solid var(--cc-border);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
}
.cc-btn:hover {
  background: var(--cc-grid);
}
.cc-btn-small {
  padding: 4px 9px;
  font-size: 11px;
}
.cc-btn[aria-pressed='true'] {
  background: var(--cc-accent-soft);
  border-color: var(--cc-accent);
}

/* ---------------------------------------------------------------------
   Charts (SVG) — bars, scatter, strips
   --------------------------------------------------------------------- */
.cc-chart-wrap {
  border: 1px solid var(--cc-border);
  border-radius: 8px;
  background: var(--cc-surface);
  padding: 6px 4px 0;
}
.cc-bars-svg,
.cc-scatter-svg {
  display: block;
  width: 100%;
  height: auto;
}
.cc-grid-line,
.cc-grid-line-v {
  stroke: var(--cc-grid);
  stroke-width: 1;
}
.cc-axis-label {
  font-size: 9px;
  fill: var(--cc-ink-muted);
  text-anchor: middle;
}
.cc-axis-label-y {
  text-anchor: end;
}
.cc-today-line {
  stroke: var(--cc-ink-secondary);
  stroke-width: 1;
  stroke-dasharray: 2, 3;
}
.cc-today-label {
  font-size: 9px;
  fill: var(--cc-ink-secondary);
}
.cc-bar {
  transition: opacity 0.1s ease;
}
.cc-direct-label {
  font-size: 9px;
  fill: var(--cc-ink-secondary);
  text-anchor: middle;
  font-variant-numeric: tabular-nums;
}
.cc-hit {
  fill: transparent;
  cursor: pointer;
}
.cc-hit:focus-visible {
  outline: 2px solid var(--cc-focus-ring);
  outline-offset: 1px;
}
.cc-point {
  stroke: var(--cc-surface);
  stroke-width: 2;
}
.cc-point-unknown-n {
  stroke-dasharray: 2, 2;
}
.cc-point-clamped-before,
.cc-point-clamped-after {
  stroke: var(--cc-ink-secondary);
  stroke-width: 1.5;
  stroke-dasharray: 1, 2;
}

/* ---------------------------------------------------------------------
   Company strips
   --------------------------------------------------------------------- */
.cc-strips-scroll {
  overflow-x: auto;
  border: 1px solid var(--cc-border);
  border-radius: 8px;
  background: var(--cc-surface);
  padding: 6px 0;
}
.cc-strips-inner {
  display: flex;
  flex-direction: column;
}
.cc-strip-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
}
.cc-strip-row:hover {
  background: var(--cc-page);
}
.cc-strip-label {
  display: flex;
  align-items: center;
  flex: none;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 4px;
  padding: 2px;
  overflow: hidden;
}
.cc-strip-label:hover {
  background: var(--cc-grid);
}
.cc-strip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cc-strip-track {
  flex: none;
}
.cc-strip-svg {
  display: block;
}
.cc-strip-bar {
  cursor: pointer;
}
.cc-strip-glyph-dot {
  pointer-events: none;
}

/* ---------------------------------------------------------------------
   Tooltip (shared across all sections)
   --------------------------------------------------------------------- */
.cc-tooltip {
  position: absolute;
  z-index: 1000;
  max-width: 280px;
  background: var(--cc-tooltip-bg);
  color: var(--cc-tooltip-ink);
  font-size: 11px;
  line-height: 1.5;
  border-radius: 6px;
  padding: 8px 10px;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
.cc-tooltip-title {
  font-weight: 700;
  margin-bottom: 2px;
}

/* ---------------------------------------------------------------------
   Responsive — usable at ~400px (SPEC.md §2's rule applied to this module)
   --------------------------------------------------------------------- */
@media (max-width: 640px) {
  .cc-legend {
    gap: 6px 10px;
  }
  .cc-body {
    gap: 16px;
  }
  .cc-strip-label {
    width: 96px !important;
  }
}
