:root {
    --boh-rail-width: calc(var(--size-16) + var(--space-1));
    --boh-rail-mobile-width: var(--size-14);
    --boh-rail-control-size: var(--size-10);
    --boh-rail-expanded-width: min(300px, calc(100vw - var(--space-8)));
    --boh-rail-drawer-width: min(var(--layout-sidebar-width), calc(100vw - var(--boh-rail-width)));
}

[data-house-theme] .boh-rail,
[data-house-theme] .boh-rail *,
[data-house-theme] .boh-rail-drawer,
[data-house-theme] .boh-rail-drawer * {
    font-family: var(--font-sans) !important;
}

.app-shell.app-shell--rail-nav {
    grid-template-columns: var(--boh-rail-width) var(--layout-sidebar-width) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas:
        "rail sidebar main";
}

.app-shell.app-shell--rail-nav .top-bar {
    position: fixed;
    top: 0;
    right: 0;
    left: var(--boh-rail-width);
    height: 0;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
    pointer-events: none;
    z-index: var(--z-topbar);
}

.app-shell.app-shell--rail-nav .top-bar__left,
.app-shell.app-shell--rail-nav .top-bar__center {
    display: none;
}

.app-shell.app-shell--rail-nav .top-bar__right {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + var(--space-3));
    right: calc(env(safe-area-inset-right, 0px) + var(--space-4));
    z-index: var(--z-topbar);
    pointer-events: auto;
}

.boh-rail {
    grid-area: rail;
    position: sticky;
    top: 0;
    z-index: var(--z-rail);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
    width: var(--boh-rail-width);
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    padding: calc(env(safe-area-inset-top, 0px) + var(--space-3)) var(--space-2) calc(env(safe-area-inset-bottom, 0px) + var(--space-3));
    background: var(--surface-app);
    border-right: 1px solid var(--border-default);
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: hidden;
    touch-action: pan-y;
    overscroll-behavior-x: none;
    transition:
        width var(--duration-normal) var(--ease-default),
        box-shadow var(--duration-fast) var(--ease-default);
}

.boh-rail__top {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
    flex-shrink: 0;
}

.boh-rail__houses {
    display: flex;
    flex: 1 1 0;
    min-height: 0;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
    overflow-x: hidden;
    overflow-y: auto;
    /* Horizontal padding + compensating negative margin: overflow clips at the
       padding edge, so the active Lumina ring and unread badges get room to
       render inside the scrollport instead of being sliced at the content box. */
    padding: var(--space-1) var(--space-2);
    margin: 0 calc(var(--space-2) * -1);
    touch-action: pan-y;
    overscroll-behavior-x: none;
    scrollbar-width: none;
}

.boh-rail__houses::-webkit-scrollbar {
    display: none;
}

.boh-rail__item {
    position: relative;
    display: grid;
    grid-template-columns: var(--boh-rail-control-size);
    align-items: center;
    /* The 40px disc track is wider than the 38px content box inside the 1px
       border; centring it on both axes lays the disc exactly over the item
       box, so the where-you-are ring is concentric on every disc. */
    align-content: center;
    justify-content: center;
    align-self: center;
    column-gap: var(--space-3);
    width: var(--boh-rail-control-size);
    height: var(--boh-rail-control-size);
    min-width: var(--boh-rail-control-size);
    min-height: var(--boh-rail-control-size);
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--text-secondary);
    text-decoration: none;
    flex-shrink: 0;
    box-sizing: border-box;
    overflow: visible;
    transition:
        background var(--duration-fast) var(--ease-default),
        border-color var(--duration-fast) var(--ease-default),
        color var(--duration-fast) var(--ease-default),
        transform var(--duration-fast) var(--ease-default);
}

.boh-rail__item:hover,
.boh-rail__item:focus-visible {
    background: var(--surface-primary);
    border-color: var(--border-default);
    color: var(--text-primary);
}

.boh-rail__item:active {
    transform: scale(0.98);
}

/* Where you are (Steven 2026-10-01 design pass): every rail item is a 40px
   disc now (Feed, Shop, Wants, the crests), so ONE ring marks the place on
   all of them: no fill behind the disc, a 2px app-coloured gap, then the 2px
   purple ring. Feed on /feed, Shop on the shop, Wants on /wants, a crest on
   its house; Shop and Wants also while the drawer router has their panel open
   (it toggles .top-bar__btn--active on [data-utility-zone]). */
.boh-rail__item.is-active,
.boh-rail__item.top-bar__btn--active {
    background: transparent;
    border-color: transparent;
    color: var(--text-primary);
    box-shadow:
        0 0 0 2px var(--surface-app),
        0 0 0 4px var(--color-purple-600);
}

/* Lumina ring pulse: lives on ::before (tooltips own ::after).
   Sized to stay inside the houses scrollport (55px) at max scale. */
.boh-rail__item.is-active::before,
.boh-rail__item.top-bar__btn--active::before {
    content: "";
    position: absolute;
    inset: calc(var(--space-1) * -1);
    border: 2px solid var(--color-purple-500);
    border-radius: inherit;
    opacity: 0.3;
    pointer-events: none;
    animation: bohLuminaPulse 2.6s var(--ease-default) infinite;
}

@keyframes bohLuminaPulse {
    0%,
    100% {
        opacity: 0.22;
        transform: scale(0.95);
    }
    50% {
        opacity: 0.85;
        transform: scale(1.08);
    }
}

.boh-rail__item--quiz {
    background: color-mix(in srgb, var(--accent-primary) 14%, transparent);
    border-color: color-mix(in srgb, var(--accent-primary) 42%, transparent);
    color: var(--text-primary);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--surface-primary) 70%, transparent);
    /* No values quiz taken yet: the button flashes like a light until it is. */
    animation: bohRailQuizFlash 1.6s var(--ease-default) infinite;
}

.boh-rail__item--quiz::before {
    content: "";
    position: absolute;
    inset: calc(var(--space-1) * -1);
    border: 1px solid color-mix(in srgb, var(--accent-primary) 48%, transparent);
    border-radius: inherit;
    opacity: 0.28;
    pointer-events: none;
    transform: scale(0.94);
    animation: bohRailQuizPulse 2.8s var(--ease-default) infinite;
}

.boh-rail__item--quiz:hover,
.boh-rail__item--quiz:focus-visible {
    background: color-mix(in srgb, var(--accent-primary) 22%, var(--surface-primary));
    border-color: var(--accent-primary);
    animation: none;
}

.boh-rail__glyph {
    grid-column: 1;
    justify-self: center;
    width: var(--size-6);
    height: var(--size-6);
    flex-shrink: 0;
}

/* All icons in circles (Steven 2026-10-01 design pass): Feed, Shop and Wants
   each wear a 40px disc, the same size and axis as the house crests below
   them. The disc is its own span so the expanded row stays a plain row with
   the disc at its left, instead of the whole row taking the disc's colour. */
.boh-rail__disc {
    grid-column: 1;
    justify-self: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--boh-rail-control-size);
    height: var(--boh-rail-control-size);
    border-radius: var(--radius-full);
}

/* Feed: neutral like Shop (white disc, dark newspaper) unless Feed is the
   current page, where it goes purple-600 with a white newspaper inside the
   shared ring. A solid purple disc read as "you are here" on house pages
   (Steven 2026-10-01). */
.boh-rail__disc--feed {
    background: var(--surface-primary);
    color: var(--text-primary);
}

.boh-rail__item.is-active .boh-rail__disc--feed {
    background: var(--color-purple-600);
    color: var(--color-white);
}

/* Shop: a white disc, the same as the crests (their images carry a white
   ground and no ring). */
.boh-rail__disc--shop {
    background: var(--surface-primary);
    color: var(--text-primary);
}

/* Wants: the Toll Bench logo target drawn big on the yellow-400 disc. The svg
   viewBox is cropped to the outer ring's centreline (_rail_nav.html), so the
   box below IS the outer ring: 85% of the disc, the logo's proportion; the
   stroke's outer half paints past the box (overflow visible), still inside
   the disc. */
.boh-rail__disc--wants {
    background: var(--color-yellow-400);
    color: var(--text-primary);
}

.boh-rail__disc-glyph {
    width: calc(var(--boh-rail-control-size) * 0.85);
    height: calc(var(--boh-rail-control-size) * 0.85);
    overflow: visible;
}

.boh-rail__item iconify-icon {
    grid-column: 1;
    justify-self: center;
    width: var(--size-5);
    height: var(--size-5);
    font-size: var(--size-5);
}

.boh-rail__house-img {
    grid-column: 1;
    justify-self: center;
    width: var(--boh-rail-control-size);
    height: var(--boh-rail-control-size);
    object-fit: cover;
    border-radius: var(--radius-full);
}

.boh-rail__house-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    grid-column: 1;
    justify-self: center;
    width: var(--boh-rail-control-size);
    height: var(--boh-rail-control-size);
    border-radius: var(--radius-full);
    background: var(--surface-secondary);
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
}

.boh-rail__label {
    display: none;
    min-width: 0;
    flex-direction: column;
    gap: 0;
    line-height: 1.15;
}

.boh-rail__label-main,
.boh-rail__label-meta {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.boh-rail__label-main {
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
}

.boh-rail__label-meta {
    color: var(--text-muted);
    font-size: var(--text-xs);
}

.boh-rail__badge {
    position: absolute;
    top: calc(-1 * var(--space-1));
    right: calc(-1 * var(--space-1));
    min-width: var(--space-5);
    height: var(--space-5);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 var(--space-1);
    border-radius: var(--radius-full);
    background: var(--indicator-unread);
    color: var(--color-white);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    line-height: 1;
}

.boh-rail__item[data-rail-tooltip]::after {
    content: attr(data-rail-tooltip);
    position: absolute;
    display: none;
    left: calc(100% + var(--space-2));
    top: 50%;
    transform: translateY(-50%);
    max-width: calc(var(--layout-sidebar-width) - var(--space-8));
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    background: var(--surface-primary);
    color: var(--text-primary);
    box-shadow: var(--shadow-md);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--duration-fast) var(--ease-default), visibility var(--duration-fast) var(--ease-default);
}

.boh-rail__item[data-rail-tooltip]:hover::after,
.boh-rail__item[data-rail-tooltip]:focus-visible::after {
    display: block;
    opacity: 1;
    visibility: visible;
}

.boh-rail-backdrop {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: var(--boh-rail-expanded-width);
    z-index: calc(var(--z-overlay) - 1);
    background: var(--surface-overlay);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-fast) var(--ease-default);
}

.boh-rail-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}

body.boh-rail-expanded {
    overflow-x: hidden;
}

body.boh-rail-expanded .boh-rail {
    width: var(--boh-rail-expanded-width);
    z-index: var(--z-overlay);
    box-shadow: var(--shadow-xl);
}

body.boh-rail-expanded .boh-rail__houses {
    margin: 0;
    padding: var(--space-1) 0;
}

/* The pop-out is HORIZONTAL ONLY (Steven 2026-09-02): a row keeps the exact
   collapsed control height, so every crest stays on the same y as it was in the
   strip and the labels slide out beside it. The old height:auto + min-height
   size-12 (48px) made each expanded row 8px taller than its collapsed twin,
   so the icons drifted down cumulatively (4, 11, 19, 27px...) on open. */
body.boh-rail-expanded .boh-rail__item {
    grid-template-columns: var(--boh-rail-control-size) minmax(0, 1fr) auto;
    justify-content: stretch;
    align-self: stretch;
    width: 100%;
    height: var(--boh-rail-control-size);
    min-width: 0;
    min-height: var(--boh-rail-control-size);
    padding-right: var(--space-3);
    border-radius: var(--radius-full);
}

body.boh-rail-expanded .boh-rail__item.is-active,
body.boh-rail-expanded .boh-rail__item.top-bar__btn--active {
    background: color-mix(in srgb, var(--color-purple-600) 10%, var(--surface-primary));
    border-color: var(--color-purple-600);
}

body.boh-rail-expanded .boh-rail__item.is-active::before,
body.boh-rail-expanded .boh-rail__item.top-bar__btn--active::before {
    display: none;
}

body.boh-rail-expanded .boh-rail__item--quiz {
    background: color-mix(in srgb, var(--accent-primary) 12%, var(--surface-primary));
}

body.boh-rail-expanded .boh-rail__item--quiz::before {
    inset: var(--space-1);
}

body.boh-rail-expanded .boh-rail__label {
    display: flex;
}

body.boh-rail-expanded .boh-rail__badge {
    position: static;
    grid-column: 3;
    justify-self: end;
    align-self: center;
}

body.boh-rail-expanded .boh-rail__item[data-rail-tooltip]::after {
    display: none;
}

@keyframes bohRailQuizFlash {
    0%,
    100% {
        background: color-mix(in srgb, var(--accent-primary) 14%, transparent);
        box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent-primary) 0%, transparent);
    }
    50% {
        background: color-mix(in srgb, var(--accent-primary) 60%, var(--surface-primary));
        box-shadow: 0 0 var(--space-4) 0 color-mix(in srgb, var(--accent-primary) 70%, transparent);
    }
}

@keyframes bohRailQuizPulse {
    0%,
    100% {
        opacity: 0.18;
        transform: scale(0.94);
    }
    50% {
        opacity: 0.52;
        transform: scale(1.08);
    }
}

.boh-rail-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    left: var(--boh-rail-width);
    z-index: var(--z-overlay);
    display: flex;
    flex-direction: column;
    width: var(--boh-rail-drawer-width);
    max-width: calc(100vw - var(--boh-rail-width));
    padding: env(safe-area-inset-top, 0px) 0 calc(env(safe-area-inset-bottom, 0px) + var(--space-4));
    background: var(--surface-primary);
    border-right: 1px solid var(--border-default);
    box-shadow: var(--shadow-xl);
    transform: translateX(-100%);
    transition: transform var(--duration-normal) var(--ease-default);
    overflow: hidden;
}

.boh-rail-drawer.is-open {
    transform: translateX(0);
}

.boh-rail-backdrop[hidden],
.boh-rail-drawer[hidden] {
    display: none;
}

.boh-rail-drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    flex-shrink: 0;
    padding: var(--space-4) var(--space-4) var(--space-3);
    border-bottom: 1px solid var(--border-subtle);
}

.boh-rail-drawer__title {
    color: var(--text-primary);
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    line-height: 1.2;
    letter-spacing: 0;
}

.boh-rail-drawer__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--size-10);
    height: var(--size-10);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-full);
    background: var(--surface-secondary);
    color: var(--text-secondary);
}

.boh-rail-drawer__close:hover,
.boh-rail-drawer__close:focus-visible {
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.boh-rail-drawer__list {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    min-height: 0;
    overflow-y: auto;
    padding: var(--space-3) var(--space-4) 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border-default) transparent;
}

.boh-rail-drawer__row {
    display: grid;
    grid-template-columns: var(--size-10) minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-3);
    min-height: var(--size-14);
    padding: var(--space-2);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    text-decoration: none;
}

.boh-rail-drawer__row:hover,
.boh-rail-drawer__row:focus-visible {
    background: var(--surface-secondary);
    border-color: var(--border-default);
}

.boh-rail-drawer__row.is-active {
    background: var(--accent-primary-subtle);
    border-color: var(--accent-primary);
}

.boh-rail-drawer__row-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--size-10);
    height: var(--size-10);
    border-radius: var(--radius-full);
    background: var(--surface-secondary);
    color: var(--text-primary);
    overflow: hidden;
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
}

.boh-rail-drawer__row-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.boh-rail-drawer__row-icon iconify-icon {
    width: var(--size-5);
    height: var(--size-5);
    font-size: var(--size-5);
}

.boh-rail-drawer__row-text {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    min-width: 0;
}

.boh-rail-drawer__row-name,
.boh-rail-drawer__row-meta {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.boh-rail-drawer__row-name {
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    line-height: 1.2;
}

.boh-rail-drawer__row-meta {
    color: var(--text-muted);
    font-size: var(--text-xs);
    line-height: 1.2;
}

.boh-rail-drawer__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--size-6);
    height: var(--size-6);
    padding: 0 var(--space-2);
    border-radius: var(--radius-full);
    background: var(--indicator-unread);
    color: var(--color-white);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
}

body.boh-rail-drawer-open {
    overflow: hidden;
}

@media (max-width: 767px) {
    :root {
        --boh-rail-drawer-width: min(var(--layout-sidebar-width), calc(100vw - var(--boh-rail-mobile-width) - var(--space-5)));
        --boh-rail-expanded-width: min(300px, calc(100vw - var(--space-5)));
    }

    .app-shell.app-shell--rail-nav {
        grid-template-columns: var(--boh-rail-mobile-width) minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr);
        grid-template-areas:
            "rail main";
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
        overflow-x: clip;
        overflow-y: visible;
        max-width: 100vw;
    }

    .app-shell.app-shell--rail-nav .top-bar {
        left: var(--boh-rail-mobile-width);
        padding: 0;
        min-width: 0;
    }

    .app-shell.app-shell--rail-nav .top-bar__right {
        top: calc(env(safe-area-inset-top, 0px) + var(--space-2));
        right: calc(env(safe-area-inset-right, 0px) + var(--space-2));
    }

    .boh-rail {
        width: var(--boh-rail-mobile-width);
        padding-left: var(--space-2);
        padding-right: var(--space-2);
    }

    .boh-rail__item {
        width: var(--size-10);
        height: var(--size-10);
        min-width: var(--size-10);
        min-height: var(--size-10);
    }

    .boh-rail__item[data-rail-tooltip]::after {
        display: none;
    }

    .boh-rail-backdrop {
        left: var(--boh-rail-expanded-width);
    }

    .boh-rail-drawer {
        left: var(--boh-rail-mobile-width);
        max-width: calc(100vw - var(--boh-rail-mobile-width) - var(--space-5));
        padding-left: var(--space-3);
        padding-right: var(--space-3);
    }

    .app-shell.app-shell--rail-nav .main-area {
        grid-column: auto;
        max-width: calc(100vw - var(--boh-rail-mobile-width));
    }

    body.rail-nav-enabled .house-mobile-bottom-nav {
        display: none !important;
    }
}

@media (hover: none) {
    .boh-rail__item[data-rail-tooltip]::after {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .boh-rail__item--quiz,
    .boh-rail__item--quiz::before,
    .boh-rail__item.is-active::before,
    .boh-rail__item.top-bar__btn--active::before {
        animation: none;
        opacity: 0.36;
        transform: none;
    }
}

/* Sideways navigation spine — centered on the same axis as the rail controls.
   The feed reveals it after the masthead scrolls away; house and passport
   destinations render their active context immediately. */
.boh-rail__spine {
    display: flex;
    justify-content: center;
    align-self: center;
    width: var(--boh-rail-control-size);
    min-width: var(--boh-rail-control-size);
    flex-shrink: 0;
    font-family: var(--font-serif);
    font-size: var(--size-6);
    font-weight: var(--font-medium);
    letter-spacing: .02em;
    line-height: 1;
    white-space: nowrap;
    color: var(--text-secondary);
    margin-top: var(--space-2);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-normal) ease;
}
.boh-rail .boh-rail__spine-text {
    writing-mode: vertical-rl;
    font-family: var(--font-serif) !important;
}
.boh-rail .boh-rail__spine-text * {
    font-family: var(--font-serif) !important;
}
.boh-rail__spine em { font-style: italic; }
.boh-rail__spine.is-visible { opacity: 1; }
body.boh-rail-expanded .boh-rail__spine { display: none; }

/* Steven 2026-08-10: yellow disc behind the Toll Bench target glyph in the
   sidebar rail nav — matches the /start homepage mark (.start-home__mark:
   yellow-400 disc, dark glyph, radius-full). Scoped to the /wants target nav
   item ONLY so no other nav icon is affected. Keeps the icon box at its
   existing 20px footprint so the row's layout and gap don't move; the glyph is
   scaled to sit inside the disc. */
.nav-item[data-utility-zone="targets"] .nav-item__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--color-yellow-400);
    color: var(--text-primary);
    border-radius: var(--radius-full);
    font-size: 13px;
}
.nav-item[data-utility-zone="targets"]:hover .nav-item__icon,
.nav-item[data-utility-zone="targets"].active .nav-item__icon {
    color: var(--text-primary);
}
