/* ==========================================
   Google Fonts
========================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');


/* ==========================================
   CSS Variables
========================================== */

:root {

    --primary: #0F766E;
    --primary-dark: #115E59;

    --secondary: #F8FAFC;

    --background: #F5F7FA;

    --white: #FFFFFF;

    --text: #1F2937;

    --text-light: #6B7280;

    --border: #E5E7EB;

    --shadow: 0 10px 30px rgba(0,0,0,.08);

    --radius: 16px;

    --transition: .3s ease;

    --max-width: 1280px;

}


/* ==========================================
   Reset
========================================== */

*{
    margin:0;
    padding:0;
    box-sizing:border-box;
}

html{
    scroll-behavior:smooth;
}

body{
    font-family: 'Poppins', sans-serif;
    margin:0;
    color:#1F2937;

    background:
        radial-gradient(circle at top left,
            rgba(15,118,110,0.10),
            transparent 70%),

        radial-gradient(circle at top right,
            rgba(16,185,129,0.08),
            transparent 70%),

        linear-gradient(
            180deg,
            #F8FAFC 0%,
            #F1F5F9 100%
        );

    position:relative;
    min-height:100vh;
}



/* ==========================================
   Common
========================================== */

img{
    max-width:100%;
    display:block;
}

a{
    text-decoration:none;
}

ul{
    list-style:none;
}

button,
input,
select{

    font-family:inherit;
}


/* ==========================================
   Container
========================================== */

.container{

    width:min(92%, var(--max-width));

    margin:auto;
}


/* ==========================================
   Main Layout
========================================== */

main{

    display:flex;

    flex-direction:column;

    gap:5rem;

    padding-bottom:5rem;
}


/* ==========================================
   Hero
========================================== */

.hero{

    min-height:55vh;

    display:flex;

    justify-content:center;

    align-items:center;

    text-align:center;

    padding:4rem 1rem;
}

.hero-content{

    max-width:850px;
}

.hero h2{

    font-size:3rem;

    font-weight:800;

    margin-bottom:1rem;

    color:var(--text);
}

.hero p{

    font-size:1.15rem;

    color:var(--text-light);
}

.search-heading{
    text-align:center;
    margin:8px 0 20px;
}

.search-heading h2{
    font-size:1.8rem;
    font-weight:700;
    color:#1F2937;
    margin-bottom:8px;
}

.search-heading p{
    font-size:1rem;
    color:#6B7280;
}

/* ==========================================
   Search
========================================== */

.search-section{

    display:flex;

    justify-content:center;

    margin-top: 1%;
}

.search-section input{

    width:min(1000px,95%);

    padding:1rem 1.2rem;

    border:1px solid var(--border);

    border-radius:var(--radius);

    outline:none;

    font-size:1rem;

    background:white;

    transition:var(--transition);
}

.search-section input:focus{

    border-color:var(--primary);

    box-shadow:0 0 0 4px rgba(15,118,110,.12);
}

.search-wrapper{

    position:relative;

    width:100%;

    max-width:800px;

    margin:0 auto;

}

.search-suggestions{

    position:absolute;

    top:100%;

    left:0;

    right:0;

    background:#fff;

    border:1px solid #E5E7EB;

    border-top:none;

    border-radius:0 0 14px 14px;

    box-shadow:0 8px 24px rgba(0,0,0,.08);

    display:none;

    max-height:300px;

    overflow-y:auto;

    z-index:999;

}

.search-item{
    display:flex;
    align-items:center;
    gap:12px;
    padding:10px 16px;
    cursor:pointer;
    transition:.2s;
}

.search-item:hover{
    background:#F8FAFC;
    transform:translateX(6px);
}

.search-item:hover::after{
    opacity:1;
    transform:translateX(0);
}

.search-item {
    display: flex;
    align-items: center;
    gap: 12px;

    padding: 11px 16px;

    cursor: pointer;
    border-bottom: 1px solid #F3F4F6;

    transition: background .2s ease, transform .2s ease;
}

.search-item:last-child {
    border-bottom: none;
}

.search-item:hover {
    background: #F8FAFC;
    transform: translateX(4px);
}

.search-item > div {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

/* Politician name */
.search-item strong {
    display: block;

    font-size: 15px;
    font-weight: 600;
    line-height: 1.25;

    color: #111827;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* District • Constituency */
.search-meta {
    display: block;

    margin-top: 6px !important;

    font-size: 11.5px;
    font-weight: 400;
    line-height: 1.25;

    color: #6B7280;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Arrow */
.search-item::after {
    content: "→";

    margin-left: auto;

    font-size: 17px;
    color: #0F766E;

    opacity: 0;
    transform: translateX(-6px);

    transition: all .2s ease;
}

.search-item:hover::after {
    opacity: 1;
    transform: translateX(0);
}

/* Profile image */
.search-avatar {
    width: 38px;
    height: 38px;

    flex-shrink: 0;

    border-radius: 50%;
    object-fit: cover;
}

.search-avatar{
    width:36px;
    height:36px;
    border-radius:50%;
    object-fit:cover;
    flex-shrink:0;
}

.search-item > div{
    display:flex;
    flex-direction:column;
    justify-content:center;
    min-width:0;
}

.search-item strong{
    font-size:15px;
    font-weight:600;
    color:#111827;
    line-height:1.2;
}

.search-meta{
    font-size:13px;
    color:#6B7280;
    margin-top:2px;
}


/* ==========================================
   Filters & Sorting
========================================== */

.filter-section,
.sort-section{

    display:flex;

    justify-content:center;

    gap:2rem;

    flex-wrap:wrap;
}

.filter-section select,
.sort-section select{

    padding:.8rem 3rem;

    border-radius:12px;

    border:1px solid var(--border);

    background:white;

    cursor:pointer;
}


/* ==========================================
   Statistics
========================================== */

.stats-section{
    width:min(92%,700px);
    margin:auto;

    display:grid;
    grid-template-columns:repeat(2,1fr);
    gap:1.2rem;
}

.stat-card{
    background:#fff;
    padding:1.5rem;
    border-radius:16px;
    box-shadow:0 8px 24px rgba(0,0,0,.08);
    text-align:center;
    border:1px solid #E5E7EB;
    transition:.25s ease;
}

.stat-card:hover{
    transform:translateY(-4px);
    border-color:#0F766E;
    box-shadow:0 12px 30px rgba(15,118,110,.12);
}

.stat-card h3{

    font-size:2.5rem;

    color:var(--primary);
}

.stat-card p{

    color:var(--text-light);

    margin-top:.5rem;
}


/* ==========================================
   Politicians Section
========================================== */

#politicians{

    width:min(92%, var(--max-width));

    margin:auto;
}


/* ==========================================
   Empty State
========================================== */

#emptyState{

    text-align:center;

    padding:5rem 1rem;
}

#emptyState h2{

    margin-bottom:1rem;
}

#emptyState p{

    color:var(--text-light);
}


/* ==========================================
   Back To Top
========================================== */

#backToTop{

    position:fixed;

    bottom:25px;

    right:25px;

    width:50px;

    height:50px;

    border:none;

    border-radius:50%;

    background:var(--primary);

    color:white;

    font-size:1.2rem;

    cursor:pointer;

    box-shadow:var(--shadow);

    transition:var(--transition);

    display:none;
}

#backToTop:hover{

    background:var(--primary-dark);

    transform:translateY(-4px);
}


/* ==========================================
   Footer
========================================== */

footer{

    background:white;

    text-align:center;

    padding:2rem;

    border-top:1px solid var(--border);

    color:var(--text-light);
}


/* ==========================================
   Utility Classes
========================================== */

.hidden{

    display:none !important;
}

.text-center{

    text-align:center;
}

.mt-2{

    margin-top:2rem;
}

.mb-2{

    margin-bottom:2rem;
}

/* ==========================================
   Controls Container
========================================== */

.controls {

    width: min(92%, var(--max-width));

    margin: 2rem auto;

    display: flex;

    flex-wrap: wrap;

    gap: 1rem;

    align-items: center;

    justify-content: center;

}


/* ==========================================
   Search
========================================== */

.search-input {

    flex: 1;

    min-width: 280px;

    height: 52px;

    padding: 0 1rem;

    border: 1px solid #d1d5db;

    border-radius: 12px;

    background: #fff;

    font-size: 1rem;

    transition: .3s;
}

.search-input:focus {

    outline: none;

    border-color: var(--primary);

    box-shadow: 0 0 0 4px rgba(15,118,110,.12);

}

.search-input{
    transition: opacity .35s ease;
}

.search-input.placeholder-fade{
    opacity:.55;
}

/* ==========================================
   Dropdowns
========================================== */

.controls select {

    height: 52px;

    min-width: 170px;

    padding: 0 1rem;

    border: 1px solid #d1d5db;

    border-radius: 12px;

    background: #fff;

    font-size: .95rem;

    cursor: pointer;

    transition: .3s;
}

.controls select:hover {

    border-color: var(--primary);

}

.controls select:focus {

    outline: none;

    border-color: var(--primary);

    box-shadow: 0 0 0 4px rgba(15,118,110,.12);

}


/* ==========================================
   Buttons
========================================== */

.controls button {

    height: 52px;

    padding: 0 1.5rem;

    border: none;

    border-radius: 12px;

    background: var(--primary);

    color: white;

    font-size: .95rem;

    font-weight: 600;

    cursor: pointer;

    transition: .3s;

    white-space: nowrap;
}

.controls button:hover {

    transform: translateY(-2px);

    filter: brightness(.95);

    box-shadow: 0 10px 20px rgba(15,118,110,.18);

}

.controls button:active {

    transform: translateY(0);

}

body{

    font-family:'Poppins',sans-serif;

}

.mobile-filter-btn{
    display:none;
}

.menu-toggle{
    display:none;
}

.mobile-actions{
    display:flex;
    align-items:center;
    gap:10px;
}

.stats-btn{
    display:none;
}

/* ==========================================
   District Rankings
========================================== */

.rankings-page {
    width: min(92%, var(--max-width));
    margin: 40px auto;
}

.rankings-page > h1 {
    color: var(--primary);
    font-size: 2rem;
    margin-bottom: 8px;
}

.rankings-page > p {
    color: var(--text-light);
    margin-bottom: 30px;
}

.ranking-section {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 24px;
    margin-bottom: 28px;
    box-shadow: var(--shadow);
}

.ranking-section h2 {
    color: var(--text);
    font-size: 1.25rem;
    margin-bottom: 18px;
}

.district-ranking-card {
    display: grid;
    grid-template-columns: 55px 1fr auto;
    align-items: center;
    gap: 16px;

    padding: 14px 16px;
    margin-bottom: 8px;

    background: #f8fafc;
    border: 1px solid #eef2f2;
    border-radius: 12px;

    transition: var(--transition);
}

.district-ranking-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
}

.district-rank {
    font-weight: 800;
    color: var(--primary);
}

.district-name {
    font-weight: 600;
    color: var(--text);
}

.district-score {
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

.district-ranking-card:nth-child(1) {
    border-left: 4px solid var(--primary);
}

.district-ranking-card:nth-child(2) {
    border-left: 4px solid #7aa7a2;
}

.district-ranking-card:nth-child(3) {
    border-left: 4px solid #a8c4c0;
}

/* ==========================================
   District Ranking Story Cards
========================================== */

.ranking-story-cards {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 30px;
}

.ranking-story-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 22px;

    cursor: pointer;

    box-shadow: var(--shadow);

    transition:
        transform 0.25s ease,
        box-shadow 0.25s ease,
        border-color 0.25s ease;
}

.ranking-story-card:hover {
    transform: translateY(-3px);
    border-color: var(--primary);
}

.ranking-story-card.expanded {
    cursor: default;
    transform: none;
    border-color: var(--primary);
    position: relative;
}

.ranking-story-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 8px;
}

.ranking-story-description {
    color: var(--text-light);
    font-size: 0.9rem;
    line-height: 1.5;
}

.ranking-story-content {
    display: none;
    margin-top: 22px;
}

.ranking-story-card.expanded .ranking-story-content {
    display: block;
}

/* Ranking rows */

.ranking-story-content .district-ranking-card {
    display: grid;
    grid-template-columns: 55px 1fr auto;
    align-items: center;
    gap: 16px;

    padding: 14px 16px;
    margin-bottom: 8px;

    background: #f8fafc;
    border: 1px solid #eef2f2;
    border-radius: 12px;

    transition: var(--transition);
}

.ranking-story-content .district-ranking-card:hover {
    border-color: var(--primary);
}

.ranking-story-content .district-rank {
    font-weight: 800;
    color: var(--primary);
}

.ranking-story-content .district-name {
    font-weight: 600;
    color: var(--text);
}

.ranking-story-content .district-score {
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

@media (max-width: 768px) {

    .rankings-page {
        width: 94%;
        margin: 25px auto;
    }

    .rankings-page > h1 {
        font-size: 1.6rem;
    }

    .ranking-section {
        padding: 16px;
        border-radius: 14px;
    }

    .ranking-section h2 {
        font-size: 1.1rem;
    }

    .district-ranking-card {
        grid-template-columns: 40px 1fr auto;
        gap: 10px;
        padding: 12px;
    }

    .district-name {
        font-size: 0.9rem;
    }

    .district-score {
        font-size: 0.85rem;
    }

}

@media (max-width:768px){

    .stats-btn{

        display:flex;

        align-items:center;

        gap:6px;

        padding:8px 14px;

        background:#0F766E;

        color:#fff;

        border-radius:999px;

        font-size:.85rem;

        font-weight:600;

        text-decoration:none;

        transition:.25s ease;
    }

    .stats-btn:hover{
        background:#115E59;
    }

}


/* ==========================================
   Responsive
========================================== */

@media (max-width:768px){

    .search-heading{
        margin:0 10px 10px;
        margin-top:24px;
        margin-bottom:2px;
    }

    .search-heading h2{
        font-size:1.35rem;
    }

    .search-heading p{
        font-size:.9rem;
    }

    .menu-toggle{
        display:block;
        font-size:1.5rem;
        background:none;
        border:none;
        cursor:pointer;
        color:#222;
    }

    .nav-links{
        display:none;
    }

    .nav-links.active{
        display:flex;
        position:absolute;
        top:70px;
        left:0;
        width:100%;
        background:#fff;
        flex-direction:column;
        padding:20px;
        box-shadow:0 8px 20px rgba(0,0,0,.1);
    }

    .controls{
        flex-direction:column;
        align-items:stretch;
    }

    .controls input,
    .controls select,
    .controls button{
        width:100%;
    }

    /* ---------- Stats ---------- */

    .stats-section{
        display:grid;
        grid-template-columns:1fr 1fr;
        gap:12px;
        padding:0 16px;
    }

    .stat-card{
        min-width:0;
        max-width:none;
        width:100%;
        padding:1rem;
    }

    .logo{
        display:flex;
        align-items:center;
        gap:8px;
    }

    #siteName{
        display:block;
        font-size:1.15rem;
        font-weight:700;
        white-space:nowrap;
    }

}

.back-map-container{
    width:100%;
    max-width:1200px;
    margin:24px auto 0;
    padding:0 20px;
    display:flex;
    justify-content:flex-end;   /* left side */
    box-sizing:border-box;
}

#backToMapBtn{
    display:inline-flex;
    align-items:center;
    gap:8px;
    padding:10px 16px;
    background:#0F766E;
    color:#fff;
    text-decoration:none;
    border-radius:10px;
    font-weight:600;
    transition:background .2s ease;
}

#backToMapBtn:hover{
    background:#0b5d59;
}

/* ==========================================
   Splash Screen
========================================== */

#splashScreen {
    position: fixed;
    inset: 0;
    z-index: 9999;

    display: flex;
    align-items: center;
    justify-content: center;

    background: #ffffff;
}

.splash-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.splash-content img {
    width: 90px;
    height: 90px;
    object-fit: contain;
}

.splash-content h1 {
    margin: 0;
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
}

.version-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;

    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(3px);

    align-items: flex-end;
    justify-content: center;
}

.version-modal.active {
    display: flex;
}

.version-content {
    width: 100%;
    max-width: 720px;
    max-height: 88vh;

    background: #ffffff;

    border-radius: 28px 28px 0 0;

    overflow-y: auto;
    overscroll-behavior: contain;

    box-shadow: 0 -10px 35px rgba(0, 0, 0, 0.12);

    box-sizing: border-box;
}


/* Header */

.version-header {
    position: sticky;
    top: 0;
    z-index: 2;

    display: flex;
    justify-content: space-between;
    align-items: flex-start;

    padding: 30px 28px 24px;

    background: #ffffff;

    border-bottom: 1px solid #eeeeee;
}

.version-header h2 {
    margin: 0;

    color: #111111;

    font-size: 28px;
    font-weight: 750;
    letter-spacing: -0.5px;
}

.version-header p {
    margin: 6px 0 0;

    color: #8a8a8a;

    font-size: 16px;
}


/* Close button */

.version-close {
    width: 38px;
    height: 38px;

    border: none;
    background: transparent;

    color: #9ca3af;

    font-size: 32px;
    line-height: 1;

    cursor: pointer;

    display: flex;
    align-items: center;
    justify-content: center;

    transition:
        color 0.2s ease,
        transform 0.2s ease;
}

.version-close:hover {
    color: #111111;
    transform: scale(1.08);
}


/* Version */

.version-item {
    padding: 28px;

    border-bottom: 1px solid #eeeeee;
}

.version-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;

    gap: 20px;

    margin-bottom: 24px;
}

.version-title {
    display: flex;
    align-items: center;
    gap: 10px;

    color: #111111;

    font-size: 22px;
    font-weight: 750;
}


/* Green latest badge */

.latest-badge {
    display: inline-flex;
    align-items: center;

    padding: 5px 10px;

    background: #e8f7f0;
    color: #16865b;

    border-radius: 999px;

    font-size: 11px;
    font-weight: 750;
    letter-spacing: 0.5px;
}

.version-date {
    color: #b0b0b0;

    font-size: 14px;
    white-space: nowrap;
}


/* Individual changes */

.change-item {
    display: flex;
    align-items: flex-start;

    gap: 16px;

    margin-bottom: 18px;
}

.change-item:last-child {
    margin-bottom: 0;
}

.change-item p {
    margin: 0;

    color: #555b64;

    font-size: 16px;
    line-height: 1.65;
}


/* NEW / FIX badges */

.change-badge {
    flex: 0 0 auto;

    min-width: 48px;

    padding: 5px 8px;

    border-radius: 6px;

    text-align: center;

    font-size: 11px;
    font-weight: 750;
    letter-spacing: 0.5px;
}

.change-badge.new {
    background: #e8f7f0;
    color: #16865b;
}

.change-badge.fix {
    background: #eef4ff;
    color: #4778c8;
}

@media (max-width: 600px) {

    .version-content {
        width: 100%;
        max-width: none;
        max-height: 90vh;

        border-radius: 26px 26px 0 0;
    }

    .version-header {
        padding: 24px 20px 20px;
    }

    .version-header h2 {
        font-size: 22px;
    }

    .version-header p {
        font-size: 13px;
    }

    .version-item {
        padding: 24px 20px;
    }

    .version-title-row {
        align-items: flex-start;
        margin-bottom: 22px;
    }

    .version-title {
        font-size: 17px;
        flex-wrap: wrap;
    }

    .version-date {
        font-size: 11px;
        font-weight: 600;
    }

    .change-item {
        gap: 12px;
        margin-bottom: 18px;
    }

    .change-item p {
        font-size: 12px;
        line-height: 1.6;
    }

    .change-badge {
        min-width: 44px;
        padding: 4px 7px;
        font-size: 8px;
    }

    .latest-badge {
        font-size: 10px;
        padding: 4px 8px;
    }

    .version-close {
        width: 34px;
        height: 34px;
        font-size: 28px;
    }

}