/* --------------------------------------------------
   Wide Open Windows — Reading tools
-------------------------------------------------- */

:root {
    --wow-reading-scale: 1;
    --wow-reading-line-height: 1.55;
    --wow-paper-bg: #f3eee3;
    --wow-paper-surface: #e9e2d5;
    --wow-paper-text: #25231f;
    --wow-paper-muted: #6b665d;
    --wow-paper-link: #34302a;
    --wow-paper-line: rgba(37, 35, 31, 0.22);
}

.reading-time {
    margin: 0.55rem 0 0;
    color: rgba(37, 35, 31, 0.58);
    font-size: 0.72rem;
    line-height: 1.4;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.reading-time[hidden] {
    display: none;
}

html.reading-paper {
    color-scheme: light;
}

html.reading-paper body {
    background-color: var(--wow-paper-bg) !important;
    color: var(--wow-paper-text);
}

html.reading-paper body[data-page-type="page"] {
    background-image: none !important;
}

html.reading-paper .site-shell,
html.reading-paper .page-main,
html.reading-paper .page,
html.reading-paper .page-title,
html.reading-paper .page-content,
html.reading-paper .page-content h2,
html.reading-paper .page-content h3,
html.reading-paper .page-content h4 {
    color: var(--wow-paper-text);
}

html.reading-paper .reading-time,
html.reading-paper .page-content .source {
    color: var(--wow-paper-muted);
}

html.reading-paper a,
html.reading-paper .page-content a {
    color: var(--wow-paper-link) !important;
}

html.reading-paper a:hover,
html.reading-paper .page-content a:hover {
    color: #000 !important;
}

html.reading-paper .page-content hr {
    background: linear-gradient(
        90deg,
        transparent,
        var(--wow-paper-line) 20%,
        rgba(37, 35, 31, 0.14) 75%,
        transparent
    );
}

html.reading-paper footer {
    background: var(--wow-paper-surface);
    color: var(--wow-paper-text);
}

/* Dark CSS backgrounds disappear in paper mode. */
html.reading-paper [class*="window-"],
html.reading-paper [data-reading-background="hide"],
html.reading-paper [style*="background-image"] {
    background-image: none !important;
}

/* Decorative images can explicitly become a subdued negative. */
html.reading-paper [data-reading-image="invert"] {
    filter:
        invert(1)
        hue-rotate(180deg)
        brightness(1.04)
        contrast(0.88)
        saturate(0.75);
}

body,
.site-shell,
.page,
.page-title,
.page-content,
.reading-time,
footer {
    transition:
        background-color 320ms ease,
        color 320ms ease,
        border-color 320ms ease;
}

@media (prefers-reduced-motion: reduce) {
    body,
    .site-shell,
    .page,
    .page-title,
    .page-content,
    .reading-time,
    footer {
        transition: none;
    }
}

/* BWP 8C.12.4 — responsive masonry gallery */
.bwp-gallery{position:relative;margin:1.75rem 0;min-height:2rem}
.bwp-gallery__item{position:absolute;top:0;left:0;margin:0;overflow:hidden;border-radius:8px;box-sizing:border-box}
.bwp-gallery__item img{display:block;width:100%;height:auto;margin:0}
.bwp-gallery__caption{box-sizing:border-box;padding:.45rem .65rem;font-size:.9rem;line-height:1.3}
@media (hover:hover){.bwp-gallery__caption{position:absolute;left:0;right:0;bottom:0;background:rgba(0,0,0,.82);color:#fff;opacity:0;transform:translateY(6px);transition:opacity .2s ease,transform .2s ease}.bwp-gallery__item:hover .bwp-gallery__caption{opacity:1;transform:none}}
@media (prefers-reduced-motion:reduce){.bwp-gallery__caption{transition:none}}

/* BWP 8C.12.5 — gallery polish + accessible lightbox */
.bwp-gallery{margin:2rem .35rem}
.bwp-gallery__item{cursor:zoom-in}
.bwp-gallery__item:focus-visible{outline:3px solid currentColor;outline-offset:3px}
html.bwp-lightbox-open,html.bwp-lightbox-open body{overflow:hidden}
.bwp-lightbox[hidden]{display:none!important}
.bwp-lightbox{position:fixed;inset:0;z-index:100000;color:#fff}
.bwp-lightbox__backdrop{position:absolute;inset:0;background:rgba(0,0,0,.92);backdrop-filter:blur(2px)}
.bwp-lightbox__stage{position:absolute;inset:0;display:grid;grid-template-columns:minmax(3.25rem,8vw) minmax(0,1fr) minmax(3.25rem,8vw);grid-template-rows:1fr;align-items:center;padding:max(1rem,env(safe-area-inset-top)) max(.5rem,env(safe-area-inset-right)) max(1rem,env(safe-area-inset-bottom)) max(.5rem,env(safe-area-inset-left));box-sizing:border-box}
.bwp-lightbox__figure{grid-column:2;margin:0;display:flex;flex-direction:column;align-items:center;justify-content:center;min-width:0;max-height:100%}
.bwp-lightbox__image{display:block;max-width:min(100%,1400px);max-height:82vh;width:auto;height:auto;object-fit:contain;box-shadow:0 8px 40px rgba(0,0,0,.45)}
.bwp-lightbox__caption{max-width:min(92vw,1400px);margin:.75rem auto 0;padding:.45rem .7rem;background:rgba(0,0,0,.72);border-radius:.3rem;text-align:center;font-size:.95rem;line-height:1.35;color:#fff}
.bwp-lightbox__close,.bwp-lightbox__prev,.bwp-lightbox__next{position:relative;z-index:2;border:0;border-radius:999px;background:rgba(0,0,0,.38);color:#fff;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;width:3.5rem;height:3.5rem;font:400 2.4rem/1 system-ui,sans-serif}
.bwp-lightbox__close{position:absolute;right:max(1rem,env(safe-area-inset-right));top:max(1rem,env(safe-area-inset-top));font-size:2rem}
.bwp-lightbox__prev{grid-column:1;justify-self:center}
.bwp-lightbox__next{grid-column:3;justify-self:center}
.bwp-lightbox__close:hover,.bwp-lightbox__prev:hover,.bwp-lightbox__next:hover,.bwp-lightbox__close:focus-visible,.bwp-lightbox__prev:focus-visible,.bwp-lightbox__next:focus-visible{background:#fff;color:#000;outline:none}
@media(max-width:640px){.bwp-gallery{margin:1.5rem 0}.bwp-lightbox__stage{grid-template-columns:3rem minmax(0,1fr) 3rem}.bwp-lightbox__image{max-height:78vh}.bwp-lightbox__close,.bwp-lightbox__prev,.bwp-lightbox__next{width:3rem;height:3rem;font-size:2rem}.bwp-lightbox__caption{font-size:.88rem}}
@media(prefers-reduced-motion:reduce){.bwp-lightbox *{scroll-behavior:auto!important;transition:none!important}}

/* BWP 8C.12.6 — responsive + sortable tables */
.bwp-table-wrap{max-width:100%;overflow-x:auto;margin:1.75rem 0;-webkit-overflow-scrolling:touch}
.bwp-table-wrap table,.bwp-table{width:100%;border-collapse:collapse;margin:0}
.bwp-table-wrap th,.bwp-table-wrap td{padding:.6rem .75rem;text-align:left;vertical-align:top;border-bottom:1px solid rgba(127,127,127,.35);white-space:normal}
.bwp-table-wrap th{font-weight:700}
.bwp-table-wrap--sortable th{padding:0}
.bwp-sort-button{display:flex;align-items:center;gap:.45rem;width:100%;padding:.6rem .75rem;border:0;background:transparent;color:inherit;font:inherit;font-weight:700;text-align:left;cursor:pointer}
.bwp-sort-button::after{content:"↕";font-size:.8em;opacity:.5}
th[aria-sort="ascending"] .bwp-sort-button::after{content:"↑";opacity:1}
th[aria-sort="descending"] .bwp-sort-button::after{content:"↓";opacity:1}
.bwp-sort-button:focus-visible{outline:2px solid currentColor;outline-offset:-3px}
@media(max-width:640px){.bwp-table-wrap{margin:1.35rem 0}.bwp-table-wrap table{min-width:36rem}.bwp-table-wrap th,.bwp-table-wrap td,.bwp-sort-button{padding:.5rem .6rem}}
