/* ==========================================================================
   SAF-T NARUCHNIK - Chapter page
   Sidebar/section/subsection classes mirror how-magi-works/sidebar.css and
   sections.css (same values, --nar- naming) since this is a genuinely richer,
   documentation-style layout for the guide - not a gildiyata reskin. The
   image-placeholder and step-flow components are reused directly (imported),
   since those are generic utilities, not naruchnik-specific.
   ========================================================================== */

@import url("variables.e2ca4fec03f7.css");
@import url("../how-magi-works/components/images.a2dd47bb1340.css");
@import url("../how-magi-works/components/step-flow.9464fc1df71a.css");
@import url("components/structures.e88951168f08.css");

/* ── Page shell ──────────────────────────────────────────────────────────── */
.nar-page {
    display: flex;
    min-height: calc(100vh - var(--navbar-height, 73px));
    background: var(--hmw-bg-page);
}

.nar-main {
    flex: 1;
    min-width: 0;
    padding: 2rem 2rem 4rem;
    max-width: 900px;
}

.nar-back-link { display: inline-block; margin-bottom: 1rem; }

/* ── Sidebar (mirrors how-magi-works/sidebar.css) ───────────────────────────── */
.nar-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--hmw-blue-deep) 0%, var(--hmw-blue-dark) 55%, var(--hmw-blue-mid) 100%);
    position: sticky;
    top: var(--navbar-height, 73px);
    height: calc(100vh - var(--navbar-height, 73px));
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
    display: flex;
    flex-direction: column;
    z-index: 10;
}
.nar-sidebar::-webkit-scrollbar { width: 4px; }
.nar-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.nar-sidebar-brand { padding: 1.5rem 1.25rem 1rem; border-bottom: 1px solid rgba(255,255,255,0.1); }
.nar-sidebar-brand-link { text-decoration: none; }
.nar-sidebar-brand-title { font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: rgba(255,255,255,0.45); margin: 0; }
.nar-sidebar-brand-name { font-size: 1.05rem; font-weight: 800; color: #fff; margin: 0.2rem 0 0; line-height: 1.2; }

.nar-sidebar-nav { list-style: none; padding: 0.75rem 0; margin: 0; flex: 1; }
.nar-sidebar-nav li { margin: 0; }

.nar-sidebar-nav-link {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.65rem 1.25rem; color: rgba(255,255,255,0.65); text-decoration: none;
    font-size: 0.82rem; font-weight: 600; border-left: 3px solid transparent;
    transition: color 0.16s, background 0.16s, border-color 0.16s;
}
.nar-sidebar-nav-link:hover { color: rgba(255,255,255,0.92); background: rgba(255,255,255,0.06); }
.nar-sidebar-nav-link.active { color: #fff; background: rgba(255,255,255,0.1); border-left-color: var(--nar-item-accent, #5ba3d0); }

.nar-sidebar-step-num, .nar-sidebar-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; border-radius: 50%;
    background: rgba(255,255,255,0.12); font-size: 0.7rem; flex-shrink: 0;
    transition: background 0.16s, color 0.16s;
}
.nar-sidebar-nav-link.active .nar-sidebar-step-num { background: var(--nar-item-accent, #1a5a8e); color: #fff; }
.nar-sidebar-nav-link:hover .nar-sidebar-step-num { background: rgba(255,255,255,0.2); }
.nar-nav-label { min-width: 0; }

.nar-sidebar-chevron { font-size: 0.55rem; margin-left: auto; flex-shrink: 0; color: rgba(255,255,255,0.65); transform: rotate(90deg); }
.nar-sidebar-divider { height: 1px; background: rgba(255,255,255,0.1); margin: 0.5rem 1.25rem; }

.nar-sidebar-subnav { list-style: none; padding: 0; margin: 0; background: rgba(0,0,0,0.15); max-height: 600px; overflow: hidden; }
.nar-sublink {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.42rem 1rem 0.42rem 2.9rem; color: rgba(255,255,255,0.55); text-decoration: none;
    font-size: 0.74rem; font-weight: 500; border-left: 2px solid transparent;
    transition: color 0.14s, background 0.14s;
}
.nar-sublink:hover { color: rgba(255,255,255,0.9); background: rgba(255,255,255,0.05); border-left-color: rgba(255,255,255,0.3); }
.nar-sublink-num { font-size: 0.62rem; font-weight: 800; color: rgba(255,255,255,0.35); flex-shrink: 0; min-width: 16px; }

.nar-sidebar-footer { padding: 1rem 1.25rem 1.5rem; border-top: 1px solid rgba(255,255,255,0.1); }
.nar-sidebar-cta {
    display: flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.6rem 1rem; background: linear-gradient(135deg, var(--hmw-blue-mid), var(--hmw-blue-bright));
    color: #fff; border-radius: 8px; text-decoration: none; font-size: 0.8rem; font-weight: 700;
    transition: opacity 0.16s, transform 0.16s;
}
.nar-sidebar-cta:hover { opacity: 0.9; transform: translateY(-1px); color: #fff; }

@media (max-width: 1100px) {
    .nar-sidebar { width: 56px; }
    .nar-sidebar-brand, .nar-sidebar-footer { display: none; }
    .nar-sidebar-nav-link { padding: 0.75rem; justify-content: center; border-left: none; border-bottom: 3px solid transparent; }
    .nar-sidebar-nav-link.active { border-left: none; border-bottom-color: var(--nar-item-accent, #5ba3d0); }
    .nar-nav-label { display: none; }
    .nar-sidebar-subnav { display: none; }
    .nar-sidebar-chevron { display: none; }
}
@media (max-width: 768px) {
    .nar-page { flex-direction: column; }
    .nar-sidebar { display: none; }
    .nar-main { padding: 1.25rem 1rem 3rem; max-width: 100%; }
}

/* ── Chapter hero ────────────────────────────────────────────────────────── */
.nar-chapter-hero {
    display: flex; align-items: stretch; gap: 1.5rem;
    background: white; border-radius: 20px; overflow: hidden;
    box-shadow: 0 4px 24px rgba(10,37,64,0.08), 0 1px 4px rgba(10,37,64,0.05);
    border: 1px solid rgba(255,255,255,0.6);
    margin-bottom: 1.5rem;
}
.nar-chapter-hero-text { flex: 1; min-width: 0; padding: 1.75rem; display: flex; flex-direction: column; justify-content: center; }
.nar-chapter-hero-eyebrow {
    display: inline-block; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase;
    color: var(--nar-accent, var(--hmw-blue-mid)); margin-bottom: 0.6rem;
}
.nar-chapter-hero-title { font-size: 1.5rem; font-weight: 800; color: var(--hmw-text-dark); margin: 0 0 0.6rem; line-height: 1.25; }
.nar-chapter-hero-title i { color: var(--nar-accent, var(--hmw-blue-mid)); margin-right: 0.5rem; }
.nar-chapter-hero-dek { color: var(--hmw-text); font-size: 0.95rem; line-height: 1.6; margin: 0; }
.nar-chapter-hero-image { flex: 0 0 300px; overflow: hidden; }
.nar-chapter-hero-image .hmw-img-placeholder { height: 100%; aspect-ratio: unset; border-radius: 0; margin: 0; color: var(--nar-accent, var(--hmw-blue-light)); }
.nar-chapter-hero-image img { width: 100%; height: 100%; object-fit: cover; display: block; }

@media (max-width: 860px) {
    .nar-chapter-hero { flex-direction: column; }
    .nar-chapter-hero-image { flex: none; height: 160px; }
}

/* ── Stat strip ──────────────────────────────────────────────────────────── */
.nar-stat-strip {
    display: flex; align-items: center; gap: 1.75rem; flex-wrap: wrap;
    background: white; border: 1px solid var(--hmw-border-soft);
    border-left: 3px solid var(--nar-accent, var(--hmw-blue-mid));
    border-radius: 14px; padding: 1rem 1.5rem; margin-bottom: 1.75rem;
    box-shadow: 0 2px 12px rgba(10,37,64,0.05);
}
.nar-stat-num { font-size: 1.4rem; font-weight: 800; color: var(--hmw-text-dark); line-height: 1.1; }
.nar-stat-lbl { font-size: 0.68rem; color: var(--hmw-text-muted); margin-top: 0.2rem; max-width: 140px; line-height: 1.35; }
.nar-stat-types { display: flex; gap: 0.25rem; }
.nar-type-pill {
    width: 24px; height: 24px; border-radius: 7px; display: flex; align-items: center; justify-content: center;
    font-size: 0.68rem; font-weight: 800;
    background: color-mix(in srgb, var(--nar-accent, var(--hmw-blue-mid)) 15%, transparent);
    color: var(--nar-accent, var(--hmw-blue-mid));
}
.nar-stat-link { margin-left: auto; font-size: 0.78rem; font-weight: 700; color: var(--nar-accent, var(--hmw-blue-mid)); text-decoration: none; white-space: nowrap; }
.nar-stat-link:hover { text-decoration: underline; }

/* ── Body prose ──────────────────────────────────────────────────────────── */
.nar-body { line-height: 1.7; color: var(--hmw-text-body); }
.nar-body > p:first-child { font-size: 1rem; color: var(--hmw-text-body); }
.nar-body table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: 0.85rem; }
.nar-body th, .nar-body td { border: 1px solid var(--hmw-border); padding: 0.5rem 0.65rem; text-align: left; }
.nar-body th { background: var(--hmw-bg-soft); color: var(--hmw-text-dark); font-weight: 700; }
.nar-body code {
    background: #eef4fb; color: var(--hmw-blue-mid); border: 1px solid var(--hmw-border-blue);
    border-radius: 4px; padding: 0.15em 0.4em; font-size: 0.9em;
}
.nar-body pre { background: #f1f5f9; padding: 0.9rem; border-radius: 8px; overflow-x: auto; }
.nar-body pre code { background: none; border: none; padding: 0; }
.nar-body blockquote { border-left: 3px solid var(--nar-purple); padding-left: 0.9rem; color: var(--hmw-text-muted); margin: 0.9rem 0; }

/* ── Section cards (built client-side from ## headings) ─────────────────── */
.nar-section {
    background: white; border-radius: 16px; overflow: hidden;
    box-shadow: 0 4px 20px rgba(10,37,64,0.06), 0 1px 4px rgba(10,37,64,0.04);
    border: 1px solid rgba(255,255,255,0.7);
    margin: 0 0 1.5rem;
    scroll-margin-top: 90px;
}
.nar-section-header { display: flex; align-items: center; gap: 0.9rem; padding: 1.1rem 1.5rem; border-bottom: 1px solid var(--hmw-bg-page); background: white; }
.nar-section-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 50%;
    background: linear-gradient(135deg, var(--hmw-blue-deep), var(--hmw-blue-mid));
    color: white; font-size: 0.75rem; font-weight: 800; flex-shrink: 0;
}
.nar-section-title { font-size: 1.05rem; font-weight: 800; color: var(--hmw-text-dark); margin: 0; line-height: 1.25; }
.nar-section-body { padding: 1.5rem; }
.nar-section-body p { margin: 0 0 0.85rem; }
.nar-section-body > p:last-child { margin-bottom: 0; }

/* ── Subsections (built client-side from ### headings) ──────────────────── */
.nar-subsection { border-top: 1px solid var(--hmw-bg-page); margin-top: 1rem; padding-top: 1rem; }
.nar-subsection:first-child { border-top: none; margin-top: 0; padding-top: 0; }
.nar-subsection-header { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.6rem; }
.nar-subsection-num {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.15rem 0.5rem; background: var(--hmw-bg-soft); color: var(--hmw-blue-mid);
    border-radius: 6px; font-size: 0.66rem; font-weight: 800; border: 1px solid var(--hmw-border-blue);
}
.nar-subsection-title { font-size: 0.92rem; font-weight: 700; color: var(--hmw-text-dark); margin: 0; }
.nar-subsection-body p { margin: 0 0 0.75rem; }

/* ── Admonition callout boxes (from markdown `!!! type "Title"` blocks) ── */
.nar-body .admonition {
    position: relative; margin: 1.1rem 0; padding: 0.85rem 1rem 0.85rem 2.7rem;
    border-radius: 10px; border: 1px solid; font-size: 0.88rem; line-height: 1.6;
}
.nar-body .admonition p:last-child { margin-bottom: 0; }
.nar-body .admonition-title { font-weight: 800; margin-bottom: 0.35rem !important; letter-spacing: 0.01em; }
.nar-body .admonition::before { font-family: "Font Awesome 6 Free"; font-weight: 900; position: absolute; left: 0.85rem; top: 0.9rem; font-size: 1rem; }

.nar-body .admonition.note, .nar-body .admonition.info { background: var(--hmw-blue-info-bg); border-color: var(--hmw-blue-info-border); color: #075985; }
.nar-body .admonition.note .admonition-title, .nar-body .admonition.info .admonition-title { color: #1d4ed8; }
.nar-body .admonition.note::before, .nar-body .admonition.info::before { content: "\f05a"; color: #3b82f6; }

.nar-body .admonition.tip, .nar-body .admonition.hint { background: var(--hmw-green-bg); border-color: var(--hmw-green-border); color: #166534; }
.nar-body .admonition.tip .admonition-title, .nar-body .admonition.hint .admonition-title { color: var(--hmw-green-dark); }
.nar-body .admonition.tip::before, .nar-body .admonition.hint::before { content: "\f0eb"; color: var(--hmw-green); }

.nar-body .admonition.warning { background: var(--hmw-yellow-bg); border-color: var(--hmw-yellow-border); color: #9a3412; }
.nar-body .admonition.warning .admonition-title { color: var(--hmw-yellow-dark); }
.nar-body .admonition.warning::before { content: "\f071"; color: var(--hmw-yellow); }

.nar-body .admonition.danger, .nar-body .admonition.important { background: var(--nar-red-bg); border-color: var(--nar-red-border); color: var(--nar-red-text); }
.nar-body .admonition.danger .admonition-title, .nar-body .admonition.important .admonition-title { color: var(--hmw-red-dark); }
.nar-body .admonition.danger::before, .nar-body .admonition.important::before { content: "\f06a"; color: var(--hmw-red); }

.nar-body .admonition.example { background: var(--nar-purple-bg); border-color: var(--nar-purple-border); color: #5b21b6; }
.nar-body .admonition.example .admonition-title { color: var(--nar-purple-dark); }
.nar-body .admonition.example::before { content: "\f121"; color: var(--nar-purple); }

/* ── Prev / next nav ─────────────────────────────────────────────────────── */
/* ── Supplementary explainer diagram (see chapter_diagram_url) ──────────── */
.nar-diagram {
    background: white; border: 1px solid var(--hmw-border-soft); border-radius: 16px;
    padding: 1rem; margin: 0 0 1.5rem;
    box-shadow: 0 4px 20px rgba(10,37,64,0.06);
}
.nar-diagram img { width: 100%; height: auto; display: block; }
.nar-diagram--inline { margin-top: 1.25rem; }

.nar-chapter-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 2rem 0 1.5rem; }
.nar-nav-link {
    display: flex; align-items: center; gap: 0.65rem; padding: 1rem 1.2rem; border-radius: 12px;
    background: white; border: 1px solid var(--hmw-border-soft); color: var(--hmw-text-dark);
    text-decoration: none; transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
    font-size: 0.86rem; font-weight: 700;
}
.nar-nav-link:hover { border-color: var(--hmw-blue-light); box-shadow: 0 6px 18px rgba(10,37,64,0.08); color: var(--hmw-text-dark); }
.nar-nav-link small { display: block; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--hmw-text-muted); margin-bottom: 0.15rem; }
.nar-nav-prev:hover { transform: translateX(-2px); }
.nar-nav-next { grid-column: 2; justify-content: flex-end; text-align: right; }
.nar-nav-next:hover { transform: translateX(2px); }
.nar-nav-next i { order: 2; }

@media (max-width: 640px) {
    .nar-chapter-nav { grid-template-columns: 1fr; }
    .nar-nav-next { grid-column: 1; }
}

/* ── In-product CTA (see _cta_strip.html) ───────────────────────────────── */
.nar-cta {
    margin: 1.5rem 0 0;
    background: linear-gradient(135deg, var(--hmw-blue-deep) 0%, var(--hmw-blue-dark) 60%, #0e4a6e 100%);
    border-radius: 18px; padding: 2rem 2.25rem 2.25rem; color: white;
    position: relative; overflow: hidden;
}
.nar-cta-header { display: flex; align-items: center; gap: 12px; margin-bottom: 0.9rem; }
.nar-cta-icon {
    flex-shrink: 0; width: 46px; height: 46px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.22);
    color: white;
}
.nar-cta-icon svg { width: 23px; height: 23px; }
.nar-cta-eyebrow { font-size: 0.78rem; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; color: var(--hmw-blue-light); }
.nar-cta-title { font-size: 1.3rem; font-weight: 800; color: white; margin: 0 0 1rem; line-height: 1.3; }
.nar-cta-features { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.35rem; }
.nar-cta-feature {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 12px; border-radius: 999px;
    background: rgba(255,255,255,0.09); border: 1px solid rgba(255,255,255,0.15);
    font-size: 0.77rem; font-weight: 600; color: rgba(255,255,255,0.88);
}
.nar-cta-feature i { color: var(--hmw-blue-light); font-size: 0.7rem; }
.nar-cta-body { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; }
.nar-cta-sub { flex: 1; min-width: 200px; color: rgba(255,255,255,0.72); font-size: 0.88rem; line-height: 1.65; margin: 0; }
.nar-cta-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 0.55rem; flex-shrink: 0; }
.nar-cta-btn {
    background: white; color: var(--hmw-blue-deep); padding: 0.68rem 1.4rem;
    border-radius: 10px; font-weight: 800; text-decoration: none; font-size: 0.86rem;
    white-space: nowrap; transition: transform 0.16s, box-shadow 0.16s;
}
.nar-cta-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0,0,0,0.22); color: var(--hmw-blue-deep); }
.nar-cta-about { font-size: 0.78rem; color: rgba(255,255,255,0.5); text-decoration: none; white-space: nowrap; display: flex; align-items: center; gap: 4px; transition: color 0.14s; }
.nar-cta-about:hover { color: rgba(255,255,255,0.82); }
.nar-cta-about i { font-size: 0.7rem; }

@media (max-width: 640px) {
    .nar-cta { padding: 1.75rem 1.5rem; }
    .nar-cta-title { font-size: 1.1rem; }
    .nar-cta-body { flex-direction: column; align-items: flex-start; gap: 1rem; }
    .nar-cta-actions { flex-direction: row; align-items: center; }
}
