:root {
    /* Swiss editorial palette */
    --bg: #ffffff;
    --bg-2: #f5f5f5;
    --text: #0a0a0a;
    --text-muted: #666666;
    --text-heading: #0a0a0a;
    --accent: #dc2626;
    --accent-hover: #b91c1c;
    --border: #e5e5e5;
    --border-strong: #0a0a0a;
    --focus: #dc2626;

    /* Fonts */
    --font-display: 'AT Season Sans', 'Helvetica Neue', Arial, sans-serif;
    --font-body: 'Geist', 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'Geist Mono', 'SF Mono', Consolas, monospace;

    /* Type scale */
    --size-xs: clamp(0.65rem, 0.6rem + 0.25vw, 0.75rem);
    --size-small: clamp(0.75rem, 0.7rem + 0.25vw, 0.85rem);
    --size-body: clamp(0.95rem, 0.9rem + 0.25vw, 1.05rem);
    --size-h3: clamp(1.15rem, 1.05rem + 0.5vw, 1.5rem);
    --size-h2: clamp(1.4rem, 1.2rem + 1vw, 2rem);
    --size-h1: clamp(2.25rem, 1.5rem + 3.5vw, 4.5rem);

    /* Spacing */
    --space-xs: clamp(0.5rem, 0.4rem + 0.5vw, 0.75rem);
    --space-sm: clamp(0.75rem, 0.6rem + 0.75vw, 1rem);
    --space-md: clamp(1.25rem, 1rem + 1.25vw, 2rem);
    --space-lg: clamp(2rem, 1.5rem + 2.5vw, 3rem);
    --space-xl: clamp(2.5rem, 1.75rem + 3.75vw, 4.5rem);

    --maxw: 1440px;
    --line: 1.5;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: var(--size-body);
    line-height: var(--line);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

a {
    color: inherit;
    text-decoration: none;
}

a:hover {
    color: var(--accent);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 800;
    color: var(--text-heading);
    line-height: 1.05;
    text-transform: uppercase;
    letter-spacing: -0.02em;
    overflow-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
}

p {
    margin-bottom: var(--space-md);
}

ul, ol {
    margin-bottom: var(--space-md);
    padding-left: 1.4em;
}

li {
    margin-bottom: var(--space-xs);
}

blockquote {
    margin: var(--space-md) 0;
    padding-left: var(--space-md);
    border-left: 3px solid var(--border-strong);
    color: var(--text-muted);
}

code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--bg-2);
    padding: 0.15em 0.35em;
}

pre {
    background: #0a0a0a;
    color: #f5f5f5;
    padding: var(--space-md);
    overflow-x: auto;
    margin-bottom: var(--space-md);
    font-family: var(--font-mono);
    font-size: var(--size-small);
    line-height: 1.5;
}

pre code {
    background: transparent;
    padding: 0;
}

/* =========================================================
   LAYOUT
   ========================================================= */
.container {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 var(--space-md);
}

.skip-link {
    position: absolute;
    top: -3rem;
    left: var(--space-md);
    background: var(--text);
    color: var(--bg);
    padding: var(--space-xs) var(--space-sm);
    z-index: 100;
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.skip-link:focus {
    top: var(--space-sm);
}

.site-header {
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--border-strong);
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.site-brand {
    display: flex;
    flex-direction: column;
    gap: 0.15em;
}

.site-title {
    font-family: var(--font-display);
    font-size: var(--size-h3);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: -0.02em;
    color: var(--text-heading);
    display: inline-block;
}

.site-title:hover {
    color: var(--text-heading);
    text-decoration: none;
}

.site-subtitle {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.main-nav {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    justify-content: flex-end;
}

.nav-link {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: var(--space-xs) 0;
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--accent);
    transition: width 0.2s ease-out;
}

.nav-link:hover,
.nav-link.active {
    color: var(--text);
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

.section {
    padding-bottom: var(--space-xl);
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   SECTION HEADER
   ========================================================= */
.section-header {
    border-top: 1px solid var(--border-strong);
    padding-top: var(--space-sm);
    margin-top: var(--space-lg);
    margin-bottom: var(--space-md);
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-md);
}

.section-header h2 {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    margin-bottom: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.55em;
}

.section-header h2::before {
    content: '';
    display: inline-block;
    width: 0.55em;
    height: 0.55em;
    background: var(--accent);
}

.section-link {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    white-space: nowrap;
}

.section-link:hover {
    color: var(--accent);
}

/* =========================================================
   HERO
   ========================================================= */
.hero {
    padding: var(--space-lg) 0 var(--space-md);
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: var(--space-md);
}

.hero h1 {
    grid-column: 1 / 9;
    font-size: var(--size-h1);
    font-weight: 900;
    line-height: 1.05;
    margin-bottom: var(--space-md);
}

.hero .lead {
    grid-column: 1 / 7;
    font-size: var(--size-body);
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: var(--space-md);
}

.hero-meta {
    grid-column: 1 / 7;
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.hero-meta strong {
    color: var(--text);
    font-weight: 600;
}

@media (max-width: 767px) {
    .hero h1,
    .hero .lead,
    .hero-meta {
        grid-column: 1 / -1;
    }
}

/* =========================================================
   PAGE HERO
   ========================================================= */
.page-hero {
    padding: var(--space-lg) 0 var(--space-md);
}

.page-hero h1 {
    font-size: var(--size-h1);
    line-height: 1.05;
    margin-bottom: var(--space-sm);
    max-width: 18ch;
}

.page-hero .lead {
    font-size: var(--size-body);
    color: var(--text-muted);
    line-height: 1.55;
    max-width: 65ch;
    margin-bottom: 0;
}

@media (max-width: 767px) {
    .page-hero {
        padding: var(--space-md) 0 var(--space-sm);
    }
}

/* =========================================================
   CARDS & GRIDS
   ========================================================= */
.card {
    border-top: 1px solid var(--border);
    padding-top: var(--space-md);
}

.card:hover {
    border-top-color: var(--accent);
}

.card-link {
    display: block;
    color: inherit;
}

.card-link:hover {
    color: inherit;
}

.grid-1,
.grid-2,
.grid-3,
.grid-4 {
    display: grid;
    gap: var(--space-lg);
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1023px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 767px) {
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }
}

/* =========================================================
   COMPONENTS
   ========================================================= */
.btn {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text);
    border: 1px solid var(--border-strong);
    padding: var(--space-xs) var(--space-sm);
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    transition: background 0.15s;
}

.btn:hover {
    background: var(--text);
    color: var(--bg);
    text-decoration: none;
}

.back-btn {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: var(--space-md);
    display: inline-block;
}

.back-btn:hover {
    color: var(--accent);
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6em;
    margin-top: var(--space-sm);
}

.tag {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 0.15em 0.35em;
    margin: -0.15em -0.35em;
    transition: background 0.15s, color 0.15s;
}

a.tag:hover {
    color: var(--accent);
    background: rgba(220, 38, 38, 0.06);
}

/* =========================================================
   BLOG
   ========================================================= */
.blog-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-xl);
}

@media (min-width: 900px) {
    .blog-layout {
        grid-template-columns: minmax(0, 1fr) 220px;
        gap: var(--space-lg);
    }
}

.blog-sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.blog-sidebar h3 {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
    border-top: 1px solid var(--border-strong);
    padding-top: var(--space-sm);
}

.search-form {
    display: flex;
    gap: var(--space-xs);
    border-bottom: 1px solid var(--border-strong);
    padding-bottom: var(--space-xs);
}

.search-form input[type="search"] {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    color: var(--text);
    font-family: var(--font-body);
    font-size: var(--size-body);
    padding: var(--space-xs) 0;
}

.search-form input[type="search"]:focus {
    outline: none;
}

.search-form button {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    flex-shrink: 0;
}

.search-form button:hover {
    color: var(--accent);
}

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5em;
}

.tag-cloud-item {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    line-height: 1.4;
}

.tag-cloud-item.active,
.tag-cloud-item:hover {
    color: var(--accent);
}

.tag-cloud-count {
    color: var(--text-muted);
    font-weight: 400;
}

.tag-cloud-item.size-1 { font-size: calc(var(--size-xs) * 0.9); }
.tag-cloud-item.size-2 { font-size: calc(var(--size-xs) * 1.0); }
.tag-cloud-item.size-3 { font-size: calc(var(--size-xs) * 1.1); }
.tag-cloud-item.size-4 { font-size: calc(var(--size-xs) * 1.25); }
.tag-cloud-item.size-5 { font-size: calc(var(--size-xs) * 1.4); }

.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.active-filter {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text);
    border: 1px solid var(--border-strong);
    padding: var(--space-xs) var(--space-sm);
}

.active-filter:hover {
    background: var(--text);
    color: var(--bg);
    text-decoration: none;
}

.results-meta {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: var(--space-md);
}

.archive-widget {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.archive-year-title {
    font-family: var(--font-display);
    font-size: var(--size-h3);
    font-weight: 800;
    color: var(--text-heading);
    margin-bottom: var(--space-xs);
}

.archive-months {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
}

.archive-month a {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: var(--space-xs) 0;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
}

.archive-month a:hover,
.archive-month.active a {
    color: var(--text);
}

.archive-count {
    color: var(--text-muted);
}

/* =========================================================
   POST PREVIEW
   ========================================================= */
.post-preview h3 {
    font-size: var(--size-h3);
    margin-bottom: var(--space-xs);
}

.post-preview h3 a {
    color: var(--text-heading);
}

.post-preview h3 a:hover {
    color: var(--accent);
}

.post-preview .meta {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
}

.post-preview p {
    color: var(--text-muted);
    margin-bottom: 0;
}

.post-list {
    display: grid;
    gap: var(--space-lg);
}

.post-list.grid-1 {
    grid-template-columns: 1fr;
}

.post-list.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 767px) {
    .post-list.grid-2 {
        grid-template-columns: 1fr;
    }
}

/* =========================================================
   ARTICLE PAGE
   ========================================================= */
.article-page header {
    margin-bottom: var(--space-lg);
}

.article-page h1 {
    font-size: var(--size-h1);
    line-height: 1.05;
    margin-bottom: var(--space-md);
    max-width: 24ch;
}

.article-page .meta {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: var(--space-md);
}

.article-body {
    max-width: 70ch;
}

.article-body h2 {
    font-size: var(--size-h2);
    margin-top: var(--space-lg);
    margin-bottom: var(--space-sm);
}

.article-body h3 {
    font-size: var(--size-h3);
    margin-top: var(--space-md);
    margin-bottom: var(--space-sm);
}

.article-body p {
    margin-bottom: var(--space-md);
}

.article-body img {
    margin: var(--space-md) 0;
    width: 100%;
    height: auto;
}

/* =========================================================
   PORTFOLIO
   ========================================================= */
.project-card {
    position: relative;
    display: flex;
    flex-direction: column;
    transition: border-top-color 0.2s ease-out;
}

.project-card h3 {
    font-size: var(--size-h3);
    margin-bottom: var(--space-xs);
    padding-right: 2.5rem;
}

.project-card p {
    color: var(--text-muted);
    margin-bottom: var(--space-md);
}

.project-number {
    position: absolute;
    top: var(--space-md);
    right: 0;
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
}

.project-image {
    width: 100%;
    aspect-ratio: 1200 / 630;
    overflow: hidden;
    margin-bottom: var(--space-md);
    background: var(--bg-2);
}

.project-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease-out;
}

.project-card:hover .project-image img {
    transform: scale(1.02);
}

.project-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5em;
    margin-bottom: var(--space-sm);
}

.project-tags span {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.project-links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    margin-top: var(--space-md);
}

/* =========================================================
   ABOUT / CV
   ========================================================= */
.about-page .article-page h1,
.cv-header h1 {
    font-size: var(--size-h1);
    line-height: 1.05;
    margin-bottom: var(--space-sm);
    max-width: 24ch;
}

.cv-header .meta {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: var(--space-md);
}

.cv-header {
    margin-bottom: var(--space-lg);
}

.contact-bar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

.reading-column {
    max-width: 70ch;
}

.cv-section {
    margin-bottom: var(--space-xl);
}

.cv-section h2 {
    font-size: var(--size-h2);
    margin-bottom: var(--space-md);
}

.timeline {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.timeline-item {
    display: grid;
    grid-template-columns: 140px 1fr;
    grid-template-rows: auto auto;
    gap: var(--space-sm) var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border);
}

.timeline-item:last-child {
    border-bottom: none;
}

.timeline-item .meta {
    grid-column: 1;
    grid-row: 1;
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    line-height: 1.4;
}

.timeline-item h4 {
    grid-column: 2;
    grid-row: 1;
    font-size: var(--size-h3);
    line-height: 1.2;
    margin-bottom: 0;
}

.timeline-item p,
.timeline-item .status {
    grid-column: 2;
    grid-row: auto;
}

.timeline-item p {
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
}

.timeline-item .status {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
}

.skills-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-md);
}

.skill-category h4 {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
}

.skill-category ul {
    list-style: none;
    padding: 0;
}

.skill-category li {
    padding: var(--space-xs) 0;
    border-bottom: 1px solid var(--border);
}

@media (max-width: 767px) {
    .timeline-item {
        grid-template-columns: 1fr;
        gap: var(--space-xs);
    }

    .skills-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* =========================================================
   FOOTER
   ========================================================= */
.site-footer {
    border-top: 1px solid var(--border-strong);
    padding: var(--space-md) 0 var(--space-lg);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* =========================================================
   UTILITIES
   ========================================================= */
.text-muted {
    color: var(--text-muted);
}

.text-center {
    text-align: center;
}

.mt-1 { margin-top: var(--space-xs); }
.mt-2 { margin-top: var(--space-sm); }
.mt-3 { margin-top: var(--space-md); }
.mt-4 { margin-top: var(--space-lg); }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--space-xs); }
.mb-2 { margin-bottom: var(--space-sm); }

/* =========================================================
   PRISM
   ========================================================= */
code[class*="language-"],pre[class*="language-"]{color:#e6edf3;background:0 0;font-family:var(--font-mono);font-size:13px;line-height:1.45;direction:ltr;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;tab-size:2;hyphens:none}
pre[class*="language-"]{padding:1em;margin:.5em 0;overflow:auto;background:#0a0a0a}
:not(pre)>code[class*="language-"],pre[class*="language-"]{background:#0a0a0a}
:not(pre)>code[class*="language-"]{padding:.2em .4em;white-space:normal}
.token.comment,.token.prolog,.token.doctype,.token.cdata{color:#8b949e;font-style:italic}
.token.punctuation{color:#8b949e}
.token.namespace{opacity:.7}
.token.property,.token.tag,.token.constant,.token.symbol,.token.deleted{color:#ff7b72}
.token.boolean,.token.number{color:#79c0ff}
.token.selector,.token.attr-name,.token.string,.token.char,.token.builtin,.token.inserted{color:#a5d6ff}
.token.operator,.token.entity,.token.url,.language-css .token.string,.style .token.string,.token.variable{color:#79c0ff}
.token.atrule,.token.attr-value,.token.function,.token.class-name{color:#d2a8ff}
.token.keyword{color:#ff7b72}
.token.regex,.token.important{color:#ffa657}
.token.important,.token.bold{font-weight:bold}
.token.italic{font-style:italic}
.token.entity{cursor:help}

/* =========================================================
   MOTION PREFERENCE
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
