/*
 * Camperata, the maps ("Carta stradale", DESIGN.md). Shared by frontend and backend.
 * SVG drawn server-side by common/helpers/Atlante and the partials in common/views/atlante/.
 *
 * The map says WHERE: white island, --mare sea, --statale roads, --panoramica route of a story,
 * thin grey province borders. The signs say WHAT and HOW RELIABLE, on top of the map:
 *   brown square = sagra, blue square (with P when there is room) = sosta, black ring = ordinanza;
 *   filled = verified, white with a dashed border = still to verify.
 * Viewbox units are about one pixel on a 375px phone (Atlante::LARGHEZZA = 343).
 */

.atlante {
    display: block;
    width: 100%;
    height: auto;
    background: var(--mare);
    border-radius: var(--raggio);
}

.atlante text {
    font-family: var(--famiglia);
}

.atlante__terra,
.atlante__provincia {
    fill: var(--fondo);
    fill-rule: evenodd;
    /* Same colour as the fill: hides the hairline seams between neighbouring provinces. */
    stroke: var(--fondo);
    stroke-width: .6;
    stroke-linejoin: round;
}

.atlante__confini,
.atlante__costa,
.atlante__statale,
.atlante__autostrada,
.atlante__cerchio,
.atlante__attiva {
    fill: none;
    stroke-linejoin: round;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
}

.atlante__confini {
    stroke: var(--tratteggio);
    stroke-width: .75px;
}

.atlante__costa {
    stroke: var(--strada);
    stroke-width: 1px;
}

.atlante__statale {
    stroke: var(--statale);
    stroke-width: .75px;
}

.atlante__autostrada {
    stroke: var(--statale);
    stroke-width: 1.5px;
}

/* The province you filtered by, or the province of the town: a heavier edge, never a fill. */
.atlante__attiva {
    stroke: var(--testo);
    stroke-width: 2.5px;
}

/* Geographic names: Overpass italic, black (on the sea --tratteggio would fail AA). */
.atlante__nome {
    fill: var(--testo);
    font-size: 13px;
    font-style: italic;
    font-weight: 400;
}

.atlante__nome--rilievo {
    letter-spacing: .06em;
}

/* Data label on the map (the town on the Comune page, "20 km"): upright, bold, haloed in white. */
.atlante__etichetta {
    fill: var(--testo);
    font-size: 15px;
    font-weight: 700;
    paint-order: stroke;
    stroke: var(--fondo);
    stroke-width: 4px;
    stroke-linejoin: round;
}

.atlante__etichetta--piccola {
    font-size: 13px;
}

/* The 20 km circle: a plain thin black line. Dashes belong to the state of a record. */
.atlante__cerchio {
    stroke: var(--testo);
    stroke-width: 1.5px;
}

/* Inset frames: the Pelagie on the island map, the locator in the corner of the surroundings. */
.atlante__riquadro {
    fill: var(--mare);
    stroke: var(--testo);
    stroke-width: 1px;
    vector-effect: non-scaling-stroke;
}

.atlante__riquadro--vuoto {
    fill: none;
}

.atlante__dove {
    fill: none;
    stroke: var(--testo);
    stroke-width: 2px;
    vector-effect: non-scaling-stroke;
}

/* The clean map of the home ("Atlante vivo"): coast and motorways only. It grows to half a desktop
   screen, so lines get a little heavier and the names (in viewBox units) smaller. */
.atlante--pulita .atlante__costa {
    stroke-width: 1.25px;
}

.atlante--pulita .atlante__autostrada {
    stroke-width: 2px;
}

@media (min-width: 40em) {
    .atlante--pulita .atlante__nome {
        font-size: 7px;
    }
}

@media (min-width: 64em) {
    .atlante--pulita .atlante__nome {
        font-size: 6.5px;
    }
}

/* ------------------------------------------------------------ the signs */

.atlante__punti {
    pointer-events: none;   /* taps go to the province underneath */
}

.atlante__sagra {
    fill: var(--sagra);
    stroke: var(--fondo);
    stroke-width: 1.5px;
}

/* The festival at the centre of its surroundings: the brown sign with its white inner border. */
.atlante__sagra-bordo {
    fill: none;
    stroke: var(--fondo);
    stroke-width: 1.5px;
}

.atlante__sosta {
    fill: var(--sosta);
    stroke: var(--fondo);
    stroke-width: 1px;
}

.atlante__p {
    fill: var(--fondo);
    font-weight: 800;
    text-anchor: middle;
}

/* A town (Comune page): a black dot with a white halo, its name beside it. */
.atlante__luogo {
    fill: var(--testo);
    stroke: var(--fondo);
    stroke-width: 2px;
}

.atlante__ordinanza {
    fill: var(--fondo);
    stroke: var(--testo);
    stroke-width: 1.6px;
}

/* Still to verify: white with a dashed border, as the markers of the stops map. */
.atlante__sagra--da-verificare,
.atlante__sosta--da-verificare {
    fill: var(--fondo);
    stroke-width: 1.5px;
    stroke-dasharray: 2.5 1.5;
}

.atlante__sagra--da-verificare {
    stroke: var(--sagra);
}

.atlante__sosta--da-verificare {
    stroke: var(--sosta);
}

.atlante__sosta--da-verificare + .atlante__p {
    fill: var(--sosta);
}

/* ------------------------------------------------------- tappable provinces */

.atlante a {
    cursor: pointer;
}

.atlante a:focus {
    outline: none;
}

.atlante a:hover .atlante__provincia {
    stroke: var(--testo);
    stroke-width: 1.5px;
    vector-effect: non-scaling-stroke;
}

.atlante a:focus-visible .atlante__provincia {
    stroke: var(--collegamento);
    stroke-width: 3px;
    vector-effect: non-scaling-stroke;
}

/* ----------------------------------------------------- route of a story */

/* A panoramic road of the atlases: a white road with green edges. */
.atlante__percorso-bordo,
.atlante__percorso {
    fill: none;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.atlante__percorso-bordo {
    stroke: var(--panoramica);
    stroke-width: 5;
}

.atlante__percorso {
    stroke: var(--fondo);
    stroke-width: 1.5;
}

/* The only movement of the stories: the route draws itself once, in 600 ms. */
@media (prefers-reduced-motion: no-preference) {
    .atlante__percorso-bordo,
    .atlante__percorso {
        stroke-dasharray: 1 1;
        stroke-dashoffset: 1;
        animation: atlante-traccia 600ms ease-out 150ms forwards;
    }
}

@keyframes atlante-traccia {
    to {
        stroke-dashoffset: 0;
    }
}

/* ------------------------------------------ routes of trips and itineraries */

/* The road of the logo: sunset orange, always on a white edge (orange on --mare is 2.4:1).
   Only lines: never text, never a state. Backend maps (lists, home, miniatures). */
.atlante__tracciato-bordo,
.atlante__tracciato {
    fill: none;
    stroke-linejoin: round;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
}

.atlante__tracciato-bordo {
    stroke: var(--fondo);
    stroke-width: 5px;
}

.atlante__tracciato {
    stroke: var(--statale);
    stroke-width: 2.5px;
}

/* Start of a route in a miniature: the black dot of the towns, with a white halo. */
.atlante__partenza {
    fill: var(--testo);
    stroke: var(--fondo);
    stroke-width: 3;
}

/* Miniature: the whole island at 7.5rem, route a little heavier so it reads at that size. */
.atlante--miniatura {
    width: 7.5rem;
    border-radius: var(--raggio);
}

.atlante--miniatura .atlante__costa {
    stroke-width: 1px;
}

.atlante--miniatura .atlante__tracciato-bordo {
    stroke-width: 6px;
}

.atlante--miniatura .atlante__tracciato {
    stroke-width: 3px;
}

/* ------------------------------------------------- photo of the territory */

/* "Foto del territorio" in the backend: 3:2, what it shows and who took it always underneath. */
.territorio {
    margin: 0;
}

.territorio img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 3 / 2;
    object-fit: cover;
    border-radius: var(--raggio);
}

.territorio figcaption {
    margin-top: var(--s2);
    font: var(--t-meta);
}

.territorio__titolo,
.territorio__firma {
    display: block;
}

.territorio__titolo {
    font-weight: 700;
}

/* --------------------------------------------- the clean map with HTML signs */

/*
 * _isola ("Atlante vivo"): home of the site, lists of trips and itineraries in the backend.
 * Moved here from frontend/web/css/site.css so both apps draw the same island.
 */
/* The island. The SVG draws the land; towns and signs are HTML on top, placed in percent with a
   fixed size in px. Phone: the shifted position (--xm, --ym), so every square has its own 44px. */
.isola {
    position: relative;
}

.isola .atlante {
    border-radius: 0;
}

.isola__citta,
.isola__segno {
    position: absolute;
    left: var(--xm, var(--x));
    top: var(--ym, var(--y));
}

/* Towns for orientation: a black dot and the name with a white halo, never a link. */
.isola__citta {
    font: 700 .8125rem/1 var(--famiglia);
    white-space: nowrap;
    text-shadow: 0 0 2px var(--fondo), 0 0 2px var(--fondo), 0 0 3px var(--fondo);
    pointer-events: none;
}

.isola__citta::before {
    content: "";
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--testo);
    box-shadow: 0 0 0 1.5px var(--fondo);
}

.isola__citta--e { transform: translate(8px, -50%); }
.isola__citta--e::before { left: -11px; top: calc(50% - 4px); }
.isola__citta--o { transform: translate(calc(-100% - 8px), -50%); }
.isola__citta--o::before { right: -11px; top: calc(50% - 4px); }
.isola__citta--n { transform: translate(-50%, calc(-100% - 7px)); }
.isola__citta--n::before { left: calc(50% - 3px); bottom: -10px; }
.isola__citta--s { transform: translate(-50%, 7px); }
.isola__citta--s::before { left: calc(50% - 3px); top: -10px; }

.isola__citta:not(.isola__citta--grande) {
    display: none;
}

/* A sign: the link has no size, square and label hang from the exact point. */
.isola__segno {
    z-index: 2;
    width: 0;
    height: 0;
    color: var(--fondo);
    text-decoration: none;
}

.isola__q {
    position: absolute;
    left: -8px;
    top: -8px;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    background: var(--sagra);
    box-shadow: 0 0 0 2px var(--fondo);
}

/* 44px touch area around the 16px square. */
.isola__q::before {
    content: "";
    position: absolute;
    inset: -14px;
}

.isola__segno--da-verificare .isola__q,
.isola-legenda--da-verificare .isola__q {
    background: var(--fondo);
    border: 2px dashed var(--sagra);
}

.isola__segno:hover .isola__q,
.isola__segno:focus-visible .isola__q {
    box-shadow: 0 0 0 2px var(--fondo), 0 0 0 4px var(--testo);
}

.isola__segno:focus-visible {
    outline: none;
}

.isola__segno:focus-visible .isola__q::before {
    outline: var(--anello);
    border-radius: var(--raggio);
}

/* Phone: squares only (eight names on 375px would cover each other); the list follows the map. */
.isola__cartello {
    display: none;
}

/* Scale bar: from tablet only (on the phone it crowded the Ionian corner). */
.isola__scala {
    display: none;
    position: absolute;
    right: 3%;
    bottom: 5%;
    height: 7px;
    border: 2px solid var(--testo);
    border-top: 0;
}

.isola__scala span {
    position: absolute;
    right: 0;
    bottom: 9px;
    font: 700 .8125rem/1 var(--famiglia);
    white-space: nowrap;
}

/* Stages of a trip: the numbered sign of the trip pages (white square, black edge, number 800),
   never blue (the blue square is the sosta). Not links: the stages are listed in the trip page. */
.isola__tappa {
    position: absolute;
    left: var(--x);
    top: var(--y);
    z-index: 2;
    display: grid;
    place-items: center;
    min-width: 1.375rem;
    height: 1.375rem;
    padding: .125rem .25rem 0;
    transform: translate(-50%, -50%);
    border: 2px solid var(--testo);
    border-radius: 3px;
    background: var(--fondo);
    color: var(--testo);
    font: 800 .8125rem/1 var(--famiglia);
    font-variant-numeric: tabular-nums;
    pointer-events: none;
}

/* Legend under the map, on the sea: black text only (--tratteggio fails AA on --mare). */
.isola-legenda {
    padding: 0 var(--lato-dx, var(--margine)) 0 var(--lato-sx, var(--margine));
    font: var(--t-meta);
}

.isola-legenda p {
    margin: var(--s1) 0 0;
}

.isola-legenda__segni {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s1) var(--s5);
    margin: 0;
    padding: 0;
    list-style: none;
}

.isola-legenda__segni li {
    display: flex;
    align-items: center;
    gap: var(--s2);
}

.isola-legenda .isola__q {
    position: relative;
    left: auto;
    top: auto;
    flex: none;
}

.isola-legenda .isola__q::before {
    display: none;
}

.isola-legenda--autostrada span {
    width: 22px;
    height: 3px;
    background: var(--statale);
    /* On the map the orange road lies on the white island: same here (orange on --mare is 2.4:1). */
    box-shadow: 0 0 0 2px var(--fondo);
}

.isola-legenda__computer {
    display: none;
}

/* From tablet: true positions, and each square gets its small brown sign (town, dates) on the side
   chosen by Atlante::latiEtichette(). */
@media (min-width: 40em) {
    .isola__citta,
    .isola__segno {
        left: var(--x);
        top: var(--y);
    }

    .isola__citta:not(.isola__citta--grande),
    .isola__scala {
        display: block;
    }

    .isola__cartello {
        display: block;
        position: absolute;
        padding: 5px 10px 4px;
        border-radius: var(--raggio);
        background: var(--sagra);
        outline: 1.5px solid var(--fondo);
        outline-offset: -4px;
        font: 400 .8125rem/1.15 var(--famiglia);
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
    }

    .isola__cartello b {
        display: block;
        font-size: .875rem;
        font-weight: 700;
    }

    .isola__cartello span {
        display: block;
    }

    .isola__segno--da-verificare .isola__cartello {
        background: var(--fondo);
        color: var(--sagra);
        outline: 2px dashed var(--sagra);
        outline-offset: -2px;
    }

    .isola__segno--e .isola__cartello { left: 16px; top: 0; transform: translateY(-50%); }
    .isola__segno--o .isola__cartello { right: 16px; top: 0; transform: translateY(-50%); }
    .isola__segno--s .isola__cartello { left: 0; top: 16px; transform: translateX(-50%); }
    .isola__segno--n .isola__cartello { left: 0; bottom: 16px; transform: translateX(-50%); }
    .isola__segno--ne .isola__cartello { left: 11px; bottom: 11px; }
    .isola__segno--se .isola__cartello { left: 11px; top: 11px; }
    .isola__segno--no .isola__cartello { right: 11px; bottom: 11px; }
    .isola__segno--so .isola__cartello { right: 11px; top: 11px; }

    .isola__segno:hover .isola__cartello b {
        text-decoration: underline;
    }

    .isola__segno:focus-visible .isola__cartello {
        outline: var(--anello);
        outline-offset: 2px;
    }

    /* The sign is on top while you point at it. */
    .isola__segno:hover,
    .isola__segno:focus-visible {
        z-index: 3;
    }

    .isola-legenda__telefono {
        display: none;
    }

    .isola-legenda__computer {
        display: block;
    }
}


@media print {
    .atlante {
        background: none;
    }
}
