/* ============================================================
   ARTICLE SHELL — the two columns and the contents rail

   .page-content > .sidebar (.sidebar-toc) + .content

   Loaded on an article, where the generator writes this markup, and
   on a location page with a hub, where template-parts/location-hub.php
   does. A place page must not load it: its body is one column.

   Needs entry.css, for the prose and the stamp's ink (--ink-mask).
   ============================================================ */

/* ------------------------------------------------------------
   1. Two-column shell
   ------------------------------------------------------------ */
.page-content,
.page-content *,
.page-content *::before,
.page-content *::after {
    box-sizing: border-box;
}

.page-content {
    max-width: 1480px;
    margin: 0 auto;
    padding: clamp(24px, 4vw, 48px) clamp(20px, 4vw, 56px);
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 32px;
}

/* Sticky table-of-contents rail from desktop up. */
@media (min-width: 1024px) {
    .page-content {
        grid-template-columns: 280px minmax(0, 1fr);
        gap: 56px;
        align-items: start;
    }

    .sidebar {
        position: sticky;
        /* Clears the sticky nav bar, which is ~68px tall. */
        top: 88px;
        /* A long contents list must not outgrow the viewport while
           pinned, or its tail becomes unreachable. */
        max-height: calc(100vh - 120px);
        overflow-y: auto;
    }
}

/* Anchor jumps must land below that same sticky nav bar. */
.content [id],
.faq-block [id] {
    scroll-margin-top: 96px;
}

/* ------------------------------------------------------------
   2. Table of contents
   ------------------------------------------------------------ */
/* A page from the passport (the stamp motif, entry.css): tinted paper
   with a perforated left edge, the numbers as small stamps. */
.sidebar {
    background: var(--c-surface-tint);
    border: 0;
    border-left: 3px dashed var(--c-border-strong);
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    padding: 22px;
}

/* Label above the list, in CSS so the generated markup stays clean. */
.sidebar-toc::before {
    content: "Съдържание";
    display: block;
    margin-bottom: 14px;
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--c-ink-faint);
}

.sidebar-toc {
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: toc;
}

.sidebar-toc li {
    counter-increment: toc;
    margin: 0;
}

.sidebar-toc li + li {
    border-top: 1px dashed var(--c-border-strong);
}

.sidebar-toc a {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 10px 2px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.45;
    color: var(--c-ink-soft);
    text-decoration: none;
    transition: color 0.18s ease;
}

.sidebar-toc a::before {
    content: counter( toc, decimal-leading-zero );
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border: 1.5px solid var(--c-accent);
    border-radius: 50%;
    outline: 1px dashed var(--c-accent);
    outline-offset: -5px;
    font-family: var(--font-display);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--c-accent);
    transform: rotate(-7deg);
    -webkit-mask-image: var(--ink-mask);
    mask-image: var(--ink-mask);
}

.sidebar-toc li:nth-child(even) a::before {
    transform: rotate(5deg);
}

.sidebar-toc a:hover {
    color: var(--c-accent);
}

@media (prefers-reduced-motion: reduce) {
    .sidebar-toc a {
        transition: none;
    }
}
