/* ============================================================
   DiagMyPCHub — "I keep getting a blue screen" hub
   Local styles only. All rules use the shared design tokens.
   Scope prefix: bsd- (blue screen of death)
   ============================================================ */

/* ---------- Reading progress ---------- */
.bsd-progress {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 3px;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
  transform: scaleX(0);
  transform-origin: left;
  z-index: 120;
  pointer-events: none;
}

/* ---------- Layout ---------- */
.bsd-grid {
  display: grid;
  gap: 40px;
  padding: clamp(24px, 4vw, 44px) 0 clamp(56px, 8vw, 88px);
}
.bsd-main { min-width: 0; }

/* TOC */
.bsd-toc { display: none; }
@media (min-width: 1000px) {
  .bsd-grid { grid-template-columns: 220px 1fr; }
  .bsd-toc {
    display: block;
    position: sticky;
    top: calc(var(--header-h) + 24px);
    align-self: start;
    max-height: calc(100vh - var(--header-h) - 48px);
    overflow-y: auto;
    padding: 4px 0;
  }
}
.bsd-toc-title {
  font: 500 0.7rem var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-3);
  margin: 0 0 10px;
}
.bsd-toc-list { display: grid; gap: 2px; }
.bsd-toc-list a {
  display: block;
  font-size: 0.8rem;
  color: var(--ink-2);
  text-decoration: none;
  padding: 5px 10px;
  border-left: 2px solid transparent;
  border-radius: 0 6px 6px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.bsd-toc-list a:hover { color: var(--ink); background: var(--tint); }
.bsd-toc-list a.is-active { color: var(--blue-deep); border-left-color: var(--blue); background: var(--tint); font-weight: 500; }

/* ---------- Head ---------- */
.bsd-head { margin-bottom: 22px; }
.bsd-head h1 { font-size: clamp(1.8rem, 1.1rem + 2.6vw, 2.6rem); font-weight: 700; letter-spacing: -0.02em; margin: 0 0 10px; }
.bsd-sub { font: 500 0.76rem var(--font-mono); letter-spacing: 0.06em; color: var(--ink-3); margin: 0; }
.bsd-main > .lead, .bsd-sec > p:first-of-type { color: var(--ink-2); }
.bsd-note { font-size: 0.85rem; color: var(--ink-2); }

/* ---------- Sections ---------- */
.bsd-sec { margin-top: clamp(40px, 6vw, 56px); }
.bsd-sec h2 { font-size: clamp(1.35rem, 1.05rem + 1.3vw, 1.7rem); font-weight: 600; letter-spacing: -0.01em; margin: 0 0 14px; }
.bsd-sec h2 .sec-kicker, .bsd-cat-title { margin-bottom: 8px; }

/* ---------- Image placeholder ----------
   Hidden by default. JS sets data-bsd-figure="visible" when
   the img has a data-src and it loads successfully. */
.bsd-figure { margin: 26px 0; }
.bsd-figure-img {
  display: none;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}
.bsd-figure[data-bsd-figure="visible"] .bsd-figure-img { display: block; }
.bsd-figure figcaption { font-size: 0.82rem; color: var(--ink-3); margin-top: 10px; }

/* ---------- Start-here steps ---------- */
.bsd-steps { list-style: none; counter-reset: bsdstep; display: grid; gap: 10px; }
.bsd-steps li {
  counter-increment: bsdstep;
  position: relative;
  padding: 14px 16px 14px 58px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.94rem;
  color: var(--ink-2);
}
.bsd-steps li::before {
  content: counter(bsdstep, decimal-leading-zero);
  position: absolute;
  left: 16px; top: 13px;
  font: 600 0.82rem var(--font-mono);
  color: var(--blue);
}
.bsd-steps a { color: var(--blue); text-decoration: underline; }

/* ---------- Filter bar ---------- */
.bsd-filterbar { display: grid; gap: 12px; margin: 18px 0 8px; }
@media (min-width: 720px) { .bsd-filterbar { grid-template-columns: 1fr auto; align-items: start; } }
.bsd-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.bsd-chip {
  font: 500 0.78rem var(--font-mono);

  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.bsd-chip:hover { border-color: var(--blue); color: var(--blue); }
.bsd-chip[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: #fff; }
/* jump-chip variant (stop codes) */
.bsd-cat .bsd-chips { margin: 0 0 6px; }
.bsd-cat .bsd-chips a { font-size: 0.72rem; padding: 6px 12px; }
.bsd-search { display: flex; align-items: center; background: var(--surface); border: 1.5px solid var(--line-2); border-radius: 10px; padding: 8px 14px; transition: border-color 0.2s, box-shadow 0.2s; }
.bsd-search:focus-within { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(15, 91, 215, 0.12); }
.bsd-search input { flex: 1; min-width: 180px; border: 0; background: transparent; font: 400 0.92rem var(--font-body); color: var(--ink); outline: none; }
.bsd-search input::placeholder { color: var(--ink-3); }
.bsd-filter-count { font: 500 0.74rem var(--font-mono); color: var(--ink-3); margin: 10px 0 4px; }
.bsd-nomatch { font-size: 0.9rem; color: var(--warn); margin: 10px 0; }
.bsd-hidden { display: none !important; }

/* ---------- Cards ---------- */
.bsd-card-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 14px; }
@media (min-width: 560px) { .bsd-card-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .bsd-card-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1240px) { .bsd-card-grid { grid-template-columns: repeat(4, 1fr); } }
.bsd-card {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}
.bsd-card:hover, .bsd-card:focus-visible { border-color: var(--blue); transform: translateY(-3px); box-shadow: var(--shadow-1); }
.bsd-card-cat { font: 500 0.64rem var(--font-mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); }
.bsd-card-title { font: 600 0.95rem/1.35 var(--font-display); }

/* Difficulty badges (label + colour, never colour alone) */
.bsd-diff {
  font: 500 0.66rem var(--font-mono);
  border-radius: 999px;
  padding: 3px 9px;
  align-self: flex-start;
}
.bsd-diff-b { color: #0c7a55; background: #e2f5ec; border: 1px solid #b5e3cf; }
.bsd-diff-i { color: #8a5a12; background: #fbf0da; border: 1px solid #ecd3a4; }
.bsd-diff-a { color: #a33a2e; background: #fbe7e3; border: 1px solid #eebdb4; }

/* ---------- Category sections & articles ---------- */
.bsd-cat { margin-top: clamp(44px, 6vw, 60px); }
.bsd-cat-title { font-size: clamp(1.35rem, 1.05rem + 1.3vw, 1.7rem); font-weight: 600; letter-spacing: -0.01em; margin: 0 0 8px; }
.bsd-cat-intro { color: var(--ink-2); max-width: 70ch; margin: 0 0 18px; }

.bsd-article {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 12px;
  transition: border-color 0.2s;
}
.bsd-article[open] { border-color: var(--blue-soft); }
.bsd-a-sum {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  cursor: pointer;
  list-style: none;
}
.bsd-a-sum::-webkit-details-marker { display: none; }
.bsd-a-num { flex: none; font: 600 0.74rem var(--font-mono); color: var(--ink-3); width: 30px; }
.bsd-a-sum-title { font: 600 1rem var(--font-display); color: var(--ink); }
.bsd-article[open] .bsd-a-sum-title { display: none; }
.bsd-a-ico { margin-left: auto; position: relative; width: 16px; height: 16px; flex: none; }
.bsd-a-ico::before, .bsd-a-ico::after {
  content: "";
  position: absolute;
  left: 0; top: 7px;
  width: 16px; height: 2px;
  background: var(--ink-3);
  transition: transform 0.25s, background 0.25s;
}
.bsd-a-ico::after { transform: rotate(90deg); }
.bsd-article[open] .bsd-a-ico::after { transform: rotate(0deg); }
.bsd-article[open] .bsd-a-ico::before, .bsd-article[open] .bsd-a-ico::after { background: var(--blue); }

.bsd-a-body { padding: 0 18px 20px; }
.bsd-a-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.bsd-a-time { font: 500 0.72rem var(--font-mono); color: var(--ink-3); }
.bsd-a-body h3 { font-size: 1.12rem; font-weight: 600; margin: 0 0 10px; }
.bsd-a-body p { color: var(--ink-2); font-size: 0.95rem; }
.bsd-a-body p strong, .bsd-a-body li strong { color: var(--ink); }
.bsd-a-body code, .bsd-sec code {
  font: 500 0.85em var(--font-mono);
  background: var(--tint);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
  word-break: break-word;
}
.bsd-a-body ul, .bsd-a-body ol { padding-left: 20px; margin: 0 0 1em; color: var(--ink-2); font-size: 0.95rem; }
.bsd-a-body li { margin-bottom: 4px; }
.bsd-a-body a { color: var(--blue); text-decoration: underline; }

/* prev/next (injected) */
.bsd-article-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line-2);
}
.bsd-article-nav a { font-size: 0.82rem; color: var(--blue); text-decoration: underline; }

/* ---------- Code blocks ---------- */
.bsd-code { background: var(--dark-2); border: 1px solid var(--dark-line); border-radius: 10px; margin: 12px 0 14px; overflow: hidden; }
.bsd-code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  border-bottom: 1px solid var(--dark-line);
  font: 500 0.68rem var(--font-mono);
  color: var(--dark-muted);
}
.bsd-copy {
  font: 500 0.7rem var(--font-mono);
  color: var(--dark-ink);
  background: none;
  border: 1px solid var(--dark-line);
  border-radius: 6px;
  padding: 3px 10px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.bsd-copy:hover { border-color: var(--cyan-bright); color: var(--cyan-bright); }
.bsd-code pre { margin: 0; padding: 14px; overflow-x: auto; }
.bsd-code code { font: 400 0.85rem/1.6 var(--font-mono); color: var(--cyan-bright); background: none; border: 0; padding: 0; white-space: pre; }

/* callout variants (shared base .callout in ../../css/style.css) */
.callout-warn { background: #fdf4e3; border-color: #e8cd9a; }
.callout-warn .callout-ico { background: #c07f1a; }
.callout-tip { background: #e8f6f0; border-color: #b5e0cd; }
.callout-tip .callout-ico { background: #1c8f66; }

/* ---------- SVG diagram ---------- */
.bsd-pf-figure { margin: 0; }
.bsd-svg {
  width: 100%;
  height: auto;
  display: block;
  background: var(--dark-2);
  border: 1px solid var(--dark-line);
  border-radius: var(--radius);
}
.bsd-pf-caption { font-size: 0.82rem; color: var(--ink-3); margin-top: 10px; }

.bsd-gridline { stroke: #12263f; stroke-width: 1; }
.bsd-glow { animation: bsd-glow 7s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }
@keyframes bsd-glow { from { opacity: 0.6; } to { opacity: 1; transform: scale(1.04); } }
.bsd-trace { stroke: #24466f; stroke-width: 2; fill: none; }
.bsd-trace-crash { stroke: #7f3a3a; }
.bsd-flow {
  stroke: #41e2f5; stroke-width: 2.4; fill: none;
  stroke-linecap: round;
  stroke-dasharray: 18 300;
  opacity: 0.85;
  animation: bsd-flow 3.4s linear infinite;
}
.bsd-f2 { animation-duration: 2.8s; animation-delay: 0.5s; }
.bsd-f3 { animation-duration: 3.1s; animation-delay: 1.2s; }
.bsd-f4 { animation-duration: 3.8s; animation-delay: 0.8s; }
.bsd-f5 { animation-duration: 3s; animation-delay: 1.6s; }
.bsd-flow-crash { stroke: #f87171; stroke-width: 2.6; stroke-dasharray: 14 304; animation-duration: 2.4s; }
@keyframes bsd-flow { to { stroke-dashoffset: -318; } }
.bsd-node rect { fill: #0e2038; stroke: #2e5f93; stroke-width: 1.5; }
.bsd-node-crash rect { fill: #2a1416; stroke: #a05252; }
.bsd-nlabel { fill: #dbe7f7; font: 600 14px var(--font-mono); letter-spacing: 1.5px; }
.bsd-node-crash .bsd-nlabel { fill: #fca5a5; }

.bsd-nsub { fill: #8aa3c4; font: 400 10px var(--font-mono); }
.bsd-pins { stroke: #2e5f93; stroke-width: 6; stroke-dasharray: 5 9; }
.bsd-chip { fill: #0e2038; stroke: #2e5f93; stroke-width: 2; }
.bsd-die { fill: #122a48; stroke: #1e3a5f; }
.bsd-core { fill: #41e2f5; animation: bsd-core 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes bsd-core { 50% { transform: scale(1.4); opacity: 0.7; } }
.bsd-chiplabel { fill: #7f95b5; font: 600 12px var(--font-mono); letter-spacing: 3px; }

/* ---------- Checklist ---------- */
.bsd-checklist { list-style: none; display: grid; gap: 8px; margin: 16px 0; }
.bsd-checklist label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.92rem;
  color: var(--ink-2);
  transition: background 0.15s, border-color 0.15s;
}
.bsd-checklist label:hover { background: var(--tint); }
.bsd-check { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--blue); flex: none; cursor: pointer; }
.bsd-check-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.bsd-check-progress { font: 500 0.74rem var(--font-mono); color: var(--ink-3); margin-right: auto; }

/* ---------- FAQ ---------- */
.bsd-faq-list { display: grid; gap: 10px; }
.bsd-faq-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); transition: border-color 0.2s; }
.bsd-faq-item[open] { border-color: var(--blue-soft); }
.bsd-faq-q {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  cursor: pointer;
  list-style: none;
  font: 600 0.98rem var(--font-body);
  color: var(--ink);
}
.bsd-faq-q::-webkit-details-marker { display: none; }
.bsd-faq-ico { margin-left: auto; position: relative; width: 16px; height: 16px; flex: none; }
.bsd-faq-ico::before, .bsd-faq-ico::after {
  content: "";
  position: absolute;
  left: 0; top: 7px;
  width: 16px; height: 2px;
  background: var(--ink-3);
  transition: transform 0.25s, background 0.25s;
}
.bsd-faq-ico::after { transform: rotate(90deg); }
.bsd-faq-item[open] .bsd-faq-ico::after { transform: rotate(0deg); }
.bsd-faq-item[open] .bsd-faq-ico::before, .bsd-faq-item[open] .bsd-faq-ico::after { background: var(--blue); }
.bsd-faq-a { padding: 0 18px 16px; }
.bsd-faq-a p { margin: 0; color: var(--ink-2); font-size: 0.93rem; }

/* ---------- Related ---------- */
.bsd-related-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 620px) { .bsd-related-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .bsd-related-grid { grid-template-columns: repeat(3, 1fr); } }
.bsd-related-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}
.bsd-related-card:hover, .bsd-related-card:focus-visible { border-color: var(--blue); transform: translateY(-3px); box-shadow: var(--shadow-1); }
.bsd-related-card h3 { font-size: 1rem; font-weight: 600; margin: 0; }
.bsd-related-card p { font-size: 0.85rem; color: var(--ink-2); margin: 0; }

/* ---------- Dark theme contrast (local components only) ---------- */
[data-theme="dark"] .bsd-diff-b { color: #5fd9a7; background: #0f2b20; border-color: #1f4a37; }
[data-theme="dark"] .bsd-diff-i { color: #eec27a; background: #2b2210; border-color: #4a3a1c; }
[data-theme="dark"] .bsd-diff-a { color: #f0938a; background: #2b1512; border-color: #4a241f; }
[data-theme="dark"] .callout-warn { background: #2b2210; border-color: #4a3a1c; }
[data-theme="dark"] .callout-tip { background: #0f2b20; border-color: #1f4a37; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .bsd-flow, .bsd-flow-crash { animation: none; stroke-dasharray: none; opacity: 0.3; }
  .bsd-core, .bsd-glow { animation: none; }
  .bsd-progress { display: none; }
}
