/* =============================================
   Chronicle Theme — Style
   ============================================= */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,300;0,6..72,400;0,6..72,500;0,6..72,600;1,6..72,300;1,6..72,400;1,6..72,500&family=Inter:wght@300;400;500;600&display=swap');

/* --- CSS Variables --- */
:root {
    --color-bg: #fcfcfa;
    --color-bg-alt: #f1f5f9;
    --color-text: #0f172a;
    --color-text-muted: #64748b;
    --color-border: #e2e8f0;
    --color-link: #0f172a;

    --font-serif: 'Newsreader', Georgia, serif;
    --font-sans: 'Inter', system-ui, sans-serif;

    --max-width: 720px;
    --max-width-wide: 1100px;
}

/* Dark mode — auto */
@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #0f172a;
        --color-bg-alt: #1e293b;
        --color-text: #f1f5f9;
        --color-text-muted: #94a3b8;
        --color-border: #334155;
        --color-link: #f1f5f9;
    }
}

/* Dark mode — forced */
html.is-dark {
    --color-bg: #0f172a;
    --color-bg-alt: #1e293b;
    --color-text: #f1f5f9;
    --color-text-muted: #94a3b8;
    --color-border: #334155;
    --color-link: #f1f5f9;
}

/* Light mode — forced (overrides OS dark) */
html.is-light {
    --color-bg: #fcfcfa;
    --color-bg-alt: #f1f5f9;
    --color-text: #0f172a;
    --color-text-muted: #64748b;
    --color-border: #e2e8f0;
    --color-link: #0f172a;
}

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

html { font-size: 17px; -webkit-font-smoothing: antialiased; }

body {
    background-color: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-sans);
    line-height: 1.6;
    transition: background-color 0.2s, color 0.2s;
}

a { color: var(--color-link); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* --- Layout --- */
.site-container { min-height: 100vh; display: flex; flex-direction: column; }

.site-main {
    flex: 1;
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.5rem;
}

.site-main--wide { max-width: var(--max-width-wide); }

/* --- Header --- */
.site-header {
    border-bottom: 1px solid var(--color-border);
    padding: 1.25rem 1.5rem;
}

.site-header__inner {
    max-width: var(--max-width-wide);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.site-header__brand { display: flex; flex-direction: column; gap: 0.1rem; }

.site-header__title {
    font-family: var(--font-serif);
    font-size: 1.4rem;
    font-weight: 500;
    letter-spacing: -0.02em;
    color: var(--color-text);
}
.site-header__title:hover { text-decoration: none; }
.site-header__logo { max-height: 2rem; width: auto; display: block; }

.site-header__tagline {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.site-header__nav { display: flex; align-items: center; gap: 1.5rem; }

.site-header__nav a {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    transition: color 0.15s;
}
.site-header__nav a:hover { color: var(--color-text); text-decoration: none; }

/* --- Footer --- */
.site-footer {
    background-color: #0f172a;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding: 5rem 1.5rem 3rem;
    margin-top: 4rem;
}

.site-footer__inner {
    max-width: var(--max-width-wide);
    margin: 0 auto;
}

.site-footer__top {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    padding-bottom: 3rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    align-items: start;
}

.site-footer__heading {
    font-family: var(--font-serif);
    font-size: 1.85rem;
    font-weight: 400;
    color: #fff;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin-bottom: 0.85rem;
}

.site-footer__desc {
    font-size: 0.875rem;
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.45);
    max-width: 26rem;
    margin-bottom: 2rem;
}

/* Baseline styles for whatever form HTML gets pasted into the signup slot */
.site-footer__form { }
.site-footer__form input[type="email"],
.site-footer__form input[type="text"] {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px 0 0 4px;
    color: #fff;
    padding: 0.6rem 1rem;
    font-size: 0.875rem;
    outline: none;
    width: 100%;
    max-width: 18rem;
    vertical-align: middle;
}
.site-footer__form input::placeholder { color: rgba(255, 255, 255, 0.3); }
.site-footer__form button,
.site-footer__form input[type="submit"] {
    background: #64748b;
    border: none;
    border-radius: 0 4px 4px 0;
    color: #fff;
    padding: 0.6rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    vertical-align: middle;
    transition: background 0.15s;
}
.site-footer__form button:hover,
.site-footer__form input[type="submit"]:hover { background: #475569; }

.site-footer__nav-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.site-footer__nav-heading {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(255, 255, 255, 0.3);
    margin-bottom: 1.25rem;
}

.site-footer__nav-list { list-style: none; }
.site-footer__nav-list li { margin-bottom: 0.9rem; }
.site-footer__nav-list a {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    transition: color 0.15s;
}
.site-footer__nav-list a:hover { color: #fff; }

.site-footer__bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.site-footer__copy {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.25);
}

/* --- Post List --- */
.post-list { padding: 3rem 0; }

.post-list__header {
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--color-border);
}

.post-list__description { color: var(--color-text-muted); font-size: 0.95rem; }

/* --- Post Card --- */
.post-card {
    display: grid;
    grid-template-columns: 1fr;
    padding: 1.75rem 0;
    border-bottom: 1px solid var(--color-border);
}

.post-card--with-image {
    grid-template-columns: 208px 1fr;
    gap: 1.5rem;
    align-items: start;
}

.post-card__meta {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.post-card__tag {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
}
.post-card__tag:hover { color: var(--color-text); text-decoration: none; }

.post-card__date { font-size: 0.8rem; color: var(--color-text-muted); }

.post-card__title {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 400;
    line-height: 1.35;
    letter-spacing: -0.01em;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}
.post-card__title a { color: inherit; }
.post-card__title a:hover { text-decoration: none; opacity: 0.75; }

.post-card__excerpt {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-card__external {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 0.4rem;
}

.post-card__image {
    border-radius: 4px;
    overflow: hidden;
    aspect-ratio: 3/2;
}
.post-card__image img { width: 100%; height: 100%; object-fit: cover; }

/* --- Pagination --- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 3rem 0 1rem;
}

.pagination a, .pagination span {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    transition: all 0.15s;
}
.pagination a:hover { color: var(--color-text); border-color: var(--color-text); text-decoration: none; }
.pagination span.current { color: var(--color-text); border-color: var(--color-text); }

/* --- Single Post --- */
.post { padding: 3rem 0 4rem; }

.post__header { margin-bottom: 2rem; }

.post__meta {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.post__tag {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
}
.post__tag:hover { color: var(--color-text); text-decoration: none; }

.post__date { font-size: 0.8rem; color: var(--color-text-muted); }

.post__title {
    font-family: var(--font-serif);
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 400;
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin-bottom: 0.75rem;
}

.post__subtitle {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    font-weight: 300;
    font-style: italic;
    color: var(--color-text-muted);
    line-height: 1.5;
    margin-bottom: 1.25rem;
}

.post__author { font-size: 0.85rem; color: var(--color-text-muted); }
.post__author a { color: var(--color-text-muted); }
.post__author a:hover { color: var(--color-text); text-decoration: none; }

.post__featured-image { margin: 2rem 0; border-radius: 4px; overflow: hidden; }
.post__featured-image img { width: 100%; height: auto; }

/* --- Post Content Typography --- */
.post__content {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    line-height: 1.8;
}

.post__content p { margin-bottom: 1.5em; }

.post__content h2 {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 500;
    letter-spacing: -0.02em;
    margin: 2.5em 0 0.75em;
    line-height: 1.3;
}

.post__content h3 {
    font-family: var(--font-serif);
    font-size: 1.2rem;
    font-weight: 500;
    margin: 2em 0 0.5em;
}

.post__content h4, .post__content h5, .post__content h6 {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin: 1.75em 0 0.5em;
}

.post__content a {
    color: var(--color-text);
    text-decoration: underline;
    text-underline-offset: 3px;
}
.post__content a:hover { opacity: 0.7; }

.post__content blockquote {
    border-left: 3px solid var(--color-border);
    margin: 2em 0;
    padding: 0.5em 0 0.5em 1.5em;
    font-style: italic;
    color: var(--color-text-muted);
}
.post__content blockquote p:last-child { margin-bottom: 0; }

.post__content ul, .post__content ol {
    margin-bottom: 1.5em;
    padding-left: 1.5em;
}
.post__content li { margin-bottom: 0.4em; }

.post__content pre {
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 1.25em;
    overflow-x: auto;
    margin-bottom: 1.5em;
    font-size: 0.85rem;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.post__content code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.85em;
    background: var(--color-bg-alt);
    padding: 0.15em 0.35em;
    border-radius: 3px;
}
.post__content pre code { background: none; padding: 0; font-size: inherit; }

.post__content img { border-radius: 4px; margin: 2em 0; }
.post__content hr { border: none; border-top: 1px solid var(--color-border); margin: 3em 0; }
.post__content figure { margin: 2em 0; }
.post__content figcaption {
    font-family: var(--font-sans);
    font-size: 0.8rem;
    color: var(--color-text-muted);
    text-align: center;
    margin-top: 0.75rem;
    font-style: italic;
}

/* --- Post Footer --- */
.post__footer {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--color-border);
}

.post__tags { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.post__tags a {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
    padding: 0.25rem 0.75rem;
    border-radius: 100px;
    transition: all 0.15s;
}
.post__tags a:hover { color: var(--color-text); border-color: var(--color-text); text-decoration: none; }

/* --- 404 --- */
.error-page { padding: 5rem 0; text-align: center; }
.error-page__code {
    font-family: var(--font-serif);
    font-size: 5rem;
    font-weight: 300;
    color: var(--color-text-muted);
    line-height: 1;
    margin-bottom: 1rem;
}
.error-page__title { font-family: var(--font-serif); font-size: 1.5rem; font-weight: 400; margin-bottom: 1rem; }
.error-page__text { color: var(--color-text-muted); margin-bottom: 2rem; }
.error-page__link {
    display: inline-block;
    padding: 0.6rem 1.5rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 0.9rem;
    transition: all 0.15s;
}
.error-page__link:hover { border-color: var(--color-text); text-decoration: none; }

/* --- Tags List --- */
.post-list__title {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 400;
    letter-spacing: -0.02em;
}

.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 1.5rem 0;
}

.tags-list__item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.85rem;
    border: 1px solid var(--color-border);
    border-radius: 100px;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    transition: all 0.15s;
}
.tags-list__item:hover { color: var(--color-text); border-color: var(--color-text); text-decoration: none; }

.tags-list__count {
    font-size: 0.75rem;
    opacity: 0.6;
}

/* --- Featured Post Card --- */
.post-card--featured {
    grid-template-columns: 1fr;
    padding: 2rem 0;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 0.25rem;
}

.post-card__featured-image {
    display: block;
    width: 100%;
    aspect-ratio: 21/9;
    overflow: hidden;
    border-radius: 4px;
    margin-bottom: 1.5rem;
}

.post-card__featured-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.2s;
}

.post-card__featured-image:hover img { opacity: 0.88; }

.post-card__featured-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-text);
    border: 1px solid var(--color-text);
    padding: 0.15rem 0.45rem;
    border-radius: 2px;
}

.post-card__title--large {
    font-size: clamp(1.5rem, 3vw, 2rem);
    line-height: 1.2;
}

.post-card__excerpt--more {
    -webkit-line-clamp: 3;
}

.post-card__excerpt--auto > * {
    display: inline;
    margin: 0;
    padding: 0;
}

.post-card__excerpt--auto img,
.post-card__excerpt--auto figure,
.post-card__excerpt--auto video,
.post-card__excerpt--auto iframe {
    display: none;
}

/* --- Search Page --- */
.search-page { padding: 3rem 0; }

.search-page .post-list__header { margin-bottom: 2rem; }

/* Publii injects its search UI — give it breathing room */
.search-page .c-search { margin-top: 0; }

/* --- Header search icon --- */
.site-header__right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.site-header__search {
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    line-height: 1;
    transition: color 0.15s;
}
.site-header__search:hover { color: var(--color-text); }

/* --- Responsive --- */
@media (max-width: 600px) {
    .post-card--with-image { grid-template-columns: 1fr; }
    .post-card__image { display: none; }
    .post-card__featured-image { aspect-ratio: 16/9; }
    .site-header__tagline { display: none; }
    .site-footer__top { grid-template-columns: 1fr; gap: 2.5rem; }
    .site-footer__nav-cols { grid-template-columns: 1fr 1fr; }
}
