/* ===== Variables ===== */
:root {
    --paper: #FFFFFF;
    --ink: #16202C;
    --muted: #5B6470;
    --line: #E6E3DC;
    --green: #01573C;
}

/* ===== Base ===== */
* {
    box-sizing: border-box;
}
html {
    background: var(--paper);
}
body {
    margin: 0;
    min-height: 100vh;
    background: var(--paper);
    color: var(--ink);
    font-family: 'Hanken Grotesk', system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.4;
    padding: calc(20px + env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
}

/* ===== Estructura de la página ===== */
main {
    max-width: 920px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 22px;
}
    header {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 10px 16px;
        padding: 6px 4px 0;
    }
        header h1 {
            margin: 0;
            line-height: 0;
        }
        header .wordmark {
            height: 44px;
            width: auto;
            display: block;
        }
        header p {
            order: 3;
            flex-basis: 100%;
            margin: 0;
            color: var(--muted);
            font-size: 15.2px;
            line-height: 1.25;
        }
    h2 {
        margin: 0 0 10px 4px;
        font-family: 'Bricolage Grotesque', system-ui, sans-serif;
        font-size: 15.68px;
        font-weight: 700;
        color: var(--muted);
        letter-spacing: -0.005em;
    }
    footer {
        color: var(--muted);
        font-size: 13.12px;
        padding: 6px 4px 0;
        max-width: 60ch;
    }

/* ===== Colores por app ===== */
/* Verde de Bizkaibus más claro en la ficha grande */

/* ===== Fichas de las apps ===== */
.tiles {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
    .tiles > li {
        display: flex;
    }

.tile {
    position: relative;
    flex: 1;
    min-height: 168px;
    padding: 16px;
    border-radius: 24px;
    background: var(--c);
    color: #fff;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    isolation: isolate;
    transition: transform .12s ease;
}
    .tile::before {
        content: '';
        position: absolute;
        inset: 0;
        z-index: -1;
        background: var(--wipe, rgba(255, 255, 255, .22));
        transform: scaleX(0);
        transform-origin: left center;
        pointer-events: none;
    }
    .tile.is-launching::before {
        transform: scaleX(1);
        transition: transform .38s cubic-bezier(.4, 0, .2, 1);
    }
    .tile.is-launching::after {
        content: '';
        position: absolute;
        inset: 0;
        z-index: -1;
        background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, .35) 50%, transparent 100%);
        transform: translateX(-100%);
        animation: launch-shine .9s ease-in-out .4s infinite;
        pointer-events: none;
    }
@keyframes launch-shine {
    to {
        transform: translateX(100%);
    }
}
    a.tile:active {
        transform: scale(.98);
    }
    a.tile:focus-visible {
        outline: 3px solid var(--ink);
        outline-offset: 3px;
    }
    .tile .appicon {
        display: block;
        width: 56px;
        height: 56px;
        border-radius: 16px;
        object-fit: cover;
    }
    .tile .mark {
        position: absolute;
        right: -26px;
        bottom: -30px;
        width: 150px;
        height: 150px;
        object-fit: contain;
        opacity: .25;
        -webkit-mask-image: radial-gradient(closest-side, #000 62%, transparent 100%);
        mask-image: radial-gradient(closest-side, #000 62%, transparent 100%);
        z-index: -1;
        pointer-events: none;
    }
    .tile .go {
        position: absolute;
        top: 16px;
        right: 16px;
        width: 22px;
        height: 22px;
        opacity: .85;
    }
    .tile .txt {
        display: block;
    }
        .tile strong {
            display: block;
            font-family: 'Bricolage Grotesque', system-ui, sans-serif;
            font-size: 22.4px;
            font-weight: 800;
            letter-spacing: -0.02em;
            line-height: 1.1;
        }
        .tile .txt span {
            display: block;
            margin-top: 4px;
            font-size: 13.76px;
            line-height: 1.3;
            opacity: .88;
        }
        .tile .txt strong > span {
            display: inline;
            margin-top: 0;
            font-size: 1em;
            line-height: 1.1;
            color: inherit;
            font-weight: inherit;
            opacity: 1;
        }
        /* Ciudad bajo el nombre (Tranvía+ Bilbao) */
        .tile .txt .tile-city {
            margin-top: -2px;
            font-size: 12.8px;
            line-height: 1.2;
            font-weight: 700;
            letter-spacing: 1.5px;
            text-transform: uppercase;
            text-align: left;
            color: rgba(255, 255, 255, .85);
            opacity: 1;
        }

/* Red recién llegada: «Nuevo» arriba, junto a la flecha de su ficha */
.tile .tile-new {
    position: absolute;
    top: 16px;
    right: 46px;
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .95);
    color: #14181c;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .06em;
    line-height: 1.3;
    text-transform: uppercase;
}
[data-view="list"] .tile .tile-new {
    position: static;
    flex: none;
    order: 2;
    background: var(--c);
    color: #fff;
}

/* ===== Selector de vista ===== */
.view-toggle {
    display: inline-flex;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
}
.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}
.lang-toggle {
    height: 44px;
    min-width: 80px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--paper);
    color: var(--ink);
    font-family: 'Hanken Grotesk', system-ui, sans-serif;
    font-weight: 700;
    font-size: 13.76px;
    text-align: center;
    cursor: pointer;
}
    .lang-toggle:hover {
        background: #FAF9F6;
    }
    .lang-toggle:focus-visible {
        outline: 3px solid var(--green);
        outline-offset: -3px;
    }

    .view-toggle > button {
        width: 44px;
        height: 44px;
        border: 0;
        background: var(--paper);
        color: var(--muted);
        display: grid;
        place-items: center;
        cursor: pointer;
    }
        .view-toggle button svg {
            width: 22px;
            height: 22px;
        }
        .view-toggle > button[aria-pressed="true"] {
            background: var(--ink);
            color: #fff;
        }
        .view-toggle > button:focus-visible {
            outline: 3px solid var(--green);
            outline-offset: -3px;
        }

/* ===== Vista en lista (accesible, iconos pequeños) ===== */
.tile .chev,
.tile .txt .last {
    display: none;
}

[data-view="list"] main {
    max-width: 640px;
}
[data-view="list"] .tile {
    --wipe: var(--c);
}
    [data-view="list"] .tile.is-launching .txt strong,
    [data-view="list"] .tile.is-launching .txt span,
    [data-view="list"] .tile.is-launching .chev {
        color: #fff;
        transition: color .18s ease .12s;
    }
    [data-view="list"] .tiles,
    [data-view="list"] .menu-apps .tiles {
        grid-template-columns: minmax(0, 1fr);
        gap: 10px;
    }
    [data-view="list"] .tile {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 14px;
        min-height: 0;
        padding: 12px 14px 12px 12px;
        border: 1px solid var(--line);
        border-radius: 16px;
        background: var(--paper);
        color: var(--ink);
    }
        [data-view="list"] a.tile:hover {
            border-color: #C9C5BB;
            background: #FAF9F6;
        }
        [data-view="list"] .tile .mark,
        [data-view="list"] .tile .go {
            display: none;
        }
        [data-view="list"] .tile .appicon {
            flex: none;
            border-radius: 14px;
        }
        [data-view="list"] .tile .txt {
            flex: 1;
            min-width: 0;
            order: 1;
        }
            [data-view="list"] .tile .txt span {
                color: var(--muted);
                opacity: 1;
                font-size: 14.72px;
            }
            [data-view="list"] .tile .txt strong > span {
                color: inherit;
                font-size: 1em;
                opacity: 1;
            }
            [data-view="list"] .tile .txt .tile-city {
                color: var(--c);
                opacity: .8;
                font-size: 12.8px;
                text-align: left;
            }
            [data-view="list"] .tile.is-last .txt .last {
                display: block;
                margin-top: 4px;
                color: var(--green);
                font-size: 12.48px;
                font-weight: 600;
            }
            [data-view="list"] .tile.is-launching.is-last .txt .last {
                color: #fff;
            }
        [data-view="list"] .tile .chev {
            display: block;
            order: 3;
            flex: none;
            width: 20px;
            height: 20px;
            color: #8C8A82;
        }

/* ===== Página 404 ===== */
.notfound {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    padding: 28px 4px;
}
    .notfound h1 {
        margin: 0;
        font-family: 'Bricolage Grotesque', system-ui, sans-serif;
        font-size: clamp(32px, 7vw, 51.2px);
        font-weight: 800;
        letter-spacing: -0.025em;
        line-height: 1.05;
    }
    .notfound p {
        margin: 0;
        color: var(--muted);
        max-width: 44ch;
    }
    .notfound .back {
        margin-top: 6px;
        padding: 12px 22px;
        border-radius: 999px;
        background: var(--green);
        color: #fff;
        font-weight: 600;
        text-decoration: none;
    }
        .notfound .back:focus-visible {
            outline: 3px solid var(--ink);
            outline-offset: 3px;
        }
    .notfound ul {
        list-style: none;
        margin: 8px 0 0;
        padding: 0;
        display: flex;
        flex-wrap: wrap;
        gap: 8px 18px;
    }
        .notfound ul a {
            color: var(--ink);
            font-weight: 600;
        }

/* ===== Escritorio ===== */
@media (min-width: 720px) {
    body {
        padding-top: 48px;
    }
    main {
        gap: 30px;
    }
        header .wordmark {
            height: 56px;
        }
        .menu-apps .tiles {
            grid-template-columns: repeat(3, minmax(0, 1fr));
        }
    .tile {
        min-height: 200px;
    }
}

/* ===== Animación al cambiar de vista ===== */
main {
    transition: opacity .12s ease;
}
    main.is-switching {
        opacity: 0;
    }

::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: .2s;
    animation-timing-function: ease;
}

/* ===== Movimiento reducido ===== */
@media (prefers-reduced-motion: reduce) {
    .tile {
        transition: none;
    }
    main {
        transition: none;
    }
    .tile.is-launching::before {
        transition: none;
    }
    .tile.is-launching::after {
        animation: none;
    }
    ::view-transition-group(*),
    ::view-transition-old(*),
    ::view-transition-new(*) {
        animation: none;
    }
}

/* ===== Mapa de la red ===== */
.menu-map-link {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 12px;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--paper);
    color: var(--ink);
    text-decoration: none;
}
    .menu-map-link > svg:first-child {
        flex: none;
        width: 28px;
        height: 28px;
        color: var(--green);
    }
    .menu-map-link > svg:last-child {
        flex: none;
        width: 20px;
        height: 20px;
        margin-left: auto;
        color: var(--muted);
    }
    .menu-map-link span {
        display: flex;
        flex-direction: column;
        gap: 2px;
    }
    .menu-map-link strong {
        font-size: 16.32px;
    }
    .menu-map-link span span {
        color: var(--muted);
        font-size: 14.08px;
    }
