/* Import Lato font */
@import url('https://fonts.googleapis.com/css2?family=Lato:wght@300;400;700&display=swap');

/* CSS Variables for color palette */
:root {
    --primary-green: #G6B827;
    --primary-orange: #F87D08;
    --secondary-green: #8DBA30;
    --dark-green: #617B47;
    --light-green: #ABBA6A;
    
    /* Balanced light/dark theme colors */
    --bg-primary: #f5f5f0;
    --bg-secondary: #e8e8e0;
    --text-primary: #2c2c2c;
    --text-secondary: #4a4a4a;
    --accent: var(--primary-orange);
    --border-color: #d0d0c8;
}

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

body {
    font-family: 'Lato', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    margin: 0;
    padding: 0;
}

a {
    color: var(--accent);
    text-decoration: none;
}

/* Header Styles */
header {
    background-color: var(--bg-secondary);
    border-bottom: 2px solid var(--border-color);
    padding: 1rem 0;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    position: relative;
}

.logo {
    flex: 1;
}

.logo a {
    display: inline-block;
    color: var(--accent);
}

.logo-img {
    height: 60px;
    width: auto;
    margin: -10px 0;
    transition: opacity 0.3s ease;
}

.logo a:hover .logo-img {
    opacity: 0.8;
}

.pulse-nav {
    margin-right: 1rem;
}

.pulse-link {
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1rem;
    text-decoration: none;
}

/* Hamburger Menu */
.hamburger {
    display: flex;
    flex-direction: column;
    cursor: pointer;
    padding: 5px;
}

.hamburger span {
    width: 25px;
    height: 3px;
    background-color: var(--text-primary);
    margin: 3px 0;
    transition: 0.3s;
}

.hamburger:hover span {
    background-color: var(--accent);
}

.nav-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: none;
    min-width: 150px;
    z-index: 1000;
}

.nav-dropdown.active {
    display: block;
}

.nav-dropdown ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-dropdown li {
    padding: 0;
}

.nav-dropdown-sep {
    height: 1px;
    margin: 0.5rem 0;
    background: var(--border-color);
    list-style: none;
}

.nav-dropdown a {
    display: block;
    padding: 12px 20px;
    color: var(--text-secondary);
    font-weight: 400;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.nav-dropdown a:hover,
.nav-dropdown a.active {
    background-color: var(--bg-primary);
    color: var(--accent);
}

/* Pulse Header */
#pulse-header {
    position: relative;
    text-align: center;
    padding: 3.5rem 2rem;
    margin-bottom: 2rem;
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 12%, var(--bg-primary)) 0%, var(--bg-secondary) 40%, var(--bg-secondary) 60%, color-mix(in srgb, var(--accent) 8%, var(--bg-primary)) 100%);
    border-radius: 0;
    overflow: hidden;
}

#pulse-header::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    opacity: 0.035;
    pointer-events: none;
}

.pulse-hero-accent {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, transparent 10%, var(--accent) 50%, transparent 90%);
    opacity: 0.7;
}

#pulse-header h1 {
    position: relative;
    z-index: 1;
    font-size: 3.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.75rem;
}

.pulse-hero-tagline {
    position: relative;
    z-index: 1;
    font-size: 1.15rem;
    color: var(--text-secondary);
    margin: 0 0 1.25rem;
}

.refresh-info {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.refresh-note {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.last-updated {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.pulse-cta-card {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 4rem;
    background: linear-gradient(to right, color-mix(in srgb, var(--accent) 8%, transparent) 0%, var(--bg-secondary) 15%);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent);
    color: var(--text-primary);
    padding: 1.25rem 2rem;
    border-radius: 12px;
    min-height: 0;
}

.pulse-cta-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.pulse-cta-line1 {
    margin: 0 0 0.25rem;
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.pulse-cta-line2 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.pulse-cta-image {
    display: flex;
    align-items: center;
    justify-content: center;
}

.pulse-cta-logo {
    max-height: 88px;
    width: auto;
    object-fit: contain;
}

@media (max-width: 500px) {
    .pulse-cta-card {
        flex-direction: column;
    }
    
    .pulse-cta-logo {
        max-height: 64px;
    }
}

.pulse-cta-card a {
    color: var(--accent);
    font-weight: 800;
    text-decoration: none;
}

.pulse-cta-card a:hover {
    color: color-mix(in srgb, var(--accent) 75%, #000);
}

.sources-btn {
    margin-bottom: 1rem;
    padding: 10px 24px;
    background: var(--primary-orange);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 25%, transparent);
}
.sources-btn:hover {
    opacity: 0.95;
    transform: translateY(-2px);
    box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent);
}

/* Sources Modal */
.sources-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}
.sources-modal[aria-hidden="false"] {
    opacity: 1;
    visibility: visible;
}
.sources-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}
.sources-modal-content {
    position: relative;
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    max-width: 440px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 1.5rem 1.75rem;
}
.sources-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.sources-modal-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}
.sources-modal-close {
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    border: none;
    font-size: 1.75rem;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
}
.sources-modal-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}
.sources-modal-intro {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
    line-height: 1.5;
}
.sources-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.sources-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}
.sources-list li:last-child {
    border-bottom: none;
}
.sources-list a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}
.sources-list a:hover {
    color: var(--dark-green);
    text-decoration: underline;
}

.countdown {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent);
    font-family: 'Courier New', monospace;
}

/* RSS Feeds Section */
.rss-retry-banner {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 1rem;
    font-size: 0.95rem;
    color: #856404;
}
.retry-btn {
    margin-left: 10px;
    padding: 6px 14px;
    background: var(--primary-orange);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
}
.retry-btn:hover {
    opacity: 0.9;
}

#wire-feed {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem 4rem;
}

.load-more-wrap {
    text-align: center;
    margin-top: 2rem;
    padding: 1rem 0;
}
.load-more-btn {
    padding: 12px 28px;
    background: var(--primary-orange);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
}
.load-more-btn:hover {
    opacity: 0.92;
    transform: translateY(-1px);
}

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

/* Large article - removed vertical spanning, now same as small */
.wire-item.large {
    display: flex;
    flex-direction: column;
    background-color: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.wire-item.large:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

/* Medium articles - removed vertical spanning, now same as small */
.wire-item.medium {
    display: flex;
    flex-direction: column;
    background-color: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.wire-item.medium:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

/* Small articles - spans 1 column, 1 row */
.wire-item.small {
    display: flex;
    flex-direction: column;
    background-color: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.wire-item.small:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.wire-image {
    overflow: hidden;
}

.wire-item.large .wire-image {
    height: 150px;
}

.wire-item.medium .wire-image {
    height: 150px;
}

.wire-item.small .wire-image {
    height: 150px;
}

.wire-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.wire-item:hover .wire-image img {
    transform: scale(1.05);
}

.wire-content {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}


.wire-source {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.source-name {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.85rem;
}

.source-time {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-style: italic;
}

.wire-item h3 {
    margin-bottom: 1rem;
    line-height: 1.2;
}

.wire-item.large h3 {
    font-size: 1rem;
}

.wire-item.medium h3 {
    font-size: 1rem;
}

.wire-item.small h3 {
    font-size: 1rem;
}

.wire-item h3 a {
    color: var(--dark-green);
    font-weight: 700;
    text-decoration: none;
    transition: color 0.3s ease;
}

.wire-item h3 a:hover {
    color: var(--accent);
}

.wire-item p {
    color: var(--text-secondary);
    line-height: 1.4;
    font-size: 0.9rem;
}

.wire-item.large p {
    font-size: 0.9rem;
}

.wire-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}
.wire-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.wire-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
}
.wire-save.saved {
    color: var(--accent);
}

/* Back to Top FAB */
.pulse-fab-back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background-color: var(--primary-orange);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(248, 125, 8, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease, box-shadow 0.2s ease;
    z-index: 1000;
}

.pulse-fab-back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.pulse-fab-back-to-top:hover {
    background-color: #e67300;
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(248, 125, 8, 0.5);
}

.pulse-fab-back-to-top.visible:hover {
    transform: translateY(-2px);
}

/* Responsive Design */
@media (max-width: 768px) {
    .wire-grid {
        grid-template-columns: 1fr;
    }
    
    .wire-item.large {
        /* No special styling needed - same as small */
    }
    
    .wire-item.large .wire-image {
        height: 150px;
    }
}

/* Loading and Fallback Styles */
.loading-container {
    text-align: center;
    padding: 4rem;
    background-color: var(--bg-secondary);
    border-radius: 12px;
    margin: 2rem 0;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.loading-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.loading {
    text-align: center;
    padding: 4rem;
    font-size: 1.2rem;
    color: var(--text-secondary);
    background-color: var(--bg-secondary);
    border-radius: 12px;
    margin: 2rem 0;
}

.fallback-message {
    text-align: center;
    padding: 4rem;
    background-color: var(--bg-secondary);
    border-radius: 12px;
    margin: 2rem 0;
}

.fallback-message h3 {
    color: var(--dark-green);
    margin-bottom: 1rem;
}

.fallback-message p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.retry-button {
    background-color: var(--accent);
    color: white;
    border: none;
    padding: 0.8rem 2rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.retry-button:hover {
    background-color: var(--primary-orange);
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
}

/* Responsive Design */
@media (max-width: 768px) {
    .market-grid {
        grid-template-columns: 1fr;
    }
    
    .permit-stats {
        flex-direction: column;
        gap: 1rem;
    }
    
    #pulse-hero .hero-content h1 {
        font-size: 3rem;
    }
    
    section {
        padding: 2rem 1rem;
    }
}
