@import url("https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.18.0/cdn/themes/light.css");

@media (min-width: 1200px) {
    .content {
        font-size: 1.2em;
    }
}

sl-tab::part(base) {
    font-size: 1.2rem;
    padding: 0.4rem 0.6rem;
}

sl-tab i {
    pointer-events: none;
}

sl-tab-panel .right,
sl-tab-panel .left {
    width: 100%;
}

hr {
    clear: both;
}

.media-pair {
    display: flow-root;
    /* contains floats; prevents next pair from rising */
    margin-block: 1rem;
    /* optional spacing */
}

/*
aside#panel-wrapper {
    display: none;
}

#main-wrapper main {
    width: 100%;
    max-width: 1000px;
}
*/

/* Float positioning */
@media (min-width: 768px) {

    /* styles for non-mobile screens */
    .col1 .left,
    .col1 .right {
        width: 50%;
        margin-top: 0;
    }

    p+.left {
        margin: .75rem 1rem 0 0;
    }

    p+.right {
        margin: .75rem 0 0 1rem;
    }

    h1,
    h2,
    h3,
    h4,
    h5,
    h6 {
        clear: both;
    }

    .col2 .post-content {
        margin-bottom: 60dvh;
    }

}

@media (max-width: 768px) {

    iframe {
        width: 100%;
    }

    /* mobile devices */
    .right,
    .left {
        width: 100%;
        float: unset;
        margin: 0 0 1rem 0;
    }
}

/* Caption styling */
.content a.popup+em,
.embed-video+em,
.embed-audio+em {
    line-height: 1.2;
    font-size: large;
    margin-bottom: 0.5em;
}

attribution {
    font-size: 90%;
    color: gray;
}

/* ****** Entity Popup ****** */

.entity-popup sl-card {
    display: flex;
    flex-direction: column;
    min-width: 200px;
    max-width: 250px;
    max-height: 600px;
    background-color: white;
    /* margin: 1rem; */
    box-shadow: rgba(50, 50, 93, 0.25) 0px 6px 12px -2px, rgba(0, 0, 0, 0.3) 0px 3px 7px -3px;
    border: 1px solid #ccc;
    border-radius: 3px;
}

.entity-popup sl-card img {
    max-height: 250px;
    object-fit: cover;
}

.entity-popup sl-card .content {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 0.5rem;
    /* padding: 0.5rem; */
    overflow-y: scroll;
    line-height: 1.2;
    font-size: 80%;
    max-height: 300px;
    overflow-y: auto;
    margin-top: 0;
}

.entity-popup sl-card .content h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0.5rem 0 0.25rem 0;
    line-height: 1;
}

.entity-popup sl-card .content .description {
    margin: 0;
    padding: 0;
}

.entity-popup sl-card .content p.description {
    font-style: italic;
}

.entity-popup .description p:last-of-type {
    margin-bottom: 0;
}

.entity-popup sl-card::part(footer) {
    padding: 0;
    background-color: #f8f8f8;
    border-top: 1px solid #ccc;
    font-size: 80%;
    font-weight: 500;
}

.entity-popup [slot='trigger'] {
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: rgba(153, 204, 204, 1);
    text-decoration-thickness: 3px;
    cursor: pointer;
}

.entity-popup [slot='trigger']:hover {
    background-color: rgba(153, 204, 204, 0.6);
}

.entity-popup sl-card [slot='footer'] {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
}

/* ****** End Entity Popup ****** */

iframe,
figure {
    box-shadow: rgba(50, 50, 105, 0.15) 0px 2px 5px 0px, rgba(0, 0, 0, 0.05) 0px 1px 1px 0px;
}

sl-tab-panel>iframe.embed-image {
    width: 100%;
}

iframe.embed-youtube {
    /* width: 100%; */
    aspect-ratio: 1.55;
}

figure.iframe-wrapper iframe {
    width: 100%;
    aspect-ratio: 0.59
}

figure.iframe-wrapper figcaption {
    font-family: "Source Sans Pro", "Helvetica Neue", Arial, sans-serif;
    text-align: center;
    font-size: 16px;
    line-height: 28px;
}

.col2 .viewer figure {
    width: 100%;
}

.preview .container,
#main-wrapper.col2>.container {
    max-width: 1200px !important;
    padding: 0 !important;
}

.preview .container>.row {
    max-width: 1000px;
    margin: auto !important;
}

.preview .container,
.col2>.container {
    width: 100% !important;
    max-width: 1200px !important;
    overflow: visible;
    display: flex;
    padding: 0 !important;
    margin: 0 !important;
}

.preview #sidebar {
    display: none !important;
    width: 0 !important;
}

.preview #main-wrapper {
    margin-left: 0;
}

#main-wrapper.col1>.container {
    width: 100% !important;
    max-width: unset;
}

.col1>.container main {
    max-width: 1200px;
}

.preview .container main,
.col2>.container main {
    width: 100%;
    padding: 0 !important;
}

.col2 article main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 1em;
}

#topbar-wrapper {
    position: sticky;
    width: 100%;
    top: 0;
    background-color: #fff;
    z-index: 200;
}

.access {
    top: 4em;
}

#toolbar {
    position: sticky;
    top: 48px;
    z-index: 100;

    height: 3rem;
    display: flex;
    align-items: center;

    background: rgba(255, 255, 255, .85);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, .08);
}

#toolbar .toolbar-inner {
    margin-left: auto;
    margin-right: .75rem;

    display: flex;
    align-items: center;
    gap: .5rem;

    padding: .3rem 0 .3rem 1rem;

    background: rgba(255, 255, 255, .92);
    border: 1px solid rgba(0, 0, 0, .10);
    border-radius: 999px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, .08);
}

/* Tooltip anchor wrapper */
#toolbar .toolbar-item {
    display: inline-flex;
    align-items: center;
}

/* Normalize common controls inside includes */
#toolbar .toolbar-inner a,
#toolbar .toolbar-inner button,
#toolbar .toolbar-inner sl-button::part(base) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;

    height: 2.2rem;
    padding: 0 .65rem;

    border-radius: .6rem;
    text-decoration: none;
}

/* If your includes are plain <a> or <button> (not sl-button) */
#toolbar .toolbar-inner a,
#toolbar .toolbar-inner button {
    border: 1px solid rgba(0, 0, 0, .12);
    background: rgba(255, 255, 255, .9);
    color: inherit;
    font: inherit;
    font-size: .9rem;
    line-height: 1;
    cursor: pointer;
}

#toolbar .toolbar-inner a:hover,
#toolbar .toolbar-inner button:hover,
#toolbar .toolbar-inner sl-button:hover::part(base) {
    box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
}

#toolbar .toolbar-inner a:active,
#toolbar .toolbar-inner button:active {
    transform: translateY(1px);
}

#toolbar .toolbar-inner a:focus-visible,
#toolbar .toolbar-inner button:focus-visible {
    outline: 2px solid rgba(0, 0, 0, .35);
    outline-offset: 2px;
}

/* Small screens: keep it from feeling cramped */
@media (max-width: 500px) {
    #toolbar {
        height: auto;
        padding: .4rem .5rem;
    }

    #toolbar .toolbar-inner {
        margin-right: .5rem;
        gap: .35rem;
        padding: .3rem .4rem;
    }

    #toolbar .toolbar-inner a,
    #toolbar .toolbar-inner button,
    #toolbar .toolbar-inner sl-button::part(base) {
        height: 2rem;
        padding: 0 .5rem;
    }
}

#search {
    margin-right: 2em;
    margin-left: auto !important;
}

.preview aside,
.col2 aside {
    display: none;
}

.col2 article header {
    /* display: none; */
}

.col2 .viewer {
    position: sticky;
    top: 92px;
    right: 0;
    width: calc(50% - 8em);
    height: 50dvh;
    /* padding-top: 1em; */
    align-items: start;
}

.col2 .active {
    background-color: #fff;
    box-shadow: 0 0 3px 1px #00000040;
    border-color: #9e9e9e;
    margin: 0 -0.5em 1em -0.5em;
    padding: 0 0.5em;
}

.trigger {
    color: inherit;
}

.post-content {
    font-size: 1.1em;
}

.col2 .post-content .active .trigger,
.col1 .post-content .trigger {
    columns: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: rgba(250, 128, 114, 0.7);
    text-decoration-thickness: 3px;
    cursor: pointer;
    color: inherit;
}

.col2 .post-content .active .trigger:hover,
.col1 .post-content .trigger:hover {
    background-color: rgba(250, 128, 114, 0.2)
}

.col2 .post-content iframe,
.col2 .post-content sl-tab-group,
.col2 .post-content figcaption,
.col2 .post-content p:has(>img),
.col2 .post-content p:has(>a>img) {
    display: none;
}

.col2 .post-content {
    /* width: calc(50% - 8px); */
    background-color: #F8F8F8;
    padding: 0 0.5em;
}

.col2 .right {
    margin: 0;
}

.viewer>iframe,
.viewer>sl-tab-group {
    width: 100%;
}

.post-index {
    margin-top: 2rem;
}

/* ===== container modes ===== */
.post-index.view-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(1, minmax(0, 1fr));
}

@media (min-width: 768px) {
    .post-index.view-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1200px) {
    .post-index.view-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* List mode: keep Chirpy-ish vertical stacking */
.post-index.view-list .post-index-item {
    margin-bottom: 1rem;
}

/* List mode: reassert Chirpy fixed card height */
.post-index.view-list .post-index-item.card {
    height: var(--bs-card-height);
    overflow: hidden;
    /* prevents long excerpts from expanding layout */
}

/* Make sure the <a> doesn’t introduce layout weirdness */
.post-index.view-list .post-index-link {
    height: 100%;
}

/* ===== link + base card layout ===== */
.post-index-link {
    display: flex;
    flex-direction: column;
    height: 100%;
    color: inherit;
    text-decoration: none;
}

/* ===== media ===== */
.post-index-media {
    width: 100%;
    overflow: hidden;
}

/* grid: top media with fixed aspect */
.post-index.view-grid .post-index-media {
    aspect-ratio: 16 / 9;
}

.post-index-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* list: side thumbnail on md+, like your original (image on the right) */
@media (min-width: 768px) {
    .post-index.view-list .post-index-link {
        flex-direction: row-reverse;
        gap: 0;
    }

    .post-index.view-list .post-index-media {
        width: 41.6667%;
        /* ~ col-md-5 */
        aspect-ratio: auto;
    }

    .post-index.view-list .post-index-body {
        width: 58.3333%;
        /* ~ col-md-7 */
    }
}

/* ===== title sizes (optional but helps match your original) ===== */
.post-index.view-list .post-index-title {
    font-size: 1.2rem;
}

/* like h1-ish */
.post-index.view-grid .post-index-title {
    font-size: 1.2rem;
}

/* like h2-ish */

/* ===== excerpt toggle behavior ===== */
/* show toggle only in grid */
.post-index.view-list .post-excerpt-toggle {
    display: none;
}

/* clamp only in grid (keeps grid tidy) */
.post-index.view-grid .post-excerpt {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    margin-bottom: 0.25rem;
    font-size: 90%;
    line-height: 1.4;
    color: var(--text-muted-color);
}

/* nicer placement */
.post-excerpt-wrap {
    position: relative;
}

.post-index.view-grid .post-excerpt-wrap::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 1.6rem;
    height: 2.4rem;
    pointer-events: none;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.9));
}

.post-excerpt-toggle {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    margin-left: auto;
    display: block;
    color: var(--bs-link-color);
}

/* expanded state */
.post-index-item.is-expanded .post-excerpt {
    -webkit-line-clamp: unset;
    display: block;
}

.post-index-item.is-expanded .post-excerpt-wrap::after {
    display: none;
}

.post-index.view-grid .post-index-item.card {
    height: auto;
}

.post-index.view-list .post-index-item.card {
    height: var(--bs-card-height);
}

.post-index.view-list .post-excerpt {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    /* tune */
    overflow: hidden;
    font-size: 90%;
    line-height: 1.4;
    color: var(--text-muted-color);
    margin-bottom: 0;
}

#main-wrapper p {
    font-size: 1.2rem;
}

.post-content {
    font-size: 1.1rem;
}

[id$="-csv"] {
    display: none;
}

.footnotes {
    overflow-wrap: break-word;
    word-wrap: break-word;
    -ms-word-break: break-all;
    word-break: break-all;
    word-break: break-word;
}

@media print {
    .keep-together-pair {
        break-inside: avoid !important;
        page-break-inside: avoid !important;
        /* Make it a real box */
        display: block !important;
    }

    /* Floats are the enemy of reliable keep-together */
    .keep-together-pair .right {
        float: none !important;
        clear: none !important;
        margin: 0 0 .6rem 0 !important;
    }

    /* If you want a “col2-ish” feel in print: use grid instead of float */
    .keep-together-pair {
        display: grid !important;
        grid-template-columns: 1fr auto;
        column-gap: 1rem;
        align-items: start;
    }

    /* Put text first, media second */
    .keep-together-pair>p {
        grid-column: 1;
    }

    .keep-together-pair>iframe,
    .keep-together-pair>sl-tab-group,
    .keep-together-pair>figure,
    .keep-together-pair>p:has(>img),
    .keep-together-pair>p:has(>a>img) {
        grid-column: 2;
    }
}

/* Base wrapper for index card images */
.post-index-item .post-index-media {
    width: 100%;
    overflow: hidden;
    border-radius: inherit;
    /* match card rounding */
}

/* Image fills the crop box */
.post-index-item .post-index-media>img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    /* avoid inline gaps */
}

/* LIST VIEW: banner-style (1200 / 630 ≈ 1.9) */
.view-list .post-index-item .post-index-media {
    aspect-ratio: 1200 / 630;
}

/* GRID VIEW: square cards */
.view-grid .post-index-item .post-index-media {
    aspect-ratio: 4 / 3;
}

iframe {
    transition: height 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

.post-tail-wrapper {
    clear: both;
}