/*
Theme Name: Mapa okregu
Theme URI: https://example.com
Author: Marcin Dąbrowski
Description: Szablon mapy okręgu wyborczego z panelem bocznym i wyszukiwarką.
Version: 1.0
*/

:root {
    --paper: #F9F8F6;
    --sand: #EFE9E3;
    --taupe: #D9CFC7;
    --camel: #C9B59C;
    --ink: #2e2925;
    --muted: #716961;
    --white: #fff;
    --shadow: 0 18px 55px rgba(62, 51, 40, 0.16);
    --topbar-height: 78px;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
}

body {
    overflow: hidden;
    background: var(--paper);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
    font: inherit;
}

button {
    color: inherit;
}

.topbar {
    position: fixed;
    inset: 0 0 auto 0;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
    padding: 12px 26px;
    background: rgba(249, 248, 246, 0.96);
    border-bottom: 1px solid var(--taupe);
    backdrop-filter: blur(14px);
    z-index: 2000;
}

.brand {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    text-decoration: none;
}

.brand-mark {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border: 1px solid #bca68a;
    border-radius: 14px;
    background: var(--camel);
    color: var(--paper);
    font-weight: 800;
    letter-spacing: -0.04em;
    position: relative;
}

.brand-mark img {
    width: 44px;
    height: 44px;
    position: absolute;
    top: 48%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.brand-copy {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.brand-copy strong {
    font-size: 1rem;
    letter-spacing: 0.01em;
}

.brand-copy small {
    margin-top: 5px;
    color: var(--muted);
    font-size: 0.75rem;
}

.search-wrap {
    position: relative;
    width: min(440px, 46vw);
}

.search-box {
    height: 48px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px 0 15px;
    border: 1px solid var(--taupe);
    border-radius: 15px;
    background: var(--white);
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.search-box:focus-within {
    border-color: var(--camel);
    box-shadow: 0 0 0 4px rgba(201, 181, 156, 0.2);
}

.search-box svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: var(--muted);
    stroke-width: 1.8;
    stroke-linecap: round;
}

.search-box input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--ink);
}

.search-box input::placeholder {
    color: #9a9189;
}

.clear-search {
    width: 30px;
    height: 30px;
    display: none;
    place-items: center;
    border: 0;
    border-radius: 9px;
    background: var(--sand);
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
}

.clear-search.is-visible {
    display: grid;
}

.search-results {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: 0;
    max-height: min(420px, 60vh);
    display: none;
    overflow-y: auto;
    padding: 7px;
    border: 1px solid var(--taupe);
    border-radius: 14px;
    background: var(--white);
    box-shadow: var(--shadow);
}

.search-results.is-open {
    display: block;
}

.search-result {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 12px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.search-result:hover,
.search-result:focus-visible {
    outline: 0;
    background: var(--sand);
}

.search-result small {
    color: var(--muted);
}

.app-shell {
    position: relative;
    width: 100%;
    height: 100%;
    /*padding-top: var(--topbar-height);*/
}

#map {
    width: 100%;
    height: 100%;
    background: var(--sand);
}

.leaflet-container {
    font-family: inherit;
}

.leaflet-control-zoom a {
    color: var(--ink) !important;
    background: var(--paper) !important;
    border-bottom-color: var(--taupe) !important;
}

.leaflet-control-attribution {
    background: rgba(249, 248, 246, 0.88) !important;
    color: var(--muted) !important;
}

.municipality-tooltip {
    padding: 7px 10px !important;
    border: 1px solid var(--taupe) !important;
    border-radius: 10px !important;
    background: var(--paper) !important;
    color: var(--ink) !important;
    box-shadow: 0 9px 24px rgba(62, 51, 40, 0.13) !important;
    font-weight: 700;
}

.municipality-tooltip::before {
    display: none;
}

.map-hint {
    position: absolute;
    z-index: 700;
    left: 24px;
    bottom: 28px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 14px;
    border: 1px solid var(--taupe);
    border-radius: 999px;
    background: rgba(249, 248, 246, 0.94);
    color: var(--muted);
    box-shadow: 0 10px 30px rgba(62, 51, 40, 0.09);
    font-size: 0.84rem;
    pointer-events: none;
}

.hint-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--camel);
    box-shadow: 0 0 0 4px rgba(201, 181, 156, 0.25);
}

.details-panel {
    position: fixed;
    z-index: 1500;
    top: var(--topbar-height);
    right: 0;
    bottom: 0;
    width: 50vw;
    min-width: 520px;
    display: flex;
    flex-direction: column;
    transform: translateX(101%);
    border-left: 1px solid var(--taupe);
    background: var(--paper);
    box-shadow: -20px 0 55px rgba(62, 51, 40, 0.15);
    transition: transform 300ms cubic-bezier(.22,.8,.22,1);
}

.details-panel.is-open {
    transform: translateX(0);
}

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 22px;
    padding: 30px 34px 22px;
    border-bottom: 1px solid var(--taupe);
}

.eyebrow {
    display: block;
    margin-bottom: 7px;
    color: #8a745d;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.panel-header h1 {
    margin: 0;
    font-size: clamp(1.75rem, 2.3vw, 2.8rem);
    line-height: 1;
    letter-spacing: -0.045em;
}

.panel-header p {
    margin: 9px 0 0;
    color: var(--muted);
}

.close-panel {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border: 1px solid var(--taupe);
    border-radius: 12px;
    background: var(--white);
    cursor: pointer;
    font-size: 27px;
    line-height: 1;
}

.close-panel:hover {
    background: var(--sand);
}

.panel-tabs {
    display: flex;
    gap: 8px;
    padding: 14px 34px;
    border-bottom: 1px solid var(--taupe);
    background: var(--sand);
}

.tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 13px;
    border: 1px solid transparent;
    border-radius: 11px;
    background: transparent;
    cursor: pointer;
    font-weight: 700;
}

.tab span {
    min-width: 22px;
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(201, 181, 156, 0.35);
    font-size: 0.72rem;
}

.tab.is-active {
    border-color: var(--taupe);
    background: var(--paper);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 26px 34px 42px;
}

.tab-content {
    display: none;
}

.tab-content.is-active {
    display: block;
}

.content-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.content-grid-text {
    gap: 16px;
}

.media-card {
    overflow: hidden;
    border: 1px solid var(--taupe);
    border-radius: 16px;
    background: var(--white);
}

.media-thumb {
    position: relative;
    aspect-ratio: 16 / 9;
    display: grid;
    place-items: center;
    background:
            radial-gradient(circle at 75% 25%, rgba(249, 248, 246, 0.9), transparent 26%),
            linear-gradient(135deg, var(--camel), var(--taupe) 58%, var(--sand));
}

.media-thumb.photo-thumb {
    aspect-ratio: 4 / 3;
}

.media-icon {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(249, 248, 246, 0.92);
    box-shadow: 0 10px 25px rgba(62, 51, 40, 0.13);
    font-size: 20px;
}

.card-body {
    padding: 15px;
}

.card-kicker {
    margin-bottom: 6px;
    color: #8a745d;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.card-body h3 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.35;
}

.card-body p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.5;
}

.post-list {
    display: grid;
    gap: 14px;
}

.post-card {
    padding: 18px;
    border: 1px solid var(--taupe);
    border-radius: 16px;
    background: var(--white);
}

.post-card header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 11px;
}

.post-card strong {
    font-size: 0.93rem;
}

.post-card time {
    color: var(--muted);
    font-size: 0.74rem;
}

.post-card p {
    margin: 0;
    color: #514a44;
    line-height: 1.6;
}

.empty-state {
    padding: 38px 24px;
    border: 1px dashed var(--camel);
    border-radius: 16px;
    background: var(--sand);
    text-align: center;
}

.empty-state strong {
    display: block;
    margin-bottom: 8px;
}

.empty-state p {
    max-width: 460px;
    margin: 0 auto;
    color: var(--muted);
    line-height: 1.6;
}

.panel-backdrop {
    position: fixed;
    z-index: 1400;
    inset: var(--topbar-height) 0 0 0;
    display: block;
    opacity: 0;
    border: 0;
    background: rgba(46, 41, 37, 0.14);
    pointer-events: none;
    transition: opacity 250ms ease;
}

.panel-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.loading-error {
    position: absolute;
    z-index: 900;
    top: 50%;
    left: 50%;
    width: min(560px, calc(100% - 40px));
    transform: translate(-50%, -50%);
    padding: 22px;
    border: 1px solid var(--taupe);
    border-radius: 16px;
    background: var(--paper);
    box-shadow: var(--shadow);
    text-align: center;
}

.loading-error code {
    padding: 2px 6px;
    border-radius: 5px;
    background: var(--sand);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

#closePanel {
    position: relative;
}
#closePanel::after {
    position: absolute;
    content: "x";
    transform: translate(0, -15%);
}

.custom-gallery-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.custom-gallery-lightbox.is-open {
    display: flex;
}

.custom-gallery-image-wrap {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
}

.custom-gallery-image {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    transform-origin: center center;
    transition: transform 0.15s ease;
    cursor: zoom-in;
}

.custom-gallery-close {
    position: absolute;
    top: 20px;
    right: 25px;
    z-index: 10;

    background: transparent;
    border: 0;
    color: white;
    font-size: 42px;
    cursor: pointer;
}

.custom-gallery-toolbar {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;

    display: flex;
    gap: 8px;
}

.custom-gallery-toolbar button {
    background: rgba(255, 255, 255, 0.95);
    border: 0;
    border-radius: 6px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 16px;
}

@media (max-width: 900px) {
    :root {
        --topbar-height: 70px;
    }

    .topbar {
        gap: 12px;
        padding: 10px 14px;
    }

    .brand-copy small {
        display: none;
    }

    .brand-copy strong {
        font-size: 0.9rem;
    }

    .brand-mark {
        width: 44px;
        height: 44px;
        border-radius: 12px;
    }

    .search-wrap {
        width: min(420px, 58vw);
    }

    .details-panel {
        width: min(100vw, 640px);
        min-width: 0;
    }

    .panel-header,
    .panel-content {
        padding-left: 22px;
        padding-right: 22px;
    }

    .panel-tabs {
        padding-left: 22px;
        padding-right: 22px;
        overflow-x: auto;
    }
}

@media (max-width: 620px) {
    .brand-copy {
        display: none;
    }

    .search-wrap {
        flex: 1;
        width: auto;
    }

    .search-box {
        height: 44px;
    }

    .details-panel {
        width: 100vw;
    }

    .content-grid {
        grid-template-columns: 1fr;
    }

    .map-hint {
        right: 14px;
        left: 14px;
        bottom: 18px;
        justify-content: center;
    }
}
