/* Phone layout. Everything here is scoped by media query: the first block only
   hides phone-only markup on wider screens, the second holds every phone rule. */

@media (min-width: 701px) {
    .mobile-only {
        display: none !important;
    }

    /* Wrapper used for the phone layout of service years; invisible to the desktop layout */
    .service-years,
    .service-group {
        display: contents;
    }

    /* The year follows the text in the source; the desktop layout shows it first */
    .recognition-line > .recognition-year {
        order: -1;
    }
}

@media (max-width: 700px) {
    .desktop-only {
        display: none !important;
    }

    body,
    .main-content {
        overflow-x: visible;
        overflow-x: clip;
    }

    .main-content {
        min-height: 0;
    }

    /* ---------- Fixed header: icon row on top, nav tabs below ---------- */

    .sidebar-toggle,
    .mobile-menu-toggle,
    .sidebar-overlay {
        display: none !important;
    }

    /* Room for the two fixed rows: 44px icons + 50px tabs */
    body {
        padding-top: 94px;
    }

    [id] {
        scroll-margin-top: 106px;
    }

    /* Row 1: profile links, icon only */
    .sidebar-links {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 101;
        box-sizing: border-box;
        width: auto;
        height: 44px;
        margin: 0;
        padding: 0 16px;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: space-evenly;
        background-color: var(--white);
    }

    .sidebar-links li {
        margin: 0;
    }

    .sidebar-link {
        width: auto;
        padding: 6px;
        font-size: 0;
        justify-content: center;
    }

    .sidebar-link i {
        width: auto;
        margin: 0;
        font-size: 20px;
    }

    /* Row 2: horizontally scrollable nav tabs between two cobalt lines */
    .header {
        position: fixed;
        top: 44px;
        left: 0;
        right: 0;
        width: auto;
        padding: 0;
        z-index: 100;
        transform: none;
        will-change: auto;
        background-color: var(--white);
    }

    .header .container {
        max-width: 100%;
        margin: 0;
        padding: 0 0 0 16px;
        border-top: 3px solid var(--primary-blue);
        border-bottom: 3px solid var(--primary-blue);
    }

    .header .header-content {
        display: flex;
        align-items: center;
        height: 44px;
        margin-left: 0;
        padding: 0 16px 0 0;
        justify-content: flex-start;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .header .header-content::-webkit-scrollbar {
        display: none;
    }

    .nav-list {
        gap: 22px;
        flex-wrap: nowrap;
        justify-content: flex-start;
        padding-right: 0;
    }

    .nav-link {
        font-size: 15px;
        padding: 2px 0;
        white-space: nowrap;
    }

    .nav-link.active::after {
        bottom: -7px;
        height: 3px;
    }

    /* ---------- Profile block (scrolls with the page) ---------- */

    .sidebar,
    .sidebar-toggle:checked ~ .sidebar,
    .sidebar-toggle:not(:checked) ~ .sidebar {
        position: static;
        transform: none !important;
        width: 100%;
        height: auto;
        padding: 14px 16px 0;
        overflow: visible;
        box-shadow: none;
        transition: none;
        will-change: auto;
    }

    /* Home only: large centered photo with the name and title centered beneath */
    .sidebar-content {
        display: flex;
        flex-direction: column;
        align-items: center;
        height: auto;
        padding: 6px 0 0;
    }

    .sidebar .profile-photo {
        width: 60vw;
        height: 60vw;
        max-width: 320px;
        max-height: 320px;
        align-self: center;
        margin: 0 0 12px;
        border-width: 3px;
        border-radius: 16px;
        box-shadow: none;
        object-fit: cover;
    }

    .sidebar-name {
        font-size: 20px;
        font-weight: 600;
        line-height: 1.25;
        text-align: center;
        margin: 0;
    }

    .sidebar-title,
    .affiliation-text {
        font-size: 15px;
        font-weight: 500;
        line-height: 1.35;
        text-align: center;
        margin: 0;
    }

    .sidebar-separator {
        display: none;
    }

    /* Other pages: no profile block, only the fixed icon row lives in the sidebar */
    body:not(.home) .sidebar {
        padding: 0 !important;
    }

    body:not(.home) .sidebar-content {
        padding: 0;
    }

    body:not(.home) .sidebar .profile-photo,
    body:not(.home) .sidebar-name,
    body:not(.home) .sidebar-title,
    body:not(.home) .affiliation-text {
        display: none;
    }

    /* ---------- Page body ---------- */

    .main {
        padding-top: 18px;
        margin-top: 0;
    }

    .container {
        max-width: 100%;
        margin-left: 0;
        padding: 0 16px;
    }

    .service-section {
        margin-top: 0;
    }

    .service-section .bibliography:first-of-type {
        margin-top: 0 !important;
    }

    .students-section:first-of-type {
        margin-top: 0;
    }

    /* ---------- Type sizes ---------- */

    .about-text,
    .update-text,
    .impact-title,
    .impact-text,
    .recognition-text,
    .venue-text,
    .publication-entry .publication-title,
    .media-title,
    .talk-title,
    .student-name-link,
    .student-name-text {
        font-size: 15px !important;
    }

    .publication-entry .publication-authors,
    .publication-entry .publication-venue,
    .publication-entry .publication-note,
    .publication-mark-legend,
    .media-source,
    .media-date,
    .talk-venue,
    .talk-description,
    .student-years,
    .student-affiliation,
    .update-meta,
    .impact-label {
        font-size: 13.5px !important;
    }

    .bibliography {
        font-size: 17px;
    }

    .update-link,
    .media-link,
    .service-link,
    .student-name-link,
    .student-name-text,
    .project-link {
        text-decoration-thickness: 1.5px;
    }

    /* ---------- Home ---------- */

    .important-announcement-banner {
        border: none;
        padding: 8px 12px 8px 10px;
        gap: 8px;
    }

    .important-announcement-text {
        font-size: 14px;
        line-height: 1.2;
        white-space: nowrap;
    }

    /* Updates: date and category on one line above the text, timeline kept on the left */
    .updates-year {
        width: auto;
        text-align: left;
    }

    .update-entry {
        display: block;
        position: relative;
        margin-left: 4px;
        padding: 0 0 18px 18px;
        border-left: 2px solid #dbe3f5;
    }

    .update-entry:last-child {
        padding-bottom: 4px;
    }

    .update-entry::before {
        content: "";
        position: absolute;
        left: -6px;
        top: 5px;
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background: var(--white);
        border: 2px solid var(--primary-blue);
        box-sizing: border-box;
    }

    .update-meta {
        text-align: left;
        line-height: 20px;
    }

    .update-cat {
        display: inline;
        margin: 0 0 0 8px;
        font-size: 12.5px;
        line-height: inherit;
    }

    .update-body {
        margin: 2px 0 0;
        padding: 0;
        border-left: none;
        min-height: 0;
    }

    .update-body::before {
        display: none;
    }

    /* ---------- Publications ---------- */

    .publication-filters {
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
        gap: 10px 12px;
        margin-bottom: 20px;
    }

    .publication-filters .filter-label {
        font-size: 15px;
    }

    .publication-filters .year-filters {
        width: auto;
        flex-wrap: nowrap;
    }

    .publication-filters .publication-mark-legend {
        flex: 0 0 100%;
        margin-left: 0;
    }

    /* Symbol column + text column, so both symbols line up with their text */
    .publication-mark-legend > div {
        display: grid;
        grid-template-columns: 18px minmax(0, 1fr);
        column-gap: 6px;
        align-items: center;
    }

    .publication-mark-legend sup {
        justify-self: center;
        font-size: 12px;
        line-height: 1;
    }

    /* ---------- Service ---------- */

    /* Entry and its years flow as one line of text */
    .service-venue {
        display: block;
        margin: 0;
        padding: 10px 0;
        line-height: 1.4;
    }

    /* Same separator as between publications */
    .service-entry + .service-entry > .service-venue,
    .service-entry + .service-entry > .recognition-line {
        border-top: 1px solid rgb(229, 231, 235);
    }

    /* Moves to the next line as a unit when it fits there */
    .service-years {
        display: inline-block;
        max-width: 100%;
        font-size: 15px;
        line-height: 1.4;
    }

    /* "(first year" and "last year)" never split; lines break only between years */
    .service-group {
        white-space: nowrap;
    }

    .service-nbsp {
        display: none;
    }

    .service-years .service-link {
        font-size: 15px;
    }

    .service-years .award-text {
        vertical-align: 1px;
    }

    /* ---------- Recognition: awards and fellowships ---------- */

    .recognition-line {
        display: block;
        margin: 0;
        padding: 10px 0;
        line-height: 1.4;
    }

    /* Year as plain text after the institution instead of a chip */
    .recognition-year,
    .recognition-year:hover {
        display: inline;
        min-width: 0;
        padding: 0;
        border: none;
        border-radius: 0;
        background: none;
        box-shadow: none;
        transform: none;
        color: var(--gray-700);
        font-size: 15px;
        font-weight: 400;
        white-space: nowrap;
    }

    a.recognition-year:not([href="#"]) {
        text-decoration: underline;
        text-underline-offset: 6px;
        text-decoration-color: var(--primary-blue);
        text-decoration-thickness: 1.5px;
    }

    /* Two rows: title, then institution and year. inline-block keeps the
       link underline off the comma. */
    .recognition-text strong {
        display: block;
    }

    .recognition-paren {
        display: none;
    }

    .recognition-year::before {
        content: ",\00a0";
        display: inline-block;
    }

    .recognition-amount {
        margin-left: 4px;
        vertical-align: 1px;
    }

    .media-entry {
        gap: 12px;
    }

    .media-date {
        width: 78px;
        min-width: 0;
        padding: 3px 0;
    }

    /* ---------- Talks and teaching: no chip, text uses the full width ---------- */

    .talk-date {
        display: none;
    }

    .talks-list {
        gap: 0;
    }

    .talk-entry {
        padding: 10px 0;
    }

    /* Same separator as between publications */
    .talk-entry + .talk-entry {
        border-top: 1px solid rgb(229, 231, 235);
    }

    .talk-entry,
    .talk-venue-container,
    .talk-content {
        display: block;
    }

    /* Invited talks: same scheme as awards, gray italic venue with a linked date */
    .service-list .talk-venue {
        color: var(--gray-600);
        font-size: 15px !important;
        font-weight: 400;
        line-height: 1.4;
    }

    .talk-date-inline {
        color: var(--gray-700);
        font-style: normal;
        white-space: nowrap;
    }

    a.talk-date-inline {
        text-decoration: underline;
        text-underline-offset: 4px;
        text-decoration-color: var(--primary-blue);
        text-decoration-thickness: 1.5px;
    }

    /* Teaching: role on its own line in the same gray */
    .talk-role {
        color: var(--gray-600);
        font-weight: 400;
    }

    /* "(Dec 2026)" after the talk title, in the regular gray text style */
    .talk-date-wrap {
        color: var(--gray-700);
        font-weight: 400;
        white-space: nowrap;
    }

    /* ---------- Media coverage: same year filter row as Publications ---------- */

    .media-coverage-filters {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 10px 12px;
        margin-bottom: 20px;
    }

    .media-coverage-filters .filter-label {
        font-size: 15px;
    }

    .media-coverage-filters .year-filters {
        width: auto;
        flex-wrap: nowrap;
        justify-content: flex-start;
    }
}
