/* ==========================================================================
   OP-XY INDUSTRIAL TRACK TUTORIAL — STYLESHEET
   Dark industrial design system. No external dependencies.
   ========================================================================== */

/* ---- 1. Design tokens ---------------------------------------------------- */
:root {
  /* color */
  --bg: #0c0c0e;
  --bg-raised: #131316;
  --bg-inset: #08080a;
  --panel: #17171b;
  --line: #2a2a30;
  --line-strong: #3a3a42;
  --text: #e8e8e4;
  --text-dim: #a6a6a0;
  --text-faint: #74746e;
  --accent: #ff4a1f;          /* rust orange — primary industrial accent */
  --accent-dim: #b33517;
  --accent-soft: rgba(255, 74, 31, 0.12);
  --hazard: #ffd23f;          /* hazard yellow — warnings / verify flags */
  --ok: #7ddb64;              /* checkpoint green */
  --cold: #6fb8c9;            /* cold steel blue — info / explanations */
  --grid-hit: #ff4a1f;
  --grid-accent: #ffd23f;
  --grid-ghost: #6f4a3f;

  /* spacing & shape */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 1rem;
  --sp-4: 1.5rem;
  --sp-5: 2.5rem;
  --sp-6: 4rem;
  --radius: 4px;
  --sidebar-w: 280px;
  --header-h: 56px;

  /* type */
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---- 2. Base / reset ------------------------------------------------------ */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 1rem); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.65;
  /* subtle industrial texture: faint scanlines */
  background-image: repeating-linear-gradient(
    0deg, transparent 0 3px, rgba(255, 255, 255, 0.012) 3px 4px);
}

h1, h2, h3, h4 { line-height: 1.25; font-weight: 700; }
h2, h3 { letter-spacing: 0.02em; }
p { margin: 0.7em 0; }
a { color: var(--accent); }
a:hover { color: var(--hazard); }
code, kbd {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-inset);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.08em 0.4em;
  white-space: nowrap;
}
kbd { border-bottom-width: 2px; color: var(--hazard); }
strong { color: #fff; }
hr { border: none; border-top: 1px solid var(--line); margin: var(--sp-5) 0; }
ul, ol { padding-left: 1.4em; }
li { margin: 0.35em 0; }

:focus-visible {
  outline: 2px solid var(--hazard);
  outline-offset: 2px;
}

/* ---- 3. Header / global progress ----------------------------------------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-3);
  background: rgba(12, 12, 14, 0.94);
  border-bottom: 1px solid var(--line-strong);
  backdrop-filter: blur(6px);
  z-index: 50;
}
.topbar .brand {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}
.topbar .brand em { color: var(--accent); font-style: normal; }

.progress-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
}
.progress-track {
  flex: 1;
  height: 8px;
  background: var(--bg-inset);
  border: 1px solid var(--line);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  transition: width 0.4s ease;
}
.progress-label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.nav-toggle {
  display: none;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.45rem 0.7rem;
  cursor: pointer;
}
.nav-toggle[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }

/* ---- 4. Layout: sidebar + main ------------------------------------------- */
.layout {
  display: flex;
  max-width: 1280px;
  margin: 0 auto;
  padding-top: var(--header-h);
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: sticky;
  top: var(--header-h);
  align-self: flex-start;
  max-height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: var(--sp-4) var(--sp-3);
  border-right: 1px solid var(--line);
}
.sidebar h2 {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--text-faint);
  margin: 0 0 var(--sp-3);
}
.sidebar ol { list-style: none; margin: 0; padding: 0; }
.sidebar li { margin: 0; }
.sidebar a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.42rem 0.5rem;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.86rem;
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.sidebar a:hover { color: var(--text); background: var(--bg-raised); }
.sidebar a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-soft);
}
.sidebar .num {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-faint);
  width: 1.6em;
  flex-shrink: 0;
}
/* per-section progress dot: fills when all checklist items done */
.sidebar .dot {
  margin-left: auto;
  width: 9px; height: 9px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
}
.sidebar .dot.partial { border-color: var(--hazard); }
.sidebar .dot.done { border-color: var(--ok); background: var(--ok); }

.content {
  flex: 1;
  min-width: 0;
  padding: var(--sp-4) var(--sp-5) var(--sp-6);
}

/* ---- 5. Hero -------------------------------------------------------------- */
.hero { padding: var(--sp-5) 0 var(--sp-4); border-bottom: 1px solid var(--line); }
.hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.9rem);
  margin: 0 0 var(--sp-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.hero h1 em { color: var(--accent); font-style: normal; }
.hero .sub { color: var(--text-dim); max-width: 62ch; font-size: 1.05rem; }
.hero .tagline {
  font-family: var(--font-mono);
  color: var(--hazard);
  font-size: 0.8rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  margin-bottom: var(--sp-2);
}

/* ---- 6. Sections ----------------------------------------------------------- */
section.step { padding: var(--sp-5) 0; border-bottom: 1px solid var(--line); }
section.step > h2 {
  font-size: 1.5rem;
  text-transform: uppercase;
  margin: 0 0 var(--sp-3);
}
.kicker {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.25em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}
section.step h3 {
  font-size: 1.08rem;
  margin: var(--sp-4) 0 var(--sp-2);
  color: #fff;
}
section.step h3::before { content: "▸ "; color: var(--accent); }

/* ---- 7. Callouts ----------------------------------------------------------- */
.callout {
  margin: var(--sp-4) 0;
  padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-4);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
}
.callout .callout-title {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  margin-bottom: var(--sp-2);
}
.callout p:first-of-type { margin-top: 0; }
.callout p:last-child, .callout ul:last-child, .callout ol:last-child { margin-bottom: 0; }

.callout.checkpoint { border-left-color: var(--ok); }
.callout.checkpoint .callout-title { color: var(--ok); }
.callout.checkpoint .callout-title::before { content: "◉ "; }

.callout.trouble {
  border-left-color: var(--hazard);
  /* hazard stripe strip on top edge */
  background-image: repeating-linear-gradient(
    -45deg, rgba(255, 210, 63, 0.06) 0 10px, transparent 10px 20px);
}
.callout.trouble .callout-title { color: var(--hazard); }
.callout.trouble .callout-title::before { content: "⚠ "; }

.callout.vary { border-left-color: var(--cold); }
.callout.vary .callout-title { color: var(--cold); }
.callout.vary .callout-title::before { content: "⟳ "; }

/* "verify on your OP-XY/manual" inline badge — honesty flag for
   firmware-dependent details this guide will not guess at */
.verify {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--hazard);
  background: rgba(255, 210, 63, 0.08);
  border: 1px dashed rgba(255, 210, 63, 0.5);
  border-radius: 3px;
  padding: 0.05em 0.45em;
  white-space: nowrap;
  vertical-align: baseline;
}

/* ---- 8. Expandable beginner explanations (details/summary) ---------------- */
details.explain {
  margin: var(--sp-3) 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-raised);
}
details.explain summary {
  cursor: pointer;
  padding: var(--sp-2) var(--sp-3);
  font-weight: 600;
  color: var(--cold);
  list-style: none;
  user-select: none;
}
details.explain summary::-webkit-details-marker { display: none; }
details.explain summary::before {
  content: "+";
  display: inline-block;
  width: 1.3em;
  color: var(--cold);
  font-family: var(--font-mono);
  font-weight: 700;
}
details.explain[open] summary::before { content: "–"; }
details.explain[open] summary { border-bottom: 1px solid var(--line); }
details.explain .body { padding: var(--sp-2) var(--sp-3) var(--sp-3); color: var(--text-dim); }
details.explain .body p:first-child { margin-top: 0.4em; }

/* ---- 9. Interactive checklists --------------------------------------------- */
.checklist {
  margin: var(--sp-4) 0 0;
  padding: var(--sp-3);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}
.checklist legend, .checklist .cl-title {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 0 var(--sp-2);
}
.checklist label {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.4rem 0.3rem;
  cursor: pointer;
  border-radius: 3px;
  font-size: 0.94rem;
}
.checklist label:hover { background: var(--bg-raised); }
.checklist input[type="checkbox"] {
  appearance: none;
  flex-shrink: 0;
  width: 18px; height: 18px;
  margin-top: 0.2em;
  border: 2px solid var(--line-strong);
  border-radius: 3px;
  background: var(--bg-inset);
  cursor: pointer;
  position: relative;
}
.checklist input[type="checkbox"]:checked { border-color: var(--accent); background: var(--accent); }
.checklist input[type="checkbox"]:checked::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0c0c0e;
  font-size: 13px;
  font-weight: 900;
}
.checklist input[type="checkbox"]:focus-visible { outline: 2px solid var(--hazard); outline-offset: 2px; }
.checklist input:checked + span { color: var(--text-faint); text-decoration: line-through; text-decoration-color: var(--accent-dim); }

/* ---- 10. Pattern grids (rendered by script.js) ------------------------------ */
.pgrid {
  margin: var(--sp-3) 0;
  padding: var(--sp-3);
  background: var(--bg-inset);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
}
.pgrid .pgrid-caption {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--hazard);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: var(--sp-2);
}
.pgrid table { border-collapse: separate; border-spacing: 3px; }
.pgrid th {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  text-align: right;
  padding-right: 0.6rem;
  white-space: nowrap;
}
.pgrid thead th {
  text-align: center;
  padding: 0 0 2px;
  color: var(--text-faint);
  font-size: 0.62rem;
}
/* beat-start columns (1, 5, 9, 13) get brighter numerals */
.pgrid thead th.beat { color: var(--text-dim); }
.pgrid td {
  width: 26px; height: 26px;
  min-width: 26px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 3px;
}
.pgrid td.beat { border-color: var(--line-strong); background: #1a1a1f; }
.pgrid td.hit { background: var(--grid-hit); border-color: var(--grid-hit); }
.pgrid td.accent {
  background: var(--grid-accent);
  border-color: var(--grid-accent);
  box-shadow: 0 0 6px rgba(255, 210, 63, 0.4);
}
.pgrid td.ghost { background: var(--grid-ghost); border-color: var(--grid-ghost); }
.pgrid .legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-top: var(--sp-2);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-faint);
}
.pgrid .legend .sw {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 2px;
  margin-right: 0.35em;
  vertical-align: -1px;
}

/* ---- 11. SVG diagram wrappers ----------------------------------------------- */
figure.diagram {
  margin: var(--sp-4) 0;
  padding: var(--sp-3);
  background: var(--bg-inset);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
figure.diagram svg { display: block; width: 100%; height: auto; }
figure.diagram figcaption {
  margin-top: var(--sp-2);
  font-size: 0.82rem;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

/* ---- 12. Tables (reference tables, not grids) -------------------------------- */
table.ref {
  width: 100%;
  border-collapse: collapse;
  margin: var(--sp-3) 0;
  font-size: 0.92rem;
}
table.ref th, table.ref td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.ref th {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  border-bottom: 2px solid var(--line-strong);
}
table.ref td:first-child { color: #fff; font-weight: 600; white-space: nowrap; }

/* ---- 13. Buttons -------------------------------------------------------------- */
.btn {
  display: inline-block;
  background: var(--accent);
  color: #0c0c0e;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.65rem 1.2rem;
  cursor: pointer;
}
.btn:hover { background: var(--hazard); }
.btn.ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--line-strong);
}
.btn.ghost:hover { color: var(--accent); border-color: var(--accent); background: transparent; }

/* ---- 14. Printable final checklist -------------------------------------------- */
#print-sheet {
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: var(--sp-4);
  margin-top: var(--sp-4);
}
#print-sheet h3 { margin-top: var(--sp-3); }
#print-sheet ul { list-style: none; padding: 0; }
#print-sheet li { padding-left: 1.7em; position: relative; margin: 0.45em 0; }
#print-sheet li::before {
  content: "";
  position: absolute;
  left: 0; top: 0.28em;
  width: 0.95em; height: 0.95em;
  border: 2px solid var(--text-faint);
  border-radius: 3px;
}

@media print {
  /* print only the final checklist sheet */
  body { background: #fff; color: #000; }
  .topbar, .sidebar, .no-print, section.step, .hero, footer { display: none !important; }
  .layout, .content { display: block; padding: 0; margin: 0; max-width: none; }
  #workflow { display: block !important; border: none; padding: 0; }
  #workflow > *:not(#print-sheet):not(h2) { display: none; }
  #print-sheet { background: #fff; border: 1px solid #999; color: #000; }
  #print-sheet h3, #workflow h2 { color: #000; }
  #print-sheet li::before { border-color: #000; }
  #workflow .kicker { color: #444; }
}

/* ---- 15. Footer ----------------------------------------------------------------- */
footer.site-footer {
  padding: var(--sp-4) 0;
  color: var(--text-faint);
  font-size: 0.82rem;
  font-family: var(--font-mono);
}

/* ---- 16. Responsive -------------------------------------------------------------- */
@media (max-width: 900px) {
  .nav-toggle { display: inline-block; }
  .layout { display: block; }
  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: min(82vw, 320px);
    background: var(--bg);
    border-right: 1px solid var(--line-strong);
    transform: translateX(-104%);
    transition: transform 0.25s ease;
    z-index: 40;
    max-height: none;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 8px 0 30px rgba(0,0,0,0.6); }
  .content { padding: var(--sp-3) var(--sp-3) var(--sp-6); }
  .progress-label .p-text { display: none; }
  .topbar .brand { font-size: 0.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .progress-fill, .sidebar { transition: none; }
}
