/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-color: #fdfdfc;
    --text-color: #1f1f1f;
    --text-light: #4b4b4b;
    --text-lighter: #757575;
    --border-color: #d9d9d5;
    --border-hover: #bcbcb8;
    --code-bg: #f1f1ee;
}

[data-theme="dark"] {
    --bg-color: #161616;
    --text-color: #efefef;
    --text-light: #c6c6c6;
    --text-lighter: #9a9a9a;
    --border-color: #3a3a3a;
    --border-hover: #5a5a5a;
    --code-bg: #232323;
}

body {
    font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", "Times New Roman", serif;
    line-height: 1.75;
    font-size: 19px;
    color: var(--text-color);
    background: var(--bg-color);
    max-width: 760px;
    margin: 0 auto;
    padding: 28px 20px 40px;
    transition: background-color 0.15s ease, color 0.15s ease;
}

/* Header and Navigation */
header {
    margin-bottom: 50px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
}

nav ul {
    list-style: none;
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.theme-toggle-item {
    margin-left: auto;
}

nav a {
    text-decoration: none;
    color: var(--text-light);
    font-weight: 400;
    font-size: 0.95em;
    letter-spacing: 0.01em;
}

nav a:hover,
nav a.active {
    color: var(--text-color);
    text-decoration: underline;
    text-underline-offset: 0.18em;
}

/* Theme toggle button */
.theme-toggle {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.theme-switch {
    position: relative;
    display: inline-flex;
    width: 44px;
    height: 24px;
    cursor: pointer;
}

.theme-slider {
    width: 100%;
    height: 100%;
    border: 1px solid var(--border-hover);
    border-radius: 999px;
    background: transparent;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.theme-slider::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-light);
    transition: transform 0.15s ease, background-color 0.15s ease;
}

.theme-toggle:checked + .theme-slider {
    border-color: var(--text-light);
}

.theme-toggle:checked + .theme-slider::after {
    transform: translateX(20px);
    background: var(--text-color);
}

.theme-switch:hover .theme-slider {
    border-color: var(--text-color);
}

.theme-switch:focus-within .theme-slider {
    outline: 2px solid var(--text-lighter);
    outline-offset: 2px;
}

/* Main content */
main {
    min-height: 60vh;
}

.hero {
    margin-bottom: 40px;
}

.hero h1 {
    font-size: clamp(2rem, 5vw, 2.7rem);
    line-height: 1.15;
    margin-bottom: 14px;
    font-weight: 500;
}

.bio {
    font-size: 1.06em;
    line-height: 1.8;
    color: var(--text-light);
    margin-bottom: 24px;
}

/* Contact information styles */
.contact-info {
    margin-top: 18px;
    padding-top: 8px;
}

.contact-info h3 {
    color: var(--text-color);
    margin-bottom: 10px;
    font-size: 1em;
    font-weight: 500;
}

.contact-links {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0;
    white-space: nowrap;
    margin-bottom: 12px;
}

.contact-link {
    display: inline-block;
    padding: 0;
    text-decoration: none;
    color: var(--text-light);
    font-size: 0.95em;
}

.contact-link + .contact-link::before {
    content: " | ";
    color: var(--text-lighter);
}

.contact-link:hover {
    color: var(--text-color);
    text-decoration: underline;
    text-underline-offset: 0.14em;
}

.cv-link {
    margin-top: 12px;
}

.cv-button {
    display: inline;
    padding: 0;
    background: none;
    color: var(--text-light);
    text-decoration: none;
    font-weight: 400;
    font-size: 0.95em;
}

.cv-button:hover {
    color: var(--text-color);
    text-decoration: underline;
    text-underline-offset: 0.14em;
}

.page-header {
    margin-bottom: 36px;
}

.page-header h1 {
    font-size: clamp(1.8rem, 4vw, 2.2rem);
    margin-bottom: 6px;
    font-weight: 500;
}

.page-header p {
    color: var(--text-light);
    font-size: 1em;
}

/* Sections */
section {
    margin-bottom: 42px;
}

section h2 {
    font-size: 1.25em;
    margin-bottom: 14px;
    font-weight: 400;
    color: var(--text-color);
}

/* Posts and cards */
.post-card,
.link-card {
    border: 0;
    border-bottom: 1px solid var(--border-color);
    padding: 16px 0 18px;
    margin-bottom: 0;
    text-decoration: none;
    color: inherit;
    display: block;
}

.post-card:hover,
.link-card:hover {
    border-bottom-color: var(--border-hover);
}

.post-card h3,
.link-card h3 {
    margin-bottom: 6px;
    font-size: 1.1em;
    font-weight: 500;
}

.post-card h3 a,
.link-card h3 a,
.article-content a {
    color: inherit;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.14em;
    overflow-wrap: anywhere;
}

.post-card p,
.link-card p {
    color: var(--text-light);
    line-height: 1.65;
}

.post-meta {
    color: var(--text-lighter);
    font-size: 0.85em;
    margin-bottom: 4px;
    letter-spacing: 0.02em;
}

.post-content {
    margin-top: 12px;
}

/* Article view */
.article {
    max-width: 680px;
    margin: 0 auto;
}

.article h1 {
    font-size: clamp(1.9rem, 5vw, 2.4rem);
    margin-bottom: 8px;
    font-weight: 500;
    line-height: 1.2;
}

.article-meta {
    color: var(--text-lighter);
    margin-bottom: 26px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9em;
}

.article-content {
    line-height: 1.85;
}

.article-content h2 {
    margin-top: 40px;
    margin-bottom: 12px;
    font-size: 1.28em;
    font-weight: 500;
}

.article-content h3 {
    margin-top: 28px;
    margin-bottom: 10px;
    font-size: 1.12em;
    font-weight: 500;
}

.article-content p {
    margin-bottom: 16px;
}

.article-content ul,
.article-content ol {
    margin-bottom: 16px;
    padding-left: 24px;
}

.article-content li {
    margin-bottom: 4px;
}

.article-content code {
    background: var(--code-bg);
    padding: 2px 4px;
    border-radius: 2px;
    font-family: "Consolas", "SFMono-Regular", Menlo, monospace;
    font-size: 0.9em;
}

.article-content pre {
    background: var(--code-bg);
    padding: 14px;
    border-radius: 2px;
    border: 1px solid var(--border-color);
    overflow-x: auto;
    margin-bottom: 16px;
}

.article-content pre code {
    background: none;
    padding: 0;
}

.article-content blockquote {
    border-left: 2px solid var(--border-color);
    padding-left: 16px;
    margin: 16px 0;
    color: var(--text-light);
    font-style: normal;
}

/* Back button */
.back-btn {
    display: inline-block;
    margin-bottom: 24px;
    color: var(--text-light);
    text-decoration: none;
    font-size: 0.9em;
}

.back-btn:hover {
    color: var(--text-color);
    text-decoration: underline;
    text-underline-offset: 0.14em;
}

/* Life clock */
.life-clock-page {
    display: flex;
    flex-direction: column;
    gap: 34px;
}

.life-header p {
    max-width: 44ch;
}

.life-intro-link {
    margin-top: 8px;
    color: var(--text-light);
}

.life-intro-link a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 0.14em;
}

.life-timers {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.life-panel {
    border: 1px solid var(--border-color);
    padding: 16px;
    background: linear-gradient(145deg, rgba(0, 0, 0, 0.04), transparent 70%);
}

[data-theme="dark"] .life-panel {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.03), transparent 70%);
}

.life-panel h2 {
    margin-bottom: 8px;
    font-size: 1em;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.life-timer {
    font-family: "Consolas", "SFMono-Regular", Menlo, monospace;
    font-size: clamp(1.2rem, 3.8vw, 1.85rem);
    letter-spacing: 0.02em;
    line-height: 1.35;
}

.life-progress {
    border-top: 1px solid var(--border-color);
    padding-top: 18px;
}

.life-progress-text {
    font-size: 1.18em;
    margin-bottom: 10px;
}

.life-progress-track {
    width: 100%;
    height: 10px;
    border: 1px solid var(--border-color);
    background: var(--code-bg);
}

.life-progress-fill {
    height: 100%;
    width: 0;
    background: var(--text-color);
    transition: width 0.35s linear;
}

.life-weeks-note {
    color: var(--text-light);
    margin-bottom: 10px;
}

#weeks-grid,
#calc-weeks-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    --week-gap: 2px;
}

.year-row {
    display: grid;
    grid-template-columns: 68px 1fr;
    align-items: center;
    column-gap: 8px;
}

.year-label {
    font-size: 0.72em;
    color: var(--text-lighter);
    line-height: 1;
    letter-spacing: 0.02em;
}

.year-weeks {
    display: grid;
    grid-template-columns: repeat(53, minmax(0, 1fr));
    gap: var(--week-gap);
    width: 100%;
}

.week {
    aspect-ratio: 1;
    width: 100%;
    min-width: 0;
    background: #3f3f3f;
    transition: background-color 0.18s ease;
}

.week.lived {
    background: #f3f3f3;
}

.week.remaining {
    background: #4a4a4a;
}

.week.current {
    outline: 1px solid var(--text-lighter);
    outline-offset: -1px;
}

[data-theme="light"] .week.lived {
    background: #171717;
}

[data-theme="light"] .week.remaining {
    background: #d4d4cf;
}

.life-quote {
    margin-top: 6px;
    color: var(--text-lighter);
    font-style: italic;
}

.life-reflection {
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

.life-reflection h2 {
    margin-bottom: 12px;
}

.life-reflection p {
    margin-bottom: 14px;
    color: var(--text-light);
}

.life-reflection blockquote {
    border-left: 2px solid var(--border-color);
    padding-left: 14px;
    margin: 12px 0 16px;
}

.life-reflection blockquote p {
    color: var(--text-color);
    font-style: italic;
    margin-bottom: 0;
}

.life-reflection a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 0.14em;
}

.life-reflection-link {
    margin-top: 4px;
}

.life-tick .life-progress-fill {
    filter: brightness(0.97);
}

.calculate-page {
    gap: 24px;
}

.calculate-form {
    display: grid;
    gap: 12px;
}

.form-row {
    display: grid;
    gap: 6px;
}

.form-row label {
    font-size: 0.95em;
    color: var(--text-light);
}

.form-row input {
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-color);
    font: inherit;
    padding: 10px 12px;
}

.form-row input:focus {
    outline: 2px solid var(--text-lighter);
    outline-offset: 1px;
}

.calc-button {
    justify-self: start;
    border: 1px solid var(--border-color);
    background: var(--text-color);
    color: var(--bg-color);
    font: inherit;
    padding: 8px 14px;
    cursor: pointer;
}

.calc-button:hover {
    filter: brightness(0.92);
}

.calculate-help {
    font-size: 0.9em;
    color: var(--text-lighter);
}

/* Footer */
footer {
    margin-top: 60px;
    padding-top: 18px;
    border-top: 1px solid var(--border-color);
    text-align: left;
    color: var(--text-lighter);
    font-size: 0.9em;
}

/* Responsive */
@media (max-width: 600px) {
    body {
        padding: 18px 16px 28px;
        font-size: 17px;
    }
    
    nav ul {
        gap: 14px;
    }

    .theme-toggle-item {
        margin-left: auto;
    }
    
    .hero h1 {
        font-size: 2rem;
    }
    
    .page-header h1 {
        font-size: 1.8em;
    }
    
    .post-card,
    .link-card {
        padding: 14px 0 16px;
    }
    
    .contact-links {
        gap: 0;
    }

    .life-clock-page {
        gap: 26px;
    }

    .life-panel {
        padding: 14px;
    }

    #weeks-grid,
    #calc-weeks-grid {
        gap: 4px;
        --week-gap: 1.5px;
    }

    .year-row {
        grid-template-columns: 52px 1fr;
        column-gap: 6px;
    }

    .year-label {
        font-size: 0.68em;
    }

    .year-weeks {
        gap: var(--week-gap);
    }
}
