
* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: #071019;
    color: #e9f3f8;
    font-family:
        Arial,
        Helvetica,
        sans-serif;
}

header {
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: #07131d;
    border-bottom: 1px solid #1d3949;
}

.logo {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 2px;
}

.subtitle {
    margin-top: 2px;
    color: #56d7ff;
    font-size: 12px;
    letter-spacing: 1px;
}

.header-stats {
    display: flex;
    gap: 20px;
    color: #a8c0ce;
    font-size: 13px;
}

#layout {
    height: calc(100% - 68px);
    display: flex;
}

#sidebar {
    width: 330px;
    flex: 0 0 330px;
    overflow-y: auto;
    background: #091722;
    border-right: 1px solid #1c3949;
}

.section {
    padding: 17px 18px;
    border-bottom: 1px solid #17303e;
}

.section h2 {
    margin: 0 0 10px;
    font-size: 15px;
    color: #65dcff;
}

.section h3 {
    margin: 0 0 12px;
    font-size: 13px;
    color: #8ce6ff;
    letter-spacing: 1px;
}

.intro {
    margin: 0;
    color: #aabdc8;
    font-size: 13px;
    line-height: 1.55;
}

label {
    display: block;
    padding: 5px 0;
    color: #c8d7df;
    font-size: 13px;
}

input[type="checkbox"] {
    margin-right: 8px;
}

#searchBox {
    width: 100%;
    padding: 10px;
    color: white;
    background: #102532;
    border: 1px solid #295064;
    border-radius: 5px;
    outline: none;
}

.searchItem {
    padding: 8px;
    margin-top: 5px;
    background: #10222e;
    cursor: pointer;
    font-size: 12px;
}

.searchItem:hover {
    background: #173748;
}

button {
    border: 1px solid #35b9e8;
    background: #0e6686;
    color: white;
    padding: 10px 14px;
    border-radius: 5px;
    cursor: pointer;
}

button:hover {
    background: #0f7fa6;
}

.analysisBox {
    margin-top: 12px;
    color: #adc3ce;
    font-size: 12px;
    line-height: 1.5;
}

.data-note {
    color: #7893a2;
    line-height: 1.5;
    font-size: 11px;
}

#mapWrap {
    flex: 1;
    position: relative;
    min-width: 0;
}

#map {
    width: 100%;
    height: 100%;
    background: #0b1117;
}

#loading {
    position: absolute;
    z-index: 900;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 15px;
    border-radius: 5px;
    background: rgba(5,17,25,.9);
    border: 1px solid #31566a;
    display: none;
}

#legend {
    position: absolute;
    z-index: 900;
    right: 12px;
    bottom: 25px;
    background: rgba(6,18,27,.92);
    border: 1px solid #294654;
    border-radius: 6px;
    padding: 10px 13px;
    font-size: 11px;
}

.line {
    display: inline-block;
    width: 25px;
    height: 3px;
    margin-right: 7px;
    vertical-align: middle;
}

.operational {
    background: #21a6ff;
}

.construction {
    background: #ffd84a;
}

.planned {
    background: #ff9f32;
}

.proposed {
    background: #cf63ff;
}

.microwave {
    background: #9ba7ae;
}

#drawer {
    width: 0;
    flex: 0 0 0;
    overflow: hidden;
    position: relative;
    background: #0b1923;
    border-left: 1px solid #234352;
    transition: width .2s ease, flex-basis .2s ease;
}

#drawer.open {
    width: 360px;
    flex-basis: 360px;
}

#drawerContent {
    width: 360px;
    padding: 24px 20px;
    overflow-y: auto;
    height: 100%;
}

#drawerClose {
    position: absolute;
    right: 9px;
    top: 7px;
    padding: 2px 9px;
    font-size: 22px;
    background: transparent;
    border: 0;
}

.detailRow {
    padding: 9px 0;
    border-bottom: 1px solid #1b3542;
}

.detailLabel {
    display: block;
    font-size: 10px;
    color: #66899b;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.detailValue {
    display: block;
    margin-top: 3px;
    color: #e8f3f8;
    font-size: 14px;
}

.score {
    font-size: 35px;
    font-weight: bold;
    color: #52e0a0;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
    background: #0e202b;
    color: white;
}

@media(max-width: 900px) {

    #sidebar {
        width: 245px;
        flex-basis: 245px;
    }

    .header-stats {
        display: none;
    }

    #drawer.open {
        width: 300px;
        flex-basis: 300px;
    }

    #drawerContent {
        width: 300px;
    }
}

/* FIBERFINDER_MOBILE_BEGIN */

/*
 * FiberFinder responsive phone layout.
 * Desktop layout remains unchanged.
 */

@media (max-width: 700px) {

    html,
    body {
        width: 100%;
        max-width: 100%;
        min-height: 100%;
        height: auto;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }


    /* =====================================================
       HEADER
       ===================================================== */

    header {
        width: 100%;
        height: auto !important;
        min-height: 64px;

        display: flex;
        flex-wrap: wrap;
        align-items: center;

        gap: 6px;

        padding:
            calc(9px + env(safe-area-inset-top))
            10px
            9px;
    }

    header > * {
        min-width: 0;
    }

    .logo {
        font-size: 18px !important;
        line-height: 1.15;
        letter-spacing: 1px;
    }

    header .subtitle,
    header p {
        font-size: 9px !important;
        line-height: 1.3;
    }

    .header-stats {
        width: 100%;

        display: flex;
        flex-wrap: wrap;

        gap: 5px;

        margin: 2px 0 0 !important;
    }

    .header-stats span {
        flex: 1 1 120px;

        min-width: 0;

        padding: 6px 8px;

        font-size: 10px;
        line-height: 1.2;

        text-align: center;

        overflow-wrap: anywhere;
    }


    /* =====================================================
       MAIN SIDEBAR
       ===================================================== */

    #sidebar {
        position: relative !important;

        top: auto !important;
        right: auto !important;
        bottom: auto !important;
        left: auto !important;

        width: 100% !important;
        max-width: none !important;
        height: auto !important;
        max-height: none !important;

        overflow: visible !important;

        border-right: none !important;
        border-bottom: 1px solid rgba(70, 150, 185, 0.35);

        padding-bottom: 8px;
    }

    #sidebar section {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    #sidebar h2 {
        font-size: 18px;
        line-height: 1.25;
    }

    #sidebar h3 {
        font-size: 11px;
        line-height: 1.25;
    }


    /* =====================================================
       SEARCH
       ===================================================== */

    #searchBox {
        width: 100% !important;

        min-height: 46px;

        padding: 10px 11px;

        font-size: 16px !important;

        border-radius: 6px;
    }

    #searchResults {
        width: 100%;
        max-height: 240px;

        overflow-y: auto;

        -webkit-overflow-scrolling: touch;
    }

    .searchItem {
        min-height: 44px;

        padding: 10px 8px !important;

        font-size: 12px;
        line-height: 1.35;

        touch-action: manipulation;
    }


    /* =====================================================
       CHECKBOXES / FILTERS
       ===================================================== */

    #sidebar label {
        min-height: 40px;

        display: flex;
        align-items: center;

        line-height: 1.3;

        touch-action: manipulation;
    }

    #sidebar input[type="checkbox"] {
        flex: 0 0 auto;

        width: 21px;
        height: 21px;

        margin-right: 8px;
    }

    #sidebar button {
        min-height: 44px;

        padding: 9px 11px;

        touch-action: manipulation;
    }


    /* =====================================================
       MAP
       ===================================================== */

    #mapWrap {
        position: relative !important;

        top: auto !important;
        right: auto !important;
        bottom: auto !important;
        left: auto !important;

        width: 100% !important;
        height: 62vh !important;
        min-height: 390px !important;
        max-height: 700px;

        overflow: hidden;
    }

    #map {
        position: absolute !important;

        inset: 0 !important;

        width: 100% !important;
        height: 100% !important;

        min-height: 390px;
    }


    /* =====================================================
       MAP LEGEND
       ===================================================== */

    #legend {
        max-width: calc(100vw - 24px) !important;
        max-height: 42vh;

        overflow-y: auto;

        padding: 8px 10px !important;

        font-size: 10px !important;
        line-height: 1.35;

        -webkit-overflow-scrolling: touch;
    }

    #legend > div {
        margin: 4px 0;
    }


    /* =====================================================
       FIBER INTELLIGENCE DRAWER
       ===================================================== */

    #drawer {
        position: fixed !important;

        top: 0 !important;
        right: -100vw !important;
        bottom: 0 !important;
        left: auto !important;

        width: 100vw !important;
        max-width: none !important;

        height: 100dvh !important;
        max-height: none !important;

        z-index: 10000;

        overflow: hidden;

        transition: right 0.22s ease !important;
    }

    #drawer.open {
        right: 0 !important;

        width: 100vw !important;
        max-width: none !important;
    }

    #drawerContent {
        width: 100% !important;
        max-width: none !important;

        height: 100%;
        max-height: 100% !important;

        overflow-x: hidden;
        overflow-y: auto;

        padding:
            calc(58px + env(safe-area-inset-top))
            14px
            calc(28px + env(safe-area-inset-bottom))
            !important;

        -webkit-overflow-scrolling: touch;

        overflow-wrap: anywhere;
        word-break: break-word;
    }

    #drawerContent h2 {
        font-size: 20px;
        line-height: 1.2;

        margin-top: 0;
    }

    #drawerContent h3 {
        font-size: 14px;
        line-height: 1.3;
    }

    #drawerContent p,
    #drawerContent li,
    #drawerContent td,
    #drawerContent th,
    #drawerContent div {
        max-width: 100%;

        overflow-wrap: anywhere;
    }

    #drawerContent table {
        display: block;

        width: 100%;
        max-width: 100%;

        overflow-x: auto;

        -webkit-overflow-scrolling: touch;
    }

    #drawerClose {
        position: fixed !important;

        top: calc(8px + env(safe-area-inset-top));
        right: 10px;

        z-index: 10001;

        width: 46px !important;
        height: 46px !important;

        min-width: 46px;
        min-height: 46px;

        padding: 0 !important;

        font-size: 30px !important;
        line-height: 42px !important;

        touch-action: manipulation;
    }


    /* =====================================================
       LEAFLET TOUCH CONTROLS
       ===================================================== */

    .leaflet-control-zoom a {
        width: 44px !important;
        height: 44px !important;

        line-height: 44px !important;

        font-size: 22px !important;
    }

    .leaflet-control-layers {
        max-width: calc(100vw - 30px);

        font-size: 12px;
    }

    .leaflet-control-layers-expanded {
        max-height: 55vh;

        overflow-y: auto;

        padding: 10px;

        -webkit-overflow-scrolling: touch;
    }

    .leaflet-control-layers label {
        min-height: 34px;

        display: flex;
        align-items: center;
    }

    .leaflet-control-layers input {
        width: 18px;
        height: 18px;

        margin-right: 7px;
    }


    /* =====================================================
       LEAFLET POPUPS
       ===================================================== */

    .leaflet-popup {
        max-width: calc(100vw - 36px);
    }

    .leaflet-popup-content-wrapper {
        max-width: calc(100vw - 36px);
    }

    .leaflet-popup-content {
        width: auto !important;

        max-width: calc(100vw - 72px);

        margin: 12px 14px;

        font-size: 12px;
        line-height: 1.45;

        overflow-wrap: anywhere;
        word-break: break-word;
    }


    /* =====================================================
       LINKS / BUTTONS
       ===================================================== */

    a,
    button,
    input,
    select {
        max-width: 100%;
    }

    button,
    a.button,
    .button {
        touch-action: manipulation;
    }

}


/* Small phones */

@media (max-width: 430px) {

    header {
        padding-left: 8px;
        padding-right: 8px;
    }

    .logo {
        font-size: 16px !important;
    }

    .header-stats span {
        font-size: 9px;
    }

    #mapWrap {
        height: 58vh !important;
        min-height: 350px !important;
    }

    #map {
        min-height: 350px;
    }

    #legend {
        font-size: 9px !important;
    }

}


/* Landscape phones */

@media
    (max-width: 900px)
    and (orientation: landscape)
    and (max-height: 520px) {

    #mapWrap {
        height: 88vh !important;
        min-height: 360px !important;
        max-height: none;
    }

    #map {
        min-height: 360px;
    }

}

/* FIBERFINDER_MOBILE_END */


/* FIBERFINDER_PHONE_MAPFIRST_BEGIN */

@media (max-width: 700px) {

    /*
     * Reorder the actual page:
     * header
     * map
     * controls
     */

    body {
        display: flex !important;
        flex-direction: column !important;

        width: 100% !important;
        min-height: 100dvh !important;
        height: auto !important;

        overflow-x: hidden !important;
        overflow-y: auto !important;
    }


    header {
        order: 1 !important;

        flex: 0 0 auto !important;

        min-height: 0 !important;

        padding:
            calc(6px + env(safe-area-inset-top))
            9px
            6px !important;
    }


    /*
     * KEEP HEADER SMALL.
     * Don't burn a third of the screen on branding/stats.
     */

    header .logo {
        font-size: 16px !important;
    }

    header .subtitle,
    header p {
        margin: 0 !important;

        font-size: 8px !important;
        line-height: 1.2 !important;
    }

    .header-stats {
        width: auto !important;

        display: flex !important;
        flex: 1 1 100% !important;

        gap: 4px !important;

        margin: 0 !important;
    }

    .header-stats span {
        flex: 1 1 auto !important;

        min-width: 0 !important;

        padding: 3px 5px !important;

        font-size: 9px !important;
        line-height: 1.1 !important;
    }


    /*
     * MAP IMMEDIATELY AFTER HEADER
     */

    #mapWrap {
        order: 2 !important;

        position: relative !important;

        top: auto !important;
        right: auto !important;
        bottom: auto !important;
        left: auto !important;

        flex: 0 0 auto !important;

        width: 100% !important;

        height: 72dvh !important;
        min-height: 480px !important;
        max-height: none !important;

        margin: 0 !important;
        padding: 0 !important;

        overflow: hidden !important;
    }

    #map {
        position: absolute !important;

        top: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        left: 0 !important;

        width: 100% !important;
        height: 100% !important;

        min-height: 0 !important;

        margin: 0 !important;
    }


    /*
     * SEARCH / FILTER SIDEBAR GOES UNDER MAP
     */

    #sidebar {
        order: 3 !important;

        position: relative !important;

        top: auto !important;
        right: auto !important;
        bottom: auto !important;
        left: auto !important;

        flex: 0 0 auto !important;

        width: 100% !important;
        height: auto !important;
        max-height: none !important;

        overflow: visible !important;

        margin: 0 !important;
    }


    /*
     * REMOVE LARGE LEGEND OVERLAY FROM PHONE MAP.
     * Layer/status controls are available below the map.
     */

    #legend {
        display: none !important;
    }


    /*
     * LEAFLET CONTROLS:
     * keep them compact and near map edges.
     */

    .leaflet-top {
        top: 6px !important;
    }

    .leaflet-left {
        left: 6px !important;
    }

    .leaflet-right {
        right: 6px !important;
    }

    .leaflet-bottom {
        bottom: 6px !important;
    }

    .leaflet-control {
        margin: 5px !important;
    }

    .leaflet-control-zoom a {
        width: 40px !important;
        height: 40px !important;

        line-height: 40px !important;

        font-size: 20px !important;
    }


    /*
     * Layer chooser stays collapsed until touched.
     */

    .leaflet-control-layers {
        max-width: calc(100vw - 60px) !important;
    }

    .leaflet-control-layers-expanded {
        max-width: calc(100vw - 30px) !important;
        max-height: 50dvh !important;

        overflow-y: auto !important;
    }


    /*
     * ATTRIBUTION: still visible, but tiny.
     */

    .leaflet-control-attribution {
        max-width: 72vw !important;

        padding: 1px 4px !important;

        font-size: 7px !important;
        line-height: 1.15 !important;

        white-space: normal !important;
    }


    /*
     * FIBER INTELLIGENCE DRAWER:
     * absolutely nothing from it should cover the map
     * while it is CLOSED.
     */

    #drawer:not(.open) {
        right: -105vw !important;

        visibility: hidden !important;
        pointer-events: none !important;
    }

    #drawer.open {
        right: 0 !important;

        visibility: visible !important;
        pointer-events: auto !important;
    }


    /*
     * Popups should not become giant overlays.
     */

    .leaflet-popup-content-wrapper {
        max-width: calc(100vw - 55px) !important;
    }

    .leaflet-popup-content {
        max-width: calc(100vw - 85px) !important;

        font-size: 11px !important;
        line-height: 1.35 !important;
    }

}


/*
 * REALLY SMALL PHONES
 */

@media (max-width: 430px) {

    #mapWrap {
        height: 74dvh !important;
        min-height: 460px !important;
    }

    .header-stats span {
        font-size: 8px !important;
    }

}


/*
 * PHONE LANDSCAPE
 */

@media
    (max-width: 900px)
    and (orientation: landscape)
    and (max-height: 520px) {

    header {
        padding-top: 4px !important;
        padding-bottom: 4px !important;
    }

    #mapWrap {
        height: 82dvh !important;
        min-height: 300px !important;
    }

}

/* FIBERFINDER_PHONE_MAPFIRST_END */

