/* ==========================================================================
   LearningByDesign — Polish layer v2 (2026-05-18)
   Aesthetic target: 1980s-imagined future / Tron.

   - Pure neon outlines (wireframe over heavy fills)
   - Sharp geometry, tight radii
   - Layered glow (close + far halo)
   - Subtle grid background texture
   - Letter-spaced display type
   - Animated states (pulse, sweep)

   Loaded AFTER tokens.css. Cyan = ecosystem thread. Red = Learning brand.
   ========================================================================== */

/* ── Tron grid background (subtle, dark mode only) ────────────────────── */
[data-theme="dark"] body::before,
body.theme-dark::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(0, 240, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 240, 255, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  background-position: -1px -1px;
  /* Radial fade so the grid is strongest at the perimeter, like a horizon */
  mask-image: radial-gradient(ellipse at center, transparent 30%, black 100%);
  -webkit-mask-image: radial-gradient(ellipse at center, transparent 30%, black 100%);
}

/* Stack page content above the Tron-grid background. Exclude fixed/sticky
   overlays (help panel, support widget, app strip) so their positioning is
   not clobbered into position:relative in dark mode. */
[data-theme="dark"] body > *:not(.tbdh-panel):not(.tbds-panel):not(.tbds-fab):not(#appSwitcherStrip),
body.theme-dark > *:not(.tbdh-panel):not(.tbds-panel):not(.tbds-fab):not(#appSwitcherStrip) {
  position: relative;
  z-index: 1;
}

/* Light mode: faint warm grid for tonal consistency */
[data-theme="light"] body::before,
body.theme-light::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(8, 145, 178, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(8, 145, 178, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, transparent 40%, black 100%);
  -webkit-mask-image: radial-gradient(ellipse at center, transparent 40%, black 100%);
}

/* ── Tile / card: wireframe + glow ────────────────────────────────────── */
.card,
[data-flow],
.workflow-tile,
.fw-chip,
.kpi-tile,
.tile,
.framework-tile {
  border: 1px solid var(--cyan);
  border-radius: 4px;  /* sharper geometry */
  background: var(--surface);
  position: relative;
  transition: box-shadow var(--speed) var(--ease),
              border-color var(--speed) var(--ease),
              transform var(--speed) var(--ease);
}

/* Light mode borders — muted */
[data-theme="light"] .card,
body.theme-light .card,
[data-theme="light"] [data-flow],
body.theme-light [data-flow],
[data-theme="light"] .workflow-tile,
body.theme-light .workflow-tile,
[data-theme="light"] .kpi-tile,
body.theme-light .kpi-tile,
[data-theme="light"] .fw-chip,
body.theme-light .fw-chip {
  border-color: rgba(8, 145, 178, 0.35);
}

/* Layered glow on hover — close edge + far halo */
.card:hover,
[data-flow]:hover,
.workflow-tile:hover,
.fw-chip:hover,
.kpi-tile:hover,
.tile:hover,
.framework-tile:hover {
  border-color: var(--cyan);
  box-shadow:
    0 0 0 1px var(--cyan),
    0 0 12px var(--cyan-glow),
    0 0 48px rgba(0, 240, 255, 0.18);
  transform: translateY(-2px);
}

/* ── Page-level headings — cyan, letter-spaced display type ───────────── */
h1,
h2,
h3,
h1.font-display,
h2.font-display,
h3.font-display,
.page-title,
.view-title,
.panel-title,
.section-title,
[data-page-title],
[data-view-title] {
  color: var(--cyan);
  letter-spacing: 0.06em;
  font-weight: 700;
  text-shadow: 0 0 12px rgba(0, 240, 255, 0.20);
}

/* Reserve the all-caps treatment for true page titles only (h1 + .font-display
   on h2/h3), so deeply nested headings stay readable. */
h1,
h1.font-display,
h2.font-display.page-title,
.page-title {
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

[data-theme="light"] h1,
[data-theme="light"] h1.font-display,
[data-theme="light"] h2.font-display,
body.theme-light h1,
body.theme-light h1.font-display,
body.theme-light h2.font-display {
  color: var(--cyan-deep);
  text-shadow: none;
}

/* Inline color overrides always win */
h1[style*="color:"],
h2[style*="color:"] {
  color: inherit;
}

/* Headings inside hero/card stay on their card color */
.card h2.font-display:not(.page-title),
.hero h2.font-display {
  color: inherit;
  text-shadow: none;
}

/* ── Eyebrows / labels — Orbitron, tracked-out ───────────────────────── */
.eyebrow,
.section-eyebrow {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* ── Buttons — sharper edge, glow on hover ────────────────────────────── */
.btn,
button.btn {
  border-radius: 4px;
  letter-spacing: 0.04em;
  transition: box-shadow var(--speed) var(--ease),
              transform var(--speed-fast) var(--ease);
}

.btn-primary:hover {
  box-shadow:
    0 0 0 1px var(--brand-primary),
    0 0 16px var(--brand-glow),
    0 0 36px rgba(255, 42, 64, 0.20);
  transform: translateY(-1px);
}

.btn-ghost:hover,
.btn-secondary:hover {
  box-shadow:
    0 0 0 1px var(--cyan),
    0 0 12px var(--cyan-glow);
}

/* ── Topbar actions stay on screen (sticky) ───────────────────────────── */
.app-topbar,
.page-topbar,
.topbar-actions,
[data-topbar],
[data-page-actions] {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Theme toggle / icon buttons sharper */
.icon-btn {
  border-radius: 4px;
  border: 1px solid transparent;
  transition: border-color var(--speed-fast) var(--ease),
              box-shadow var(--speed-fast) var(--ease);
}
.icon-btn:hover {
  border-color: var(--cyan);
  box-shadow: 0 0 8px var(--cyan-glow);
}

/* ── Brand wordmark — red R + cyan ByDesign ───────────────────────────── */
.brand-mark .brand-by,
.app-brand .brand-by,
.brand-wordmark .brand-by {
  color: var(--cyan);
  text-shadow: 0 0 8px var(--cyan-glow);
}

.brand-mark,
.app-brand,
.brand-wordmark {
  font-family: var(--font-head);
  letter-spacing: 0.06em;
}

/* ── Focus ring (cyan, glowing) ──────────────────────────────────────── */
*:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  box-shadow: 0 0 12px var(--cyan-glow);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px var(--cyan), 0 0 12px var(--cyan-glow);
}

/* ── All SVG icons cyan by default (except brand-red badges) ────────── */
svg,
.icon svg,
button svg,
a svg,
.sidebar svg,
.icon-btn svg,
[data-flow] svg,
.workflow-tile svg,
.card svg,
.tile svg {
  color: var(--cyan);
  stroke: var(--cyan);
}

/* Exceptions: items intentionally branded red */
.brand-badge,
.brand-badge svg,
[data-brand-badge],
[data-brand-badge] svg,
.kpi-tile[data-state="overdue"] svg,
.kpi-tile.kpi-danger svg,
.alert-danger svg,
.btn-danger svg {
  color: var(--brand-primary);
  stroke: var(--brand-primary);
}

/* Workflow tile icon container: cyan-edged dark plate */
[data-flow] .card-body > div > span:first-child,
[data-flow] span[style*="border-radius:10px"],
.workflow-tile span[style*="border-radius:10px"] {
  background: rgba(0, 240, 255, 0.08) !important;
  border: 1px solid var(--cyan) !important;
  color: var(--cyan) !important;
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.15);
}

/* ── Sidebar lettering all cyan (text + icons + wordmark) ──────────── */
.sidebar a,
.sidebar [data-nav-item],
.sidebar .nav-item,
.sidebar-item,
.sidebar-item a,
.sidebar-item span,
nav.sidebar a,
nav.sidebar span,
aside a,
aside.sidebar a,
[data-sidebar] a,
[data-sidebar] span {
  color: var(--cyan);
}

.sidebar a svg,
.sidebar [data-nav-item] svg,
.sidebar-item svg,
nav.sidebar svg,
aside.sidebar svg,
[data-sidebar] svg {
  color: var(--cyan);
  stroke: var(--cyan);
}

/* LR badge — red lettering on dark-red plate with red text glow + cyan halo */
.sidebar-brand .brand-mark,
.brand-mark {
  position: relative;
  background: #2a0a10;
  color: var(--brand-primary);
  border: 1px solid var(--brand-primary);
  text-shadow:
    0 0 4px rgba(255, 42, 64, 0.95),
    0 0 10px rgba(255, 42, 64, 0.65),
    0 0 18px rgba(255, 42, 64, 0.35);
  box-shadow:
    0 0 0 1px var(--cyan),
    0 0 8px var(--cyan-glow),
    0 0 24px rgba(0, 240, 255, 0.30),
    inset 0 0 12px rgba(255, 42, 64, 0.28);
  transition: box-shadow var(--speed) var(--ease);
}
.sidebar-brand:hover .brand-mark,
.brand-mark:hover {
  box-shadow:
    0 0 0 1px var(--cyan),
    0 0 14px var(--cyan-glow),
    0 0 40px rgba(0, 240, 255, 0.50);
}

/* Wordmark "LearningByDesign" — cyan letters with red "By" accent.
   Markup (verified live):
     <div class="sidebar-brand">
       <span class="brand-mark">LR</span>            ← stays red (brand badge)
       <span class="brand-text">Learning<span class="accent">By</span>Design</span>
     </div>
   "Learning" + "Design" → cyan
   "By" (.accent) → red (brand color emphasis) */
.sidebar-brand .brand-text,
.brand-text,
.auth-logo {
  color: var(--cyan);
  text-shadow: 0 0 8px var(--cyan-glow);
}

.sidebar-brand .brand-text .accent,
.brand-text .accent,
.auth-logo .accent {
  color: var(--brand-primary);
  text-shadow: 0 0 8px var(--brand-glow);
}

/* ── Active sidebar item — cyan stripe + icon glow ───────────────────── */
.sidebar-item.active,
[data-nav-item].active,
.nav-item.active {
  border-left: 3px solid var(--cyan);
  box-shadow: inset 0 0 32px rgba(0, 240, 255, 0.10);
}

.sidebar-item.active svg,
[data-nav-item].active svg,
.nav-item.active svg {
  filter: drop-shadow(0 0 8px var(--cyan-glow));
}

/* ── Charts: lightcycle outlines + glow.
   Two-rule system:
     1. Bars + lines + outlines: force cyan stroke
     2. Pie/donut paths: keep original stroke (carries data color), add cyan halo */

/* Bars (rect) and outline shapes — cyan stroke */
.chart-svg rect,
.chart-svg circle,
.chart-svg ellipse,
.chart-svg polyline,
.chart-svg polygon,
[data-chart] rect,
[data-chart] circle,
[data-chart] ellipse,
[data-chart] polyline,
[data-chart] polygon,
svg.chart rect,
svg.chart circle,
svg.chart ellipse,
svg.chart polyline,
svg.chart polygon {
  stroke: var(--cyan);
  stroke-width: 2;
  paint-order: stroke fill;
  filter: drop-shadow(0 0 6px var(--cyan-glow))
          drop-shadow(0 0 16px rgba(0, 240, 255, 0.20));
}

/* Generic paths (line charts, etc.) — cyan stroke + glow */
.chart-svg path,
[data-chart] path,
svg.chart path {
  stroke: var(--cyan);
  stroke-width: 2;
  filter: drop-shadow(0 0 6px var(--cyan-glow))
          drop-shadow(0 0 16px rgba(0, 240, 255, 0.20));
}

/* OVERRIDE for pie/donut paths — preserve their original stroke color
   (data meaning), just keep the cyan halo from the filter. The inline
   stroke="..." attribute is lower specificity than CSS, so we have to
   explicitly opt out by clearing the stroke set above. */
.chart-svg.pie path,
.chart-svg.donut path,
[data-chart="pie"] path,
[data-chart="donut"] path {
  stroke: unset;          /* lets the inline stroke="" attribute apply */
  stroke-width: unset;    /* lets inline stroke-width="22" apply */
}

/* Bar charts — the top edge of each bar gets a bright glow line.
   Lightcycle trail effect: brighter than the bar's own cyan stroke. */
.chart-svg line.bar-cap,
[data-chart] line.bar-cap,
svg.chart line.bar-cap {
  stroke: var(--cyan-soft, #66F7FF);
  stroke-width: 3;
  stroke-linecap: round;
  filter:
    drop-shadow(0 0 4px var(--cyan))
    drop-shadow(0 0 10px var(--cyan-glow))
    drop-shadow(0 0 24px rgba(0, 240, 255, 0.45));
}

/* Pie / donut arcs — cyan outline only; slice fills stay as authored
   (different colors per slice carry the data meaning). */
.chart-svg.pie path,
[data-chart="pie"] path,
[data-chart="donut"] path {
  stroke-width: 2.5;
  /* no fill override — slice colors preserved */
}

/* Line charts — no fill, just the glowing line */
.chart-svg.line path,
.chart-svg.line polyline,
[data-chart="line"] path,
[data-chart="line"] polyline {
  fill: none;
  stroke-width: 2.5;
}

/* Chart text labels — white, no glow (Tom: too small for glow to read) */
.chart-svg text,
[data-chart] text,
svg.chart text {
  filter: none;
  stroke: none;
  fill: #FFFFFF;
  font-weight: 500;
}

/* Light mode: keep labels dark for contrast against cream bg */
[data-theme="light"] .chart-svg text,
[data-theme="light"] [data-chart] text,
[data-theme="light"] svg.chart text,
body.theme-light .chart-svg text,
body.theme-light [data-chart] text,
body.theme-light svg.chart text {
  fill: var(--text);
}

/* Grid lines stay subtle (no glow) */
.chart-svg line.axis,
.chart-svg line.gridline,
[data-chart] line.axis,
[data-chart] line.gridline {
  filter: none;
  stroke: rgba(255,255,255,0.10);
}

/* Reference / baseline lines explicitly tagged stay dim */
.chart-svg line:not(.bar):not(.stroke),
[data-chart] line:not(.bar):not(.stroke) {
  filter: none;
}

/* ── Pulse animation on critical alerts (e.g., OVERDUE count) ─────────── */
@keyframes tron-pulse-danger {
  0%, 100% { box-shadow: 0 0 0 1px var(--brand-primary), 0 0 0px transparent; }
  50%      { box-shadow: 0 0 0 1px var(--brand-primary), 0 0 24px var(--brand-glow); }
}
.kpi-tile[data-state="overdue"],
.kpi-tile.kpi-danger {
  border-color: var(--brand-primary);
  animation: tron-pulse-danger 2.8s ease-in-out infinite;
}

/* ── Tag/pill chips: sharp, glowing edge ──────────────────────────────── */
.tag,
.chip,
.badge,
.pill {
  border-radius: 2px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 0.7rem;
  font-weight: 700;
}

.tag.active {
  border: 1px solid var(--cyan);
  background: rgba(0, 240, 255, 0.08);
  color: var(--cyan);
  box-shadow: 0 0 8px var(--cyan-glow);
}

/* ── Scrollbar: thinner, cyan-glow on hover ───────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 0;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan-glow);
}

/* ── Selection — neon cyan ───────────────────────────────────────────── */
::selection {
  background: var(--cyan);
  color: var(--bg);
  text-shadow: 0 0 8px var(--cyan);
}

/* ── Link micro-glow on hover ────────────────────────────────────────── */
a:not(.btn):not(.card):not([data-flow]):hover {
  text-shadow: 0 0 8px var(--cyan-glow);
  color: var(--cyan-soft, var(--cyan));
}

/* ── Stranger Things atmosphere: red ambient halo + scanlines ─────────── */
/* Subtle red glow at the top-left and bottom-right corners (the "Upside
   Down" warm color leaking into the digital grid). Dark mode only. */
[data-theme="dark"] body::after,
body.theme-dark::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 60% 50% at 0% 0%, rgba(255, 42, 64, 0.06), transparent 60%),
    radial-gradient(ellipse 60% 50% at 100% 100%, rgba(255, 42, 64, 0.05), transparent 60%);
}

/* CRT scanline texture (extremely subtle — readable but feels retro) */
[data-theme="dark"] body::before,
body.theme-dark::before {
  background-image:
    /* horizontal scanlines */
    repeating-linear-gradient(
      to bottom,
      transparent 0px,
      transparent 2px,
      rgba(0, 240, 255, 0.012) 3px,
      transparent 4px
    ),
    /* tron grid */
    linear-gradient(rgba(0, 240, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 240, 255, 0.04) 1px, transparent 1px);
  background-size: 100% 4px, 48px 48px, 48px 48px;
}

/* Brand wordmark "ByDesign" — Stranger Things-style chromatic split */
.brand-mark .brand-by,
.app-brand .brand-by,
.brand-wordmark .brand-by {
  text-shadow:
     1px 0 0 rgba(255, 42, 64, 0.50),
    -1px 0 0 rgba(0, 240, 255, 0.50),
     0 0 8px var(--cyan-glow);
}

/* ── Reduced motion: keep static look ────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .kpi-tile[data-state="overdue"],
  .kpi-tile.kpi-danger {
    animation: none;
  }
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
  }
}
