* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100svh;
    margin: 0;
    background: #f3f6f9;
    color: #172b3a;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
}

@supports (min-height: 100dvh) {
    body {
        min-height: 100dvh;
    }
}

button,
input {
    font: inherit;
}

.wrap {
    width: min(100% - 32px, 1040px);
    margin-inline: auto;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

/* HOME */
.home-wrap {
    display: grid;
    flex: 1;
    place-items: center;
    padding: clamp(10px, 2vh, 22px) 16px;
}

.home-column {
    display: flex;
    flex-direction: column;
    gap: clamp(8px, 1.4vh, 13px);
    width: min(100%, 620px);
}

.home-card {
    width: 100%;
    padding: clamp(18px, 2.6vh, 30px) clamp(18px, 4vw, 34px);
    border: 1px solid #d9e2ea;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 10px 30px rgb(23 50 77 / 7%);
    text-align: center;
}

.eyebrow {
    margin: 0 0 5px;
    color: #1769aa;
    font-size: .76rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.home-card h1 {
    margin: 0;
    color: #17324d;
    font-size: clamp(1.8rem, 4.5vw, 2.4rem);
    line-height: 1.15;
}

.home-page .subtitle {
    margin: 8px 0 15px;
    color: #4f5f6b;
    line-height: 1.4;
}

.search-hint {
    margin: 7px 0 0;
    color: #60717e;
    font-size: .82rem;
}

.home-page .search-message {
    margin: 10px 0 0;
}

/* PUBBLICITÀ */
.ad-slot {
    min-height: 100px;
    padding: 8px;
    border: 1px solid #e1e8ef;
    border-radius: 12px;
    background: #fff;
    text-align: center;
}

.ad-label {
    display: block;
    margin-bottom: 4px;
    color: #7a8792;
    font-size: .72rem;
    letter-spacing: .06em;
    text-transform: uppercase;
}

/* Spazi pubblicitari della home: compatti, ma senza tagliare l'annuncio */
.home-page .ad-slot {
    min-height: 82px;
    padding: 5px 8px;
}

.home-page .ad-label {
    margin-bottom: 2px;
    font-size: .68rem;
}

.home-page .ad-slot .adsbygoogle {
    max-width: 100%;
}

/* RICERCA */
.search-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px;
}

.search-input-wrap {
    position: relative;
    flex: 1 1 240px;
    min-width: 0;
}

.search-input-wrap > input {
    width: 100%;
    min-height: 50px;
    padding: 12px 15px;
    border: 1px solid #aebdca;
    border-radius: 10px;
    background: #fff;
    color: #172b3a;
    font-size: 1rem;
}

.search-input-wrap > input:focus {
    border-color: #1769aa;
    outline: 3px solid rgb(23 105 170 / 18%);
}

.search-form > button {
    min-height: 50px;
    padding: 12px 22px;
    border: 0;
    border-radius: 10px;
    background: #17324d;
    color: #fff;
    font-weight: 650;
    cursor: pointer;
}

.search-form > button:hover {
    background: #21476c;
}

.search-form > .button-secondary {
    background: #e6edf3;
    color: #17324d;
}

.search-form > .button-secondary:hover {
    background: #d6e2ec;
}

/* Ricerca della home leggermente più bassa */
.home-page .search-input-wrap > input,
.home-page .search-form > button {
    min-height: 46px;
}

.home-page .search-input-wrap > input {
    padding: 10px 13px;
}

.home-page .search-form > button {
    padding: 10px 18px;
}

.search-suggestions {
    position: absolute;
    z-index: 20;
    top: calc(100% + 7px);
    right: 0;
    left: 0;
    max-height: 320px;
    overflow-y: auto;
    padding: 5px;
    border: 1px solid #d9e2ea;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 10px 28px rgb(23 50 77 / 15%);
    text-align: left;
}

.suggestion-item {
    display: flex;
    width: 100%;
    min-height: 46px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 0;
    border-radius: 7px;
    background: #fff;
    color: #172b3a;
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.suggestion-item:hover,
.suggestion-item:focus-visible,
.suggestion-item.is-active {
    background: #eff5fa;
    outline: none;
}

.suggestion-name {
    font-weight: 650;
}

.suggestion-meta {
    flex-shrink: 0;
    color: #60717e;
    font-size: .8rem;
    text-align: right;
}

.suggestion-item.is-unavailable {
    background: #fffaf0;
    color: #714b08;
}

.suggestion-item.is-unavailable:hover,
.suggestion-item.is-unavailable:focus-visible,
.suggestion-item.is-unavailable.is-active {
    background: #fff2d8;
}

.suggestion-item.is-unavailable .suggestion-meta {
    color: #8a6116;
}

.suggestion-empty {
    padding: 12px;
    color: #5c6c78;
    font-size: .9rem;
}

.home-page .quick-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 14px;
    color: #5c6c78;
    font-size: .86rem;
}

.quick-links a {
    padding: 4px 10px;
    border-radius: 999px;
    background: #eef3f7;
    color: #17324d;
    font-weight: 550;
    text-decoration: none;
}

.quick-links a:hover {
    background: #dce7f0;
}

.home-page .all-link-wrap {
    margin-top: 15px;
    padding-top: 13px;
    border-top: 1px solid #e6edf3;
}

.all-link {
    color: #1769aa;
    font-weight: 650;
    text-decoration: none;
}

.all-link:hover {
    text-decoration: underline;
}

/* PAGINA ELENCO */
.page-header {
    padding: 28px 0 32px;
    background: #17324d;
    color: #fff;
}

.back-link {
    display: inline-block;
    margin-bottom: 12px;
    color: #c4d7e8;
    font-size: .92rem;
    text-decoration: none;
}

.back-link:hover {
    color: #fff;
    text-decoration: underline;
}

.page-header h1 {
    margin: 0;
    font-size: clamp(1.6rem, 4vw, 2.2rem);
    line-height: 1.2;
}

.page-header p {
    margin: 8px 0 0;
    color: #dce7f0;
}

.page-main {
    flex: 1;
    padding-top: 24px;
    padding-bottom: 44px;
}

.search-panel {
    padding: 18px;
    border: 1px solid #d9e2ea;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 4px 14px rgb(23 50 77 / 5%);
}

.search-panel > label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
}

.result-count {
    margin: 16px 0 0;
    color: #4f5f6b;
    font-size: .95rem;
}

.region-section {
    margin-top: 28px;
}

.region-section h2 {
    margin: 0 0 12px;
    color: #17324d;
    font-size: 1.05rem;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.station-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 235px), 1fr));
    gap: 10px;
}

.station-card {
    display: flex;
    width: 100%;
    min-height: 54px;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 15px;
    border: 1px solid #d9e2ea;
    border-radius: 10px;
    background: #fff;
    color: #172b3a;
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

a.station-card:hover {
    border-color: #83a9c8;
    background: #f8fbfe;
}

.station-name {
    font-weight: 650;
}

.station-action {
    flex-shrink: 0;
    color: #1769aa;
    font-size: .82rem;
    text-align: right;
}

.station-card.is-unavailable {
    border-color: #ead7b3;
    background: #fffaf0;
    color: #5f4b23;
}

.station-card.is-unavailable:hover {
    border-color: #d9b87a;
    background: #fff5e2;
}

.station-card.is-unavailable .station-action {
    color: #8a6116;
}

/* PAGINE LEGALI */
.legal-page {
    max-width: 820px;
    padding-top: 32px;
    padding-bottom: 48px;
    color: #2b3d4b;
}

.legal-page h2 {
    margin: 32px 0 10px;
    color: #17324d;
    font-size: 1.2rem;
}

.legal-page p,
.legal-page li {
    margin: 0 0 12px;
}

.legal-page ul,
.legal-page ol {
    padding-left: 22px;
}

.legal-page a {
    color: #1769aa;
}

/* FOOTER */
.site-footer {
    padding: 18px 0 24px;
    border-top: 1px solid #d9e2ea;
    color: #5c6c78;
    font-size: .86rem;
    text-align: center;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 18px;
    margin-bottom: 10px;
}

.footer-links a {
    color: #1769aa;
    font-weight: 600;
    text-decoration: none;
}

.footer-links a:hover {
    text-decoration: underline;
}

.home-page .site-footer {
    padding: 10px 0 12px;
}

.home-page .footer-links {
    gap: 6px 14px;
    margin-bottom: 5px;
}

.home-page .site-footer p {
    max-width: 900px;
    margin: 0 auto;
    padding-inline: 12px;
    line-height: 1.35;
}

a:focus-visible,
button:focus-visible {
    outline: 3px solid rgb(23 105 170 / 35%);
    outline-offset: 2px;
}

/* SMARTPHONE */
@media (max-width: 560px) {
    .home-wrap {
        padding: 10px 12px;
    }

    .home-column {
        gap: 8px;
    }

    .home-card {
        padding: 17px 16px;
        border-radius: 13px;
    }

    .home-card h1 {
        font-size: clamp(1.7rem, 7vw, 2rem);
    }

    .home-page .subtitle {
        margin: 6px 0 12px;
        font-size: .94rem;
    }

    .home-page .search-form {
        flex-wrap: nowrap;
        align-items: stretch;
        gap: 8px;
    }

    .home-page .search-input-wrap {
        flex: 1 1 0%;
    }

    .home-page .search-input-wrap > input {
        min-height: 46px;
        padding: 10px 11px;
    }

    .home-page .search-form > button {
        flex: 0 0 auto;
        min-height: 46px;
        padding: 10px 16px;
    }

    .search-form > button {
        flex: 1 1 auto;
    }

    .home-page .search-form > button {
        flex: 0 0 auto;
    }

    .home-page .search-hint {
        margin-top: 5px;
        font-size: .78rem;
    }

    .home-page .quick-links {
        gap: 5px;
        margin-top: 10px;
        font-size: .82rem;
    }

    .quick-links a {
        padding: 4px 9px;
    }

    .home-page .all-link-wrap {
        margin-top: 11px;
        padding-top: 10px;
    }

    .home-page .ad-slot {
        min-height: 72px;
    }

    .suggestion-meta {
        max-width: 45%;
    }

    .page-header {
        padding: 22px 0 26px;
    }

    .search-panel {
        padding: 14px;
    }
}

/* Telefoni molto stretti */
@media (max-width: 360px) {
    .home-wrap {
        padding-inline: 10px;
    }

    .home-card {
        padding-inline: 14px;
    }

    .home-page .search-form > button {
        padding-inline: 12px;
    }

    .home-page .search-input-wrap > input {
        padding-inline: 9px;
        font-size: .94rem;
    }
}

/* Riduce gli spazi quando la finestra è bassa */
@media (max-height: 760px) {
    .home-wrap {
        padding-top: 6px;
        padding-bottom: 6px;
    }

    .home-column {
        gap: 7px;
    }

    .home-page .home-card {
        padding-top: 13px;
        padding-bottom: 13px;
    }

    .home-page .subtitle {
        margin-top: 6px;
        margin-bottom: 10px;
    }

    .home-page .search-hint {
        margin-top: 5px;
    }

    .home-page .quick-links {
        margin-top: 8px;
    }

    .home-page .all-link-wrap {
        margin-top: 9px;
        padding-top: 9px;
    }

    .home-page .ad-slot {
        min-height: 70px;
        padding-block: 4px;
    }

    .home-page .site-footer {
        padding-top: 7px;
        padding-bottom: 8px;
    }

    .home-page .footer-links {
        margin-bottom: 4px;
    }
}

/* Ulteriore compattezza in finestre molto basse, ad esempio in orizzontale */
@media (max-height: 580px) {
    .home-wrap {
        padding-top: 4px;
        padding-bottom: 4px;
    }

    .home-column {
        gap: 5px;
    }

    .home-page .home-card {
        padding-top: 10px;
        padding-bottom: 10px;
    }

    .home-page .home-card h1 {
        font-size: 1.65rem;
    }

    .home-page .subtitle {
        margin-top: 4px;
        margin-bottom: 7px;
        font-size: .9rem;
    }

    .home-page .quick-links {
        margin-top: 6px;
    }

    .home-page .all-link-wrap {
        margin-top: 7px;
        padding-top: 7px;
    }

    .home-page .ad-slot {
        min-height: 58px;
    }

    .home-page .site-footer {
        padding-top: 4px;
        padding-bottom: 6px;
    }
}
@media (max-width: 560px), (pointer: coarse) {
    .home-page .ad-top {
        display: none !important;
    }
}