/* ==========================================================================
   IronStride — Manual
   ERZEUGT von Werkzeuge/handbuch_bauen.py. Änderungen hier überlebt der nächste
   Lauf nicht — sie gehören ins Skript.

   Alle Farben kommen als Token aus site.css. Dadurch dreht der Dunkelmodus der
   Website hier von selbst mit, ohne einen zweiten Satz Regeln.
   ========================================================================== */

.hb { padding-block: clamp(28px, 5vw, 56px) clamp(48px, 8vw, 96px); }

.hb-wrap {
    display: grid;
    grid-template-columns: 272px minmax(0, 1fr);
    gap: clamp(24px, 4vw, 56px);
    align-items: start;
}

/* --- Seitenleiste --------------------------------------------------------- */

.hb-side {
    position: sticky;
    top: 88px;
    max-height: calc(100vh - 108px);
    overflow-y: auto;
    padding-right: 6px;
}

.hb-sidehead { margin-bottom: 18px; }

.hb-eyebrow {
    margin: 0;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .10em;
    text-transform: uppercase;
    color: var(--is);
}

.hb-title {
    margin: 2px 0 0;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -.02em;
    color: var(--ink);
}

.hb-stand { margin: 4px 0 0; font-size: .78rem; color: var(--ink-mute); }

/* --- Suche ---------------------------------------------------------------- */

.hb-searchbox { position: relative; margin-bottom: 18px; }

.hb-search {
    width: 100%;
    padding: 10px 34px 10px 12px;
    font: inherit;
    font-size: .92rem;
    color: var(--ink);
    background: var(--paper-tint);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    -webkit-appearance: none;
    appearance: none;
}

.hb-search:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    background: var(--paper);
}

.hb-search::-webkit-search-cancel-button { display: none; }

.hb-clear {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 26px;
    height: 26px;
    font-size: 1.1rem;
    line-height: 1;
    color: var(--ink-mute);
    background: none;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.hb-clear:hover { color: var(--ink); background: var(--paper-sink); }

.hb-searchhint { margin: 6px 2px 0; font-size: .74rem; color: var(--ink-mute); }

/* --- Kapitelliste --------------------------------------------------------- */

.hb-navlist, .hb-navsublist { margin: 0; padding: 0; list-style: none; }

.hb-navlink {
    display: flex;
    gap: 9px;
    align-items: baseline;
    padding: 7px 10px;
    font-size: .9rem;
    line-height: 1.35;
    color: var(--ink-body);
    text-decoration: none;
    border-radius: var(--r-sm);
}

.hb-navnr {
    flex: none;
    min-width: 1.3em;
    font-size: .74rem;
    font-variant-numeric: tabular-nums;
    color: var(--ink-mute);
}

.hb-navlink:hover { background: var(--paper-tint); color: var(--ink); }

.hb-navlink[aria-current="true"] {
    font-weight: 650;
    color: var(--is);
    background: var(--accent-wash);
}

.hb-navlink[aria-current="true"] .hb-navnr { color: var(--is); }

/* Unterpunkte erscheinen nur im offenen Kapitel — sonst ist die Leiste eine
   Wand aus vierzig Zeilen, in der man das Kapitel nicht mehr sieht. */
.hb-navsublist { display: none; margin: 2px 0 8px 30px; }
.hb-navitem.is-open .hb-navsublist { display: block; }

.hb-navsub {
    display: block;
    padding: 4px 8px;
    font-size: .82rem;
    line-height: 1.35;
    color: var(--ink-mute);
    text-decoration: none;
    border-left: 2px solid var(--line);
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

.hb-navsub:hover { color: var(--ink); border-left-color: var(--is); background: var(--paper-tint); }
.hb-navsub[aria-current="true"] { color: var(--is); border-left-color: var(--is); font-weight: 600; }

/* --- Umschalter auf schmalen Geräten -------------------------------------- */

.hb-sidetoggle {
    display: none;
    width: 100%;
    margin-bottom: 16px;
    padding: 11px 14px;
    font: inherit;
    font-size: .9rem;
    font-weight: 600;
    color: var(--ink);
    background: var(--paper-tint);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    cursor: pointer;
}

/* --- Trefferliste --------------------------------------------------------- */

.hb-results { margin-bottom: 22px; }

.hb-resulthead {
    margin: 0 0 10px;
    font-size: .8rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--ink-mute);
}

.hb-hitlist { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }

.hb-hit {
    display: block;
    width: 100%;
    padding: 12px 14px;
    text-align: left;
    font: inherit;
    color: var(--ink-body);
    background: var(--paper-tint);
    border: 1px solid var(--line);
    border-radius: var(--r);
    cursor: pointer;
}

.hb-hit:hover, .hb-hit:focus-visible, .hb-hit.is-cursor {
    border-color: var(--is);
    background: var(--accent-wash);
}

.hb-hitwo { display: block; font-size: .74rem; color: var(--ink-mute); }
.hb-hittitel { display: block; margin-top: 1px; font-weight: 650; color: var(--ink); }
.hb-hitschnipsel { display: block; margin-top: 4px; font-size: .85rem; line-height: 1.5; }

.hb-leer { margin: 0; font-size: .9rem; color: var(--ink-mute); }

/* --- Inhalt --------------------------------------------------------------- */

.hb-doc { max-width: 46rem; }

.hb-kicker {
    margin: 0;
    font-size: .74rem;
    font-weight: 600;
    letter-spacing: .10em;
    text-transform: uppercase;
    color: var(--ink-mute);
}

.hb-h2 {
    margin: 6px 0 22px;
    font-size: clamp(1.6rem, 3.4vw, 2.1rem);
    font-weight: 700;
    letter-spacing: -.022em;
    line-height: 1.15;
    color: var(--ink);
}

.hb-h4 {
    margin: 24px 0 6px;
    font-size: 1rem;
    font-weight: 650;
    color: var(--ink);
}

.hb-h3 {
    margin: 34px 0 10px;
    font-size: 1.12rem;
    font-weight: 650;
    letter-spacing: -.012em;
    color: var(--ink);
    scroll-margin-top: 92px;
}

/* Die Sprungmarke ist ein Angebot, kein Schriftzeichen: Dauerhaft sichtbar liest sie
   sich wie ein Tippfehler vor jeder Überschrift. Sie erscheint beim Überfahren — und
   ebenso beim Tabben, sonst wäre sie mit der Tastatur unsichtbar erreichbar. */
.hb-anchor {
    margin-right: .35em;
    font-weight: 400;
    color: var(--is);
    text-decoration: none;
    opacity: 0;
    transition: opacity .15s var(--ease);
}

.hb-h3:hover .hb-anchor,
.hb-anchor:focus-visible { opacity: 1; }

@media (hover: none) {
    /* Ohne Zeigegerät gibt es kein Überfahren — dort dauerhaft, aber zurückhaltend. */
    .hb-anchor { opacity: .35; }
}

.hb-doc p { margin: 0 0 12px; line-height: 1.72; color: var(--ink-body); }
.hb-doc ul, .hb-doc ol { margin: 0 0 14px; padding-left: 1.3em; color: var(--ink-body); }
.hb-doc li { margin-bottom: 6px; line-height: 1.66; }
.hb-doc li > ul, .hb-doc li > ol { margin-top: 6px; }
.hb-doc strong { color: var(--ink); font-weight: 650; }
.hb-doc hr { margin: 26px 0; border: 0; border-top: 1px solid var(--line-soft); }

.hb-doc code {
    padding: .1em .38em;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .87em;
    color: var(--ink);
    background: var(--paper-sink);
    border-radius: 4px;
}

.hb-note {
    margin: 0 0 16px;
    padding: 13px 16px;
    color: var(--ink-body);
    background: var(--accent-wash);
    border-left: 3px solid var(--is);
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

.hb-note > p:last-child, .hb-note > ul:last-child, .hb-note > ol:last-child { margin-bottom: 0; }

/* Tabellen scrollen einzeln — eine sechsspaltige Tabelle darf nicht die ganze
   Seite seitlich wegschieben. */
.hb-tablewrap { margin: 0 0 18px; overflow-x: auto; -webkit-overflow-scrolling: touch; }

.hb-doc table { width: 100%; border-collapse: collapse; font-size: .9rem; }

.hb-doc th, .hb-doc td {
    padding: 9px 12px;
    text-align: left;
    vertical-align: top;
    line-height: 1.5;
    border-bottom: 1px solid var(--line-soft);
}

.hb-doc th {
    font-weight: 650;
    color: var(--ink);
    white-space: nowrap;
    border-bottom-color: var(--line);
}

.hb-doc td { color: var(--ink-body); }

/* --- Suchtreffer im Text -------------------------------------------------- */

mark.hb-treffer {
    padding: .05em .15em;
    color: var(--ink);
    background: var(--warn-bg);
    border-radius: 3px;
}

.hb-part.is-ziel { animation: hb-blink 1.6s var(--ease); }

@keyframes hb-blink {
    0%, 55% { background: var(--accent-wash); }
    100%    { background: transparent; }
}

/* --- Blättern ------------------------------------------------------------- */

.hb-blaettern {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    margin-top: 44px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

.hb-blaettern a {
    max-width: 47%;
    padding: 11px 15px;
    font-size: .92rem;
    font-weight: 600;
    color: var(--ink);
    text-decoration: none;
    background: var(--paper-tint);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
}

.hb-blaettern a:hover { border-color: var(--is); color: var(--is); }
.hb-next { text-align: right; }

.hb-blaettern span {
    display: block;
    font-size: .72rem;
    font-weight: 500;
    color: var(--ink-mute);
}

.hb-visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* --- Schmale Geräte ------------------------------------------------------- */

@media (max-width: 900px) {
    /* Eine Spalte, und der Umschalter steht als eigenes Rasterkind direkt ÜBER der
       Seitenleiste. Stand er im Textblock, klappte die Leiste unterhalb des ganzen
       Kapitels auf — man tippte oben und es passierte scheinbar nichts. */
    .hb-wrap { grid-template-columns: minmax(0, 1fr); }
    .hb-sidetoggle { display: block; margin-bottom: 0; }
    .hb-side { position: static; max-height: none; margin-top: 14px; }
    .hb-side:not(.is-open) { display: none; }
    .hb-navsublist { display: block; }
}

/* --- Druck ---------------------------------------------------------------- */

@media print {
    .nav, .footer, .hb-side, .hb-sidetoggle, .hb-results, .hb-blaettern,
    .hb-anchor, .skip-link { display: none !important; }
    /* Gedruckt wird das ganze Buch, nicht das offene Kapitel. */
    .hb-chapter[hidden] { display: block !important; }
    .hb-chapter { break-before: page; }
    .hb-chapter:first-child { break-before: auto; }
    .hb-h3 { break-after: avoid; }
    .hb-doc { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
    .hb-part.is-ziel { animation: none; }
}
