/* ============================================================================
   ZakERP site - inner page components.
   Used by Why / ERP 101 / the product tour and, from phase 2, every chapter of
   the user manual. Long-form reading is the priority here: measured line
   length, calm rhythm, and a printed page that still makes sense.
   ========================================================================== */

/* ------------------------------------------------------------- page hero -- */
.page-hero {
    position: relative; overflow: hidden;
    padding-top: calc(var(--nav-h) + clamp(2.4rem, 1.4rem + 3vw, 4.2rem));
    padding-bottom: clamp(2.4rem, 1.6rem + 3vw, 3.8rem);
    border-bottom: 1px solid var(--border);
    background: var(--bg-2);
}
.page-hero .glow-blob { width: 560px; height: 560px; top: -300px; right: -120px; background: rgba(108, 99, 255, .26); }
.page-hero .wrap, .page-hero .wrap-narrow { position: relative; z-index: 1; }
.page-hero h1 { font-size: clamp(2rem, 1.4rem + 2.4vw, 3.2rem); margin: .9rem 0 1rem; }
.page-hero .lead { max-width: 46rem; }
.page-hero .meta { margin-top: 1.6rem; display: flex; flex-wrap: wrap; gap: .6rem; }

/* ------------------------------------------------------------ breadcrumb -- */
.crumb { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; font-size: .84rem; color: var(--ink-3); }
.crumb a { color: var(--ink-2); }
.crumb a:hover { color: var(--brand-light); }
.crumb i { font-size: .7rem; opacity: .6; }

/* ----------------------------------------------------- two-column layout -- */
.page-layout {
    display: grid; gap: clamp(2rem, 1rem + 3vw, 3.4rem);
    grid-template-columns: 250px minmax(0, 1fr);
    align-items: start;
    padding-block: clamp(2.6rem, 1.6rem + 3vw, 4.5rem);
}
@media (max-width: 940px) { .page-layout { grid-template-columns: 1fr; } }
/* Grid items default to min-width:auto, so one wide element - a 560px table -
   sets the column's minimum and pushes the whole page off a phone screen.
   Letting the items shrink hands the overflow back to the scroll containers
   that were built for it (.table-wrap, .fig-box, .code). */
.page-layout > * { min-width: 0; }

/* ------------------------------------------------------- table of contents */
.toc { position: sticky; top: calc(var(--nav-h) + 1.4rem); }
.toc h5 {
    font-family: var(--font); font-size: .74rem; letter-spacing: .13em; text-transform: uppercase;
    color: var(--ink-3); margin-bottom: .9rem; font-weight: 700;
}
.toc ul { list-style: none; padding: 0; display: grid; gap: .1rem; border-left: 1px solid var(--border); }
.toc a {
    display: block; padding: .42rem .9rem; margin-left: -1px;
    border-left: 2px solid transparent; font-size: .89rem; color: var(--ink-2);
    transition: color .2s, border-color .2s;
}
.toc a:hover { color: var(--ink); }
.toc a.active { color: var(--brand-light); border-left-color: var(--brand); font-weight: 600; }
:root[data-theme="light"] .toc a.active { color: var(--brand-dark); }
@media (max-width: 940px) {
    .toc { position: static; border: 1px solid var(--border); border-radius: var(--r); padding: 1.1rem 1.2rem; background: var(--surface); }
    .toc ul { border-left: 0; }
    .toc a { border-left: 0; padding: .34rem 0; }
}

/* ----------------------------------------------------------------- prose -- */
.prose { max-width: 46rem; }
.prose > * + * { margin-top: 1.15rem; }
.prose h2 {
    font-size: clamp(1.5rem, 1.2rem + 1.1vw, 2rem);
    margin-top: 3.4rem; margin-bottom: .2rem; scroll-margin-top: calc(var(--nav-h) + 1.6rem);
}
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-size: 1.18rem; margin-top: 2.2rem; margin-bottom: .1rem; scroll-margin-top: calc(var(--nav-h) + 1.6rem); }
.prose p { font-size: 1.02rem; line-height: 1.78; }
.prose strong { color: var(--ink); font-weight: 600; }
.prose a:not(.btn) { color: var(--brand-light); border-bottom: 1px solid color-mix(in srgb, var(--brand) 45%, transparent); }
:root[data-theme="light"] .prose a:not(.btn) { color: var(--brand-dark); }
.prose a:not(.btn):hover { border-bottom-color: currentColor; }
.prose ul, .prose ol { padding-left: 1.35rem; display: grid; gap: .6rem; }
.prose li { color: var(--ink-2); line-height: 1.72; }
.prose li::marker { color: var(--brand-light); }
.prose blockquote {
    border-left: 3px solid var(--brand); padding: .2rem 0 .2rem 1.3rem;
    font-size: 1.06rem; line-height: 1.7; color: var(--ink); font-style: italic;
}
.prose hr { height: 1px; background: var(--border); border: 0; margin-block: 2.6rem; }
.prose .code { margin-block: 1.6rem; }
.prose figure { margin-block: 2rem; }

/* the little pilcrow that appears on hover next to a heading */
.prose h2 a.anchor, .prose h3 a.anchor {
    opacity: 0; margin-left: .45rem; color: var(--ink-3); font-size: .7em;
    border: 0; transition: opacity .2s;
}
.prose h2:hover a.anchor, .prose h3:hover a.anchor { opacity: 1; }

/* -------------------------------------------------------------- callouts -- */
.note {
    display: grid; grid-template-columns: auto 1fr; gap: .9rem;
    padding: 1.1rem 1.25rem; border-radius: var(--r);
    background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--brand);
    margin-block: 1.6rem;
}
.note i { font-size: 1.15rem; color: var(--brand-light); margin-top: .12rem; }
.note p { margin: 0; font-size: .96rem; }
.note p + p { margin-top: .6rem; }
.note b { color: var(--ink); }
:root[data-theme="light"] .note i { color: var(--brand-dark); }

.note.tip     { border-left-color: var(--mint); }
.note.tip i   { color: var(--mint); }
.note.warn    { border-left-color: var(--amber); }
.note.warn i  { color: var(--amber); }
.note.stop    { border-left-color: var(--rose); }
.note.stop i  { color: var(--rose); }

/* --------------------------------------------------------------- figures -- */
figure.fig { margin-block: 2.2rem; }
figure.fig .fig-box {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
    padding: 1.6rem 1.4rem; overflow-x: auto;
}
:root[data-theme="light"] figure.fig .fig-box { box-shadow: var(--shadow-sm); }
figure.fig svg { margin-inline: auto; max-width: 100%; height: auto; }
figure.fig figcaption {
    margin-top: .85rem; font-size: .87rem; color: var(--ink-3); text-align: center; line-height: 1.6;
}
/* On a phone a full-width diagram would scale down to about 40%, which makes
   its labels too small to read. Hold it at a legible size instead and let the
   box scroll sideways - swiping a diagram beats squinting at one. */
@media (max-width: 700px) {
    figure.fig svg { min-width: 520px; }
    figure.fig .fig-box { -webkit-overflow-scrolling: touch; }
    figure.fig figcaption::after {
        content: " · swipe the diagram sideways to see all of it";
        color: var(--ink-3); font-style: italic;
    }
}
/* diagram colours driven by the theme, so one SVG works in both */
.dia-fill      { fill: var(--surface-2); }
.dia-stroke    { stroke: var(--border-strong); }
.dia-brand     { fill: var(--brand); }
.dia-brand-s   { stroke: var(--brand); }
.dia-text      { fill: var(--ink); font-family: var(--font); font-size: 13px; font-weight: 600; }
.dia-sub       { fill: var(--ink-3); font-family: var(--font); font-size: 11px; }
.dia-line      { stroke: var(--border-strong); fill: none; }

/* ----------------------------------------------------------- data tables -- */
.prose table, table.data {
    width: 100%; border-collapse: collapse; margin-block: 1.6rem;
    font-size: .94rem; background: var(--surface); border-radius: var(--r); overflow: hidden;
}
.prose th, table.data th {
    text-align: left; padding: .8rem 1rem; background: var(--surface-2);
    font-family: var(--font-head); font-size: .86rem; color: var(--ink); border-bottom: 1px solid var(--border);
}
.prose td, table.data td { padding: .8rem 1rem; border-bottom: 1px solid var(--border); color: var(--ink-2); vertical-align: top; }
.prose tr:last-child td, table.data tr:last-child td { border-bottom: 0; }
.prose td strong { color: var(--ink); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r); margin-block: 1.6rem; }
.table-wrap table { margin: 0; border: 0; min-width: 560px; }

/* -------------------------------------------------------------- glossary -- */
.glossary { display: grid; gap: 0; margin-block: 1.6rem; }
.glossary div {
    display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 1.2rem;
    padding: 1rem 0; border-bottom: 1px solid var(--border);
}
.glossary div:last-child { border-bottom: 0; }
.glossary dt { font-weight: 600; color: var(--ink); font-size: .97rem; }
.glossary dd { margin: 0; color: var(--ink-2); font-size: .96rem; line-height: 1.7; }
@media (max-width: 620px) { .glossary div { grid-template-columns: 1fr; gap: .3rem; } }

/* ------------------------------------------------------- numbered blocks -- */
.big-points { display: grid; gap: 2.4rem; counter-reset: bp; }
.big-point { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 1.5rem; }
.big-point .bp-n {
    counter-increment: bp; width: 52px; height: 52px; border-radius: 15px; flex-shrink: 0;
    display: grid; place-items: center; font-family: var(--font-head); font-weight: 700; font-size: 1.15rem;
    background: var(--grad-brand); color: #fff; box-shadow: var(--glow);
}
.big-point .bp-n::before { content: "0" counter(bp); }
.big-point h3 { margin-bottom: .5rem; }
.big-point p { font-size: 1rem; line-height: 1.75; }
.big-point p + p { margin-top: .8rem; }
@media (max-width: 620px) { .big-point { grid-template-columns: 1fr; gap: .9rem; } }

/* ------------------------------------------------------- fit / not a fit -- */
.fit-grid { display: grid; gap: 1.4rem; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.fit-col { border-radius: var(--r-lg); border: 1px solid var(--border); padding: 1.8rem; background: var(--surface); }
.fit-col h4 { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.1rem; }
.fit-col.yes { border-color: color-mix(in srgb, var(--mint) 30%, transparent); }
.fit-col.yes h4 i { color: var(--mint); }
.fit-col.nope h4 i { color: var(--ink-3); }
.fit-col ul { list-style: none; padding: 0; display: grid; gap: .75rem; }
.fit-col li { display: flex; gap: .7rem; font-size: .95rem; color: var(--ink-2); line-height: 1.6; }
.fit-col li i { margin-top: .22rem; flex-shrink: 0; font-size: .9rem; }
.fit-col.yes li i { color: var(--mint); }
.fit-col.nope li i { color: var(--ink-3); }

/* ---------------------------------------------------------- page footer -- */
.page-nav {
    display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    margin-top: 3.6rem; padding-top: 2rem; border-top: 1px solid var(--border);
}
.page-nav a {
    display: block; padding: 1.1rem 1.3rem; border-radius: var(--r);
    border: 1px solid var(--border); background: var(--surface);
    transition: border-color .25s, transform .25s var(--ease), background .25s;
}
.page-nav a:hover { border-color: var(--border-strong); transform: translateY(-2px); background: var(--surface-2); }
.page-nav span { display: block; font-size: .76rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); margin-bottom: .3rem; }
.page-nav b { font-family: var(--font-head); font-size: 1rem; color: var(--ink); }
.page-nav a.next { text-align: right; }

/* ------------------------------------------------------------- print ---- */
@media print {
    .toc, .page-nav, .crumb, .page-hero .meta { display: none !important; }
    .page-layout { grid-template-columns: 1fr; padding-block: 0; }
    .page-hero { background: none; border-bottom: 1px solid #ccc; padding-top: 0; }
    .prose { max-width: none; }
    .prose h2, .prose h3 { break-after: avoid; }
    .note, figure.fig, .big-point, table { break-inside: avoid; }
    .dia-text { fill: #000; }
    .dia-sub { fill: #444; }
}
