/**
 * Chart Accessibility Styles
 * Sprint 17: Keyboard Toggle Visible State
 *
 * Provides styling for toggled data table visibility
 * @module chart-accessibility.css
 */

/* =============================================================================
   VISIBLE TABLE STATE (Sprint 17)
   ============================================================================= */

/**
 * Visible state for keyboard-toggled data tables
 * Removes screen-reader-only hiding and displays table visually
 */
.chart-data-table-visible {
  /* Override visually-hidden properties */
  position: static !important;
  width: auto !important;
  height: auto !important;
  padding: 0 !important;
  margin: 1rem 0 !important;
  overflow: visible !important;
  clip: auto !important;
  white-space: normal !important;
  border: 0 !important;

  /* Visual styling for toggled tables */
  display: table;
  border-collapse: collapse;
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius, 0.5rem);
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
  font-size: 0.875rem;
  width: 100%;
  max-width: 100%;
}

/* Table elements when visible */
.chart-data-table-visible caption {
  padding: 1rem;
  font-weight: 600;
  font-size: 1rem;
  text-align: left;
  background: var(--bg-secondary, #f9fafb);
  border-bottom: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius, 0.5rem) var(--radius, 0.5rem) 0 0;
}

.chart-data-table-visible thead {
  background: var(--bg-secondary, #f9fafb);
  border-bottom: 2px solid var(--border, #e5e7eb);
}

.chart-data-table-visible th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary, #111827);
}

.chart-data-table-visible td {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border, #e5e7eb);
  color: var(--text-secondary, #6b7280);
}

.chart-data-table-visible tbody tr:hover {
  background: var(--bg-hover, #f3f4f6);
}

.chart-data-table-visible tfoot {
  background: var(--bg-secondary, #f9fafb);
  border-top: 2px solid var(--border, #e5e7eb);
  font-weight: 600;
}

.chart-data-table-visible tfoot th,
.chart-data-table-visible tfoot td {
  padding: 0.75rem 1rem;
  color: var(--text-primary, #111827);
}

/* =============================================================================
   CANVAS FOCUS INDICATOR
   ============================================================================= */

/**
 * Focus indicator for keyboard-accessible chart canvases
 * WCAG 2.1 AA: 2.4.7 Focus Visible
 */
canvas[tabindex="0"]:focus {
  outline: 2px solid var(--focus-color, #2563eb);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Respect user preference for reduced motion */
@media (prefers-reduced-motion: no-preference) {
  canvas[tabindex="0"]:focus {
    transition: outline-offset 0.2s ease;
  }
}

/* =============================================================================
   RESPONSIVE DESIGN
   ============================================================================= */

/* Mobile: Scroll horizontal tables */
@media (max-width: 768px) {
  .chart-data-table-visible {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .chart-data-table-visible table {
    min-width: 100%;
  }

  .chart-data-table-visible th,
  .chart-data-table-visible td {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
  }
}

/* =============================================================================
   PRINT STYLES
   ============================================================================= */

/* Include visible tables in print */
@media print {
  .chart-data-table-visible {
    page-break-inside: avoid;
    border: 1px solid #000;
    box-shadow: none;
  }

  .chart-data-table-visible caption {
    background: #f5f5f5;
    border-bottom: 2px solid #000;
  }

  .chart-data-table-visible thead {
    background: #f5f5f5;
    border-bottom: 2px solid #000;
  }

  .chart-data-table-visible tbody tr:hover {
    background: transparent;
  }
}

/* =============================================================================
   HIGH CONTRAST MODE
   ============================================================================= */

/* Windows High Contrast Mode support */
@media (prefers-contrast: high) {
  .chart-data-table-visible {
    border: 2px solid currentColor;
  }

  .chart-data-table-visible th,
  .chart-data-table-visible td {
    border: 1px solid currentColor;
  }

  canvas[tabindex="0"]:focus {
    outline: 3px solid currentColor;
    outline-offset: 3px;
  }
}
