i {
    font-style: italic;
}

main {
    width: 97%;
    max-width: 2100px;
}

/* HEADER */
body>header {
    height: auto !important;
    flex: 0 0 auto;
}

body>header .first {
    display: flex;
    align-items: center;
    width: 23%;
    margin-left: 1.5rem;
    border-right: solid 2px rgba(0, 0, 0, 0.2);
    max-width: 20rem;
}

body>header .main {
    width: 100%;
    padding-top: 1rem !important;
    padding-bottom: 1rem;
    max-width: unset;

}

body>header .second ul {
    font-size: 18px;
    margin-bottom: auto;
    margin-top: auto;
    max-width: 56rem;
}

body>header .first img {
    height: 57px;
}

body>header .second {
    position: relative;
    padding-right: 21%;
    width: 65%;
}

body>header .second img {
    position: absolute;
    right: 3%;
    top: -2rem;
    height: 87px;
    transform: rotate(5deg);
}

body>header .first h1 {
    font-size: 16px;
    text-align: left;
    margin-bottom: 0;
    margin-left: 0.2rem;
    width: 100%;
}


/* HERO  */
header .hero .left {
    margin-top: 2rem;
}

/* INTRODUCTION */
.intro {
    margin-top: 2rem;
    margin-left: 2rem;
}

/* TIMELINE CONTAINER */
#timeline {
    display: flex;
}

/* TIMELINE OVERVIEW (left) */
.overview {
    margin-top: 3rem;
    margin-right: 1rem;
}

.overview .item {
    display: flex;
    margin-bottom: 2rem;
    align-items: center;
    cursor: pointer;
    font-size: 18px;
    min-height: 5rem;
    z-index: 10;
    position: relative;
    user-select: none;
}

.overview .item img {
    width: 39px;
    margin-right: 0.3rem;
    border-radius: 0.3rem;
}

.overview .item img[alt="No cover"] {
    opacity: 0.4;
}

.overview .item .date {
    min-width: 7rem;
    text-align: right;
    margin-right: 2rem;
    font-family: SohneHalbfett;
}


.overview .item .id {
    width: 3rem;
}

.overview ul {
    position: relative;
}

.verticalDivider {
    z-index: 0;
    pointer-events: none;
    user-select: none;
    position: absolute;
    display: block;
    left: 7.8rem;
    width: 9px;
    /* thickness of the bar */
    height: 100%;
    background: white;
    /* the central color */
    /* soft shadows on both sides */
    box-shadow:
        -1px 0 5px rgba(0, 0, 0, 0.08),
        /* left shadow */
        1px 0 5px rgba(0, 0, 0, 0.08);
    /* right shadow */
}

.activeDivider {
    display: none;
    left: 7.8rem;
    width: 9px;
    /* thickness of the bar */
    height: 46px;
    background: var(--red);
    border-radius: 10px;
    position: absolute;
    margin-top: 0.1rem;
}

.activeDivider.active {
    display: block;
}

/* FACS (right) */

.facs {
    width: -webkit-fill-available;
    margin-top: 3rem;
    position: sticky;
    top: 6dvh;
    max-height: 100dvh;
    overflow: auto;
    overscroll-behavior: contain;
    display: flex;

}

.facs::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, new Edge */
}

#mirador {
    min-width: 100%;
    position: relative;
    margin-left: 2rem;
    border-radius: 16px;
    margin-left: -4rem;
    margin-right: 0.5rem;
    z-index: 0;
}

.reading {
    min-width: 73%;
    height: 90%;
    display: flex;
    margin-bottom: 2rem;
    justify-content: space-around;
    position: relative;
}

.facs .arrow {
    cursor: pointer;
    margin-top: auto;
    margin-bottom: auto;
    z-index: 1;
}

.leftArrowContainer {
    left: 45px;
}

.rightArrowContainer {
    right: 45px;
}

.leftArrowContainer,
.rightArrowContainer {
    display: flex;
    position: absolute;
    top: 50%
}

.rightArrowContainer img {
    transform: rotate(180deg);
}

.rightArrowContainer img,
.leftArrowContainer img {
    background-color: white;
    border-radius: 5rem;
    border: white solid 1px;
}

.miradorNav {
    position: absolute;
    top: 0.8rem;
    left: 3rem;
    display: flex;
    font-size: 0.772rem;
    background-color: white;
    padding: 0.4rem;
    border-radius: 1rem;
    opacity: 0.8;
}

.miradorNav>p {
    font-family: SohneHalbfett;
}

.miradorNav ul {
    display: flex;
}

.miradorNav ul li {
    margin-left: 1rem;
}

.miradorNav ul a {
    color: black
}

/* METADATA SECTION */

.toEditionButton {
    text-align: center;
}

.toEditionButton a {
    color: black;
    width: 11rem;
    display: inline-block;
    border-radius: 25px;
    border: 1px solid black;
    text-decoration: none;
    font-weight: 500;
    text-align: center;
    font-size: 1rem;
    line-height: 2rem;
    width: 8rem;
}

.toEditionButton a:hover {
    background-color: black;
    color: white;
}

.dropdown {
    width: -webkit-fill-available;
    font-size: 15px;
    margin-bottom: 2rem;
}

.dropdown .heading {
    font-size: 16px;
    font-family: SohneHalbfett;
    display: flex;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.2);
}

.dropdown .heading h4 {
    margin-left: 0.8rem;
    margin-bottom: 0.2rem;
}

.dropdown .heading img {
    width: 1rem;
    margin-left: 0.1rem;
}

.metadata .details {
    margin-top: 0.8rem;
    margin-left: 0.5rem
}

.metadata .details h4 {
    font-family: SohneHalbfett;
}

.metadata .details .cover {
    height: 83px;
}

.metadata .details .detailsContainer {
    margin-top: 0.5rem;
    display: flex;
}

.metadata .details li {
    display: flex;
    margin-bottom: 0.8rem;
}

.metadata .details li .label {
    font-family: SohneHalbfett;
    min-width: 7rem;
}

.metadata .details li .value {
    line-height: 1.3rem;
}

.metadata .details .desc {
    display: inline;
}

.metadata .details .desc .label {
    margin-bottom: 0.2rem;
}

.metadata .details .layers {
    margin-top: 0.8rem;
    display: block;
}

.metadata .details .layers .label {
    margin-bottom: 0.3rem;
}

.metadata .details .layers .layersContent li {
    display: block;
    margin-bottom: 0;
    margin-bottom: 0.5rem;
}

.layersContent li .layerId {
    display: inline-block;
    background: #eee;
    padding: 2px 2px;
    border-radius: 4px;
    margin-right: 6px;
    white-space: nowrap;
}

.layersContent li {
    margin-left: 1.5rem;
}

.layersContent li::before {
    content: "•";
    position: absolute;
    left: 1rem;
    font-size: 1.1em;
    color: black;
}


.downloadsLinks {
    margin-bottom: 5rem;
}


.downloadsContainer ul {
    margin-top: 0.5rem;
    margin-left: 0.5rem
}

.downloadsContainer a {
    display: flex;
    align-items: center;
    text-decoration: underline 1px black;
    color: black;
    margin-bottom: 1rem;
    margin-left: 1rem;
}

.downloadsContainer a:hover {
    text-decoration: underline 1px var(--green);
    color: var(--green)
}

.downloadsContainer li {
    cursor: pointer;
    margin-left: 0.5rem
}

.downloadsContainer li img {
    margin-top: 0.2rem;
    width: 31px;
    margin-right: 1rem;
}

.linksContainer li {
    margin-left: 0.5rem;
    margin-top: 0.8rem;
    cursor: pointer;
}

.linksContainer img {
    height: 39px;
    margin-right: 1rem;
    margin-left: 1rem;
}

.linksContainer a {
    display: flex;
    align-items: center;
    color: black;
    text-decoration: underline black solid 1px;
}

.linksContainer a:hover {
    color: var(--green);
    text-decoration: underline var(--green) solid 1px;
}

.copyright .value {
    width: 73%;
    margin-left: auto;
    margin-right: auto;
    margin-top: 0.5rem;
    line-height: 1.2rem;
}

.dropdown.closed .content {
    display: none;
}

.dropdown.closed .heading img {
    transform: rotate(90deg);
}

.dropdown .heading img {
    transform: rotate(180deg);
}

#mirador header {
    height: auto;
}

.side-panel {
    min-width: 23%;
    max-width: 23%;
    height: 90%;
    position: relative;
    overflow: auto;
}

.help {
    height: 2rem;
    cursor: pointer;
    position: absolute;
    bottom: 1%;
    right: 4%;
    visibility: visible;
}

.noReading {
    position: absolute;
    width: 75%;
    text-align: center;
    top: 5rem;
}

#driver-popover-title {
    height: auto;
    background-color: white;
}



/* === Mobile hamburger (hidden on desktop) === */
.hamburger {
    display: none;
    position: absolute;

    right: 1rem;
    top: 1rem;
    width: 42px;
    height: 42px;
    border: 0;
    background: transparent;
    z-index: 100001;
}

/* Bars */
.hamburger span {
    display: block;
    width: 28px;
    height: 2px;
    background: #111;
    border-radius: 1px;
    transition: transform .25s ease, opacity .25s ease;
}

/* X state */
.hamburger[aria-expanded="true"] span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.hamburger[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
}

.hamburger[aria-expanded="true"] span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

/* Full-screen mobile menu overlay */
.mobileMenu {
    position: fixed;
    inset: 0;
    z-index: 100000;
    background: rgba(255, 255, 255, 0.98);
    display: none;
    padding: 6rem 2rem 2rem;
}

.mobileMenu.open {
    display: block;
}

/* Typography/layout inside the cloned UL */
.mobileMenu ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 1.25rem;
}

.mobileMenu li a {
    font-family: SohneHalbfett, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: clamp(1.35rem, 3.5vw, 2rem);
    text-decoration: none;
    color: #111;
}

/* Prevent body scroll when menu is open */
body.menu-open {
    overflow: hidden;
}

.mobileVersion {
    display: none !important;
}

.facsC {
    display: none !important;
}

/* ===== Mobile resilience & iOS viewport utilities ===== */
html {
    -webkit-text-size-adjust: 100%;
}

:root {
    --vh: 1vh;
    --header-h: 56px;
}

@supports (height: 100dvh) {
    :root {
        --vh: 1dvh;
    }
}

.vh-100 {
    height: calc(var(--vh) * 100);
}

html,
body {
    min-height: 100%;
}

body {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1 1 auto;
    min-height: 0;
}

input,
select,
textarea {
    font-size: 16px;
}

body,
p,
li {
    overflow-wrap: anywhere;
}

/* ===== Mobile layout (<=800px or <=500px height) ===== */
@media (max-width: 800px),
(max-height: 500px) {

    main {
        overflow: visible;
        min-height: 0;
    }

    /* Keep sticky and respect iPhone safe area */
    .facs {
        position: sticky;
        top: calc(var(--header-h) + env(safe-area-inset-top, 0px));
        width: 100%;
        width: -webkit-fill-available;
        margin-top: 1rem !important;
        display: initial !important;
        overflow: initial !important;
        /* keep Mirador free */
    }

    /* Move scrolling inside, with dynamic height */
    .reading {
        position: relative;
        overflow: auto;
        -webkit-overflow-scrolling: touch;
        min-height: calc(80dvh - var(--header-h) - env(safe-area-inset-top, 0px));
        max-height: calc(80dvh - var(--header-h) - env(safe-area-inset-top, 0px));
        min-width: 100%;
        z-index: 20000;
    }

    .mobileMenu {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        overscroll-behavior: contain;
        z-index: 100002;
    }

     div[id^="tippy"] { display: none; } 

    .mobileVersion {
        display: initial !important;
    }

    header>.main:nth-child(1) {
        display: none !important;
    }

    .hamburger {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-direction: column;
        gap: 6px;
        position: absolute;
        right: 1rem;
        top: 1rem;
        width: 42px;
        height: 42px;
        border: 0;
        background: transparent;
        z-index: 100003;
    }

    header .second ul {
        display: none;
    }

    header .main {
        position: relative;
    }

    header {
        top: env(safe-area-inset-top, 0px);
        background: var(--white, #fff);
        height: auto;
        margin-left: calc(50% - 50vw);
        margin-right: calc(50% - 50vw);
        padding-left: 1rem;
    }

    .mobileMenu .mobileLogo {
        position: absolute;
        left: 1rem;
        top: 1.5rem;
        height: 28px;
        width: auto;
        display: block;
    }

    *,
    *::before,
    *::after {
        box-sizing: border-box;
    }

    html,
    body {
        margin: 0;
        padding: 0;
    }

    header .main h1 {
        display: none;
    }

    body>header .main {
        width: 100% !important;
        max-width: none !important;
        align-items: center;
        display: block !important;
        background-color: var(--white);
        padding-top: 1.5rem !important;
    }

    header>.main:first-of-type>img {
        display: none;
    }

    header .main .mobileLogo {
        display: block;
        margin: 0;
        padding: 0;
        height: 28px !important;
        width: auto;
    }

    header .second {
        width: 100% !important;
        margin: 0;
        margin-top: 1rem !important;
        position: initial !important;
    }

    header .second h1 {
        font-size: 28px !important;
        margin: 0.25rem 0 0.5rem !important;
        text-align: left !important;
        color: var(--green);
    }

    header .mobileBird {
        position: absolute !important;
        top: 8.3px !important;
        right: 53px !important;
        height: 3.8rem !important;
    }

    .intro p {
        display: none !important;
    }

    .intro {
        margin-top: 0.8rem !important;
        margin-left: 1.3rem !important;
    }

    #timeline {
        display: initial !important;
    }

    .overview {
        margin-top: 0.5rem !important;
        margin-right: 0 !important;
    }

    .overview ul {
        display: flex;
        overflow: auto;
        gap: 0.75rem;
    }

    .overview .verticalDivider {
        width: 552rem !important;
        height: 9px !important;
        bottom: 27px !important;
        left: 1.8rem !important;
    }

    .overview .activeDivider {
        width: 46px !important;
        height: 9px !important;
        bottom: -5px !important;
        left: 7.2rem !important;
    }

    .overview .item .date {
        margin-right: 0.4rem !important;
    }

    .overview .item .id {
        width: 3rem !important;
    }

    .side-panel {
        min-width: 92% !important;
        margin-left: auto;
        margin-right: auto;
    }

    .help {
        display: none !important;
    }

    /* Mirador container stability */
    #mirador {
        position: initial !important;
        min-height: 60dvh;
    }

    #mirador .mirador21 {
        padding-left: 0 !important;
        padding-top: 0 !important;
    }

    .miradorNav {
        z-index: 5000;
        width: 93%;
        overflow: auto;
        left: 1rem;
    }

    
    .miradorNav ul li, .miradorNav p {
        width: max-content;
        overflow-wrap: unset;
    }

    .miradorNav > p {
        min-width: 4rem;
    }

    .leftArrowContainer,
    .rightArrowContainer {
        top: 92%;
    }

    .rightArrowContainer {
        right: 4px;
    }

    .leftArrowContainer {
        left: 4px;
    }

    /* Mirador touch handling */
    .mirador-viewer,
    .openseadragon-container,
    .openseadragon-canvas {
        touch-action: none;
        overscroll-behavior: contain;
    }
}