.infobox {
    --infobox-border-color: #d6d6d6;
    --infobox-title-bg: #f2f2f2;
    --infobox-text-color: #333;
    --link-color: #007bff;
    --link-hover-color: #0056b3;

    float: right;
    width: 20rem;
    margin: 1rem 0 1rem 2rem;
    padding: 0;
    border: 0.0625rem solid var(--infobox-border-color);
    border-radius: 0.5rem;
    box-shadow: 0 0.125rem 0.3125rem rgba(0, 0, 0, 0.1);
    font-family: 'Rubik', sans-serif;
    font-size: 0.95rem;
    line-height: 1.5;
    background-color: var(--background-color, #fff);
    color: var(--infobox-text-color);
    overflow: hidden;
}

.infobox-title {
    margin: 0;
    padding: 0.8rem 1rem;
    background-color: var(--infobox-title-bg);
    border-bottom: 0.0625rem solid var(--infobox-border-color);
    font-size: 1.25rem;
    font-weight: 700;
    text-align: center;
    color: var(--main-color-dark);
}

.infobox-content {
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

.infobox-content > img {
    margin: 0 auto;
    max-width: calc(20rem - 2rem); /* Adjust for padding */
    min-width: unset;
}

/* Thumbnail preview row for infoboxes */
.infobox-thumbs {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    justify-content: center;
    flex-wrap: nowrap; /* keep them in a single row */
    overflow-x: auto; /* allow horizontal scrolling if there are too many thumbnails */
    -webkit-overflow-scrolling: touch;
}

/* Target generic image output inside the thumbs container so the shortcode remains generic */
.infobox-thumbs .blogImage {
    width: 3.25rem !important;
    height: 3.25rem !important;
    max-width: none !important;
    max-height: none !important;
    min-width: 0 !important; /* override .blogImage min-width on small screens */
    flex: 0 0 auto; /* don't grow or shrink */
    object-fit: cover;
    border-radius: 0.375rem;
    box-shadow: 0 0.0625rem 0.1875rem rgba(0,0,0,0.08);
    cursor: default;
}

@media (max-width: 40rem) {
    .infobox-thumbs {
        gap: 0.5rem;
    }
    .infobox-thumbs .blogImage {
        width: 3rem !important;
        height: 3rem !important;
    }
}

/* CSS-only image switcher: inputs, big items, and labels are rendered by the `infobox_images` shortcode */
.infobox-switcher {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}

/* Reorder items visually: big-items first (full width), then labels (horizontal row), inputs hidden */
.infobox-switcher .infobox-big-item { 
    order: 1;
    flex-basis: 100%;
    opacity: 0;
    transition: opacity 0.3s ease, visibility 0s ease 0.3s;
    position: absolute;
    width: calc(20rem - 2rem);
}

.infobox-switcher .infobox-thumb-label { order: 2; }
.infobox-switcher input[type="radio"] { order: 3; }

/* Show only the big item immediately after a checked radio */
.infobox-switcher input[type="radio"]:checked + .infobox-big-item { 
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0s ease;
    position: static;
    width: auto;
    transform: none;
}

.infobox-switcher .infobox-thumb-label { 
    cursor: pointer; 
    display: inline-block;
}

.infobox-switcher .infobox-thumb { 
    width: 3.25rem; 
    height: 3.25rem; 
    object-fit: cover; 
    border-radius: 0.375rem; 
    box-shadow: 0 0.0625rem 0.1875rem rgba(0,0,0,0.08);
    transition: box-shadow 0.3s ease;
}

.infobox-switcher .infobox-big-img { 
    max-width: calc(20rem - 2rem); 
    width: 100%; 
    height: auto; 
    display: block; 
    margin: 0 auto; 
}

/* Fade in shadow with gap for selected thumbnail */
.infobox-switcher input[type="radio"]:checked + .infobox-big-item + .infobox-thumb-label .infobox-thumb { 
    box-shadow: 0 0.0625rem 0.1875rem rgba(0,0,0,0.08), 0 0 0 0.125rem var(--background-color, #fff), 0 0 0 0.25rem var(--main-color-dark);
}

/* Make sure inputs are visually hidden but still focusable */
.infobox-switcher input[type="radio"] { 
    position: absolute; 
    
    outline: none;
}

.infobox-content dl {
    margin: 1rem auto;
    padding: 0;
    display: grid;
    grid-template-columns: 50% 50%;
    gap: 0.5rem 1rem;
    max-width: calc(20rem - 3rem); /* Adjust for padding and gap */
}

.infobox-content dt {
    font-weight: 700;
    color: var(--main-color-dark);
    text-align: left;
}

.infobox-content dd {
    margin-left: 0;
    text-align: left;
}

.infobox-content dd ul {
    margin: 0;
    padding-left: 1.2rem;
    list-style-type: disc;
}

.infobox-content dd ul li {
    margin-bottom: 0.2rem;
}

.infobox-content dd a {
    color: var(--link-color);
    text-decoration: none;
}

.infobox-content dd a:hover {
    text-decoration: underline;
    color: var(--link-hover-color);
}

@media (max-width: 40rem) {
    .infobox {
        float: none;
        width: 100%;
        margin: 1.5rem auto;
        box-sizing: border-box;
    }

    .infobox-content dd {
        text-align: right;
    }

    aside.infobox .infobox-content > div {
        max-width: 20rem;
        margin-left: auto;
        margin-right: auto;
    }
}

/* Only target first-level ULs (exclude ULs nested inside other ULs) */
ul li {
    font-weight: bold;
}

ul ul li {
    font-weight: normal;
    padding-left: 0;
}

ul ul li::before {
    content: unset;
}

ul > * > ul {
    list-style-type: none;
    padding-left: 1rem;
    padding-right: 1rem;
}