/* ════════════════════════════════════════════════════════════════
   Shared editorial layout for module pages (matches /how-it-works)
   Used by: krew, automation (Studio), coder, models, vault, guard, mesh
   ════════════════════════════════════════════════════════════════ */

.hiw-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 0;
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 var(--pad-x);
  align-items: start;
}
@media (max-width: 900px) {
  .hiw-layout { grid-template-columns: 1fr; }
  .hiw-sidebar { display: none; }
}

/* Sidebar */
.hiw-sidebar { position: sticky; top: 80px; padding: 40px 20px 40px 0; border-right: 1px solid var(--rule); }
.hiw-sidebar-label {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted-2); margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--rule);
}
.hiw-nav { list-style: none; padding: 0; margin: 0; }
.hiw-nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px;
  font-size: 13px; font-weight: 500; color: var(--muted); text-decoration: none;
  transition: color .12s, background .12s; line-height: 1.3;
}
.hiw-nav a:hover { color: var(--ink); background: var(--paper-2); }
.hiw-nav a.active { color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.hiw-nav-num { font-family: var(--font-mono); font-size: 10px; color: var(--muted-2); flex-shrink: 0; min-width: 18px; }
.hiw-nav-sep { height: 1px; background: var(--rule); margin: 8px 10px; }

/* Hero */
.hiw-hero { padding: clamp(52px,6vw,80px) var(--pad-x) clamp(28px,4vw,44px); max-width: 1140px; margin: 0 auto; }
.hiw-hero-sub { font-size: clamp(15px, 1.4vw, 17px); line-height: 1.75; color: var(--muted); max-width: 62ch; margin-bottom: 32px; }
.hiw-hero h1 { font-size: clamp(26px, 3.8vw, 42px); font-weight: 600; letter-spacing: -0.03em; line-height: 1.15; margin-bottom: 16px; }
.hiw-hero h1 em { font-family: var(--font-serif); font-weight: 400; font-style: italic; }
.hiw-jump-grid { display: flex; flex-wrap: wrap; gap: 8px; max-width: 760px; }
.hiw-jump {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border: 1px solid var(--rule);
  border-radius: 24px; font-size: 12.5px; font-weight: 500; color: var(--muted); text-decoration: none;
  transition: border-color .12s, color .12s;
}
.hiw-jump:hover { border-color: var(--accent); color: var(--accent); }
.hiw-jump-num { font-family: var(--font-mono); font-size: 10px; color: var(--muted-2); }

/* Full-width showcase between hero and body */
.krew-showcase { max-width: 1140px; margin: 8px auto 0; padding: 0 var(--pad-x) clamp(40px,5vw,64px); }
.krew-showcase .mstage-head {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; color: var(--muted-2);
  padding: 10px 2px; text-transform: none;
}
.krew-showcase .mstage-head .right { color: var(--accent); }

/* Main */
.hiw-main { padding: 52px 0 80px 44px; max-width: 720px; }
@media (max-width: 900px) { .hiw-main { padding: 36px 0 64px; max-width: 100%; } }

.hiw-back {
  display: inline-flex; align-items: center; gap: 7px; font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted-2); text-decoration: none;
  transition: color .12s; margin-bottom: 30px;
}
.hiw-back:hover { color: var(--ink); }

/* Section */
.hiw-section { margin-top: 60px; padding-top: 60px; border-top: 1px solid var(--rule); }
.hiw-section:first-of-type { border-top: none; margin-top: 0; padding-top: 0; }
.hiw-section-tag {
  display: flex; align-items: center; gap: 10px; font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); margin-bottom: 12px;
}
.hiw-section-num {
  display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px;
  border: 1px solid var(--accent); border-radius: 50%; font-size: 9px; color: var(--accent); flex-shrink: 0;
}
.hiw-section h2 { font-size: clamp(21px, 2.6vw, 28px); font-weight: 600; letter-spacing: -0.025em; line-height: 1.2; margin-bottom: 6px; }
.hiw-section h2 em, .hiw-section h2 .it { font-family: var(--font-serif); font-weight: 400; font-style: italic; }
.hiw-oneliner {
  font-size: 14px; color: var(--muted-2); font-family: var(--font-mono); letter-spacing: 0.015em;
  margin-bottom: 22px; padding-bottom: 22px; border-bottom: 1px solid var(--rule);
}
.hiw-section > p { font-size: 15px; line-height: 1.85; color: var(--muted); margin-bottom: 18px; max-width: 66ch; }
.hiw-section > p strong { color: var(--ink); font-weight: 600; }
.hiw-section > p code, .hiw-section li code { font-family: var(--font-mono); font-size: 12.5px; background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent); padding: 1px 5px; border-radius: 3px; }

/* Story card */
.story { background: var(--paper-2); border: 1px solid var(--rule); border-radius: 14px; padding: 26px 28px; margin: 24px 0 28px; }
[data-theme="ink"] .story { background: #161614; }
.story-who {
  display: flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 600; color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 14px;
}
.story-who::before { content: ''; width: 7px; height: 7px; background: var(--accent); border-radius: 50%; flex-shrink: 0; }
.story h4 { font-size: 16px; font-weight: 600; color: var(--ink); margin: 0 0 12px; line-height: 1.35; }
.story p { font-size: 14px !important; line-height: 1.8 !important; color: var(--muted) !important; margin-bottom: 10px !important; }
.story p:last-child { margin-bottom: 0 !important; }
.story strong { color: var(--ink); font-weight: 600; }
.story em { color: var(--accent); font-style: normal; font-weight: 600; }

/* Steps */
.steps { list-style: none; margin: 20px 0 28px; padding: 0; counter-reset: s; }
.steps li { display: flex; gap: 14px; align-items: flex-start; padding-bottom: 18px; position: relative; }
.steps li::before {
  counter-increment: s; content: counter(s); flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; font-family: var(--font-mono);
  display: flex; align-items: center; justify-content: center;
}
.steps li::after { content: ''; position: absolute; left: 12px; top: 30px; bottom: 0; width: 1px; background: var(--rule); }
.steps li:last-child::after { display: none; }
.step-text strong { display: block; font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: 3px; }
.step-text span { font-size: 14px; line-height: 1.7; color: var(--muted); }

/* Before / After */
.ba { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 20px 0 28px; }
@media (max-width: 540px) { .ba { grid-template-columns: 1fr; } }
.ba-box { border: 1px solid var(--rule); border-radius: 12px; padding: 18px 20px; }
.ba-box.before { background: var(--paper-2); }
.ba-box.after  { background: color-mix(in srgb, var(--accent) 7%, transparent); border-color: color-mix(in srgb, var(--accent) 28%, transparent); }
[data-theme="ink"] .ba-box.before { background: #161614; }
[data-theme="ink"] .ba-box.after  { background: #1a1730; }
.ba-head { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; margin-bottom: 12px; }
.ba-box.before .ba-head { color: var(--muted-2); }
.ba-box.after  .ba-head { color: var(--accent); }
.ba-box ul { list-style: none; margin: 0; padding: 0; }
.ba-box ul li { font-size: 13px; line-height: 1.7; color: var(--muted); padding: 2px 0 2px 18px; position: relative; }
.ba-box.before ul li::before { content: '✕'; position: absolute; left: 0; color: #e05a5a; font-size: 10px; top: 5px; }
.ba-box.after  ul li::before { content: '✓'; position: absolute; left: 0; color: #22c55e; font-size: 10px; top: 5px; }
.ba-box ul li strong { color: var(--ink); font-weight: 600; }

/* Replaces chips */
.replaces { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 32px; align-items: center; }
.replaces-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted-2); }
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 11px; background: var(--paper-2);
  border: 1px solid var(--rule); border-radius: 20px; font-size: 12px; color: var(--muted); font-weight: 500;
}
[data-theme="ink"] .chip { background: #1a1a17; }
.chip::before { content: '↳'; color: var(--muted-2); font-size: 11px; }

/* Result highlight */
.result-box {
  border-left: 3px solid var(--accent); padding: 14px 20px; background: color-mix(in srgb, var(--accent) 5%, transparent);
  border-radius: 0 10px 10px 0; margin: 16px 0 24px; font-size: 14px; line-height: 1.75; color: var(--muted);
}
[data-theme="ink"] .result-box { background: #1a1730; }
.result-box strong { color: var(--ink); font-weight: 600; }

/* Figure (an app mockup embedded in the narrative) */
.hiw-figure { margin: 26px 0 30px; }
.hiw-figure .figcap {
  display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 11px;
  color: var(--muted-2); letter-spacing: 0.02em; margin-top: 12px; line-height: 1.5;
}
.hiw-figure .figcap::before { content: ''; width: 14px; height: 1px; background: var(--accent); flex-shrink: 0; }
@media (min-width: 1024px) { .hiw-figure--wide { width: calc(100% + 168px); } }

/* Generic light frame for app mockups */
.frame { border: 1px solid var(--rule); border-radius: 12px; overflow: hidden; }
.frame-dark { background: #0E0E0C; border-color: rgba(242,239,233,0.12); }
.frame-top { display: flex; align-items: center; gap: 7px; padding: 12px 16px; border-bottom: 1px solid rgba(242,239,233,0.08); }
.frame-top .ldot { width: 9px; height: 9px; border-radius: 50%; background: rgba(242,239,233,0.18); }
.frame-top .ftitle { font-family: var(--font-mono); font-size: 11px; color: rgba(242,239,233,0.5); margin-left: 8px; }
.frame-body { color: #F2EFE9; }

/* Final CTA */
.hiw-cta { background: var(--paper-2); border: 1px solid var(--rule); border-radius: 16px; padding: 36px; text-align: center; margin-top: 64px; }
[data-theme="ink"] .hiw-cta { background: #161614; }
.hiw-cta h2 { font-size: clamp(18px,2.2vw,24px); font-weight: 600; margin: 0 0 10px; letter-spacing: -0.02em; }
.hiw-cta h2 .it { font-family: var(--font-serif); font-style: italic; font-weight: 400; }
.hiw-cta p  { font-size: 14px; color: var(--muted); margin: 0 0 22px; line-height: 1.7; }
.hiw-cta-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.cta-btn-main { display: inline-flex; align-items: center; gap: 7px; padding: 10px 22px; background: var(--accent); color: #fff; border-radius: 8px; font-size: 13px; font-weight: 600; text-decoration: none; transition: opacity .15s; }
.cta-btn-main:hover { opacity: .87; }
.cta-btn-ghost { display: inline-flex; align-items: center; gap: 7px; padding: 10px 22px; border: 1px solid var(--rule-strong); color: var(--ink); border-radius: 8px; font-size: 13px; font-weight: 500; text-decoration: none; transition: all .15s; }
.cta-btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* Print: hide chrome, keep the narrative + figures */
@media print {
  nav, .mobile-nav-drawer, .mobile-nav-overlay, .hiw-hero, .hiw-sidebar, .hiw-back, footer, .hiw-cta, .krew-showcase { display: none !important; }
  .hiw-layout { display: block !important; padding: 0 !important; }
  .hiw-main { padding: 0 !important; max-width: 100% !important; }
  .hiw-figure--wide { width: 100% !important; }
}
