/**
 * Design tokens + building blocks shared by the routes index page
 * (trufi-index.css) and the route detail page (trufi-route.css): hero
 * banner, stat blocks, list headers, line/route badges, icons, Leaflet
 * control theming, the geolocation button/marker, the "Compartir" button +
 * its confirmation toast, and the app store buttons.
 */

:root {
    --trufi-white: #FFFFFF;
    --trufi-gray-500: #ADB5BD;
    --trufi-gray-500-a: #ADB5BD80;
    --trufi-gray-900: #212529;
    --trufi-pink: #D81B60;
    --trufi-pink-light: #F06292;
    --trufi-gray-600: #6C757D;
    --trufi-gray-100: #F8F9FA;
    --trufi-dark: #121212;
    --trufi-black: #000000;
}

/* The active theme (OnePress) renders its own "<h1>Routes</h1>" page-title
 * banner above the_content on both virtual pages this plugin serves. It
 * duplicates the hero title below and can't be removed from the theme
 * side without a child theme, so hide it here - this stylesheet only
 * loads on those two pages (see enqueue-scripts.php), so the rule is
 * effectively scoped even though .page-header itself isn't ours. */
.page-header {
    display: none;
}

/* Template tokens toggle optional blocks (e.g. the Sindicatos stat) with the
 * `hidden` attribute; don't let theme display rules override it. */
.trufi-index [hidden],
.trufi-route [hidden] {
    display: none !important;
}

.trufi-icon {
    display: inline-flex;
    width: 1em;
    height: 1em;
    vertical-align: -0.15em;
}

.trufi-icon svg {
    width: 100%;
    height: 100%;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Hero banner (dark, pink headline, eyebrow + stats row) ------------------ */

.trufi-hero {
    background: var(--trufi-dark);
    color: var(--trufi-white);
    padding: 20px 24px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex: 0 0 auto;
}

.trufi-hero-copy {
    max-width: 640px;
    font-family: inherit;
}

.trufi-hero-eyebrow {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--trufi-gray-500);
    font-size: 14px;
    margin: 0 0 12px;
}

.trufi-hero h1 {
    color: var(--trufi-pink-light);
    font-size: 24px;
    line-height: 1.2;
    margin: 0 0 8px;
}

.trufi-hero-copy > p {
    color: var(--trufi-gray-500);
    margin: 0;
    font-size: 14px;
}

.trufi-hero-stats {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.trufi-hero-stat strong {
    display: block;
    font-size: 22px;
    color: var(--trufi-pink-light);
    line-height: 1;
}

.trufi-hero-stat span {
    display: block;
    color: var(--trufi-gray-500);
    font-size: 12px;
    margin-top: 4px;
}

/* List header (sidebar title row, optionally with a trailing button) */

.trufi-list-title {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--trufi-pink);
    border-bottom: 1px solid var(--trufi-gray-500-a);
    background: var(--trufi-white);
}

.trufi-list-title-label {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Route/line badge (pink pill with the short name, e.g. "119") ----------- */

.trufi-line-badge {
    background: var(--trufi-pink);
    color: var(--trufi-white);
    font-weight: 700;
    font-size: 12px;
    min-width: 40px;
    text-align: center;
    padding: 8px 6px 6px;
    border-radius: 6px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    line-height: 1.1;
}

.trufi-line-badge .trufi-icon {
    font-size: 16px;
}

/* Buttons ------------------------------------------------------------------ */

.trufi-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--trufi-black);
    color: var(--trufi-white);
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}

.trufi-btn:hover {
    background: var(--trufi-pink);
}

.trufi-share-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    margin: 0;
    padding: 4px 10px;
    border: 1px solid var(--trufi-pink);
    border-radius: 999px;
    background: var(--trufi-white);
    color: var(--trufi-pink);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    text-transform: none;
    letter-spacing: normal;
    white-space: nowrap;
    cursor: pointer;
}

.trufi-share-btn:hover,
.trufi-share-btn:focus-visible {
    background: var(--trufi-pink);
    color: var(--trufi-white);
}

/* Share confirmation toast (Trufi.share.toast) ---------------------------- */

.trufi-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 100000;
    width: max-content;
    max-width: calc(100vw - 32px);
    transform: translate(-50%, 16px);
    padding: 10px 16px;
    border-radius: 10px;
    background: var(--trufi-dark);
    color: var(--trufi-white);
    font-size: 14px;
    line-height: 1.4;
    text-align: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.trufi-toast.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
}

.trufi-toast input {
    display: block;
    width: 100%;
    margin: 8px 0 0;
    padding: 6px 8px;
    border: 1px solid var(--trufi-gray-500);
    border-radius: 6px;
    background: var(--trufi-white);
    color: var(--trufi-gray-900);
    font-size: 13px;
}

/* Geolocation button + toast/hint pill + pulse marker (both pages) ------- */

.trufi-geo-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 400;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--trufi-dark);
    color: var(--trufi-white);
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.trufi-geo-btn:hover,
.trufi-geo-btn.is-locating {
    background: var(--trufi-pink);
}

.trufi-geo-btn[data-show-location="0"] {
    display: none;
}

.trufi-map-hint {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--trufi-dark);
    color: var(--trufi-white);
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 13px;
    z-index: 500;
    pointer-events: none;
    text-align: center;
    max-width: calc(100% - 24px);
}

.trufi-geo-pulse-icon {
    position: relative;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #1971c2;
    border: 2px solid #fff;
}

.trufi-geo-pulse-icon::after {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid rgba(25, 113, 194, 0.6);
    animation: trufi-geo-pulse 1.6s ease-out infinite;
}

@keyframes trufi-geo-pulse {
    0% {
        transform: scale(0.5);
        opacity: 1;
    }
    100% {
        transform: scale(2.2);
        opacity: 0;
    }
}

/* Direction arrows drawn along a route's geometry ------------------------- */

.trufi-arrow-wrap {
    pointer-events: none;
}

/* Destination pin marker (Trufi.routeDraw.pinMarker) - strip Leaflet's
 * default .leaflet-div-icon white box/border, the SVG draws its own shape. */
.trufi-pin-wrap {
    background: transparent;
    border: none;
}

.trufi-arrow {
    font-size: 16px;
    line-height: 1;
    text-shadow: 0 0 2px #fff, 0 0 2px #fff;
}

/* Stops ("paradas") list + matching map markers --------------------------- */

.trufi-stop {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 4px;
    font-size: 13px;
    color: var(--trufi-gray-900);
    cursor: pointer;
    border-bottom: 1px solid var(--trufi-gray-100);
}

.trufi-stop:hover,
.trufi-stop.is-active {
    background: var(--trufi-gray-100);
    color: var(--trufi-pink);
}

.trufi-stop-dot {
    flex: 0 0 auto;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--trufi-gray-500);
    background: var(--trufi-white);
}

.trufi-stop.is-start .trufi-stop-dot {
    border-color: #2e7d32;
    background: #2e7d32;
}

.trufi-stop.is-end .trufi-stop-dot {
    border-color: #c62828;
    background: #c62828;
}

.trufi-index-empty {
    padding: 24px 12px;
    color: var(--trufi-gray-600);
    font-size: 14px;
}

/* Leaflet chrome, themed to match the dark/pink palette ------------------- */

.trufi-map .leaflet-top,
.trufi-map .leaflet-bottom {
    z-index: 400;
}

.trufi-map .leaflet-control-zoom {
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(18, 18, 18, 0.35);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.trufi-map .leaflet-control-zoom a {
    background: var(--trufi-dark);
    color: var(--trufi-white);
    border-bottom: 1px solid rgba(255, 255, 255, 0.22);
    width: 34px;
    height: 34px;
    line-height: 32px;
    font-size: 20px;
}

.trufi-map .leaflet-control-zoom a:hover {
    background: var(--trufi-pink);
    color: var(--trufi-white);
}

.trufi-map .leaflet-control-zoom a.leaflet-disabled {
    background: var(--trufi-gray-600);
    color: rgba(255, 255, 255, 0.6);
}

.trufi-map .leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.75);
    font-size: 10px;
    color: var(--trufi-gray-600);
}

/* App store badges (route detail page) ------------------------------------ */

.trufi-store-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.trufi-store-buttons a {
    text-decoration: none;
}

.trufi-store-buttons img {
    max-width: 160px;
    height: auto;
    display: block;
}

/* Text fallback when no badge image is uploaded in the settings. */
.trufi-store-badge {
    display: inline-flex;
    align-items: center;
    padding: 9px 16px;
    border-radius: 8px;
    background: var(--trufi-black);
    color: var(--trufi-white);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.trufi-store-buttons a:hover .trufi-store-badge,
.trufi-store-buttons a:focus-visible .trufi-store-badge {
    background: var(--trufi-pink);
}
