:root {
    --bg-color: #ffffff;
    --text-color: #111827;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --primary: #000000;
    --primary-inv: #ffffff;
    --accent: #4f46e5;
    --radius: 12px;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --transition: 0.15s ease;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #0f1115;
        --text-color: #f3f4f6;
        --text-muted: #9ca3af;
        --border-color: #1f2937;
        --primary: #ffffff;
        --primary-inv: #000000;
    }
}

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* === Base === */
body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

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

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

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

/* === Layout === */
.container {
    max-width: 820px;
    margin: 0 auto;
    padding: 0 20px;
}

/* === Header === */
.site-header {
    padding: 24px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 40px;
    position: sticky;
    top: 0;
    background: var(--bg-color);
    z-index: 100;
    backdrop-filter: saturate(180%) blur(8px);
    -webkit-backdrop-filter: saturate(180%) blur(8px);
}

.site-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.logo {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    flex-shrink: 0;
}
.logo:hover { text-decoration: none; }

nav a {
    margin-left: 18px;
    font-size: 0.9rem;
    color: var(--text-muted);
    transition: color var(--transition);
    white-space: nowrap;
}
nav a:hover { color: var(--text-color); text-decoration: none; }

/* === Page Header === */
.page-header { margin-bottom: 32px; }
.page-header h1 { margin-bottom: 6px; }
.page-subtitle { color: var(--text-muted); font-size: 1rem; }
.quote-count { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }

/* === Hero Featured === */
.hero-featured {
    text-align: center;
    padding: 60px 0 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.hero-quote-wrapper {
    max-width: 720px;
    margin: 0 auto 48px;
    padding: 40px;
    border-radius: 24px;
    background: linear-gradient(145deg, color-mix(in srgb, var(--primary) 2%, var(--bg-color)), color-mix(in srgb, var(--primary) 6%, var(--bg-color)));
    border: 1px solid color-mix(in srgb, var(--primary) 8%, transparent);
    box-shadow: 0 20px 40px color-mix(in srgb, var(--primary) 3%, transparent);
}
.hero-quote {
    position: relative;
    margin-bottom: 24px;
}
.quote-mark {
    position: absolute;
    top: -40px;
    left: -20px;
    font-size: 6rem;
    font-family: Georgia, serif;
    color: color-mix(in srgb, var(--primary) 10%, transparent);
    line-height: 1;
    user-select: none;
}
.hero-quote p {
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 1.25;
    position: relative;
    z-index: 1;
}
.hero-author {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-muted);
    display: block;
    margin-bottom: 24px;
}
.hero-author a:hover { color: var(--text-color); }
.hero-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
}

/* === Search Bar === */
.search-bar { width: 100%; max-width: 520px; }
.search-bar form {
    display: flex;
    border: 1px solid var(--border-color);
    border-radius: 30px;
    overflow: hidden;
    background: var(--bg-color);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.search-bar form:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}
.search-bar input {
    flex: 1;
    padding: 14px 24px;
    border: none;
    background: transparent;
    color: var(--text-color);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    min-width: 0;
}
.search-bar input::placeholder { color: var(--text-muted); }
.search-bar button {
    padding: 14px 28px;
    border: none;
    background: var(--primary);
    color: var(--primary-inv);
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    transition: opacity var(--transition);
    flex-shrink: 0;
}
.search-bar button:hover { opacity: 0.85; }
.search-bar button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* === Headings === */
h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); font-weight: 700; margin-bottom: 12px; letter-spacing: -0.03em; line-height: 1.15; }
h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: 8px; }

/* === Quote Masonry Feed === */
.quote-masonry {
    column-count: 1;
    column-gap: 24px;
    margin-bottom: 60px;
}
@media (min-width: 600px) { .quote-masonry { column-count: 2; } }

/* Legacy feed fallback */
.quote-feed { display: flex; flex-direction: column; gap: 24px; margin-bottom: 60px; }

/* === Quote Card === */
.quote-card {
    padding: 28px 32px;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-color);
    transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
    break-inside: avoid;
    display: inline-block; /* Fix for masonry in some browsers */
    width: 100%;
}
.quote-card:hover {
    border-color: color-mix(in srgb, var(--primary) 20%, var(--border-color));
    transform: translateY(-4px);
    box-shadow: 0 12px 24px color-mix(in srgb, var(--primary) 4%, transparent);
}

.quote-text {
    font-size: 1.35rem;
    font-weight: 300;
    line-height: 1.5;
    margin-bottom: 14px;
}
.quote-text p { quotes: none; }
.quote-card.large .quote-text { font-size: clamp(1.4rem, 3vw, 2rem); }
.quote-author {
    font-size: 0.95rem;
    font-weight: 600;
    font-style: normal;
    color: var(--text-muted);
    display: block;
    margin-bottom: 18px;
}
.quote-author a:hover { color: var(--text-color); }

.quote-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    padding-top: 14px;
    gap: 12px;
    flex-wrap: wrap;
}
.quote-tags { margin-top: 12px; }
.topic-tag {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 600;
}
.topic-tag:hover { color: var(--text-color); text-decoration: none; }

/* === Inline Actions === */
.quote-actions-inline {
    display: flex;
    align-items: center;
    gap: 10px;
}
.view-link {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: color var(--transition);
}
.view-link:hover { color: var(--text-color); text-decoration: none; }

.share-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background var(--transition), color var(--transition);
}
.share-btn:hover {
    background: var(--border-color);
    color: var(--text-color);
}
.share-btn.primary, .download-img-btn {
    background: var(--border-color);
    padding: 10px 20px;
    border-radius: 24px;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-color);
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: background var(--transition), opacity var(--transition);
}
.share-btn.primary:hover, .download-img-btn:hover { opacity: 0.75; }

/* === Single Quote Page === */
.single-quote-page {}
.quote-actions {
    display: flex;
    gap: 14px;
    margin: 24px 0 36px;
    justify-content: center;
    flex-wrap: wrap;
}

/* === Context block & Enrichment === */
.content-enrichment {
    display: grid;
    gap: 32px;
    margin-bottom: 40px;
}
@media (min-width: 768px) {
    .content-enrichment { grid-template-columns: 1fr 1fr; }
}
.quote-context, .author-info {
    background: color-mix(in srgb, var(--text-color) 3%, var(--bg-color));
    padding: 32px;
    border-radius: var(--radius);
    border-top: 3px solid var(--border-color);
}
.quote-context h2, .author-info h2 { font-size: 1.15rem; margin-bottom: 12px; }
.author-info p { font-size: 0.95rem; color: var(--text-muted); margin-bottom: 16px; }
.quote-context p { font-size: 1rem; color: var(--text-color); line-height: 1.7; }

/* === Related Quotes === */
.related-quotes { margin-top: 48px; }
.related-quotes h2 { font-size: 1.4rem; margin-bottom: 20px; }

/* === Author Bio === */
.author-bio {
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1.7;
    margin: 8px 0 20px;
    max-width: 600px;
}

/* === Breadcrumb === */
.breadcrumb {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--text-color); text-decoration: none; }

/* === Silo List (Topics/Authors Hub) === */
.silo-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 40px;
}
.silo-list li a {
    display: block;
    padding: 16px 18px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: border-color var(--transition), background var(--transition);
}
.silo-list li a:hover {
    border-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 4%, var(--bg-color));
    text-decoration: none;
}

/* === Tag Clouds (Internal Linking) === */
.internal-links-section {
    margin: 40px 0;
    padding-top: 32px;
    border-top: 1px solid var(--border-color);
}
.internal-links-section h2 {
    font-size: 1.15rem;
    margin-bottom: 16px;
    color: var(--text-color);
}
.chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    list-style: none;
}
.chip {
    display: inline-block;
    padding: 8px 16px;
    background: color-mix(in srgb, var(--text-color) 4%, var(--bg-color));
    border: 1px solid var(--border-color);
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.chip:hover {
    background: color-mix(in srgb, var(--primary) 6%, var(--bg-color));
    color: var(--text-color);
    border-color: var(--primary);
    text-decoration: none;
}

/* === A-Z Filter === */
.az-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 28px;
}
.az-btn {
    display: inline-block;
    padding: 5px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.az-btn:hover, .az-btn.active {
    border-color: var(--primary);
    color: var(--text-color);
    background: color-mix(in srgb, var(--primary) 5%, var(--bg-color));
    text-decoration: none;
}

/* === Pagination === */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin: 40px 0;
}
.pagination-btn {
    padding: 10px 22px;
    border: 1px solid var(--border-color);
    border-radius: 24px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: border-color var(--transition), background var(--transition);
}
.pagination-btn:hover {
    border-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 5%, var(--bg-color));
    text-decoration: none;
}
.pagination-info { font-size: 0.9rem; color: var(--text-muted); }

/* === Footer === */
.site-footer {
    padding: 48px 0 32px;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 60px;
}
.footer-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 32px;
    margin-bottom: 32px;
}
.footer-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.footer-col strong {
    color: var(--text-color);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}
.footer-col a {
    color: var(--text-muted);
    font-size: 0.9rem;
    transition: color var(--transition);
}
.footer-col a:hover { color: var(--text-color); text-decoration: none; }
.footer-copy {
    text-align: center;
    border-top: 1px solid var(--border-color);
    padding-top: 24px;
    font-size: 0.85rem;
}

/* === 404 Page === */
.error-page { text-align: center; padding: 80px 0; }
.error-page h1 { font-size: 5rem; opacity: 0.15; margin-bottom: 16px; }
.error-page p { color: var(--text-muted); margin-bottom: 24px; }

/* === Animations === */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-fade-up {
    animation: fadeUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.delay-1 { animation-delay: 0.15s; }
.delay-2 { animation-delay: 0.3s; }

/* === Responsive === */
@media (max-width: 640px) {
    .site-header { padding: 16px 0; }
    .logo { font-size: 1.15rem; }
    nav a { margin-left: 12px; font-size: 0.82rem; }
    .hero { padding: 32px 0 40px; }
    .quote-card { padding: 20px; }
    .quote-text { font-size: 1.15rem; }
    .quote-card.large .quote-text { font-size: 1.3rem; }
    .footer-links { grid-template-columns: repeat(2, 1fr); gap: 20px; }
    .az-filter { gap: 4px; }
    .az-btn { padding: 4px 7px; font-size: 0.75rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* =========================================
   AdSense Placement & CLS Prevention
   ========================================= */
.ad-slot {
    margin: 40px auto;
    text-align: center;
    position: relative;
    background: var(--bg-color-alt);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    overflow: hidden;
}

/* Prevent CLS by reserving height */
.ad-slot.horizontal {
    min-height: 90px;
    width: 100%;
    max-width: 728px;
}

.ad-slot.rectangle {
    min-height: 250px;
    width: 100%;
    max-width: 300px;
}

/* Optional text before ad loads */
.ad-slot::before {
    content: 'Advertisement';
    position: absolute;
    z-index: 0;
}

.ad-slot ins {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    height: 100%;
}

