/* =============================================================================
 * Periphery Guide Layout
 * -----------------------------------------------------------------------------
 * Layout primitives unique to multi-page guide pages: sidebar, sidebar-nav,
 * chapter-pager, chapter-list cards, changelog entries.
 *
 * Loaded ALONGSIDE design-system.css (which must be linked first).
 * Uses Periphery brand tokens — no duplication of base styles.
 * ============================================================================= */

/* === LAYOUT === */
body.guide-page {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}
@media (max-width: 720px) {
  body.guide-page { grid-template-columns: 1fr; }
  .guide-sidebar { position: relative; height: auto; }
}

/* === SIDEBAR === */
.guide-sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  background: var(--color-inkwell);
  color: var(--color-white);
  padding: 32px 0 24px;
  font-family: var(--font-body);
}
.guide-sidebar .sb-brand {
  padding: 0 24px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 16px;
}
.guide-sidebar .sb-eyebrow {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--color-lime);
  margin-bottom: 4px;
}
.guide-sidebar .sb-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  line-height: 1.3;
  color: var(--color-white);
}
.guide-sidebar .sb-subtitle {
  font-family: var(--font-body);
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  margin-top: 6px;
  line-height: 1.4;
}
.guide-sidebar .sb-version {
  display: inline-block;
  margin-top: 8px;
  padding: 2px 10px;
  background: rgba(255,255,255,0.12);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
}
.guide-sidebar .sb-nav-label {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.5);
  padding: 0 24px;
  margin: 24px 0 8px;
}
.guide-sidebar ol, .guide-sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.guide-sidebar li a {
  display: block;
  padding: 8px 24px 8px 28px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.4;
  border-left: 3px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.guide-sidebar li a:hover {
  color: var(--color-white);
  background: rgba(255,255,255,0.04);
}
.guide-sidebar li a.active {
  color: var(--color-white);
  background: rgba(82, 41, 211, 0.18);
  border-left-color: var(--color-purple);
  font-weight: 500;
}
.guide-sidebar .sb-counter {
  display: inline-block;
  width: 22px;
  margin-right: 8px;
  color: rgba(255,255,255,0.4);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}
.guide-sidebar .sb-tools {
  margin-top: 24px;
  padding: 24px 24px 0;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.guide-sidebar .sb-tools a {
  display: block;
  padding: 8px 0;
  color: rgba(255,255,255,0.6);
  font-size: 13px;
  text-decoration: none;
}
.guide-sidebar .sb-tools a:hover { color: var(--color-white); }
.guide-sidebar .sb-tools a.active {
  color: var(--color-white);
  font-weight: 500;
}

/* === SECTION-GROUPED SIDEBAR (used when manifest has sections:) === */
.guide-sidebar .nav-section { margin-bottom: 4px; }
.guide-sidebar .nav-section-header {
  display: flex;
  align-items: center;
  padding: 10px 24px;
  cursor: pointer;
  color: rgba(255,255,255,0.6);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  user-select: none;
}
.guide-sidebar .nav-section-header:hover { color: rgba(255,255,255,0.9); }
.guide-sidebar .nav-section-header .chevron {
  margin-left: auto;
  font-size: 10px;
  transition: transform 0.2s;
}
.guide-sidebar .nav-section.collapsed .chevron { transform: rotate(-90deg); }
.guide-sidebar .nav-section.collapsed .nav-items { display: none; }

/* === MAIN CONTENT === */
.guide-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.guide-main .header-band .eyebrow {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--color-lime);
  margin-bottom: 8px;
}
.guide-main .article {
  flex: 1;
}
.guide-main .article .lead {
  font-size: var(--fs-body-lg);
  color: var(--color-stone);
  margin-bottom: var(--space-5);
  line-height: 1.6;
}

/* === CHAPTER PAGER === */
.chapter-pager {
  display: flex;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6) var(--space-6);
  border-top: 1px solid var(--color-border);
  font-family: var(--font-body);
  gap: var(--space-4);
}
.chapter-pager a {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--color-inkwell);
  max-width: 45%;
}
.chapter-pager a:hover .pager-title { color: var(--color-purple); }
.chapter-pager .pager-label {
  font-size: 12px;
  color: var(--color-stone);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}
.chapter-pager .pager-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 16px;
}
.chapter-pager .pager-next {
  text-align: right;
  margin-left: auto;
}
.chapter-pager .pager-next .pager-title::after { content: " \2192"; }
.chapter-pager .pager-prev .pager-title::before { content: "\2190 "; }

/* === CHAPTER LIST (index page) === */
.chapter-list { margin: var(--space-5) 0; }
.chapter-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-3);
}
.chapter-card {
  background: var(--color-row-alt);
  padding: var(--space-4);
  text-decoration: none;
  color: var(--color-inkwell);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  border-top: 1px solid var(--color-inkwell);
}
.chapter-card:hover { background: var(--color-row-hover); }
.chapter-card .ch-num {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--color-stone);
}
.chapter-card .ch-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  line-height: 1.3;
}
.chapter-card .ch-desc {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--color-stone);
  line-height: 1.5;
}

/* === CHANGELOG === */
.cl-entries { margin-top: var(--space-5); }
.cl-entry {
  padding-top: var(--space-5);
  margin-top: var(--space-5);
  border-top: 1px solid var(--color-border);
}
.cl-entry:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.cl-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.cl-v {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
  color: var(--color-inkwell);
}
.cl-date {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--color-stone);
}
.cl-current {
  display: inline-block;
  padding: 2px 10px;
  background: var(--color-purple);
  color: var(--color-white);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
}
.cl-summary {
  font-size: 16px;
  margin-bottom: var(--space-3);
  color: var(--color-inkwell);
}
.cl-section { margin-bottom: var(--space-3); }
.cl-section-label {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--color-stone);
  margin-bottom: var(--space-2);
}
.cl-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.cl-section li {
  padding: var(--space-1) 0 var(--space-1) var(--space-3);
  position: relative;
  font-size: 14px;
  line-height: 1.5;
}
.cl-section li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 14px;
  width: 8px;
  height: 1px;
  background: var(--color-stone);
}

/* === FULL-FILE EMBED (collapsible "View full file" at chapter end) ===
 * V3 brand: tint only, no border, no radius. Content container, not a card. */
.file-embed {
  margin: var(--space-5) 0 var(--space-4);
  background: var(--color-row-alt);
  overflow: hidden;
}
.file-embed > summary {
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 14px;
  color: var(--color-inkwell);
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  user-select: none;
}
.file-embed > summary::-webkit-details-marker { display: none; }
.file-embed > summary::before {
  content: "▸";
  display: inline-block;
  color: var(--color-purple);
  font-size: 12px;
  transition: transform 0.15s;
}
.file-embed[open] > summary::before { transform: rotate(90deg); }
.file-embed > summary:hover { background: var(--color-row-hover); }
.file-embed > summary code {
  background: rgba(82, 41, 211, 0.08);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 13px;
}
.file-embed .file-embed-meta {
  padding: var(--space-2) var(--space-4);
  font-size: 12px;
  color: var(--color-stone);
  background: var(--color-white);
  border-top: 1px solid var(--color-border);
}
.file-embed .file-embed-meta code {
  background: transparent;
  padding: 0;
  font-size: 12px;
  color: var(--color-inkwell);
}
.file-embed .file-embed-code {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  background: #FAFAFA;
  border-top: 1px solid var(--color-border);
  max-height: 70vh;
  overflow: auto;
  font-size: 12px;
  line-height: 1.55;
  color: var(--color-inkwell);
}
.file-embed .file-embed-code code {
  background: transparent;
  padding: 0;
  color: var(--color-inkwell);
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace);
  font-size: 12px;
  white-space: pre;
  display: block;
}

/* === CALLOUT NOTE (used for "no Elmwood example yet" on health/performance) ===
 * V3 brand: tint only, no rail, no radius. Mirrors design-system.css .callout--tip. */
.callout-note {
  margin: var(--space-5) 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--color-row-alt);
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--color-inkwell);
  line-height: 1.5;
}
.callout-note strong {
  color: var(--color-inkwell);
  font-weight: 600;
}

/* === INTAKE HERO (v1.3 index callout) ===
 * V3 brand: card-ness from background tint alone. No border, no radius, no shadow.
 * Hero uses the purple tint (--color-row-alt) directly. Inner cards compose
 * design-system.css's canonical .callout .callout--{success,tip,warning} tints. */
.intake-hero {
  background: var(--color-row-alt);
  padding: var(--space-5) var(--space-5);
  margin: var(--space-2) 0 var(--space-5);
}
.intake-hero-eyebrow {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--color-inkwell);
  margin: 0 0 var(--space-2);
}
.intake-hero-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 24px;
  line-height: 1.25;
  color: var(--color-inkwell);
  margin: 0 0 var(--space-3);
  border: 0;
  padding: 0;
}
.intake-hero-title code {
  background: var(--color-white);
  padding: 2px 8px;
  font-size: 22px;
}
.intake-hero-lead {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--color-inkwell);
  margin: 0 0 var(--space-4);
  max-width: 680px;
}
.intake-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.intake-grid .callout { margin: 0; }
.intake-hero-status {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--color-stone);
  line-height: 1.55;
  margin: 0;
}
.intake-hero-status a {
  color: var(--color-inkwell);
  font-weight: 600;
  text-decoration: underline;
}

/* === IN-PROGRESS QUALIFIER ===
 * Inline marker for unbuilt skills/tools/features. Italic stone, no chrome.
 * Use directly after the first <code>/skill-name</code> mention per chapter. */
.in-progress {
  font-family: var(--font-body);
  font-style: italic;
  font-weight: 400;
  font-size: 0.85em;
  color: var(--color-stone);
  margin-left: 4px;
}

/* === Password gate (Periphery brand, sessionStorage-persistent) === */
.pw-gate {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: var(--color-inkwell);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
  color: var(--color-white);
  transition: opacity 0.25s ease;
}
.pw-gate.hidden { opacity: 0; pointer-events: none; }
.pw-gate-eyebrow {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--color-lime);
  margin: 0 0 var(--space-2);
}
.pw-gate-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  line-height: 1.3;
  color: var(--color-white);
  margin: 0 0 var(--space-1);
  text-align: center;
}
.pw-gate-sub {
  font-family: var(--font-body);
  font-size: 13px;
  color: rgba(247, 249, 242, 0.55);
  margin: 0 0 var(--space-5);
  text-align: center;
  letter-spacing: 0.02em;
}
.pw-gate input {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--color-purple);
  color: var(--color-white);
  font-family: var(--font-body);
  font-size: 16px;
  padding: 10px 4px;
  width: 280px;
  text-align: center;
  outline: none;
  letter-spacing: 0.04em;
  caret-color: var(--color-lime);
}
.pw-gate input::placeholder { color: rgba(247, 249, 242, 0.35); }
.pw-gate input:focus { border-bottom-color: var(--color-lime); }
.pw-gate-error {
  margin-top: var(--space-3);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  color: var(--color-coral);
  opacity: 0;
  transition: opacity 0.2s ease;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}
.pw-gate-error.show { opacity: 1; }

/* === PRINT === */
@media print {
  body.guide-page { grid-template-columns: 1fr; }
  .guide-sidebar { display: none; }
  .chapter-pager { display: none; }
  .file-embed[open] .file-embed-code { max-height: none; overflow: visible; }
}
