/* Zoe Swellmark Behavioral Tomography & Draughts Arena - Zero-CDN WCAG AA/AAA Stylesheet */

html[data-theme="dark"],
body.ta-body[data-theme="nocturnal"] {
  --bg-canvas: #0D1017;
  --bg-surface: #151A24;
  --bg-elevated: #1C2331;
  --bg-nested: #131822;
  --border-subtle: #2A3346;
  --ta-border-strong: #465574;
  --text-primary: #F2F4F8;
  --text-muted: #B6C0D4;
  --accent-primary: #7AD3F0;
  --accent-secondary: #E6A85C;
  --accent-tertiary: #8BE0A4;
  --accent-quaternary: #C3A6FF;
  --accent-danger: #F28B82;
  --accent-contrast-text: #0D1017;
  --svg-grid: #273042;
  --svg-axis: #5E6E8E;
  --board-light: #353E52;
  --board-dark: #181E2B;
  --piece-a: #D9534F;
  --piece-b: #EDE6D6;
}

html[data-theme="light"],
body.ta-body[data-theme="vellum"] {
  --bg-canvas: #F6F2E9;
  --bg-surface: #FFFDF8;
  --bg-elevated: #EFE9DC;
  --bg-nested: #F8F4EC;
  --border-subtle: #D5CCB9;
  --ta-border-strong: #8F8472;
  --text-primary: #1B1E24;
  --text-muted: #4A5160;
  --accent-primary: #0F5C78;
  --accent-secondary: #8C4A08;
  --accent-tertiary: #1B6B3A;
  --accent-quaternary: #5B3D99;
  --accent-danger: #9B2226;
  --accent-contrast-text: #FFFDF8;
  --svg-grid: #DDD4C4;
  --svg-axis: #6D6455;
  --board-light: #E8DEC8;
  --board-dark: #6E5D47;
  --piece-a: #9B2226;
  --piece-b: #FFFDF8;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body.ta-body {
  margin: 0;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}

body.ta-body:not(.ns-split-ready) {
  padding: 0;
}

body.ta-body.ns-split-ready {
  padding-top: 56px;
}

/* Commercial IP Lock Banner */
.ta-shell .zs-licensing-band {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px 20px;
  padding: 16px 20px;
  border-radius: 12px;
  border: 1px solid var(--ta-border-strong);
  background-color: var(--bg-surface);
  color: var(--text-primary);
}

.ta-shell .zs-licensing-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.ta-shell .zs-licensing-copy p {
  margin: 0;
  max-width: 65ch;
  line-height: 1.6;
  color: var(--text-primary);
}

.ta-shell .zs-licensing-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.ta-shell .zs-licensing-actions .zs-btn {
  min-height: 44px;
}

/* Strict 4-level type hierarchy inside .ta-shell */
.ta-shell h1,
.ta-shell h2,
.ta-shell h3,
.ta-shell p,
.ta-shell ul {
  margin-top: 0;
}

.ta-shell h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.25rem;
  line-height: 1.25;
  letter-spacing: -0.015em;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.ta-shell h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  line-height: 1.35;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.ta-shell h3,
.ta-shell .card-heading {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.ta-shell code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.875rem;
  background-color: var(--bg-elevated);
  color: var(--text-primary);
  padding: 2px 5px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ta-shell .prose-lead,
.ta-shell .prose-body,
.ta-shell .prose-muted {
  max-width: 65ch;
  line-height: 1.6;
}

.ta-shell .prose-muted {
  color: var(--text-muted);
  font-size: 0.9375rem;
  margin-bottom: 8px;
}

.ta-shell .hidden-block {
  display: none;
}

/* Gestalt Proximity: outer section gap (32px) > inner grid gap (14px) */
.page-shell.ta-shell {
  max-width: 1340px;
  margin: 0 auto;
  padding: 28px 20px 48px;
  overflow-x: clip;
}

.ta-shell .main-stack {
  display: flex;
  flex-direction: column;
  gap: 32px;
  min-width: 0;
}

.ta-shell .surface-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  max-width: 100%;
}

.ta-shell .section-header > div,
.ta-shell .subpanel-top > div,
.ta-shell .hero-grid > *,
.ta-shell .two-col-grid > *,
.ta-shell .kpi-four-grid > *,
.ta-shell .kpi-six-grid > *,
.ta-shell .kpi-mini-grid > *,
.ta-shell .resonance-inputs-grid > *,
.ta-shell .constitutional-grid > *,
.ta-shell .council-strip > * {
  min-width: 0;
}

.ta-shell .hero-top-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.ta-shell .brand-tag,
.ta-shell .badge-group,
.ta-shell .legend-row,
.ta-shell .pair-selectors,
.ta-shell .control-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.ta-shell .badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  max-width: 100%;
  overflow-wrap: anywhere;
}

.ta-shell .badge-accent {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.ta-shell .badge-warn {
  border-color: var(--accent-secondary);
  color: var(--accent-secondary);
}

.ta-shell .badge-good {
  border-color: var(--accent-tertiary);
  color: var(--accent-tertiary);
}

.ta-shell .badge-danger {
  border-color: var(--accent-danger);
  color: var(--accent-danger);
}

.ta-shell .hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.ta-shell .equation-strip {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.875rem;
  color: var(--accent-primary);
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 10px 14px;
  overflow-x: auto;
  margin-bottom: 0;
}

.ta-shell .control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.ta-shell .control-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Fitts's Law: interactive targets >= 44px x 44px */
.ta-shell .control-btn,
.ta-shell .control-select,
.ta-shell .control-input {
  min-height: 44px;
  min-width: 44px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--ta-border-strong);
  background-color: var(--bg-elevated);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
}

.ta-shell .control-btn,
.ta-shell .control-select {
  cursor: pointer;
}

.ta-shell .control-input {
  font-weight: 500;
  width: 100%;
}

.ta-shell .control-btn:hover,
.ta-shell .control-select:hover,
.ta-shell .control-input:hover {
  border-color: var(--accent-primary);
}

.ta-shell .control-btn:focus-visible,
.ta-shell .control-select:focus-visible,
.ta-shell .control-input:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
}

.ta-shell .control-btn[aria-pressed="true"],
.ta-shell .control-btn[data-active="true"] {
  background-color: var(--accent-primary);
  color: var(--accent-contrast-text);
  border-color: var(--accent-primary);
}

.ta-shell .primary-cta {
  background-color: var(--accent-primary);
  color: var(--accent-contrast-text);
  border-color: var(--accent-primary);
}

.ta-shell .button-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ta-shell .select-wrap {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}

.ta-shell .control-select {
  max-width: 100%;
}

.ta-shell .field-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ta-shell .field-action {
  justify-content: flex-end;
}

/* Grids */
.ta-shell .kpi-six-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 14px;
}

.ta-shell .kpi-four-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}

.ta-shell .kpi-mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.ta-shell .two-col-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.ta-shell .subpanel {
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ta-shell .subpanel-nested {
  background-color: var(--bg-nested);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ta-shell .kpi-card {
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 14px;
}

.ta-shell .kpi-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  display: block;
}

.ta-shell .kpi-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  display: block;
  margin: 4px 0;
}

.ta-shell .kpi-sub {
  font-size: 0.875rem;
  color: var(--text-muted);
  display: block;
}

.ta-shell .section-header,
.ta-shell .subpanel-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.ta-shell .bio-controls-bar,
.ta-shell .draughts-controls-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.ta-shell .bio-trend-box {
  background-color: var(--bg-nested);
  border-left: 3px solid var(--accent-primary);
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 0;
}

.ta-shell .resonance-inputs-grid {
  display: grid;
  grid-template-columns: 2.2fr 0.8fr 0.8fr 0.8fr auto;
  gap: 12px;
  align-items: end;
}

/* SVG Frames & Primitives */
.ta-shell .svg-frame {
  width: 100%;
  overflow-x: auto;
}

.ta-shell .svg-frame svg {
  width: 100%;
  height: auto;
  display: block;
}

.ta-shell .draughts-board-wrap svg {
  max-width: 440px;
  margin: 0 auto;
}

.ta-shell .svg-grid-line {
  stroke: var(--svg-grid);
  stroke-width: 1;
}

.ta-shell .svg-axis-line {
  stroke: var(--svg-axis);
  stroke-width: 1.25;
}

.ta-shell .svg-ref-line {
  stroke: var(--accent-secondary);
  stroke-width: 1.2;
  stroke-dasharray: 4 4;
}

.ta-shell .svg-label {
  fill: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
}

.ta-shell .svg-label-strong {
  fill: var(--text-primary);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 12px;
  font-weight: 600;
}

.ta-shell .svg-line-0 { stroke: var(--accent-primary); stroke-width: 2.4; fill: none; }
.ta-shell .svg-line-1 { stroke: var(--accent-secondary); stroke-width: 2.4; fill: none; }
.ta-shell .svg-line-2 { stroke: var(--accent-tertiary); stroke-width: 2.4; fill: none; }
.ta-shell .svg-line-3 { stroke: var(--accent-quaternary); stroke-width: 2.4; fill: none; }
.ta-shell .svg-line-4 { stroke: var(--accent-danger); stroke-width: 2.2; fill: none; }
.ta-shell .svg-line-5 { stroke: var(--text-primary); stroke-width: 2.0; stroke-dasharray: 5 3; fill: none; }

.ta-shell .svg-dot-0 { fill: var(--accent-primary); }
.ta-shell .svg-dot-1 { fill: var(--accent-secondary); }
.ta-shell .svg-dot-2 { fill: var(--accent-tertiary); }
.ta-shell .svg-dot-3 { fill: var(--accent-quaternary); }
.ta-shell .svg-dot-4 { fill: var(--accent-danger); }
.ta-shell .svg-dot-5 { fill: var(--text-primary); }

.ta-shell .svg-radar-poly-0 {
  fill: var(--accent-primary);
  fill-opacity: 0.22;
  stroke: var(--accent-primary);
  stroke-width: 2.2;
}

.ta-shell .svg-radar-poly-1 {
  fill: var(--accent-secondary);
  fill-opacity: 0.20;
  stroke: var(--accent-secondary);
  stroke-width: 2.2;
}

.ta-shell .svg-box-whisker {
  stroke: var(--text-primary);
  stroke-width: 1.6;
}

.ta-shell .svg-box-rect {
  fill: var(--accent-primary);
  fill-opacity: 0.28;
  stroke: var(--accent-primary);
  stroke-width: 2;
}

.ta-shell .svg-box-median {
  stroke: var(--accent-secondary);
  stroke-width: 2.6;
}

/* Draughts Board SVG Classes */
.ta-shell .svg-sq-light {
  fill: var(--board-light);
}

.ta-shell .svg-sq-dark {
  fill: var(--board-dark);
  cursor: pointer;
}

.ta-shell .svg-sq-selected {
  fill: var(--board-dark);
  stroke: var(--accent-primary);
  stroke-width: 3;
}

.ta-shell .svg-sq-target {
  fill: var(--board-dark);
  stroke: var(--accent-tertiary);
  stroke-width: 3;
}

.ta-shell .svg-piece-a {
  fill: var(--piece-a);
  stroke: #1B1E24;
  stroke-width: 2;
  cursor: pointer;
}

.ta-shell .svg-piece-b {
  fill: var(--piece-b);
  stroke: #1B1E24;
  stroke-width: 2;
  cursor: pointer;
}

.ta-shell .svg-piece-king-ring {
  fill: none;
  stroke: var(--accent-secondary);
  stroke-width: 2.5;
  pointer-events: none;
}

.ta-shell .svg-target-dot {
  fill: var(--accent-tertiary);
  fill-opacity: 0.85;
  pointer-events: none;
}

.ta-shell .svg-const-edge {
  stroke: var(--ta-border-strong);
  stroke-width: 1.5;
  opacity: 0.85;
}

.ta-shell .svg-hex-cell {
  fill: var(--bg-surface);
  stroke: var(--ta-border-strong);
  stroke-width: 2;
}

.ta-shell .svg-hex-center {
  fill: var(--bg-surface);
  stroke: var(--accent-primary);
  stroke-width: 2.6;
}

.ta-shell .legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--text-primary);
  padding: 4px 10px;
  border-radius: 6px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
}

.ta-shell .legend-swatch {
  width: 14px;
  height: 4px;
  border-radius: 2px;
  display: inline-block;
}

.ta-shell .legend-swatch-0 { background-color: var(--accent-primary); }
.ta-shell .legend-swatch-1 { background-color: var(--accent-secondary); }
.ta-shell .legend-swatch-2 { background-color: var(--accent-tertiary); }
.ta-shell .legend-swatch-3 { background-color: var(--accent-quaternary); }
.ta-shell .legend-swatch-4 { background-color: var(--accent-danger); }
.ta-shell .legend-swatch-5 { background-color: var(--text-primary); }

/* Tables & Diagnostic Lists */
.ta-shell .table-scroll {
  width: 100%;
  overflow-x: auto;
}

.ta-shell .data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.ta-shell .data-table th,
.ta-shell .data-table td {
  padding: 9px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.ta-shell .data-table th {
  color: var(--text-muted);
  font-weight: 600;
  background-color: var(--bg-surface);
}

.ta-shell .data-table td.num {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.ta-shell .data-table td.wrap-cell {
  white-space: normal;
  min-width: 180px;
}

.ta-shell .delta-pos {
  color: var(--accent-tertiary);
  font-weight: 600;
}

.ta-shell .delta-neg {
  color: var(--accent-danger);
  font-weight: 600;
}

.ta-shell .diagnostic-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ta-shell .diagnostic-item {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.875rem;
}

/* Constitutional & Council Scope */
.ta-shell .constitutional-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.ta-shell .flag-pill {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-radius: 8px;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.875rem;
}

.ta-shell .council-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.ta-shell .council-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px;
  font-size: 0.875rem;
}

.ta-shell .equations-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (max-width: 960px) {
  .ta-shell .hero-grid,
  .ta-shell .two-col-grid,
  .ta-shell .resonance-inputs-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 520px) {
  .page-shell.ta-shell {
    padding: 16px 12px 32px;
  }

  .ta-shell .surface-card {
    padding: 16px;
  }
}
