/**
 * Better in New Haven - Indiana + Patriotic, Modern
 * Color palette from Indiana state flag + Old Glory
 */

:root {
    --indiana-blue: #000F5D;
    --indiana-gold: #bd4e2c;
    --patriotic-red: #B22234;
    --patriotic-white: #F8F9FA;
    --patriotic-navy: #002868;
    --text-primary: #1a1a2e;
    --text-muted: #5c5c7a;
    --radius: 10px;
    --radius-sm: 8px;
    --shadow: 0 2px 8px rgba(0, 15, 93, 0.08);
    --shadow-hover: 0 4px 16px rgba(0, 15, 93, 0.12);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

img {
    max-width: 100%;
    height: auto;
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text-primary);
    background: var(--patriotic-white);
    margin: 0;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-top: 0;
}

.main-content {
    flex: 1;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1.5rem 2rem;
    width: 100%;
}

/* Header — logo (scrolls); nav is sibling below with position:sticky */
.site-header {
    color: white;
}

.header-logo-bar {
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, var(--indiana-blue) 0%, var(--patriotic-navy) 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.header-inner {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
}

.logo {
    flex-shrink: 0;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 120px;
    overflow: hidden;
}

.logo-img {
    height: 180px;
    width: auto;
    max-width: 540px;
    display: block;
    object-fit: contain;
}

.logo:hover .logo-img {
    opacity: 0.9;
}

.main-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem 1.5rem;
    flex-wrap: wrap;
    padding: 0.65rem 1.5rem 1rem;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    position: relative;
}

.main-nav-sticky {
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.main-nav-sticky::before {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 100vw;
    top: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--indiana-blue) 0%, var(--patriotic-navy) 100%);
    z-index: -1;
}

.nav-primary,
.nav-actions {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.main-nav a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-weight: 500;
}

.main-nav a:hover {
    color: var(--indiana-gold);
}

.main-nav a.btn-nav-outline:hover {
    color: var(--indiana-gold);
}

.main-nav a.btn-primary:hover {
    color: #fff;
}

.user-name {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
}

.btn-nav {
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
}

.btn-nav-outline {
    border: 1px solid rgba(255, 255, 255, 0.5);
    background: transparent;
    color: rgba(255, 255, 255, 0.95);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}

.btn-nav-outline:hover {
    border-color: var(--indiana-gold);
    color: var(--indiana-gold);
}

.btn-primary {
    background: var(--indiana-gold);
    color: #fff;
    border: none;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s, color 0.2s;
}

.btn-primary:hover {
    background: #d55a38;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(189, 78, 44, 0.4);
}

a.btn-primary {
    color: #fff;
    text-decoration: none;
}

a.btn-primary:hover {
    color: #fff;
}

.btn-sm {
    padding: 0.4rem 1rem;
    font-size: 0.9rem;
}

.btn-secondary {
    background: var(--patriotic-navy);
    color: white;
    border: none;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
    display: inline-block;
}

.btn-secondary:hover {
    background: var(--indiana-blue);
}

.btn-secondary.btn-sm {
    padding: 0.4rem 1rem;
    font-size: 0.9rem;
}

.btn-block {
    width: 100%;
    padding: 0.75rem;
}

/* Hero */
.hero {
    position: relative;
    text-align: center;
    padding: 4rem 1.5rem;
    margin-bottom: 2rem;
    min-height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100vw;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    overflow: hidden;
}

.hero-parallax {
    background-image: url('../hero.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

@media (max-width: 768px) {
    .hero-parallax {
        background-attachment: scroll;
    }
}

.hero-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 15, 93, 0.55);
    z-index: 0;
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 600px;
}

.hero h1 {
    font-size: 2.25rem;
    font-weight: 700;
    color: white;
    margin: 0 0 0.5rem;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.hero-subtitle {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.95);
    max-width: 500px;
    margin: 0 auto;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.5rem;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Posts */
.posts-section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.posts-section h2 {
    font-size: 1.5rem;
    color: var(--indiana-blue);
    margin: 0;
}

.sort-controls {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.sort-link {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid #ddd;
    background: white;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.sort-link:hover {
    color: var(--indiana-blue);
    border-color: var(--indiana-blue);
}

.sort-link.active {
    color: white;
    background: var(--indiana-blue);
    border-color: var(--indiana-blue);
}

.cta-card {
    background: white;
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--indiana-gold);
    opacity: 0;
    transform: translateY(24px);
}

.cta-card.animated-in {
    opacity: 1;
    transform: translateY(0);
}

.cta-card-after-posts {
    margin-top: 1.5rem;
}

.cta-card-text {
    margin: 0 0 1rem;
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.55;
}

.cta-card-actions {
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.posts-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.post-card {
    display: flex;
    gap: 1.25rem;
    background: white;
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    opacity: 0;
    transform: translateY(24px);
}

.post-card.animated-in {
    opacity: 1;
    transform: translateY(0);
}

.post-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.vote-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.vote-btn {
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s, transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vote-btn:hover:not(.disabled) {
    color: var(--indiana-gold);
    transform: scale(1.15);
}

.vote-btn.active {
    color: var(--indiana-gold);
}

.vote-btn.disabled {
    cursor: default;
    opacity: 0.6;
}

.vote-btn.vote-down:hover:not(.disabled),
.vote-btn.vote-down.active {
    color: var(--patriotic-red);
}

.vote-score {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--indiana-blue);
    min-width: 1.5em;
    text-align: center;
}

.vote-score.vote-updated {
    transform: scale(1.2);
    transition: transform 0.2s;
}

.post-content {
    flex: 1;
}

.post-content h3 {
    margin: 0 0 0.5rem;
    font-size: 1.2rem;
    color: var(--text-primary);
}

.post-description {
    margin: 0 0 0.75rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.post-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.post-meta-left span + span::before {
    content: ' \u2022 ';
}

.btn-share {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.65rem;
    margin: 0;
    border: 1px solid var(--indiana-blue);
    border-radius: var(--radius-sm);
    background: var(--indiana-blue);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.btn-share:hover {
    border-color: var(--patriotic-navy);
    background: var(--patriotic-navy);
    color: #fff;
}

.post-admin-actions {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #eee;
}

.btn-delete-post {
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--radius-sm);
    border: 1px solid #a93226;
    background: #c0392b;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.btn-delete-post:hover {
    background: #a93226;
    border-color: #922b21;
    color: #fff;
}

/* Auth forms */
.auth-container,
.submit-container {
    max-width: 420px;
    margin: 2rem auto;
}

.auth-card,
.submit-card {
    background: white;
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(24px);
}

.auth-card.animated-in,
.submit-card.animated-in {
    opacity: 1;
    transform: translateY(0);
}

.auth-card h1,
.submit-card h1 {
    font-size: 1.75rem;
    color: var(--indiana-blue);
    margin: 0 0 0.5rem;
}

.auth-subtitle,
.submit-subtitle {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.auth-form label,
.submit-form label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
}

.auth-form input,
.auth-form button,
.submit-form input,
.submit-form textarea,
.submit-form button {
    width: 100%;
    padding: 0.65rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid #ddd;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
}

.submit-form textarea {
    resize: vertical;
    min-height: 120px;
}

.auth-form input:focus,
.submit-form input:focus,
.submit-form textarea:focus {
    outline: none;
    border-color: var(--indiana-gold);
    box-shadow: 0 0 0 3px rgba(189, 78, 44, 0.2);
}

.auth-footer {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.auth-footer a {
    color: var(--indiana-blue);
    font-weight: 600;
}

/* Install page */
.install-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--indiana-blue) 0%, var(--patriotic-navy) 100%);
    padding-top: 0;
}

.install-container {
    background: white;
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    max-width: 400px;
    width: 90%;
}

.install-container h1 {
    color: var(--indiana-blue);
    margin: 0 0 0.25rem;
}

.install-container .subtitle {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.install-form label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.install-form input {
    width: 100%;
    padding: 0.65rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid #ddd;
    border-radius: var(--radius-sm);
}

/* Admin */
.admin-dashboard h1,
.admin-pending h1 {
    color: var(--indiana-blue);
    margin-bottom: 0.5rem;
}

.admin-subtitle {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    position: relative;
    opacity: 0;
    transform: translateY(24px);
}

.stat-card.animated-in {
    opacity: 1;
    transform: translateY(0);
}

.stat-number {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--indiana-gold);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.stat-link {
    display: inline-block;
    margin-top: 0.5rem;
    color: var(--indiana-blue);
    font-weight: 600;
    font-size: 0.9rem;
}

.admin-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    opacity: 0;
    transform: translateY(24px);
}

.admin-actions.animated-in {
    opacity: 1;
    transform: translateY(0);
}

.pending-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.pending-card {
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
    align-items: flex-start;
    opacity: 0;
    transform: translateY(24px);
}

.pending-card.animated-in {
    opacity: 1;
    transform: translateY(0);
}

.pending-content {
    flex: 1;
    min-width: 250px;
}

.pending-content h3 {
    margin: 0 0 0.5rem;
}

.pending-description {
    color: var(--text-muted);
    margin: 0 0 0.5rem;
}

.pending-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.pending-actions {
    flex-shrink: 0;
}

.moderate-form {
    display: flex;
    gap: 0.5rem;
}

.btn-approve {
    background: #28a745;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.btn-approve:hover {
    background: #218838;
}

.btn-deny {
    background: var(--patriotic-red);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.btn-deny:hover {
    background: #9b1c2a;
    color: #fff;
}

.btn-approve.btn-sm,
.btn-deny.btn-sm {
    color: #fff;
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
}

.btn-approve.btn-sm:hover,
.btn-deny.btn-sm:hover {
    color: #fff;
}

.admin-back {
    margin-top: 2rem;
}

.admin-back a {
    color: var(--indiana-blue);
    font-weight: 600;
}

.btn-back {
    display: inline-block;
    background: var(--indiana-blue);
    color: white !important;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s;
}

.btn-back:hover {
    background: var(--patriotic-navy);
    color: white !important;
}

.admin-invites h1,
.admin-invites h2 {
    color: var(--indiana-blue);
}

.admin-invites h2 {
    font-size: 1.2rem;
    margin: 2rem 0 1rem;
}

.admin-invites h2:first-of-type {
    margin-top: 0;
}

.invite-section,
.invites-list-section,
.admins-list-section {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.invite-form label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.form-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.form-row input {
    flex: 1;
    min-width: 200px;
    padding: 0.6rem 1rem;
    border: 1px solid #ddd;
    border-radius: var(--radius-sm);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.admin-table th {
    font-weight: 600;
    color: var(--text-muted);
}

.admin-table tr:hover {
    background: var(--patriotic-white);
}

.muted {
    color: var(--text-muted);
}

.accept-invite-container {
    max-width: 480px;
    margin: 2rem auto;
}

.accept-invite-card {
    background: white;
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.accept-invite-card h1 {
    color: var(--indiana-blue);
    margin: 0 0 1rem;
}

.accept-invite-card .btn-block {
    margin-top: 1rem;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(24px);
}

.empty-state.animated-in {
    opacity: 1;
    transform: translateY(0);
}

.empty-state a {
    color: var(--indiana-blue);
    font-weight: 600;
}

/* Footer */
.site-footer {
    background: var(--indiana-blue);
    color: rgba(255, 255, 255, 0.9);
    padding: 1.5rem;
    margin-top: auto;
}

.footer-inner {
    max-width: 900px;
    margin: 0 auto;
    text-align: center;
}

.footer-logo {
    display: inline-block;
    margin-bottom: 0.75rem;
}

.footer-inner p {
    margin: 0;
    font-size: 0.9rem;
}

/* Scroll animation base - 500ms ease-out, stagger via data-animate-delay */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.animate-on-scroll.animated-in {
    opacity: 1;
    transform: translateY(0);
}

/* ---------- Mobile responsive ---------- */
@media (max-width: 768px) {
    .main-content {
        padding: 0 1rem 1.5rem;
    }

    .header-logo-bar {
        padding: 0.75rem 1rem;
    }

    .logo {
        height: 72px;
    }

    .logo-img {
        height: 100px;
        max-width: min(100vw - 2rem, 360px);
    }

    .main-nav {
        padding: 0.65rem 1rem;
        gap: 0.75rem;
    }

    .nav-primary,
    .nav-actions {
        gap: 0.75rem 1rem;
        justify-content: center;
    }

    .user-name {
        max-width: 100%;
        text-align: center;
        word-break: break-word;
    }

    .hero {
        padding: 2.5rem 1rem;
        min-height: 200px;
        margin-bottom: 1.25rem;
    }

    .hero h1 {
        font-size: clamp(1.35rem, 5vw, 1.85rem);
    }

    .hero-subtitle {
        font-size: 0.95rem;
    }

    .posts-section-head {
        flex-direction: column;
        align-items: stretch;
    }

    .sort-controls {
        justify-content: flex-start;
    }

    .post-card {
        flex-direction: column;
        padding: 1rem 1.15rem;
        gap: 1rem;
    }

    .vote-controls {
        flex-direction: row;
        justify-content: center;
        width: 100%;
        padding-bottom: 0.5rem;
        border-bottom: 1px solid #eee;
    }

    .post-meta {
        flex-direction: column;
        align-items: flex-start;
    }

    .cta-card {
        padding: 1rem 1.15rem;
    }

    .cta-card-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .cta-card-actions .btn,
    .cta-card-actions a.btn {
        text-align: center;
        justify-content: center;
        width: 100%;
    }

    .auth-card,
    .submit-card {
        padding: 1.35rem 1.15rem;
        margin-left: 0;
        margin-right: 0;
    }

    .auth-container,
    .submit-container {
        margin: 1.25rem auto;
        padding: 0 0.25rem;
    }

    .admin-stats {
        grid-template-columns: 1fr;
    }

    .admin-actions {
        flex-direction: column;
    }

    .admin-actions .btn {
        width: 100%;
        text-align: center;
    }

    .pending-card {
        flex-direction: column;
    }

    .pending-content {
        min-width: 0;
    }

    .pending-actions {
        width: 100%;
    }

    .moderate-form {
        flex-direction: column;
        width: 100%;
    }

    .moderate-form .btn {
        width: 100%;
    }

    .invite-section {
        padding: 1rem 1rem;
    }

    .invites-list-section,
    .admins-list-section {
        padding: 1rem 1rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .invites-list-section .admin-table,
    .admins-list-section .admin-table {
        min-width: 520px;
    }

    .form-row {
        flex-direction: column;
    }

    .form-row input {
        min-width: 0;
        width: 100%;
    }

    .accept-invite-card {
        padding: 1.35rem 1.15rem;
    }

    .accept-invite-container {
        margin: 1.25rem auto;
        padding: 0 0.5rem;
    }

    .install-container {
        padding: 1.5rem 1.15rem;
        margin: 1rem;
        width: auto;
        max-width: none;
    }

    .site-footer {
        padding: 1.25rem 1rem;
    }
}

@media (max-width: 480px) {
    .main-nav {
        flex-direction: column;
        align-items: stretch;
    }

    .nav-primary,
    .nav-actions {
        width: 100%;
        justify-content: center;
    }

    .empty-state {
        padding: 2rem 1rem;
    }
}
