/**
 * Blueprint Reading Guide — Interactive Component
 * Page: /welding/symbols/how-to-read-weld-symbols/
 *
 * Uses Clause5 Molten Trace design tokens (--bg, --text, --arc, etc.) from shared.css.
 * Tab switcher (Anatomy / Joints / Line Types-deferred) + chip→SVG-highlight interaction.
 */

/* ---------- Tab bar ---------- */
.bp-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 32px 0 0;
  border-bottom: 1px solid var(--border-subtle);
}

.bp-tab {
  padding: 12px 20px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: 'Syne', sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
  min-height: 44px;
}

.bp-tab:hover { color: var(--text); }

.bp-tab[aria-selected="true"] {
  color: var(--arc);
  border-bottom-color: var(--arc);
}

.bp-tab[disabled] {
  color: var(--text-dim);
  cursor: not-allowed;
  opacity: 0.6;
}

.bp-tab[disabled]::after {
  content: ' · coming soon';
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 0.7;
}

/* ---------- Tab panels ---------- */
.bp-panel {
  padding: 24px 0;
}

.bp-panel[hidden] { display: none; }

/* ---------- Anatomy tab: SVG diagram ---------- */
.bp-anatomy-svg-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 20px;
  text-align: center;
  overflow-x: auto;
}

.bp-anatomy-svg {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
}

/* Default state — all parts subdued */
.bp-anatomy-svg g[data-anatomy] {
  transition: opacity 0.2s ease, fill 0.2s ease, stroke 0.2s ease;
  opacity: 0.7;
}

.bp-anatomy-svg g[data-anatomy] text,
.bp-anatomy-svg g[data-anatomy] line,
.bp-anatomy-svg g[data-anatomy] path,
.bp-anatomy-svg g[data-anatomy] polygon,
.bp-anatomy-svg g[data-anatomy] circle,
.bp-anatomy-svg g[data-anatomy] rect {
  /* Bright warm off-white (--text = #F0EDE8) so the symbol reads cleanly against void black */
  stroke: var(--text);
  fill: var(--text);
  transition: stroke 0.2s ease, fill 0.2s ease;
}

/* Highlighted state — chip clicked */
.bp-anatomy-svg g[data-anatomy].highlighted {
  opacity: 1;
  animation: bpHighlightPulse 280ms ease-out;
  transform-origin: center;
}

@keyframes bpHighlightPulse {
  0%   { filter: drop-shadow(0 0 0 var(--arc-glow)); }
  45%  { filter: drop-shadow(0 0 10px var(--arc-hot)); }
  100% { filter: drop-shadow(0 0 4px var(--arc-glow)); }
}

.bp-anatomy-svg g[data-anatomy].highlighted text,
.bp-anatomy-svg g[data-anatomy].highlighted line,
.bp-anatomy-svg g[data-anatomy].highlighted path,
.bp-anatomy-svg g[data-anatomy].highlighted polygon,
.bp-anatomy-svg g[data-anatomy].highlighted circle,
.bp-anatomy-svg g[data-anatomy].highlighted rect {
  stroke: var(--arc);
  fill: var(--arc);
  filter: drop-shadow(0 0 4px var(--arc-glow));
}

/* SVG text labels — slightly muted but still legible against void black.
   Font-size kept at 12px minimum per project CSS consistency rule (WCAG/zoom). */
.bp-anatomy-svg .bp-svg-label {
  fill: var(--text-muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  font-weight: 400;
  opacity: 1;
}

/* ---------- Anatomy tab: chip row ---------- */
.bp-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  justify-content: center;
}

.bp-chip {
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
  min-height: 36px;
}

.bp-chip:hover {
  border-color: var(--arc);
  color: var(--text);
}

.bp-chip[aria-pressed="true"] {
  background: var(--arc);
  border-color: var(--arc);
  color: #08080A;
}

.bp-chip--clear {
  font-style: italic;
  opacity: 0.7;
}

/* ---------- Anatomy tab: explainer panel ---------- */
.bp-explainer {
  background: var(--surface-deep);
  border: 1px solid var(--border);
  border-left: 3px solid var(--arc);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 20px;
  min-height: 80px;
}

.bp-explainer__label {
  font-family: 'Syne', sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--arc);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.bp-explainer__title {
  font-family: 'Syne', sans-serif;
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 8px;
}

.bp-explainer__text {
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.bp-explainer__ref {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  color: var(--arc);
  letter-spacing: 0.04em;
}

.bp-explainer__example {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
}

.bp-explainer--empty .bp-explainer__text {
  color: var(--text-dim);
  font-style: italic;
}

/* ---------- Anatomy tab: Quick Reference table ---------- */
.bp-quickref {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-top: 24px;
}

.bp-quickref__label {
  font-family: 'Syne', sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--arc);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.bp-quickref__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.bp-quickref__table th,
.bp-quickref__table td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.bp-quickref__table th {
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  color: var(--text-dim);
  font-size: 0.82rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.bp-quickref__table tr:last-child td { border-bottom: none; }

/* ---------- Joints tab: card grid ---------- */
.bp-joints-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 8px;
}

.bp-joint-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.bp-joint-card:hover {
  border-color: var(--arc);
  box-shadow: 0 0 16px var(--arc-glow-subtle);
}

.bp-joint-card__svg {
  width: 100%;
  height: 80px;
  margin-bottom: 12px;
  display: block;
}

.bp-joint-card__svg path,
.bp-joint-card__svg line,
.bp-joint-card__svg rect {
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 1.5;
  transition: stroke 0.2s ease;
}

.bp-joint-card:hover .bp-joint-card__svg path,
.bp-joint-card:hover .bp-joint-card__svg line,
.bp-joint-card:hover .bp-joint-card__svg rect {
  stroke: var(--arc);
}

.bp-joint-card__title {
  font-family: 'Syne', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.bp-joint-card__def {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 8px;
}

.bp-joint-card__ref {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  color: var(--arc);
  letter-spacing: 0.04em;
}

.bp-joints-callout {
  background: rgba(255,182,39,0.06);
  border: 1px solid rgba(255,182,39,0.2);
  border-radius: 8px;
  padding: 16px 20px;
  margin-top: 20px;
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.bp-joints-callout strong { color: var(--arc); }

/* ---------- Lines tab: card grid (now grouped — outer is a vertical stack of groups) ---------- */
.bp-lines-grid {
  display: block;
  margin-top: 8px;
}

.bp-lines-group__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.bp-line-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  transition: border-color 0.2s ease;
}

.bp-line-card:hover { border-color: var(--arc); }

.bp-line-card__visual {
  background: var(--surface-deep);
  border-radius: 4px;
  padding: 10px 4px;
  margin-bottom: 10px;
  /* Bright warm off-white so the line samples read clearly against the dark inset */
  color: var(--text);
}

/* ---------- Lines tab: group dividers ---------- */
.bp-lines-group {
  margin-top: 24px;
}

.bp-lines-group:first-of-type {
  margin-top: 8px;
}

.bp-lines-group__heading {
  font-family: 'Syne', sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--arc);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
}

.bp-lines-group__caption {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 12px;
  font-style: italic;
}

/* ---------- Anatomy chip explainer: learn-more link ---------- */
.bp-explainer__learn-more {
  display: inline-block;
  margin-top: 10px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.82rem;
  color: var(--arc);
  text-decoration: none;
  border-bottom: 1px solid var(--arc);
  padding-bottom: 1px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.bp-explainer__learn-more:hover {
  color: var(--arc-hot);
  border-bottom-color: var(--arc-hot);
}

.bp-line-svg {
  display: block;
  width: 100%;
  height: 24px;
}

.bp-line-card__title {
  font-family: 'Syne', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.bp-line-card__def {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 8px;
}

.bp-line-card__spec {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.bp-line-card__ref {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  color: var(--arc);
  letter-spacing: 0.03em;
}

/* ---------- Deferred placeholder (legacy — kept for any future deferred tabs) ---------- */
.bp-deferred {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 40px 24px;
  text-align: center;
}

.bp-deferred__title {
  font-family: 'Syne', sans-serif;
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 12px;
}

.bp-deferred__text {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 480px;
  margin: 0 auto;
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  .bp-tabs { gap: 0; }
  .bp-tab { padding: 10px 12px; font-size: 0.85rem; }
  .bp-chip-row { gap: 6px; }
  .bp-chip { padding: 6px 10px; font-size: 0.78rem; }
  .bp-joints-grid { grid-template-columns: 1fr; }
  .bp-anatomy-svg-wrap { padding: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .bp-anatomy-svg g[data-anatomy],
  .bp-chip,
  .bp-tab,
  .bp-joint-card { transition: none; }
}

@media print {
  .bp-tabs, .bp-chip-row { display: none; }
  .bp-panel { display: block !important; padding: 8px 0; }
}
