/* Shared responsive safeguards for every page. Page styles can refine these. */

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    font-variant-emoji: text;
    -webkit-font-variant-emoji: text;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    max-width: 100%;
}

body {
    overflow-x: hidden;
    overflow-x: clip;
}

img,
video,
iframe,
canvas,
svg {
    max-width: 100%;
}

img,
video {
    width: auto;
    height: auto;
}

/* Let grid and flex children shrink to the available viewport width. */
main,
section,
header,
footer,
article,
nav,
figure,
form,
fieldset {
    min-width: 0;
    max-width: 100%;
}

.foto-pagina .fullscreen-foto {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    object-fit: cover;
}

iframe {
    display: block;
}

#siteFrame {
    height: 100vh;
    height: 100dvh;
}

h1,
h2,
h3,
h4 {
    max-width: 100%;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
}

p,
li,
figcaption,
blockquote {
    max-width: 100%;
    overflow-wrap: anywhere;
}

input,
textarea,
select,
button {
    max-width: 100%;
}

textarea {
    min-width: 0;
}

pre,
code {
    max-width: 100%;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.dropdown-content {
    width: max-content;
    max-width: calc(100vw - 24px);
}

.dropdown-content a {
    min-height: 44px;
    overflow-wrap: anywhere;
}

@media (max-width: 800px) {
    body {
        width: 100%;
        min-width: 0;
        /* Reserve scrollable room below the final content. Mobile Chrome can
           overlay its bottom toolbar on the document's last pixels. */
        padding-bottom: calc(104px + env(safe-area-inset-bottom, 0px)) !important;
        scroll-padding-bottom: calc(104px + env(safe-area-inset-bottom, 0px));
    }

    main,
    section,
    article,
    figure,
    form {
        max-width: 100%;
    }

    img,
    video,
    iframe,
    canvas,
    svg {
        max-width: 100%;
    }

    table {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Keep expanded footer navigation in normal document flow on touchscreens.
       Absolute footer menus can be clipped by mobile browser viewports. */
    .grim-footer {
        position: relative !important;
        z-index: 20;
        isolation: isolate;
        overflow: visible !important;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        scroll-margin-bottom: 24px;
    }

    .grim-footer-dropdown {
        position: static !important;
        inset: auto !important;
        width: 100% !important;
        max-height: 0;
        overflow: hidden;
    }

    .grim-footer.footer-open .grim-footer-dropdown {
        position: static !important;
        max-height: none !important;
        overflow: visible;
    }

    .fullscreen-foto,
    .foto-pagina .fullscreen-foto {
        width: 100%;
        height: 100vh;
        height: 100dvh;
        object-fit: cover;
    }
}

@media (max-width: 600px) {
    html {
        overflow-x: clip;
    }

    body {
        width: 100%;
        max-width: 100%;
        overflow-x: clip;
    }

    /* Some older page styles use desktop minimum widths. Clamp every item to
       its parent on narrow screens so it stays reachable instead of being cut
       off at the viewport edge. */
    body * {
        min-width: 0 !important;
    }

    body > *,
    main,
    section,
    article,
    figure,
    form,
    img,
    video,
    iframe,
    canvas,
    table,
    input,
    textarea,
    select,
    button {
        max-width: 100% !important;
    }

    /* Keep display headings bold and unmistakably large on phones while
       allowing them to wrap at spaces instead of clipping off-screen. */
    h1 {
        max-width: 100%;
        font-size: clamp(48px, 17vw, 108px) !important;
        line-height: .82 !important;
        text-wrap: balance;
        overflow-wrap: normal;
        word-break: normal;
    }

    h2 {
        max-width: 100%;
        font-size: clamp(40px, 14vw, 88px) !important;
        line-height: .88 !important;
        text-wrap: balance;
        overflow-wrap: normal;
        word-break: normal;
    }

    p,
    li {
        font-size: clamp(.9rem, 3.8vw, 1.1rem);
        line-height: 1.45;
    }

    marquee {
        max-width: 100%;
        font-size: clamp(1rem, 6vw, 2rem);
    }

    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="url"],
    input[type="number"],
    textarea,
    select {
        font-size: max(16px, 1em);
    }

    .dropdown-content {
        min-width: min(200px, calc(100vw - 24px));
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    .radio-player {
        max-height: calc(100dvh - 24px);
        overflow-y: auto;
    }
}

@media (hover: none) {
    button:hover,
    a:hover {
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
