/* ===== Guide / Pomoc page — chaptered redesign, built on styles.css tokens =====
   Page-scoped: loaded only by /guide/index.html. Uses styles.css variables;
   never overrides global rules except the local section-padding reset on .guide-chapter.
   ============================================================================ */

/* ---------- Hero ---------- */
.guide-hero { padding: calc(var(--header-h) + 56px) 0 44px; background: var(--bg-ice); text-align: center; }
.guide-hero .container { max-width: 840px; }
.guide-hero h1 { font-size: clamp(2.1rem, 4.4vw, 3.3rem); line-height: 1.08; letter-spacing: -0.02em; margin: 18px 0 16px; }
.guide-lead { font-size: 1.12rem; color: var(--muted); line-height: 1.7; margin: 0 auto 28px; max-width: 680px; }

/* ---------- Two-column layout: grouped sticky TOC + chapter stack ---------- */
.guide-layout { display: grid; grid-template-columns: 268px minmax(0, 1fr); gap: 52px; max-width: var(--container); margin: 0 auto; padding: 24px 24px var(--section-pad); align-items: start; }

/* grouped sticky TOC — matches the blog "Tematy" catalog (card surface, flat active state) */
.guide-toc { position: sticky; top: calc(var(--header-h) + 22px); align-self: start; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-card-rest); padding: 18px 14px; }
.guide-toc-part { margin: 0 0 10px; padding-left: 12px; font-family: var(--font-label); font-size: 0.74rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.guide-toc-part:not(:first-of-type) { margin-top: 18px; }
.guide-toc ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.guide-toc a { display: flex; align-items: baseline; gap: 11px; padding: 8px 12px; border-radius: 11px; color: var(--ink-soft); text-decoration: none; font-family: var(--font-label); font-size: 0.92rem; font-weight: 600; transition: background var(--transition), color var(--transition); }
.guide-toc a:hover { background: var(--bg-ice); color: var(--ink); }
.guide-toc a.is-active { background: var(--bg-ice); color: var(--accent); }
.guide-toc a .num { font-family: var(--font-mono); font-size: 0.76rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.guide-toc a.is-active .num { color: var(--accent); }
/* catalog toggle button — desktop hidden, shown as collapsible menu on mobile */
.guide-toc-toggle { display: none; }
/* the fixed bottom clone is mobile-only — hidden everywhere until the media query below shows it */
.guide-toc-docked { display: none; }

/* tabbed views: JS reveals one chapter at a time; without JS the full page stays readable */
.guide-layout.is-tabbed .guide-chapter[hidden] { display: none; }

/* subtle fade + slide-in each time a chapter becomes the active view */
@keyframes guide-chapter-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.guide-layout.is-tabbed .guide-chapter:not([hidden]) { animation: guide-chapter-in 190ms ease-out; }

@media (prefers-reduced-motion: reduce) {
    .guide-layout.is-tabbed .guide-chapter:not([hidden]) { animation: none; }
    .guide-toc, .guide-toc-docked { transition: none; }
}

/* ---------- Chapter: the contained "room" ---------- */
.guide-content { min-width: 0; display: flex; flex-direction: column; gap: 30px; }
.guide-chapter { padding: 0; scroll-margin-top: 104px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-panel); box-shadow: var(--shadow-card); overflow: hidden; }

/* chapter header band — the unmistakable "start" */
.guide-chapter-head { display: flex; align-items: center; gap: 20px; padding: 16px 36px; border-bottom: 1px solid var(--border); }
.guide-chapter-num { flex-shrink: 0; width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; background: var(--lime); color: var(--lime-ink); border-radius: 16px; font-family: var(--font-display); font-weight: 700; font-size: 1.55rem; letter-spacing: -0.02em; box-shadow: 0 6px 16px rgba(15, 21, 46, .14); }
.guide-chapter--staff .guide-chapter-num { background: var(--card-amber); color: #fff; }
.guide-chapter-eyebrow { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); font-weight: 600; display: block; margin-bottom: 4px; }
.guide-chapter--staff .guide-chapter-eyebrow { color: var(--card-amber); }
.guide-chapter-head h2 { font-size: clamp(1.45rem, 2.6vw, 2rem); line-height: 1.12; letter-spacing: -0.01em; }

/* chapter body */
.guide-chapter-body { padding: 28px 36px 34px; }
.guide-intro { font-size: 1.02rem; color: var(--muted); line-height: 1.7; margin-bottom: 26px; max-width: 62ch; }

/* sub-section group (keeps the h3 + its anchor id) */
.guide-group { scroll-margin-top: 104px; padding-top: 26px; margin-top: 26px; border-top: 2px solid var(--border); }
.guide-group:first-of-type { padding-top: 0; margin-top: 0; border-top: none; }
.guide-group > h3 { font-size: 1.2rem; margin-bottom: 18px; display: flex; align-items: baseline; gap: 10px; }
.guide-group > h3 .gnum { font-family: var(--font-mono); font-size: 0.82rem; color: var(--accent); font-weight: 600; }

/* step: one labelled block (text + screenshot), delimited from the next */
.guide-step { padding-top: 22px; margin-top: 22px; border-top: 1px dashed var(--border); }
.guide-step:first-child, .guide-group > .guide-step:first-of-type { padding-top: 0; margin-top: 0; border-top: none; }
.guide-step-label { display: inline-flex; align-items: center; gap: 9px; font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink); font-weight: 600; margin-bottom: 15px; }
.guide-step-label .tag { background: var(--accent); color: #fff; padding: 3px 9px; border-radius: 6px; letter-spacing: 0.04em; }
.guide-step-body { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 40px; align-items: start; }
.guide-step--flip .guide-step-body { grid-template-columns: 240px minmax(0, 1fr); }
.guide-step--flip .guide-step-shot { order: -1; }
.guide-step--full .guide-step-body { grid-template-columns: minmax(0, 1fr); }

/* numbered steps + bullet lists */
.guide-steps { list-style: none; display: flex; flex-direction: column; gap: 16px; counter-reset: step; }
.guide-steps li { position: relative; padding-left: 46px; counter-increment: step; line-height: 1.6; }
.guide-steps li::before { content: counter(step); position: absolute; left: 0; top: -1px; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; background: var(--accent); color: #fff; border-radius: 50%; font-family: var(--font-display); font-weight: 700; font-size: 0.88rem; }
.guide-steps li strong, .guide-list li strong { color: var(--ink); }
.guide-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.guide-list li { position: relative; padding-left: 20px; line-height: 1.6; }
.guide-list li::before { content: '\2013'; position: absolute; left: 0; top: 0; color: var(--muted); }
.ui { font-family: var(--font-mono); font-size: 0.82em; background: var(--bg-ice); color: var(--accent); padding: 1px 7px; border-radius: 6px; white-space: nowrap; }

/* phone screenshot */
.guide-step-shot { position: sticky; top: 100px; }
.guide-phone { background: var(--ink); border-radius: 30px; padding: 8px; width: 100%; max-width: 240px; margin: 0 auto; box-shadow: 0 18px 40px rgba(15, 21, 46, .22); }
.guide-phone img { display: block; width: 100%; height: auto; border-radius: 22px; }
.guide-step-shot figcaption { text-align: center; margin-top: 11px; font-size: 0.8rem; color: var(--muted); }

/* typed callouts (tip / warn / note) */
.guide-callout { display: flex; gap: 13px; padding: 15px 18px; border-radius: 12px; margin-top: 22px; border: 1px solid var(--border); }
.guide-callout p { font-size: 0.93rem; color: var(--ink-soft); margin: 0; }
.guide-callout strong { color: var(--ink); }
.guide-callout a { color: var(--accent); font-weight: 600; }
.guide-callout .ic { flex-shrink: 0; width: 22px; height: 22px; margin-top: 1px; }
.guide-callout--tip { background: #F7FAE3; border-color: rgba(150, 165, 40, .45); }
.guide-callout--tip .ic { color: #6c7a16; }
.guide-callout--warn { background: #FBF1E8; border-color: rgba(186, 118, 69, .40); }
.guide-callout--warn .ic { color: var(--card-amber); }
.guide-callout--note { background: var(--bg-ice); border-color: rgba(32, 42, 115, .25); }
.guide-callout--note .ic { color: var(--accent); }

/* role / permissions table */
.guide-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-card); margin-bottom: 6px; -webkit-overflow-scrolling: touch; }
.guide-table { width: 100%; border-collapse: collapse; min-width: 540px; background: var(--bg-card); }
.guide-table th, .guide-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.guide-table thead th { background: var(--bg-ice); color: var(--ink); font-weight: 700; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.04em; text-align: center; }
.guide-table thead th:first-child { text-align: left; }
.guide-table td:first-child { font-weight: 600; color: var(--ink); }
.guide-table td.cell { text-align: center; }
.guide-table td.yes { color: var(--success); font-weight: 700; }
.guide-table td.no { color: var(--muted); }
.guide-table tbody tr:last-child td { border-bottom: none; }

/* scroll hint above the table — shown only on narrow screens where the table overflows (rules in @media 540) */
.scroll-hint { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
    .guide-layout { grid-template-columns: 1fr; gap: 0; }

    /* On load: an inline white card above the chapters (collapsible, opens downward) */
    .guide-toc { position: static; align-self: stretch; margin-bottom: 24px; padding: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-card); transition: opacity .25s ease; }
    .guide-toc.is-replaced { opacity: 0; pointer-events: none; }   /* faded out (still in flow → no reflow) as the docked pill takes over at the nav line */
    body { padding-bottom: 84px; }   /* page-scoped (guide.css loads only here): keeps the docked pill clear of the footer */

    /* Separate JS-cloned pill: always fixed bottom-center, dark, opens upward. Hidden until the
       inline TOC scrolls off; .is-visible fades + slides it in/out — only paint props move, nothing jumps. */
    .guide-toc-docked { display: flex; position: fixed; top: auto; bottom: 16px; left: 50%; width: min(var(--container), calc(100% - 48px)); z-index: 40; margin: 0; flex-direction: column-reverse; border-radius: var(--r-chip); background: var(--bg-dark); border-color: rgba(255, 255, 255, .14); box-shadow: var(--shadow-nav);
        opacity: 0; transform: translate(-50%, calc(100% + 24px)); pointer-events: none;
        transition: opacity .3s ease, transform .34s cubic-bezier(.22, 1, .36, 1); }
    .guide-toc-docked.is-visible { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
    .guide-toc-docked.is-open { border-radius: var(--r-card); }

    .guide-toc-toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 13px 16px; background: none; border: 0; border-radius: inherit; cursor: pointer; font: inherit; font-weight: 600; font-size: 0.95rem; color: var(--ink); }
    .guide-toc-toggle-lbl { display: flex; align-items: center; gap: 10px; min-width: 0; }
    .guide-toc-toggle-lbl svg { width: 20px; height: 20px; color: var(--accent); flex-shrink: 0; }
    .guide-toc-caret { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; transition: transform var(--transition); }
    .guide-toc.is-open .guide-toc-caret { transform: rotate(180deg); }              /* inline: caret up when open */
    .guide-toc-docked .guide-toc-caret { transform: rotate(180deg); }              /* docked: caret up when closed (opens upward) */
    .guide-toc-docked.is-open .guide-toc-caret { transform: rotate(0deg); }
    #guideTocNav { display: none; padding: 6px 12px 14px; border-top: 1px solid var(--border); }
    .guide-toc.is-open #guideTocNav { display: block; }
    .guide-toc-docked nav { display: none; padding: 14px 12px 6px; border-bottom: 1px solid rgba(255, 255, 255, .14); max-height: 70svh; overflow-y: auto; }
    .guide-toc-docked.is-open nav { display: block; }

    /* dark-surface colors on the docked pill */
    .guide-toc-docked .guide-toc-toggle { color: #fff; }
    .guide-toc-docked .guide-toc-toggle-lbl svg { color: var(--lime); }
    .guide-toc-docked .guide-toc-caret { color: var(--muted-on-dark); }
    .guide-toc-docked .guide-toc-part { color: var(--muted-on-dark); }
    .guide-toc-docked a { color: var(--muted-on-dark); }
    .guide-toc-docked a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
    .guide-toc-docked a.is-active { background: rgba(255, 255, 255, .10); color: #fff; }
    .guide-toc-docked a .num { color: var(--muted-on-dark); }
    .guide-toc-docked a.is-active .num { color: var(--lime); }

    .guide-step-body, .guide-step--flip .guide-step-body { grid-template-columns: minmax(0, 1fr); gap: 22px; }
    .guide-step--flip .guide-step-shot { order: 0; }
    .guide-step-shot { position: static; max-width: 250px; margin: 4px auto 0; }
    .guide-chapter-head { padding: 14px 18px; }
    .guide-chapter-body { padding: 24px 20px 28px; }
}

@media (max-width: 540px) {
    .guide-chapter-num { width: 48px; height: 48px; font-size: 1.3rem; border-radius: 14px; }
    .guide-chapter-head { gap: 14px; }

    /* sticky first column keeps the row label on screen while the table scrolls sideways */
    .guide-table th:first-child,
    .guide-table td:first-child { position: sticky; left: 0; z-index: 1; background: var(--bg-card); box-shadow: 1px 0 0 var(--border); }
    .guide-table thead th:first-child { background: var(--bg-ice); z-index: 3; }

    /* "scroll sideways" hint chip above the table */
    .scroll-hint { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin: 0 2px 8px; font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
    .scroll-hint svg { width: 15px; height: 15px; }
}

/* ---------- Browser-window screenshot frame ----------
   Landscape dashboard shots (the web panel) don't fit the portrait phone column,
   so they use a full-width browser frame placed below the prose in .guide-step--full. */
.guide-step-shot--wide { position: static; top: auto; max-width: none; margin: 24px auto 0; }
.guide-browser { background: var(--ink); border-radius: 15px; padding-bottom: 10px; box-shadow: 0 18px 40px rgba(15, 21, 46, .22); overflow: hidden; }
.guide-browser-bar { display: flex; align-items: center; gap: 7px; padding: 12px 15px 13px; }
.guide-browser-bar i { width: 11px; height: 11px; border-radius: 50%; background: rgba(255, 255, 255, .22); flex-shrink: 0; }
.guide-browser-url { margin-left: 9px; min-width: 0; font-family: var(--font-mono); font-size: 0.74rem; color: rgba(255, 255, 255, .6); background: rgba(255, 255, 255, .08); border-radius: 7px; padding: 4px 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.guide-browser img { display: block; width: calc(100% - 20px); height: auto; margin: 0 10px; border-radius: 8px; box-shadow: 0 2px 12px rgba(0, 0, 0, .22); }
.guide-step-shot--wide figcaption { text-align: center; margin-top: 12px; font-size: 0.82rem; color: var(--muted); }

/* On phones the single grid column would size to the screenshot's min-content and clip its
   right edge (chapter is overflow:hidden). Stacking the full-step body as plain blocks lets the
   frame scale to the column width — the whole shot stays visible; detail lives in tap-to-zoom. */
@media (max-width: 1024px) {
    .guide-step--full .guide-step-body { display: block; }
    .guide-step--full .guide-step-body > * + * { margin-top: 22px; }
}

/* ---------- Tap-to-zoom: the wide dashboard shots open full-screen (readable at real size) ---------- */
.guide-step-shot--wide .guide-browser { cursor: zoom-in; position: relative; }
.guide-zoom-badge { position: absolute; top: 10px; right: 12px; z-index: 2; display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 9px; background: rgba(15, 21, 46, .55); color: #fff; pointer-events: none; }
.guide-zoom-badge svg { width: 17px; height: 17px; }
.guide-step-shot--wide .guide-browser:hover .guide-zoom-badge,
.guide-step-shot--wide .guide-browser:focus-visible .guide-zoom-badge { background: var(--accent); }
.guide-step-shot--wide .guide-browser:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.guide-lightbox { position: fixed; inset: 0; z-index: 200; display: none; background: rgba(15, 21, 46, .93); }
.guide-lightbox.is-open { display: block; }
.guide-lightbox-stage { position: absolute; inset: 0; overflow: auto; -webkit-overflow-scrolling: touch; display: flex; align-items: center; justify-content: center; padding: 20px; }
.guide-lightbox-stage img { display: block; border-radius: 8px; box-shadow: 0 12px 48px rgba(0, 0, 0, .5); }
.guide-lightbox-stage.is-fit img { max-width: 100%; max-height: 100%; width: auto; height: auto; cursor: zoom-in; }
.guide-lightbox-stage.is-actual { align-items: flex-start; justify-content: flex-start; }
.guide-lightbox-stage.is-actual img { max-width: none; max-height: none; margin: auto; cursor: zoom-out; }
.guide-lightbox-close { position: fixed; top: 14px; right: 14px; z-index: 2; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border: 0; border-radius: 12px; background: rgba(255, 255, 255, .12); color: #fff; cursor: pointer; }
.guide-lightbox-close:hover, .guide-lightbox-close:focus-visible { background: rgba(255, 255, 255, .22); }
.guide-lightbox-close svg { width: 22px; height: 22px; }
body.guide-lightbox-open { overflow: hidden; }
