/*
 * UniCore | Spazio studenti
 *
 * File: assets/css/mobile-layout.css
 * Funzione: Stili per mobile layout.
 *
 * Copyright © 2026 Davide Giovanni Paolo Di Salvatore.
 * Proprietario di UniCore. Tutti i diritti riservati.
 *
 * Condizioni d’uso del codice e dei materiali originali in LICENSE.md.
 */

@media (max-width: 900px) {
  /* Contain horizontal overflow at the viewport, with scrollable tables inside. */
  html {
    overflow-x: hidden;
    overscroll-behavior-x: none;
  }
  @supports (overflow: clip) {
    html { overflow-x: clip; }
    body { overflow-x: clip; }
  }
  :is(.schedule-table-wrap, .schedule-admin-table-wrap) {
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
  }
  body:is(.front-public, .front-authenticated) .landing-header.front-header {
    display: flex !important;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: .25rem .75rem !important;
    height: auto !important;
    padding: .5rem 1rem !important;
  }
  body.front-authenticated .front-header>.front-nav {
    display: flex !important;
    flex: 1 0 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
    order: 10;
    margin: 0 !important;
  }
  body.front-authenticated .front-header .front-nav>a[data-nav] { display: flex !important; }
  body :is(.front-header, .backend-top) :is(nav a, nav summary, .backend-exit) { min-height: 44px !important; }
  body.front-authenticated .front-header .front-account { margin: 0 !important; }
  body.front-authenticated .front-header .front-account summary { min-width: 0; }
  body.front-authenticated .front-header .front-account summary strong {
    display: block;
    max-width: 20vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  body.front-authenticated .front-header .academic-context-selector {
    flex: 1 0 100%;
  }
  body.front-authenticated .front-header .academic-context-selector label { min-width: 0; }
  body.front-authenticated .front-header .academic-context-selector select { width: min(20rem, 85vw); }
  body .front-header .front-more>div {
    position: fixed;
    inset: auto 1rem auto;
    margin-top: .25rem;
    width: auto;
    max-height: 54vh;
    overflow-y: auto;
  }
}
@media (max-width: 640px) {
  body:is(.front-public, .front-authenticated) .front-header { position: relative !important; }
  body.front-public .landing-header.front-header.is-menu-hidden {
    transform: none !important;
    opacity: 1 !important;
  }
  body.front-authenticated .front-header .front-more>div { position: fixed; inset: auto 1rem auto; width: auto; }
  body.front-authenticated .front-header .front-account-menu { position: absolute !important; inset: 100% 0 auto auto !important; width: min(18rem, 88vw) !important; }
  body:is(.student-page, .auth-body, .contact-page), .admin-shell {
    overflow-wrap: anywhere;
  }
  body :is(.admin-shell, .login-page, .contact-hero, .contact-information, .contact-map-section) {
    min-width: 0;
    max-width: 100%;
  }
  body :is(.login-page, .contact-hero, .contact-information, .contact-map-section) {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  :is(.admin-shell, .auth-card, body.student-page) :is(input:not([type=checkbox]):not([type=radio]), select, textarea) {
    font-size: 16px !important;
    max-width: 100%;
  }
  body :is(.contact-map-board, .admin-shell) :is(iframe, img) { max-width: 100%; }
}

@media (max-width: 900px) {
  body.front-public .landing-header.front-header { flex-wrap: nowrap; }
  body.front-public .front-header > .public-brand-group { min-width: 0; }
  body.front-public .front-header :is(.public-brand-note, nav > a:not(.button)) { display: none; }
  body.front-public .front-header > nav {
    flex: none;
    margin-inline-start: auto !important;
  }
  body.front-public .front-header > nav > .button {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
  }
  html[data-backend-theme] .backend-top .backend-nav {
    flex-wrap: wrap;
    overflow: visible !important;
  }
  html[data-backend-theme] .backend-top .backend-toolbar {
    flex-wrap: wrap;
    min-width: 0;
    max-width: 100%;
  }
  html[data-backend-theme] .backend-top .backend-nav-group { position: static; }
  html[data-backend-theme] .backend-top .backend-nav-group .backend-nav-menu {
    position: absolute;
    inset: 100% .75rem auto;
    width: auto;
    max-height: 55dvh;
    overflow-y: auto;
  }
}
@media (max-width: 640px) {
  .admin-shell :is(.admin-hero, .admin-page-title, .admin-actions) { flex-wrap: wrap; }
  .admin-shell :is(.users-grid, .materials-grid, .dashboard-directory-grid, .user-data-grid, .sponsor-grid) {
    grid-template-columns: minmax(0, 1fr);
  }
}

.front-header :is(.public-menu-toggle, .public-mobile-login) { display: none !important; }

@media (max-width: 900px) {
  body.front-public .landing-header.front-header:has(.public-menu-toggle:not([hidden])) {
    position: relative !important;
    height: auto !important;
    padding-block: .6rem 1.15rem;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
  }
  body.front-public .front-header:has(.public-menu-toggle:not([hidden])) > .public-brand-group {
    grid-area: 1 / 2;
    justify-self: center;
  }
  body.front-public .front-header > .public-menu-toggle:not([hidden]) {
    grid-area: 1 / 1;
    justify-self: start;
    display: inline-flex !important;
    align-items: center;
    gap: .35rem;
    min-height: 44px;
    padding: .4rem .5rem;
    border: 1px solid currentColor;
    border-radius: 10px;
    background: transparent;
    color: inherit;
    font: 700 .8rem system-ui, sans-serif;
    cursor: pointer;
  }
  body.front-public .front-header:has(.public-menu-toggle:not([hidden])) > .public-mobile-login {
    grid-area: 1 / 3;
    justify-self: end;
    display: inline-flex !important;
    margin: 0;
    min-height: 44px;
    padding-inline: .6rem;
  }
  body.front-public .front-header > .public-mobile-login::after { display: none; }
  body.front-public .front-header:has(.public-menu-toggle:not([hidden])) > nav { display: none !important; }
  body.front-public .front-header:has(.public-menu-toggle[aria-expanded="true"]) > nav {
    position: absolute;
    z-index: 15;
    inset: calc(100% + .35rem) 1rem auto;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0 !important;
    padding: .5rem;
    border: 1px solid currentColor;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 10px 28px #102b3d26;
  }
  html[data-theme="dark"] body.front-public .front-header > nav { background: #192a33; }
  body.front-public .front-header:has(.public-menu-toggle[aria-expanded="true"]) > nav > a:not(.button) {
    display: flex;
    align-items: center;
  }
  body.front-public .front-header:has(.public-menu-toggle:not([hidden])) > nav > .button { display: none; }
}

.backend-menu-toggle, .backend-exit-short { display: none; }

@media (max-width: 760px) {
  .backend-top > .backend-menu-toggle:not([hidden]) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: .35rem .65rem;
    border: 1px solid #ffffff50;
    border-radius: .55rem;
    background: #ffffff10;
    color: #fff;
    font: 700 .8rem system-ui, sans-serif;
    cursor: pointer;
  }
  .backend-top > .backend-menu-toggle:focus-visible { outline: 2px solid #98e3cf; outline-offset: 3px; }
  .backend-top > .backend-menu-toggle:not([hidden])[aria-expanded="false"] + .backend-nav { display: none !important; }
  .backend-top > .backend-menu-toggle[aria-expanded="true"] + .backend-nav {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr);
    gap: .3rem;
    padding: .55rem 0;
    border-top: 1px solid #ffffff30;
  }
  html[data-backend-theme] .backend-top .backend-nav .backend-nav-group .backend-nav-menu {
    position: static;
    width: auto;
    max-height: none;
    margin-bottom: .35rem;
    box-shadow: none;
  }
  .backend-top .backend-nav .backend-nav-group:not([open]) .backend-nav-menu { display: none; }
  .backend-top .backend-nav .backend-nav-group summary { justify-content: space-between; }
}

@media (max-width: 760px) {
  html[data-backend-theme] .backend-top {
    align-items: center;
    column-gap: .5rem !important;
  }
  html[data-backend-theme] .backend-top .backend-toolbar {
    align-items: center;
    flex-wrap: nowrap;
    gap: .35rem;
  }
  html[data-backend-theme] .backend-top .backend-toolbar .backend-exit {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-height: 44px !important;
    margin: 0 !important;
    padding: 0 .65rem !important;
    font-size: .8rem !important;
    line-height: 1.2;
    text-align: center;
  }
  html[data-backend-theme] .backend-top .backend-toolbar .backend-exit::before { content: none !important; }
  .backend-top .backend-exit-full { display: none; }
  .backend-top .backend-exit-short { display: inline; }
  html[data-backend-theme] .backend-top .backend-nav > :is(a, .backend-nav-group),
  html[data-backend-theme] .backend-top .backend-nav > .backend-nav-group > summary {
    box-sizing: border-box;
    width: 100%;
    margin: 0;
  }
  html[data-backend-theme] .backend-top .backend-nav > a,
  html[data-backend-theme] .backend-top .backend-nav > .backend-nav-group > summary {
    display: flex;
    align-items: center;
    min-height: 44px !important;
    padding: 0 .75rem !important;
    border: 1px solid transparent;
    line-height: 1.25;
    text-align: start;
  }
}
