/* ── SHARED SUB-PAGE STYLES ── */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
  font-size: 13px;
  color: var(--muted);
}
.breadcrumb a {
  color: var(--accent2);
  text-decoration: none;
  transition: color 0.3s;
}
.breadcrumb a:hover {
  color: var(--accent);
}

@media (max-width: 768px) {
  .breadcrumb {
    font-size: 12px;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
}
@media (max-width: 480px) {
  .breadcrumb {
    font-size: 11px;
    margin-bottom: 1rem;
    gap: 0.3rem;
  }
  .breadcrumb span {
    margin: 0 0.2rem;
  }
}

#robotCanvas {
  touch-action: pan-y;
}

/* ══════════════════════════════════════════════════════════════════
   ІЗБАСАР РОБОТЫ GUIDE PAGE — page-specific layout
   (moved out of index.html's inline <style> block so this page's CSS
   lives in one file, cacheable and diffable like every other stylesheet
   instead of re-shipped inline on every request)
══════════════════════════════════════════════════════════════════ */

/* ---------------------------------------------------------------- */
/* Shared layout tokens                                             */
/* ---------------------------------------------------------------- */
/* One fluid horizontal inset used by the breadcrumb bar, the shell,
   and every card-like section below (intro, parts summary, gate
   teaser). Using a single clamp() instead of separate vw values per
   section is what keeps everything's left/right edge lined up at
   every viewport width instead of jumping independently at
   different breakpoints. Mobile-first: increased minimums for better spacing. */
:root {
  --guide-pad-x: clamp(1.75rem, 6vw, 4rem);
  --card-pad: clamp(2.25rem, 7vw, 3.25rem);
  --hero-pad: clamp(2.5rem, 8vw, 4.25rem);
  --hero-pad-y: clamp(2.75rem, 9vw, 4.5rem);
}
.guide-shell {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0 var(--guide-pad-x) 4rem;
}
.guide-nav {
  display: flex;
  gap: clamp(0.3rem, 1vw, 0.4rem);
  overflow-x: auto;
  overflow-y: hidden;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: clamp(0.65rem, 1.5vw, 0.75rem) clamp(0.15rem, 1vw, 0.25rem);
  margin-bottom: clamp(1.2rem, 3vw, 1.5rem);
  position: sticky;
  top: var(--nav-h, 72px);
  z-index: 20;
  background: var(--bg);
  border-bottom: 0.5px solid var(--border);
}
.guide-nav::-webkit-scrollbar { display: none; }
@media (min-width: 640px) {
  .guide-shell { padding-bottom: 6rem; }
  .guide-nav { margin-bottom: 2rem; }
}
/* Only meaningful on desktop (see the 1040px block below, where it
   becomes position:absolute). Below that, .guide-nav is a row of
   horizontally-scrolling pills and this rail has no layout rules of
   its own — left visible it sits as an empty first flex child,
   adding a stray gap before the first pill and nudging the whole
   scroller over. */
.guide-nav-rail { display: none; }
.guide-nav-link {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  padding: clamp(0.45rem, 1vw, 0.5rem) clamp(0.75rem, 1.5vw, 0.9rem);
  border-radius: 999px;
  border: 0.5px solid var(--border);
  white-space: nowrap;
  transition: all 0.2s;
}
.guide-nav-link.active {
  color: white;
  background: var(--accent);
  border-color: transparent;
}
.guide-content {
  max-width: 980px;
  margin: 0 auto;
  width: 100%;
}
.guide-content > section,
.guide-content #gatedContent > section { padding: 0; }

/* Desktop: real sidebar with vertical progress rail */
@media (min-width: 1040px) {
  .guide-shell {
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    gap: 3rem;
  }
  .guide-nav {
    flex-direction: column;
    overflow: visible;
    width: 230px;
    flex-shrink: 0;
    margin-bottom: 0;
    padding: 0 0 0 1.1rem;
    background: none;
    border-bottom: none;
    top: calc(var(--nav-h, 96px) + 2rem);
    gap: 0.15rem;
  }
  .guide-nav-rail {
    display: block;
    position: absolute;
    left: 0;
    top: 0.3rem;
    bottom: 0.3rem;
    width: 2px;
    background: var(--border);
    border-radius: 2px;
  }
  .guide-nav-rail-fill {
    position: absolute;
    left: 0;
    top: 0;
    width: 2px;
    background: var(--accent);
    border-radius: 2px;
    transition: height 0.15s ease-out;
  }
  .guide-nav-link {
    border: none;
    border-radius: 8px;
    padding: 0.55rem 0.9rem;
    text-align: left;
  }
  .guide-nav-link.active {
    background: rgba(45, 106, 79, 0.14);
    color: var(--accent2);
  }
  .guide-content { margin: 0; }
}

/* ---------------------------------------------------------------- */
/* Intro                                                             */
/* ---------------------------------------------------------------- */
/* Mobile-first card: text stack + centered 3D stage. The visual is
   width-constrained and horizontally centered so it lines up with the
   centered title/paragraphs instead of sitting flush-left. */
.intro-section {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg2);
  border: 0.5px solid rgba(45, 106, 79, 0.3);
  border-radius: 8px;
  padding: clamp(1.75rem, 5vw, 2.5rem) clamp(1.25rem, 4vw, 2.5rem);
  margin-top: clamp(1.25rem, 3vw, 2rem);
  margin-bottom: clamp(1.5rem, 4vw, 2.5rem);
  scroll-margin-top: 6.5rem;
  text-align: center;
}
.intro-section::before {
  content: "";
  position: absolute;
  top: -100px;
  right: -80px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(45, 106, 79, 0.08) 0%, transparent 70%);
  pointer-events: none;
}
.intro-section h1 {
  position: relative;
  font-family: var(--font-display);
  font-size: clamp(26px, 7vw, 44px);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin: 0 0 1rem;
  max-width: 18ch;
  color: var(--accent2);
  word-break: break-word;
  text-align: center;
}
.intro-section p {
  position: relative;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.7;
  max-width: 36rem;
  margin: 0;
  text-align: center;
}
.intro-section p + p {
  margin-top: 0.75rem;
}
/* 3D demo stage — full width of the card on mobile, capped & centered
   on larger screens so it never looks left-aligned under the text. */
.intro-section .intro-visual {
  width: 100%;
  max-width: 100%;
  margin-top: 1.5rem;
  margin-left: auto;
  margin-right: auto;
  aspect-ratio: 1 / 0.78;
  border-radius: 6px;
}
.intro-section .intro-visual .ctrl-wrap {
  left: 0.6rem;
  right: 0.6rem;
  bottom: 0.6rem;
  gap: 0.4rem;
}
.intro-section .intro-visual .ctrl-btn {
  font-size: 11px;
  padding: 0.5rem 0.45rem;
}
@media (min-width: 480px) {
  .intro-section {
    padding: clamp(2rem, 5vw, 2.75rem) clamp(1.5rem, 5vw, 3rem);
  }
  .intro-section h1 {
    font-size: clamp(30px, 6vw, 44px);
    max-width: 20ch;
  }
  .intro-section p {
    font-size: 14.5px;
    line-height: 1.75;
  }
  .intro-section .intro-visual {
    max-width: 480px;
    margin-top: 1.75rem;
  }
}
@media (min-width: 640px) {
  .intro-section {
    padding: clamp(2.25rem, 5vw, 3.25rem) clamp(2rem, 6vw, 3.5rem);
  }
  .intro-section p {
    font-size: 15.5px;
    line-height: 1.8;
    max-width: 38rem;
  }
  .intro-section p + p {
    margin-top: 0.9rem;
  }
  .intro-section .intro-visual {
    max-width: 560px;
    margin-top: 2rem;
    aspect-ratio: 1 / 0.8;
  }
  .intro-section .intro-visual .ctrl-wrap {
    left: 0.9rem;
    right: 0.9rem;
    bottom: 0.9rem;
    gap: 0.5rem;
  }
  .intro-section .intro-visual .ctrl-btn {
    font-size: 12px;
    padding: 0.55rem 0.75rem;
  }
}
@media (min-width: 900px) {
  .intro-section .intro-visual {
    max-width: 620px;
  }
}

/* ---------------------------------------------------------------- */
/* Parts grid                                                        */
/* ---------------------------------------------------------------- */
#parts { scroll-margin-top: 6.5rem; margin-bottom: 2rem; }
#build-log { scroll-margin-top: 6.5rem; margin-bottom: 2rem; }
@media (min-width: 640px) {
  #parts { margin-bottom: 2.75rem; }
  #build-log { margin-bottom: 2.75rem; }
}
.parts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.1rem;
  margin-top: 1.5rem;
}
.part-card {
  background: var(--bg2);
  border: 0.5px solid var(--border);
  border-radius: 8px;
  padding: 1.3rem;
  transition: all 0.25s;
}
.part-card:hover {
  border-color: rgba(45, 106, 79, 0.5);
  transform: translateY(-3px);
}
.part-icon { font-size: 28px; margin-bottom: 0.6rem; }
.part-card h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--accent2);
}
.part-card p { font-size: 13px; color: var(--muted); line-height: 1.6; }
.part-card h4 {
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.9rem;
  margin-bottom: 0.35rem;
}
.parts-summary {
  margin-top: 2rem;
  background: var(--bg2);
  border: 0.5px solid rgba(45, 106, 79, 0.3);
  border-radius: 8px;
  padding: clamp(1.4rem, 4vw, 1.8rem);
  font-size: 13px;
  color: var(--muted);
  line-height: 1.75;
}
@media (min-width: 640px) {
  .parts-grid { grid-template-columns: repeat(2, 1fr); gap: 1.5rem; margin-top: 2rem; }
  .part-card { padding: 1.6rem; }
  .part-icon { font-size: 32px; margin-bottom: 0.8rem; }
  .part-card h4 { font-size: 12.5px; }
  .parts-summary { font-size: 14px; }
}

/* ---------------------------------------------------------------- */
/* Steps                                                             */
/* ---------------------------------------------------------------- */
.step-container { margin: 0 0 2rem; scroll-margin-top: 6.5rem; }
@media (min-width: 640px) {
  .step-container { margin-bottom: 2.75rem; }
}
.step-header {
  background: var(--accent);
  color: white;
  padding: 1.1rem 1.3rem;
  border-radius: 8px 8px 0 0;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
.step-number {
  font-family: var(--font-body);
  font-size: 24px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  flex-shrink: 0;
}
@media (min-width: 640px) {
  .step-header { padding: 1.6rem 2rem; gap: 1.2rem; }
  .step-number { font-size: 36px; width: 60px; height: 60px; }
}
.step-title h2 { font-family: var(--font-display); font-size: 19px; font-weight: 800; margin-bottom: 0.3rem; }
.step-title p { font-size: 12px; opacity: 0.9; }
.step-content {
  background: var(--bg2);
  border: 0.5px solid rgba(45, 106, 79, 0.3);
  border-radius: 0 0 8px 8px;
  padding: 1.4rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.6rem;
}
@media (min-width: 760px) {
  .step-title h2 { font-size: 24px; }
  .step-title p { font-size: 13px; }
  .step-content { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding: 2.2rem; gap: 2.2rem; }
}
/* min-width: 0 overrides the grid item's default content-based minimum
   size — without it, a wide <pre class="code-block"> (long unwrapped
   code lines) forces its whole column past its 1fr share and the
   column overflows the card instead of the code block scrolling. */
.step-page { display: flex; flex-direction: column; min-width: 0; }
.step-page h3 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--accent2);
  margin-bottom: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.step-text { font-size: 14px; color: var(--muted); line-height: 1.75; margin-bottom: 1.2rem; }
.step-highlight {
  background: rgba(45, 106, 79, 0.1);
  border-left: 3px solid var(--accent);
  padding: 1rem 1.1rem;
  border-radius: 8px;
  margin: 1.2rem 0;
  font-size: 14px;
  color: var(--text);
  line-height: 1.7;
}
.step-bullet {
  display: flex;
  gap: 0.7rem;
  margin-bottom: 0.8rem;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
}
.step-bullet::before { content: "✦"; color: var(--accent); flex-shrink: 0; font-weight: bold; }
.teaser {
  background: rgba(45, 106, 79, 0.15);
  border: 0.5px solid rgba(45, 106, 79, 0.3);
  border-radius: 8px;
  padding: 1.2rem;
  margin-top: 1.5rem;
  font-size: 13px;
  color: var(--accent2);
  font-weight: 600;
  line-height: 1.6;
}
.checklist { display: flex; flex-direction: column; gap: 0.7rem; }
.checklist-item { display: flex; gap: 0.7rem; font-size: 13px; color: var(--muted); align-items: flex-start; }
.checklist-item::before { content: "☐"; color: var(--accent); flex-shrink: 0; font-weight: bold; font-size: 15px; }

/* ---------------------------------------------------------------- */
/* Code block + "test in IDE" button                                */
/* ---------------------------------------------------------------- */
.code-block {
  background: #0b0a14;
  border: 0.5px solid rgba(45, 106, 79, 0.35);
  border-radius: 8px;
  padding: 0.9rem;
  margin: 1.1rem 0 0.9rem;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11.5px;
  line-height: 1.6;
  color: #d7d2f7;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: pre;
  max-width: 100%;
  box-sizing: border-box;
}
.ide-test-btn {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent2);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 13px;
  padding: 0.75rem 1.1rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 0.5rem;
}
.ide-test-btn:hover { background: rgba(45, 106, 79, 0.14); }
@media (min-width: 640px) {
  .code-block { padding: 1.2rem; font-size: 12.5px; line-height: 1.65; }
  .ide-test-btn { display: inline-flex; width: auto; justify-content: flex-start; }
}

/* ---------------------------------------------------------------- */
/* "Only on desktop" inline notice for the IDE test button          */
/* ---------------------------------------------------------------- */
.ide-mobile-notice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.6rem;
  background: rgba(255, 159, 67, 0.12);
  border-left: 3px solid #ff9f43;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin: 0.6rem 0 1.2rem;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
}
.ide-mobile-notice[hidden] { display: none; }
.ide-force-btn {
  align-self: stretch;
  background: transparent;
  border: 1px solid #ff9f43;
  color: #ff9f43;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 12.5px;
  padding: 0.55rem 0.9rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}
.ide-force-btn:hover { background: rgba(255, 159, 67, 0.16); }
@media (min-width: 640px) {
  .ide-force-btn { align-self: flex-start; }
}

/* ---------------------------------------------------------------- */
/* Section eyebrow/title (site-wide convention)                     */
/* ---------------------------------------------------------------- */
.guide-section-head { margin-bottom: 0.5rem; }

/* ---------------------------------------------------------------- */
/* Registration gate (client-side only — see note in the script)    */
/* ---------------------------------------------------------------- */
/* #gatedContent sits inside the same 980px .guide-content column as
   every other section (intro, parts, step-1) and takes no padding
   of its own, so whatever markup lands here via fetch() renders at
   exactly the same width as the content that was already on the
   page — it can't drift even if the fetched fragment brings stray
   width/margin rules with it, because those are overridden below. */
#gatedContent {
  width: 100%;
  box-sizing: border-box;
}
#gatedContent > * {
  max-width: 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}
.gated-content.is-locked { display: none !important; }

.gate-teaser {
  display: none;
  background: var(--bg2);
  border: 0.5px solid rgba(45, 106, 79, 0.3);
  border-radius: 8px;
  padding: var(--card-pad);
  text-align: center;
  margin-bottom: 3rem;
}
.gate-teaser.is-visible { display: block; }
.gate-teaser h3 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 0.6rem;
  color: var(--accent2);
}
.gate-teaser p { font-size: 13.5px; color: var(--muted); line-height: 1.7; max-width: 480px; margin: 0 auto 1.4rem; }
.gate-form { display: flex; flex-direction: column; gap: 0.7rem; max-width: 320px; margin: 0 auto; }
.gate-form input {
  font-family: var(--font-body);
  font-size: 14px;
  padding: 0.7rem 0.9rem;
  border-radius: 4px;
  border: 0.5px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.gate-form button {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 14px;
  padding: 0.75rem 1.1rem;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  color: white;
  background: var(--accent);
}
.gate-error { display: none; font-size: 12.5px; color: #ff6b6b; margin-top: 0.8rem; }
.gate-error.is-visible { display: block; }
.gate-methods { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; margin-bottom: 1rem; }
.gate-method-btn {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 13.5px;
  padding: 0.7rem 1.1rem;
  border-radius: 4px;
  border: 0.5px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
}
.gate-method-btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.gate-status { font-size: 13px; color: var(--muted); line-height: 1.7; max-width: 420px; margin: 0 auto; }

/* ── Section title semantics fix ──
   .sec-title was a plain <div> sitewide (no real heading tag between the
   page's one <h1> and the <h3>s inside cards). Promoted to <h2> on this
   page; browsers give h2 a default margin that the div never had, so it's
   zeroed here to keep the existing spacing. If this gets rolled out
   sitewide, move this rule into the shared stylesheet instead. */
.sec-title { margin: 0; }


.code-wrapper {
  position: relative;
}

.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 8px 16px;
  background-color: #4CAF50;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.copy-btn:hover {
  background-color: #45a049;
}

.copy-btn.copied {
  background-color: #2196F3;
}
