/* ==========================================================
   TABLET
   Applies from 761px through 1050px
========================================================== */

@media (min-width: 761px) and (max-width: 1050px) {
    .masthead {
        grid-template-columns: minmax(0, 1fr) 240px;
        gap: 32px;
    }

    .masthead__portrait {
        width: 240px;
        justify-self: end;
    }

    .project-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .secondary-grid {
        grid-template-columns: 1fr;
        gap: 60px;
    }

    .about-panel {
        padding-top: 48px;
        padding-left: 0;

        border-top: 1px solid var(--border);
        border-left: 0;
    }
}


/* ==========================================================
   MOBILE
   Applies only below 760px
========================================================== */

@media (max-width: 760px) {
    body,
    button,
    a {
        cursor: auto;
    }

    .cursor,
    .glow {
        display: none;
    }


    /* ======================================================
       HEADER
    ====================================================== */

    .masthead {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 138px;
        gap: 14px;
        align-items: end;

        min-height: auto;
        padding: 60px 0 26px;
    }

    .masthead__content {
        grid-column: 1;
        grid-row: 1;

        min-width: 0;
        align-self: end;
    }

    .masthead__portrait {
        grid-column: 2;
        grid-row: 1;

        width: 138px;
        align-self: end;
        justify-self: end;

        overflow: visible;
        background: transparent;
    }
.masthead__portrait .portrait-image {
    display: block;

    width: 100%;
    height: auto;

    object-fit: contain;
    object-position: center bottom;

    opacity: 1;
    filter: none;
    mix-blend-mode: normal;
}

/* Light theme */
.masthead__portrait .portrait-image--light {
    display: block;
}

.masthead__portrait .portrait-image--dark {
    display: none;
}

/* Dark theme */
html[data-theme="dark"]
.masthead__portrait
.portrait-image--light {
    display: none;
}

html[data-theme="dark"]
.masthead__portrait
.portrait-image--dark {
    display: block;
}

    .masthead__name {
        margin-bottom: 12px;

        font-size: clamp(3.7rem, 14vw, 4.5rem);
        line-height: 0.82;
    }

    .masthead__intro {
        margin-bottom: 18px;

        font-size: 1.15rem;
    }

    .primary-nav {
        gap: 10px 16px;
    }


    /* ======================================================
       THEME TOGGLE
    ====================================================== */

    .theme-toggle {
        top: 12px;
        right: 0;

        padding: 6px 8px;
    }

    .theme-toggle__icon {
        width: 13px;
        height: 13px;

        font-size: 0.75rem;
    }

    .theme-toggle__track {
        width: 34px;
        height: 18px;
    }

    .theme-toggle__thumb {
        width: 12px;
        height: 12px;
    }

    html[data-theme="dark"] .theme-toggle__thumb {
        transform: translateX(16px);
    }


    /* ======================================================
       GENERAL SECTION HEADINGS
    ====================================================== */

    .section-heading {
        flex-direction: column;
        align-items: flex-start;
    }


    /* ======================================================
       MOBILE SELECTED WORK ACCORDION
    ====================================================== */

    .work-section {
        padding: 0;

        border-top: 1px solid var(--border);
        border-bottom: 1px solid var(--border);
    }

    .work-section__heading {
        display: block;

        width: 100%;
        margin: 0;
        padding: 0;
    }

    .desktop-section-title {
        display: none;
    }

    .mobile-section-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;

        width: 100%;
        min-height: 116px;
        margin: 0;
        padding: 18px 0;

        border: 0;
        background: transparent;

        text-align: left;
    }

    .mobile-section-toggle > span:first-child {
        display: flex;
        flex-direction: column;
        align-items: flex-start;

        margin: 0;
        padding: 0;
    }

    .mobile-section-toggle .eyebrow {
        display: block;
        align-self: flex-start;

        margin: 0 0 6px 0;
        padding: 0;

        position: static;

        text-align: left;
        text-indent: 0;

        transform: none;
    }

    .mobile-section-title {
        display: block;
        align-self: flex-start;

        margin: 0;
        padding: 0;

        font-family: "Cormorant Garamond", serif;
        font-size: 2rem;
        font-weight: 500;
        line-height: 1;

        text-align: left;
    }

    .mobile-section-arrow {
        flex: 0 0 auto;

        width: 12px;
        height: 12px;
        margin-right: 2px;

        border-right: 2px solid currentColor;
        border-bottom: 2px solid currentColor;

        transform: rotate(45deg);
        transition: transform 220ms ease;
    }

    .mobile-section-toggle[aria-expanded="true"]
    .mobile-section-arrow {
        transform: rotate(225deg);
    }


    /* ======================================================
       COLLAPSED PROJECT CONTENT
    ====================================================== */

    .work-section__content {
        display: none;

        padding-bottom: 32px;
    }

    .mobile-collapsible.is-expanded
    .work-section__content {
        display: block;
    }

    .filter-bar {
        display: none;

        margin-bottom: 24px;
    }

    .mobile-collapsible.is-expanded
    .filter-bar {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .project-grid {
        grid-template-columns: 1fr;
        gap: 28px;
    }


    /* ======================================================
       MOBILE BOOKSHELF ACCORDION
    ====================================================== */

    .writing-panel__heading {
        display: none;
    }

    #bookshelf-content {
        display: none;

        margin-bottom: 32px;
    }

    .mobile-section-toggle,
    .mobile-section-toggle * {
        cursor: pointer;
        user-select: none;
        -webkit-user-select: none;
        caret-color: transparent;
    }

    .mobile-collapsible.is-expanded
    #bookshelf-content {
        display: block;
    }


    /* ======================================================
       WRITING AND ABOUT
    ====================================================== */

    .secondary-grid {
        grid-template-columns: 1fr;
        gap: 0;

        padding-top: 0;
        border-top: 0;
    }

    .about-panel {
        padding-top: 40px;
        padding-left: 0;

        border-top: 1px solid var(--border);
        border-left: 0;
    }


    /* ======================================================
       FOOTER
    ====================================================== */

    .site-footer {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .site-footer span,
    .site-footer span:nth-child(2),
    .site-footer span:last-child {
        text-align: left;
    }
}


/* ==========================================================
   SMALL PHONES
   Applies only below 480px
========================================================== */

@media (max-width: 480px) {
    :root {
        --page-padding: 18px;
    }

    .masthead {
        grid-template-columns: minmax(0, 1fr) 118px;
        gap: 10px;
        align-items: end;
    }

    .masthead__portrait {
        width: 118px;
    }

    .masthead__name {
        font-size: clamp(3.25rem, 13vw, 3.8rem);
    }

    .masthead__intro {
        font-size: 1rem;
    }

    .primary-nav {
        gap: 8px 14px;
    }

    .filter-button {
        padding: 6px 10px;

        font-size: 0.68rem;
    }
}