/* Shared styles for all district race pages */

.race-detail {
    max-width: 900px;
    margin: 0 auto;
}

.district-map {
    width: 100%;
    height: 300px;
    margin: 2rem 0;
    background-color: white;
    border-radius: 50px;
    padding: 1.5rem;
    overflow: hidden;
    box-shadow: 0px 0px 5px 1px rgba(35, 49, 102, 0.4);
}

.info-section {
    margin: 2rem 0;
    padding: 1rem;
}

.info-section:first-of-type {
    margin-top: 1rem !important;
}

.ap-result-section {
    padding: 1rem;
    overflow: hidden;
    background-color: white;
}

.ap-result-section iframe {
    display: block;
    width: 100%;
    border: none;
}

.info-section h2 {
    border-bottom: 2px solid #233166;
    padding-bottom: 0.5rem;
    padding-top: 0.5rem;
    margin-top: 0;
}

.candidates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.candidate-card {
    background-color: #D5E2EE;
    box-shadow: 0px 0px 5px 1px rgba(35, 49, 102, 0.6);
    border-radius: 50px;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
    display: grid;
    grid-template-areas: "stack";
    position: relative;
    overflow: hidden;
    cursor: pointer;
    aspect-ratio: 3/4;
}

.info-section .candidate-card-link {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: block;
    border-radius: inherit;
}

.info-section .candidate-card-link:focus-visible {
    outline: 3px solid #3090c9;
    outline-offset: 3px;
}

.candidate-card:hover {
    transform: translateY(-7px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    border-color: #000;
}

.candidate-card:hover .candidate-info {
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(100px);
    -webkit-backdrop-filter: blur(100px);
}

.candidate-card:hover .candidate-icon img {
	transform: rotate(360deg);
}

.candidate-icon {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 3;
    width: 2.5rem;
    height: 2.5rem;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.candidate-icon img {
    width: 1.5rem;
    height: 1.5rem;
    filter: invert(48%) sepia(79%) saturate(1234%) hue-rotate(166deg) brightness(93%) contrast(93%);
    transition: transform 0.5s ease;
}

.candidate-card:hover .candidate-icon {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.candidate-photo {
    width: 100%;
    height: 100%;
    border-radius: 50px;
    object-fit: cover;
    grid-area: stack;
}

.candidate-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: #999;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    grid-area: stack;
}

.candidate-info {
    padding-bottom: 1rem;
    z-index: 2;
    grid-area: stack;
    padding-top: 60%;
    padding-left: 2rem;
    padding-right: 2rem;
    align-self: end;
    background: rgba(#F3F6FA, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom-left-radius: 48px;
    border-bottom-right-radius: 48px;
    transition: all 0.3s ease;
    mask: linear-gradient(0deg, black 30%, transparent 66%);
    -webkit-mask: linear-gradient(0deg, black 30%, transparent 66%);
}

.candidate-info p,.candidate-info h1, .candidate-info h2, .candidate-info h3, .candidate-info h4 {
    color: #f5f7fa !important;
    -webkit-text-stroke: 2px rgba(35, 49, 102, 0.8);
    paint-order: stroke fill;
}

.candidate-name {
    font-size: 1.5rem;
    font-weight: bolder;
    margin-bottom: 0;
    margin-top: 0
}

.candidate-incumbent {
    font-family: 'Heebo', sans-serif;
    font-weight: 600;
    margin-bottom: 0;
    margin-top: 0;
}

.candidate-party {
    font-family: 'Heebo', sans-serif;
    margin: 0;
    font-weight: 600;
}

.candidate-occupation {
    color: #555;
    font-size: 0.95rem;
    margin-top: 0.5rem;
}

.info-grid {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 1rem;
    margin: 1rem 0;
}

.info-label {
    font-weight: bold;
    color: #555;
}

.info-value {
    color: #333;
}

.error-message {
    text-align: center;
    padding: 2rem;
    color: red;
}

.loading-message {
    text-align: center;
    padding: 2rem;
}

.stories-list {
    margin-top: 1rem;
}

.story-item {
    padding: 1rem 0;
    border-bottom: 1px solid #e0e0e0;
    display: grid;
    grid-auto-flow: column;
    justify-items: start;
    transition: all 0.2s ease;

}

.story-item:hover {
    background-color: rgba(234, 241, 247, 0.8);
    border-radius: 8px;
}

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

.story-headline, .story-meta > a.story-headline {
    display: block;
    font-size: 0.9rem;
    font-weight: 700;
    color: #233166 !important;
    text-decoration: none;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
}

.story-headline:hover {
    color: #005a87;
    text-decoration: underline;
}

.story-cover-img {
    width: 100%;
    max-width: 650px;
    height: auto;
    margin: 0;
    display: block;
}

.story-data {
    display: flex;
    flex-direction: row;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.story-byline {
    font-size: 0.8rem;
    font-family: 'Heebo', sans-serif;
    color: #515151;
}

.story-featured-img {
    width: 60%;
}

.story-publisher {
    font-size: 0.8rem;
    font-family: 'Heebo', sans-serif;
    color: #515151;
}

.funds-raised-list {
    display: grid;
    gap: 0.85rem;
    margin-top: 1rem;
    padding-bottom: 0.5rem;
}

.funds-raised-row {
    display: grid;
    grid-template-columns: minmax(170px, 220px) 1fr;
    align-items: center;
    gap: 0.9rem;
}

.funds-raised-name {
    font-family: "Publico Roman", "Georgia", "serif";
    font-weight: 700;
    color: #233166;
    line-height: 1.25;
    border-right: 2px solid #D5E2EE;
}

.funds-raised-bar-track {
    position: relative;
    width: 100%;
    background: #F3F6FA;
    border-radius: 12px;
    min-height: 2.1rem;
    display: flex;
    align-items: stretch;
    overflow: hidden;
    box-shadow: inset 5px 5px 5px 0px rgba(35, 49, 102, 0.1);
}

.funds-raised-bar {
    min-height: 2.1rem;
    position: relative;
    display: flex;
    align-items: center;
    overflow: hidden;
    padding: 0;
    white-space: nowrap;
    color: #ffffff;
    font-weight: 700;
    font-size: 0.88rem;
    transition: width 250ms ease;
}

.funds-raised-bar-fill {
    position: absolute;
    inset: 0;
    box-shadow: inset 5px 5px 5px 0px rgba(35, 49, 102, 0.1);
    transform-origin: left center;
    transform: scaleX(1);
}

.funds-raised-list.in-view .funds-raised-bar-fill {
    animation: funds-raised-grow 0.5s ease-out both;
}

.funds-raised-bar.with-inside-label {
    padding: 0 0.7rem;
}

.funds-raised-amount {
    position: relative;
    z-index: 1;
    font-family: 'Heebo', sans-serif;
}

.funds-raised-amount-outside {
    position: absolute;
    font-weight: 700;
    right: 0.7rem;
    font-size: 0.88rem;
    top: 50%;
    transform: translateY(-50%);
    color: #233166;
}

.funds-raised-bar.party-democrat .funds-raised-bar-fill {
    background: #003cb9;
}

.funds-raised-bar.party-republican .funds-raised-bar-fill {
    background: #e9141e;
}

.funds-raised-bar.party-independent .funds-raised-bar-fill {
    background: #e69f00;
}

.funds-raised-bar.party-other .funds-raised-bar-fill {
    background: #515151;
}

.top-donors-list {
    display: grid;
    gap: 0.85rem;
    margin-top: 1rem;
    padding-bottom: 0.5rem;
}

.top-donors-row {
    display: grid;
    grid-template-columns: minmax(220px, 280px) 1fr;
    align-items: center;
    gap: 0.9rem;
}

.top-donors-name-group {
    padding-right: 0.8rem;
    border-right: 2px solid #D5E2EE;
}

.top-donors-name {
    font-family: "Publico Roman", "Georgia", "serif";
    font-weight: 700;
    color: #233166;
    line-height: 1.25;
}

.top-donors-count {
    font-size: 0.78rem;
    color: #515151;
    margin-top: 0.25rem;
    font-family: 'Heebo', sans-serif;
}

.top-donors-bar-track {
    position: relative;
    width: 100%;
    background: #F3F6FA;
    border-radius: 12px;
    min-height: 2.1rem;
    display: flex;
    align-items: stretch;
    overflow: hidden;
    box-shadow: inset 5px 5px 5px 0px rgba(35, 49, 102, 0.1);
}

.top-donors-bar {
    min-height: 2.1rem;
    position: relative;
    display: flex;
    align-items: center;
    overflow: hidden;
    padding: 0;
    white-space: nowrap;
    color: #ffffff;
    font-weight: 700;
    font-size: 0.88rem;
    transition: width 250ms ease;
}

.top-donors-bar-fill {
    position: absolute;
    inset: 0;
    box-shadow: inset 5px 5px 5px 0px rgba(35, 49, 102, 0.1);
    transform-origin: left center;
    transform: scaleX(1);
    background: #7CA982;
}

.top-donors-list.in-view .top-donors-bar-fill {
    animation: funds-raised-grow 0.5s ease-out both;
}

.top-donors-bar.with-inside-label {
    padding: 0 0.7rem;
}

.top-donors-amount {
    position: relative;
    z-index: 1;
    font-family: 'Heebo', sans-serif;
}

.top-donors-amount-outside {
    position: absolute;
    font-weight: 700;
    right: 0.7rem;
    font-size: 0.88rem;
    top: 50%;
    transform: translateY(-50%);
    color: #233166;
}

.top-donors-note-icon {
    width: 1.05rem;
    height: 1.05rem;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #ffffff;
    background: #233166;
    flex: 0 0 auto;
}

.top-donors-note a {
    color: #233166;
    text-decoration: underline;
}

.top-donors-note a:hover {
    color: #005a87;
}

@keyframes funds-raised-grow {
    from {
        transform: scaleX(0);
    }
    to {
        transform: scaleX(1);
    }
}

@media (prefers-reduced-motion: reduce) {
    .funds-raised-list.in-view .funds-raised-bar-fill {
        animation: none;
    }

    .funds-raised-bar-fill {
        transform: none;
    }

    .top-donors-list.in-view .top-donors-bar-fill {
        animation: none;
    }

    .top-donors-bar-fill {
        transform: none;
    }
}

 .story-data a {
    font-family: 'Publico Banner', sans-serif;
 }

@media (min-width: 770px) {
    .candidate-card:only-child {
        max-width: 50%;
    }
}

@media (max-width: 769px) {
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    .candidates-grid {
        grid-template-columns: 1fr;
    }
    .race-detail {
        padding: 0;
    }

    .story-data {
        flex-direction: column-reverse;
        margin-right: 0;
    }

    .story-item {
        grid-auto-flow: row;
    } 

    .story-cover-img {
        margin: 0.75rem 0;
    }

    .story-featured-img {
        width: 100%;
    }

    .funds-raised-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        border-bottom: 1px solid #D5E2EE;
        padding-bottom: 0.5rem;
    }

    .top-donors-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        border-bottom: 1px solid #D5E2EE;
        padding-bottom: 0.5rem;
    }

    .top-donors-name-group {
        border-right: none;
        padding-right: 0;
    }


}
