/* ==========================================================================
   Campus map — الخريطة التفاعلية
   components/uowa/pages/campus-map.blade.php + assets/js/campus-map.js

   Leaflet over OpenStreetMap tiles in the site's own chrome. Tokens come from
   style.css/en.css (--ul-primary navy, --ul-c3 gold, --ul-gray*). Layout is
   written with logical properties so the one file serves both directions; the
   map canvas itself is geography and never mirrors.

   Per-category colour arrives on the element as --ul-map-color (set inline
   from config/campus_map.php) and is read by the pin, the chip dot, the list
   number and the card tag.
   ========================================================================== */

.ul-map-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
    gap: 22px;
    align-items: start;
}

/* ---- Map canvas + details card ------------------------------------------- */

.ul-map-stage {
    position: relative;
    isolation: isolate;
}

.ul-map-canvas {
    position: relative;
    height: clamp(380px, 52vw, 600px);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(11, 37, 78, 0.14);
    background: var(--ul-gray);
    /* Leaflet positions everything physically. The page direction must not
       leak in or the tile pane and controls drift. */
    direction: ltr;
}

.ul-map-canvas:focus-visible {
    outline: 3px solid var(--ul-c3);
    outline-offset: 2px;
}

/* No JS / Leaflet failed: one quiet line centred on the grey canvas. */
.ul-map-offline {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    margin: 0;
    padding: 24px;
    text-align: center;
    color: var(--ul-gray2);
    font-size: 15px;
}

/* Leaflet chrome in the site's language */
.ul-map-canvas .leaflet-container {
    font-family: inherit;
    font-size: 13px;
    background: #e9eef5;
}

.ul-map-canvas .leaflet-bar {
    border: 0;
    border-radius: 8px;
    box-shadow: 0 6px 16px -6px rgba(11, 37, 78, 0.45);
    overflow: hidden;
}

.ul-map-canvas .leaflet-bar a {
    width: 34px;
    height: 34px;
    line-height: 34px;
    color: var(--ul-primary);
    border-bottom-color: rgba(11, 37, 78, 0.12);
    font-weight: 700;
}

.ul-map-canvas .leaflet-bar a:hover,
.ul-map-canvas .leaflet-bar a:focus {
    background: var(--ul-primary);
    color: var(--white);
}

.ul-map-canvas .leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.82);
    color: var(--ul-gray2);
    font-size: 10.5px;
    padding: 2px 8px;
    border-start-start-radius: 6px;
}

.ul-map-canvas .leaflet-control-attribution a {
    color: var(--ul-primary);
}

/* ---- Pins ---------------------------------------------------------------- */

/* Leaflet wraps each pin in its own positioned element; this is the inner
   disc. The number ties the pin to its list entry. */
.ul-map-pin {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--ul-map-color, var(--ul-primary));
    color: var(--ul-map-ink, var(--white));
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    border: 2px solid var(--white);
    box-shadow: 0 4px 10px -3px rgba(0, 0, 0, 0.5);
    transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.ul-map-marker {
    /* Leaflet's own wrapper; the disc is centred on the coordinate. */
    background: none;
    border: 0;
    cursor: pointer;
}

.ul-map-marker:hover .ul-map-pin,
.ul-map-marker:focus-visible .ul-map-pin {
    transform: scale(1.15);
}

.ul-map-marker:focus-visible {
    outline: none;
}

.ul-map-marker:focus-visible .ul-map-pin {
    box-shadow: 0 0 0 3px var(--ul-c3), 0 6px 14px -4px rgba(0, 0, 0, 0.5);
}

.ul-map-marker.is-active .ul-map-pin {
    transform: scale(1.3);
    box-shadow: 0 0 0 3px var(--ul-c3), 0 6px 14px -4px rgba(0, 0, 0, 0.5);
}

/* A ring that expands out of the chosen pin — twice, then it settles. Left
   running forever it would pull the eye off whatever the reader chose it for. */
.ul-map-marker.is-active .ul-map-pin::after {
    content: "";
    position: absolute;
    inset: -7px;
    border-radius: 50%;
    border: 2px solid var(--ul-c3);
    animation: ul-map-pulse 1.4s ease-out 2;
    pointer-events: none;
}

.ul-map-marker.is-active .ul-map-pin {
    position: relative;
}

@keyframes ul-map-pulse {
    from { transform: scale(0.8); opacity: 1; }
    to   { transform: scale(1.7); opacity: 0; }
}

/* Hover / focus label */
.ul-map-tip {
    padding: 6px 12px;
    border: 0;
    border-radius: 6px;
    background: var(--ul-primary);
    color: var(--white);
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    box-shadow: 0 8px 20px -10px rgba(11, 37, 78, 0.7);
}

.ul-map-tip::before {
    border-top-color: var(--ul-primary);
}

/* The canvas is forced LTR for Leaflet; the label text is the page's. */
.ul-map-tip.is-rtl {
    direction: rtl;
}

/* ---- Details card -------------------------------------------------------- */

.ul-map-panel {
    position: absolute;
    inset-inline-start: 12px;
    inset-block-end: 12px;
    z-index: 1000; /* above Leaflet's panes (≤ 800) and its controls (1000 at most) */
    width: min(360px, calc(100% - 24px));
    padding: 16px 18px 18px;
    border-radius: 8px;
    background: var(--white);
    color: var(--ul-black);
    border-inline-start: 4px solid var(--ul-map-color, var(--ul-c3));
    box-shadow: 0 16px 36px -14px rgba(11, 37, 78, 0.6);
}

.ul-map-panel[hidden] {
    display: none;
}

.ul-map-panel:focus {
    outline: none;
}

.ul-map-panel:focus-visible {
    outline: 3px solid var(--ul-c3);
    outline-offset: 2px;
}

.ul-map-panel-close {
    position: absolute;
    inset-inline-end: 8px;
    inset-block-start: 8px;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--ul-gray2);
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.ul-map-panel-close:hover,
.ul-map-panel-close:focus-visible {
    background: var(--ul-gray);
    color: var(--ul-primary);
    outline: none;
}

.ul-map-panel-tag {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 6px;
    padding-inline-end: 36px;
    color: var(--ul-gray2);
    font-size: 12.5px;
    font-weight: 700;
}

.ul-map-panel-title {
    margin: 0 0 6px;
    padding-inline-end: 24px;
    color: var(--ul-primary);
    font-size: 17px;
    font-weight: 700;
    line-height: 1.5;
}

.ul-map-panel-address {
    margin: 0;
    color: var(--ul-gray2);
    font-size: 14px;
    line-height: 1.8;
}

.ul-map-panel-address:empty {
    display: none;
}

.ul-map-panel-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-block-start: 12px;
    color: var(--ul-primary);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    transition: gap 0.2s ease, color 0.2s ease;
}

.ul-map-panel-link:hover,
.ul-map-panel-link:focus-visible {
    color: var(--ul-primary);
    gap: 12px;
    text-decoration: underline;
    text-decoration-color: var(--ul-c3);
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
}

.ul-map-panel-link[hidden] {
    display: none;
}

/* ---- Aside: hint, search, chips, count, list ----------------------------- */

.ul-map-dot {
    flex: none;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--ul-map-color, var(--ul-primary));
    box-shadow: 0 0 0 2px rgba(11, 37, 78, 0.08);
}

.ul-map-hint {
    font-size: 14px;
    color: var(--ul-gray2);
    margin: 0 0 14px;
}

.ul-map-search {
    margin-block-end: 14px;
}

.ul-map-search-label {
    display: block;
    margin-block-end: 6px;
    color: var(--ul-primary);
    font-size: 13px;
    font-weight: 700;
}

.ul-map-search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 4px 4px 14px;
    border: 1px solid rgba(11, 37, 78, 0.2);
    border-radius: 8px;
    background: var(--white);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ul-map-search-box:focus-within {
    border-color: var(--ul-primary);
    box-shadow: 0 0 0 3px rgba(254, 190, 53, 0.35);
}

.ul-map-search-box > i {
    color: var(--ul-gray3);
    font-size: 14px;
}

.ul-map-search-input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 8px 0;
    border: 0;
    background: transparent;
    color: var(--ul-black);
    font-size: 15px;
    font-family: inherit;
}

.ul-map-search-input:focus {
    outline: none;
}

.ul-map-search-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}

.ul-map-search-clear {
    flex: none;
    padding: 7px 12px;
    border: 0;
    border-radius: 6px;
    background: var(--ul-gray);
    color: var(--ul-primary);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.ul-map-search-clear:hover,
.ul-map-search-clear:focus-visible {
    background: var(--ul-primary);
    color: var(--white);
    outline: none;
}

.ul-map-search-clear[hidden] {
    display: none;
}

.ul-map-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-block-end: 12px;
}

.ul-map-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 15px;
    border-radius: 22px;
    border: 1px solid rgba(11, 37, 78, 0.2);
    background: var(--white);
    color: var(--ul-gray2);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.22s ease, color 0.22s ease, border-color 0.22s ease;
}

.ul-map-chip:hover {
    border-color: var(--ul-primary);
    color: var(--ul-primary);
}

.ul-map-chip:focus-visible {
    outline: 3px solid var(--ul-c3);
    outline-offset: 2px;
}

.ul-map-chip.is-active {
    background: var(--ul-primary);
    border-color: var(--ul-primary);
    color: var(--white);
}

.ul-map-chip.is-active .ul-map-dot {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
}

.ul-map-count {
    margin: 0 0 8px;
    color: var(--ul-gray2);
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.ul-map-list {
    position: relative; /* entries' offsetTop is measured against the list */
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 430px;
    overflow: auto;
    border: 1px solid rgba(11, 37, 78, 0.12);
    border-radius: 8px;
    scrollbar-width: thin;
}

.ul-map-list li + li .ul-map-entry {
    border-block-start: 1px solid rgba(11, 37, 78, 0.1);
}

.ul-map-list li[hidden] {
    display: none;
}

.ul-map-entry {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    padding: 11px 14px;
    border: 0;
    background: var(--white);
    color: var(--ul-black);
    font-size: 15px;
    font-family: inherit;
    text-align: start;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.ul-map-entry:hover {
    background: var(--ul-gray);
}

.ul-map-entry:focus-visible {
    outline: 3px solid var(--ul-c3);
    outline-offset: -3px;
}

.ul-map-entry.is-active {
    background: var(--ul-primary);
    color: var(--white);
}

.ul-map-entry-num {
    display: grid;
    place-items: center;
    flex: none;
    width: 26px;
    height: 26px;
    margin-block-start: 1px;
    border-radius: 50%;
    background: var(--ul-map-color, var(--ul-primary));
    color: var(--ul-map-ink, var(--white));
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    border: 2px solid var(--white);
    box-shadow: 0 0 0 1px rgba(11, 37, 78, 0.12);
}

.ul-map-entry.is-active .ul-map-entry-num {
    box-shadow: 0 0 0 2px var(--ul-c3);
}

.ul-map-entry-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.ul-map-entry-label {
    font-weight: 700;
    line-height: 1.5;
}

.ul-map-entry-meta {
    color: var(--ul-gray2);
    font-size: 12.5px;
    line-height: 1.6;
}

.ul-map-entry.is-active .ul-map-entry-meta {
    color: rgba(255, 255, 255, 0.78);
}

.ul-map-empty {
    margin: 0;
    padding: 18px;
    border-radius: 8px;
    background: var(--ul-gray);
    color: var(--ul-gray2);
    font-size: 14px;
    font-weight: 700;
    text-align: center;
}

.ul-map-empty[hidden] {
    display: none;
}

/* ---- Responsive ---------------------------------------------------------- */

@media (max-width: 991px) {
    .ul-map-layout {
        grid-template-columns: 1fr;
    }

    .ul-map-canvas {
        height: clamp(360px, 60vw, 520px);
    }

    /* One column: a card floating over a shorter map hides too much of it
       (and the pins under it). Stack it under the map instead, in flow, so
       it never meets the fixed widgets in the corners either. */
    .ul-map-panel {
        position: static;
        width: auto;
        margin-block-start: 12px;
        box-shadow: 0 10px 24px -14px rgba(11, 37, 78, 0.5);
        border: 1px solid rgba(11, 37, 78, 0.12);
        border-inline-start: 4px solid var(--ul-map-color, var(--ul-c3));
    }

    .ul-map-list {
        max-height: 360px;
    }
}

@media (max-width: 767px) {
    .ul-map-canvas {
        height: 360px;
    }
}

@media (max-width: 575px) {
    .ul-map-search-box {
        padding-inline-start: 12px;
    }

    .ul-map-chip {
        flex: 1 1 calc(50% - 4px);
        justify-content: center;
    }

    .ul-map-list {
        max-height: 320px;
    }
}
