@font-face {
  font-family: 'SourceSansPro';
  font-weight: 400;
  font-display: swap;
  src: url('fonts/SourceSansPro-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'SourceSansPro';
  font-weight: 600;
  font-display: swap;
  src: url('fonts/SourceSansPro-SemiBold.woff2') format('woff2');
}
@font-face {
  font-family: 'SourceSansPro';
  font-weight: 700;
  font-display: swap;
  src: url('fonts/SourceSansPro-Bold.woff2') format('woff2');
}

body {
    font-family: 'SourceSansPro', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        Helvetica, Arial, sans-serif;
    margin: 0;
    background: #f2f5f6;
}

label {
    font-family: 'SourceSansPro', 'Roboto', sans-serif;
    font-weight: bold;
}

.slider-label {
    font-size: 14px;
}

.thuenen-logo-box {
    background: rgba(255, 255, 255, 0.90);
    padding: 6px 10px;
    margin-left: 10px;
    border-radius: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.thuenen-logo-box:hover {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.legal-footer {
    background: rgba(255, 255, 255, 0.8);
    padding: 0;
    font-size: 11px;
    line-height: 1.6;
    color: #333;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.legal-footer a {
    color: #333;
    text-decoration: none;
}

.legal-footer a:hover {
    color: #008cd2;
    text-decoration: underline;
}

.legal-footer-sep {
    color: #888;
}

.legal-footer-mobile {
    display: none;
}

.stac-panel-box {
    position: absolute;
    bottom: 26px;
    right: 10px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.9);
    padding: 4px 12px;
    border-radius: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    min-height: 24px;
    display: flex;
    align-items: center;
}

.bottom-left-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}

.opacity-slider-box {
    width: 100%;
    background: transparent;
    padding: 8px 0 0;
    border-radius: 0;
    box-shadow: none;
    min-height: auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.opacity-slider-box .rc-slider {
    width: 100%;
    margin: 0;
}

.opacity-slider-box .rc-slider-tooltip {
    display: none !important;
}

.stac-panel-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.stac-panel-text {
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
}

.stac-panel-logo {
    width: 80px;
    height: auto;
    display: block;
}

.floating-header {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.96);
    color: #151819;
    padding: 10px 14px;
    border-left: 4px solid #008cd2;
    border-radius: 0;
    box-shadow: 0 6px 16px rgba(2, 6, 23, 0.15);
    max-width: 360px;
}

.thuenen-logo {
    display: block;
    height: 40px;
    width: auto;
}

.app-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.2px;
}

/* ── Header title row with icon buttons ─────────────────────── */
.header-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.header-icon-group {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.header-icon-btn {
    background: #008cd2;
    border: none;
    color: #f8fafc;
    border-radius: 0;
    width: 26px;
    height: 26px;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: background 0.15s;
    line-height: 1;
}

.header-icon-btn:hover {
    background: #0078b8;
    color: #f8fafc;
}

.header-icon-img {
    width: 18px;
    height: 18px;
    display: block;
}

/* ── Dataset info modal ──────────────────────────────────────── */
.info-modal {
    position: absolute;
    top: 88px;
    left: 10px;
    z-index: 1200;
    width: min(380px, calc(100vw - 32px));
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 0;
    box-shadow: 0 10px 28px rgba(2, 6, 23, 0.22);
    padding: 14px;
}

.info-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.info-modal-title {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
}

.info-modal-close {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: #64748b;
    line-height: 1;
    padding: 0 2px;
}

.info-modal-close:hover { color: #0f172a; }

.info-modal-body {
    font-size: 13px;
    color: #334155;
    line-height: 1.6;
    margin-bottom: 12px;
}

.info-modal-stac-link {
    display: inline-block;
    font-size: 13px;
    font-weight: 600;
    color: #2563eb;
    text-decoration: none;
}

.info-modal-stac-link:hover { text-decoration: underline; }

.app-subtitle {
    font-size: 13px;
    opacity: 0.9;
    margin-top: 2px;
}

.floating-panel {
    position: absolute;
    top: 12px;
    right: 10px;
    z-index: 1000;
    width: 300px;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    background-color: rgba(255, 255, 255, 0.94);
    padding: 12px;
    border-radius: 0;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2);
    border: 1px solid rgba(15, 23, 42, 0.08);
}

.panel-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 8px;
    color: #0f172a;
}

.panel-label {
    display: block;
    margin: 8px 0 6px;
    font-size: 13px;
    color: #334155;
}

#class-filter-label {
    margin-top: 0;
}

.class-filter {
    display: grid;
    gap: 6px;
    margin-bottom: 6px;
    max-height: 280px;
    overflow-y: auto;
}

/* ── Dataset tab bar (top-centre of map) ───────────────────── */
.dataset-tab-bar {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1001;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid #d9dfe6;
    border-radius: 0;
    padding: 5px 6px;
    box-shadow: 0 4px 14px rgba(2, 6, 23, 0.15);
    white-space: nowrap;
}

.dataset-tabs {
    display: flex;
    gap: 4px;
}

.dataset-tabs label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    border-radius: 0;
    color: #151819;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    user-select: none;
}

.dataset-tabs label:hover {
    background: #eef6fc;
    color: #008cd2;
}

/* Active tab – :has() is supported in all modern browsers */
.dataset-tabs label:has(input:checked) {
    background: #008cd2;
    color: #ffffff;
    font-weight: 700;
}

.dataset-tabs input[type="radio"] {
    display: none;
}

.class-filter label {
    font-weight: 500;
    font-size: 13px;
    display: flex;
    align-items: center;
}

.stats-graph {
    margin-top: 10px;
}

@media (max-width: 900px) {
    .floating-panel {
        top: auto;
        bottom: 84px;
        right: 10px;
        width: min(88vw, 320px);
        max-height: 42vh;
    }

    .floating-header {
        max-width: calc(100vw - 24px);
    }
}

.pixel-popup {
    position: absolute;
    left: 10px;
    top: 88px;
    z-index: 1100;
    width: min(390px, calc(100vw - 32px));
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 0;
    box-shadow: 0 10px 24px rgba(2, 6, 23, 0.24);
    padding: 8px;
}

.pixel-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.pixel-popup-title {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
}

.pixel-popup-coords {
    font-size: 12px;
    color: #475569;
    margin-bottom: 6px;
}

.pixel-popup-close {
    background: #008cd2;
    color: #fff;
    border: none;
    border-radius: 0;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
}

.pixel-popup-close:hover {
    background: #0078b8;
}

#pixel-diversity-container {
    margin-top: 8px;
}

#pixel-timeseries-graph {
    margin-bottom: 4px;
}

.pixel-hint-popup {
    position: absolute;
    left: 10px;
    top: 88px;
    z-index: 1090;
    width: min(320px, calc(100vw - 32px));
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 0;
    box-shadow: 0 8px 20px rgba(2, 6, 23, 0.2);
    padding: 10px;
    pointer-events: none;
}

.pixel-hint-title,
.pixel-hint-text {
    pointer-events: none;
}

.pixel-hint-close {
    pointer-events: auto;
}

.pixel-hint-title {
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 4px;
}

.pixel-hint-text {
    font-size: 12px;
    color: #475569;
    margin-bottom: 8px;
}

.pixel-hint-close {
    background: #334155;
    color: #fff;
    border: none;
    border-radius: 0;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
}

.pixel-hint-close:hover {
    background: #1e293b;
}

@media (max-width: 900px) {
    .bottom-left-controls {
        left: 10px;
        bottom: 88px;
        gap: 6px;
    }

    .opacity-slider-box {
        width: min(56vw, 230px);
    }

    .pixel-popup {
        top: 72px;
        left: 10px;
        width: min(92vw, 390px);
    }

    .pixel-hint-popup {
        top: 72px;
        left: 10px;
        width: min(92vw, 320px);
    }
}
/* ── Map controls toggle (mobile only) ─────────────────────── */
.map-controls-toggle {
    display: none;
}

/* ── Mobile phone layout ───────────────────────────────────── */
@media (max-width: 600px) {
    /* Hide desktop-only elements */
    .stac-panel-box,
    .thuenen-logo-box,
    .pixel-hint-popup,
    .pixel-popup,
    .bottom-left-controls .legal-footer {
        display: none !important;
    }

    /* Legal footer moves to the bottom of the map controls panel */
    .legal-footer-mobile {
        display: flex;
        margin-top: 10px;
        padding-top: 8px;
        border-top: 1px solid #e2e8f0;
    }

    /* Map fills the viewport without browser-chrome overlap */
    #map {
        height: 100dvh;
    }

    /* Compact title header */
    .floating-header {
        max-width: 55vw;
    }
    .app-title {
        font-size: 15px;
    }
    .app-subtitle {
        display: none;
    }

    /* Dataset tabs: full-width, horizontally scrollable */
    .dataset-tab-bar {
        top: 60px;
        left: 10px;
        right: 10px;
        transform: none;
        width: auto;
        overflow-x: auto;
        white-space: nowrap;
    }
    .dataset-tabs label {
        padding: 8px 14px;
        font-size: 14px;
    }

    /* Map controls start collapsed; the button toggles the panel */
    .map-controls-toggle {
        display: block;
        position: absolute;
        top: 10px;
        right: 10px;
        z-index: 1002;
        background: #008cd2;
        color: #fff;
        border: none;
        border-radius: 0;
        padding: 7px 12px;
        font-size: 14px;
        font-family: 'SourceSansPro', 'Roboto', sans-serif;
        cursor: pointer;
    }
    .map-controls-toggle:hover {
        background: #0078b8;
    }

    /* Expanded controls: panel pops up right below the tabs */
    #map-controls-panel {
        display: none;
    }
    .floating-panel {
        top: 100px;
        bottom: auto;
        left: 10px;
        right: 10px;
        width: auto;
        max-height: 40vh;
        overflow-y: auto;
    }

    /* Pixel analysis / dataset info fit the screen */
    .pixel-popup,
    .info-modal {
        top: 110px;
        left: 10px;
        width: calc(100vw - 20px);
    }

    /* Year slider: slim, full-width, directly above the credits */
    #year-slider-label {
        display: none;
    }
    #year-slider-container {
        left: 10px !important;
        right: 10px !important;
        transform: none !important;
        width: auto !important;
        bottom: 36px !important;
        padding: 4px !important;
    }

    /* Leaflet credits flush with the bottom edge */
    .leaflet-control-attribution {
        margin-bottom: 0 !important;
    }
}
