/* Library rail: the tick index at the left edge, built by rail.js.
   The host sets --rail, --rail-hot, --rail-dim and --rail-z. */

.lib-dim {
    position: fixed;
    inset: 0;
    z-index: var(--rail-z, 95);
    background: var(--rail-dim, rgba(17, 20, 24, 0.72));
    opacity: 0;
    pointer-events: none;
    transition: opacity 250ms ease;
}

.lib-dim.is-on {
    opacity: 1;
}

/* Hidden ticks must not take keyboard focus, so visibility follows opacity. */
.lib-rail {
    position: fixed;
    top: 50%;
    left: calc(var(--page-pad) - 4px);
    z-index: calc(var(--rail-z, 95) + 1);
    color: var(--rail, #f2efe5);
    transform: translateY(-50%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 250ms ease, visibility 0s linear 250ms;
}

.lib-rail.is-on {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 250ms ease;
}

.lib-rail-back {
    display: grid;
    place-items: center;
    width: 2.2rem;
    height: 2.2rem;
    margin: 0 0 0.5rem -0.35rem;
    padding: 0;
    border: 0;
    background: none;
    color: var(--rail, #f2efe5);
    font: 600 1.5rem/1 var(--mono);
    transition: color 160ms ease;
}

.lib-rail-back:hover {
    color: var(--rail-hot, #f0a45c);
}

.lib-rail-back:focus-visible {
    outline: 1px solid currentColor;
    outline-offset: 0;
}

/* Each row is a wide hit target; the drawn tick is the ::before line. */
.lib-rail-ticks {
    position: relative;
    width: 90px;
}

.lib-rail-tick {
    position: relative;
    display: block;
    height: 13px;
    color: inherit;
}

.lib-rail-tick::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 4px;
    width: var(--w, 16px);
    height: 2px;
    margin-top: -1px;
    background: currentColor;
    opacity: 0.45;
    transition: width 160ms var(--ease-out), opacity 160ms ease;
}

.lib-rail-tick[aria-current="true"]::before {
    width: max(26px, var(--w, 16px));
    opacity: 1;
}

.lib-rail-tick.is-hot {
    color: var(--rail-hot, #f0a45c);
}

.lib-rail-tick.is-hot::before {
    opacity: 1;
}

.lib-rail-tick:focus-visible {
    outline: 1px solid currentColor;
    outline-offset: -1px;
}

.lib-rail-label {
    position: absolute;
    top: 0;
    left: 100px;
    color: var(--rail-hot, #f0a45c);
    font: 400 1rem/1 var(--fancy);
    white-space: nowrap;
    transform: translateY(-50%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease;
}

.lib-rail.is-scanning .lib-rail-label {
    opacity: 1;
}

/* Phones and tablets: no ticks, only the back button, pinned top left. */
@media (max-width: 900px) {
    .lib-dim,
    .lib-rail-ticks {
        display: none;
    }

    .lib-rail {
        top: calc(1rem + env(safe-area-inset-top, 0px));
        left: var(--page-pad);
        transform: none;
    }

    .lib-rail-back {
        margin: 0;
        border: 1px solid currentColor;
        font-size: 1.25rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .lib-dim,
    .lib-rail,
    .lib-rail.is-on,
    .lib-rail-back,
    .lib-rail-tick::before,
    .lib-rail-label {
        transition: none;
    }
}
