/* ============================================================
   Startup & Boot tutorial — local styles
   Base components (tables, callouts, buttons, footer, consent,
   check items, tokens) come from the shared /css/style.css.
   This file only adds the tutorial-specific chrome: layout,
   TOC, section headings, code blocks, details, the SVG, the
   triage helper, the image/ad placeholders, and print/reduced-motion.
   ============================================================ */

/* ---------- Reading progress ---------- */
.progress {
  position: fixed; top: 0; left: 0;
  width: 0; height: 3px;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
  z-index: 60;
  transition: width 0.1s linear;
}
/* Page rhythm: keep content clear of the sticky header and footer */
main { padding: clamp(28px, 5vw, 56px) 0 clamp(64px, 8vw, 96px); }

/* ---------- Article layout ---------- */
.article-grid { display: grid; gap: 40px; align-items: start; }
.toc { display: none; }
@media (min-width: 600px) and (max-width: 1023px) {
  .toc {
    display: block;
    grid-column: 1 / -1;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
  }
  .toc-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px 24px; }
}
@media (min-width: 1024px) {
  .article-grid { grid-template-columns: 260px 1fr; gap: 56px; }
  .toc {
    display: block;
    position: sticky;
    top: calc(var(--header-h) + 20px);
    max-height: calc(100vh - var(--header-h) - 40px);
    overflow-y: auto;
    border-right: 1px solid var(--line);
    padding-right: 22px;
  }
  .toc-list { grid-template-columns: 1fr; }
}
.toc-title { font: 500 0.7rem var(--font-mono); text-transform: uppercase; letter-spacing: 0.16em; color: var(--ink-3); margin: 0 0 12px; }
.toc-filter { position: relative; margin-bottom: 14px; }
.toc-filter input {
  width: 100%;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 8px 12px;
  font: 400 0.85rem var(--font-body);
  background: var(--surface);
  color: var(--ink);
}
.toc-filter input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(15, 91, 215, 0.12); }
.toc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.toc-list a {
  display: block;
  padding: 6px 10px;
  font-size: 0.86rem;
  line-height: 1.35;
  color: var(--ink-2);
  text-decoration: none;
  border-left: 2px solid transparent;
  border-radius: 0 6px 6px 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.toc-list a:hover { color: var(--ink); background: var(--tint); }
.toc-list a.is-active { color: var(--blue); border-left-color: var(--blue); background: var(--tint); font-weight: 500; }
.toc-cat-link { font-weight: 600; color: var(--ink); margin-top: 6px; }
.toc-topics { margin: 2px 0 6px 0; padding-left: 8px; }
.toc-topics a { font-size: 0.82rem; color: var(--ink-3); }
.toc-item.is-hidden { display: none; }

/* ---------- Article typography ---------- */
.article-head { margin-bottom: 26px; }
.article-head h1 { font-size: clamp(1.9rem, 1.2rem + 2.6vw, 2.7rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1.08; margin: 0 0 14px; }
.article-sub { font: 500 0.82rem var(--font-mono); color: var(--ink-3); margin: 0; }
.article-main { max-width: 78ch; }
.article-main p { font-size: 1.02rem; line-height: 1.75; color: var(--ink-2); margin: 0 0 1.15em; }
.article-main p strong, .article-main li strong { color: var(--ink); font-weight: 600; }
.article-main a { color: var(--blue); text-decoration: underline; text-underline-offset: 2px; }
.article-main a:hover { color: var(--blue-deep); }
.article-main code { font-family: var(--font-mono); font-size: 0.88em; background: var(--tint); padding: 0.12em 0.4em; border-radius: 5px; color: var(--ink); }
.lead { font-size: 1.12rem !important; color: var(--ink) !important; }

/* ---------- Image placeholder (hidden until data-src is valid) ---------- */
.article-figure { display: none; margin: 0 0 30px; }
.article-figure.is-ready { display: block; }
.article-figure-img { width: 100%; height: auto; display: block; border-radius: var(--radius); border: 1px solid var(--line); }
.article-figure figcaption { font: 400 0.82rem var(--font-mono); color: var(--ink-3); margin-top: 10px; }

/* ---------- Section headings ---------- */
.tut-section { margin-bottom: clamp(40px, 6vw, 64px); scroll-margin-top: calc(var(--header-h) + 20px); }
.tut-category { padding-top: 12px; border-top: 1px solid var(--line); margin-top: 8px; }
.tut-h2 { display: flex; align-items: baseline; gap: 14px; font-size: clamp(1.4rem, 1rem + 1.4vw, 1.9rem); font-weight: 600; letter-spacing: -0.01em; margin: 0 0 16px; scroll-margin-top: calc(var(--header-h) + 20px); }
.tut-num { flex: none; font: 600 0.82rem var(--font-mono); color: var(--blue); background: var(--tint); border: 1px solid var(--blue-soft); border-radius: 8px; padding: 3px 9px; }
.cat-intro { font-size: 1.02rem; color: var(--ink-2); margin: 0 0 8px; }
.cat-note { font-size: 0.9rem; color: var(--ink-3); }
.tut-topic { margin-bottom: clamp(32px, 5vw, 48px); }
.topic-h { display: flex; align-items: baseline; gap: 12px; font-size: clamp(1.15rem, 0.95rem + 0.9vw, 1.5rem); font-weight: 600; margin: 0 0 12px; scroll-margin-top: calc(var(--header-h) + 20px); }
.topic-num { flex: none; font: 500 0.78rem var(--font-mono); color: var(--ink-3); }

/* ---------- Lists & steps ---------- */
.steps { list-style: none; counter-reset: step; margin: 0 0 1.15em; padding: 0; }
.steps li { counter-increment: step; position: relative; padding: 0 0 0 42px; margin-bottom: 12px; font-size: 1rem; color: var(--ink-2); line-height: 1.6; }
.steps li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute; left: 0; top: 1px;
  font: 600 0.78rem var(--font-mono);
  color: var(--blue); background: var(--tint);
  border: 1px solid var(--blue-soft);
  border-radius: 7px; padding: 3px 7px;
}
.tut-list { margin: 0 0 1.15em; padding-left: 22px; }
.tut-list li { margin-bottom: 8px; font-size: 1rem; color: var(--ink-2); line-height: 1.6; }

/* ---------- Warn callout (base .callout is in shared CSS) ---------- */
.callout-warn { background: #fdf4e3; border-color: #eccf97; }
.callout-warn .callout-ico { background: #d98a2b; }
[data-theme="dark"] .callout-warn { background: #2a2110; border-color: #6b5426; }
[data-theme="dark"] .callout-warn .callout-ico { background: #d98a2b; }

/* ---------- Platform pills ---------- */
.plat { display: inline-block; font: 500 0.7rem var(--font-mono); letter-spacing: 0.04em; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line-2); border-radius: 6px; padding: 2px 8px; margin-right: 6px; }

/* ---------- Risk badges ---------- */
.risk { display: inline-block; font: 600 0.66rem var(--font-mono); text-transform: uppercase; letter-spacing: 0.08em; border-radius: 999px; padding: 3px 10px; }
.risk--safe { color: #1c7a58; background: #e2f5ec; border: 1px solid #b6e2cd; }
.risk--caution { color: #9a6a1c; background: #fbf0d6; border: 1px solid #ecd49a; }
.risk--no { color: #a33; background: #fbe4e4; border: 1px solid #eebcbc; }
[data-theme="dark"] .risk--safe { color: #57d6a6; background: #0e2a1e; border-color: #1d4a37; }
[data-theme="dark"] .risk--caution { color: #f2c069; background: #2a2110; border-color: #6b5426; }
[data-theme="dark"] .risk--no { color: #f09a9a; background: #2a1414; border-color: #5a2a2a; }

/* ---------- Expandable steps (native <details>) ---------- */
.tut-details { border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 14px; background: var(--surface); overflow: hidden; }
.tut-details summary { cursor: pointer; list-style: none; padding: 14px 16px; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 10px; }
.tut-details summary::-webkit-details-marker { display: none; }
.tut-details summary::before { content: "+"; font-family: var(--font-mono); color: var(--blue); font-size: 1.1rem; width: 18px; text-align: center; transition: transform 0.2s; }
.tut-details[open] summary::before { content: "–"; }
.tut-details summary:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.tut-details-body { padding: 4px 16px 16px; border-top: 1px solid var(--line); }
.tut-details-body p { font-size: 0.95rem; color: var(--ink-2); }

/* ---------- Code blocks ---------- */
.code-block { margin: 14px 0 20px; border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; background: var(--dark-2); }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: rgba(255, 255, 255, 0.04); border-bottom: 1px solid var(--dark-line); }
.code-lang { font-size: 0.72rem; color: var(--dark-muted); letter-spacing: 0.06em; }
.copy-btn { font: 500 0.74rem var(--font-mono); color: var(--dark-ink); background: none; border: 1px solid var(--dark-line); border-radius: 6px; padding: 4px 10px; cursor: pointer; transition: border-color 0.15s, color 0.15s; }
.copy-btn:hover { border-color: var(--cyan-bright); color: var(--cyan-bright); }
.copy-btn:focus-visible { outline: 2px solid var(--cyan-bright); outline-offset: 2px; }
.code-block pre { margin: 0; padding: 14px 16px; overflow-x: auto; }
.code-block code { font-family: var(--font-mono); font-size: 0.86rem; color: var(--cyan-bright); background: none; padding: 0; white-space: pre; }

/* ---------- Triage (decision helper) ---------- */
.triage-set { border: 0; padding: 0; margin: 0 0 8px; }
.triage-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 560px) { .triage-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .triage-grid { grid-template-columns: repeat(4, 1fr); } }
.triage-opt { position: relative; display: block; cursor: pointer; }
.triage-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.triage-opt span {
  display: block;
  padding: 12px 14px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--surface);
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--ink-2);
  transition: border-color 0.15s, background 0.15s, color 0.15s, box-shadow 0.15s;
}
.triage-opt:hover span { border-color: var(--blue); color: var(--ink); }
.triage-opt input:checked + span { border-color: var(--blue); background: var(--tint); color: var(--ink); box-shadow: inset 0 0 0 1px var(--blue); font-weight: 500; }
.triage-opt input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }
.triage-result { margin-top: 18px; padding: 18px 20px; border: 1px solid var(--blue-soft); border-left: 4px solid var(--blue); border-radius: 10px; background: var(--tint); }
.triage-result p { margin: 0 0 10px; font-size: 0.95rem; color: var(--ink-2); }
.triage-result p:last-child { margin-bottom: 0; }
.triage-stage { font-size: 1rem; color: var(--ink); }
.triage-links { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.triage-links-label { font: 500 0.72rem var(--font-mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-3); width: 100%; }
.check-suggest { display: inline-block; font-size: 0.84rem; color: var(--blue); text-decoration: none; background: var(--surface); border: 1px solid var(--blue-soft); border-radius: 999px; padding: 5px 12px; transition: background 0.15s, border-color 0.15s; }
.check-suggest:hover, .check-suggest:focus-visible { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ---------- Boot pipeline SVG ---------- */
.pt-figure { margin: 26px 0; }
.pt-svg { width: 100%; height: auto; display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.pt-track { stroke: var(--line-2); stroke-width: 3; }
.pt-flow { stroke: var(--cyan-bright); stroke-width: 3; stroke-dasharray: 12 240; opacity: 0.8; animation: ptflow 4s linear infinite; }
@keyframes ptflow { to { stroke-dashoffset: -252; } }
.pt-dot { fill: var(--surface); stroke: var(--line-2); stroke-width: 2.5; }
.pt-pulse { fill: none; stroke: var(--cyan-bright); stroke-width: 1.5; opacity: 0; transform-box: fill-box; transform-origin: center; animation: ptpulse 3s ease-out infinite; }
@keyframes ptpulse { 0% { transform: scale(0.6); opacity: 0.7; } 70% { transform: scale(2.1); opacity: 0; } 100% { opacity: 0; } }
.pt-node:nth-of-type(2) .pt-pulse { animation-delay: 0.4s; }
.pt-node:nth-of-type(3) .pt-pulse { animation-delay: 0.8s; }
.pt-node:nth-of-type(4) .pt-pulse { animation-delay: 1.2s; }
.pt-node:nth-of-type(5) .pt-pulse { animation-delay: 1.6s; }
.pt-node:nth-of-type(6) .pt-pulse { animation-delay: 2s; }
.pt-node:nth-of-type(7) .pt-pulse { animation-delay: 2.4s; }
.pt-node:nth-of-type(8) .pt-pulse { animation-delay: 2.8s; }
.pt-label { font-family: var(--font-mono); font-size: 13px; fill: var(--ink-2); text-anchor: middle; }
.pt-caption { font: 400 0.82rem var(--font-mono); color: var(--ink-3); margin-top: 10px; }

/* ---------- Related ---------- */
.related-links { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Ad slot: hide when empty (safety net on top of shared JS) ---------- */
#ad-wrap { margin: 0 0 clamp(40px, 6vw, 64px); }
#ad-wrap:has(#ad-slot:empty) { display: none; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .progress { transition: none; }
  .pt-flow { animation: none; stroke-dasharray: none; opacity: 0.35; }
  .pt-pulse { animation: none; opacity: 0; }
  .toc-list a, .triage-opt span, .copy-btn { transition: none; }
}

/* ---------- Print ---------- */
@media print {
  .progress, .topbar, .toc, .nav-cta, .nav-toggle, .theme-toggle, .ad-wrap,
  .to-top, .consent, .related-links, .triage-set, .triage-result, #ad-wrap { display: none !important; }
  .article-grid { display: block; }
  .article-main { max-width: 100%; }
  .pt-figure, .tut-section { break-inside: avoid; }
  body { background: #fff; }
}
