/* ===== Google Fonts ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ===== Themes ===== */
:root {
    /* Dark theme (default) */
    --color-bg:        #090e1a;
    --color-bg2:       #0d1526;
    --color-surface:   #111d35;
    --color-border:    #1e2d4a;
    --color-text:      #e2e8f0;
    --color-muted:     #64748b;
    --color-accent:    #00c9b1;
    --color-accent-dim:#00c9b120;
    --color-heading:   #f1f5f9;

    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --max-width: 740px;
    --radius: 4px;
    --transition: 200ms ease;
}

[data-theme="light"] {
    --color-bg:        #f4f6f9;
    --color-bg2:       #edf0f5;
    --color-surface:   #ffffff;
    --color-border:    #d1dae8;
    --color-text:      #1e293b;
    --color-muted:     #64748b;
    --color-accent:    #0097a7;
    --color-accent-dim:#0097a720;
    --color-heading:   #0f172a;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
}

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 99px; }
::-webkit-scrollbar-track { background: transparent; }

body {
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-sans);
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background var(--transition), color var(--transition);
    -webkit-font-smoothing: antialiased;
}

main { flex: 1; }
a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Typography ===== */
h1, h2, h3 { color: var(--color-heading); font-weight: 700; line-height: 1.2; }
h1 { font-size: 2.25rem; letter-spacing: -0.02em; }
h2 { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.12em; color: var(--color-accent); margin-bottom: 2rem; }
h3 { font-size: 1.05rem; font-weight: 600; }
p  { margin-bottom: 1rem; color: var(--color-text); }

/* ===== Layout ===== */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 2rem;
}

/* ===== Nav ===== */
.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    transition: background var(--transition);
}

.nav__inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 2rem;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 2rem;
}

.nav__logo {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--color-heading);
    margin-right: auto;
    letter-spacing: 0;
    display: flex;
    align-items: center;
    gap: 0.4em;
}
.nav__logo:hover { text-decoration: none; color: var(--color-heading); }
.nav__logo::after {
    content: '_';
    color: var(--color-accent);
    animation: blink 1s steps(1) infinite;
}
.nav__logo-prompt { color: var(--color-accent); }

@keyframes blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}

.nav__links {
    list-style: none;
    display: flex;
    gap: 0.25rem;
}

.nav__links a {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-muted);
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius);
    transition: color var(--transition), background var(--transition);
}
.nav__links a:hover { color: var(--color-heading); background: var(--color-surface); text-decoration: none; }

.nav__lang {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 500;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.25rem 0.5rem;
    color: var(--color-muted);
    transition: border-color var(--transition), color var(--transition);
}
.nav__lang:hover { border-color: var(--color-accent); color: var(--color-accent); text-decoration: none; }

/* Theme toggle — data URI avoids SVG parsing issues in Thymeleaf fragments */
.nav__theme {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    width: 32px;
    height: 32px;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 15px 15px;
    transition: border-color var(--transition), background-image var(--transition);
    flex-shrink: 0;
    /* Dark mode default: show moon */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z'/%3E%3C/svg%3E");
}
.nav__theme:hover {
    border-color: var(--color-accent);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300c9b1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z'/%3E%3C/svg%3E");
}
/* Light mode: show sun */
[data-theme="light"] .nav__theme {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='5'/%3E%3Cpath d='M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42'/%3E%3C/svg%3E");
}
[data-theme="light"] .nav__theme:hover {
    border-color: var(--color-accent);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230097a7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='5'/%3E%3Cpath d='M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42'/%3E%3C/svg%3E");
}

/* ===== Hero ===== */
.hero {
    padding: 7rem 2rem 5rem;
    max-width: var(--max-width);
    margin: 0 auto;
}

.hero__label {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--color-accent);
    letter-spacing: 0.08em;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.hero__label::before {
    content: '';
    display: inline-block;
    width: 24px;
    height: 1px;
    background: var(--color-accent);
}

.tooltip { position: relative; cursor: default; }
.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    background: var(--color-surface, #1e1e1e);
    color: var(--color-text, #e0e0e0);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    white-space: nowrap;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    border: 1px solid var(--color-accent);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}
.tooltip:hover::after { opacity: 1; }

.hero h1 { font-size: 3rem; margin-bottom: 1rem; }
.hero h1 span { color: var(--color-accent); }

.hero__bio {
    font-size: 1.05rem;
    color: var(--color-muted);
    max-width: 480px;
    line-height: 1.8;
    margin-bottom: 2.5rem;
}

.hero__cta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.55rem 1.25rem;
    border-radius: var(--radius);
    transition: background var(--transition), color var(--transition), border-color var(--transition);
    text-decoration: none !important;
}

.btn--primary {
    background: var(--color-accent);
    color: #090e1a;
    border: 1px solid var(--color-accent);
}
.btn--primary:hover { background: transparent; color: var(--color-accent); }

.btn--ghost {
    border: 1px solid var(--color-border);
    color: var(--color-muted);
}
.btn--ghost:hover { border-color: var(--color-accent); color: var(--color-accent); }

/* ===== Sections ===== */
.section {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 4rem 2rem;
    border-top: 1px solid var(--color-border);
}

/* ===== Tabs ===== */
.tabs__nav {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 2rem;
}

.tabs__btn {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    padding: 0.6rem 1.25rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--color-muted);
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition);
    letter-spacing: 0.03em;
}
.tabs__btn:hover { color: var(--color-text); }
.tabs__btn.active {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
}

.tabs__panel {
    display: none;
    animation: fadeIn 0.15s ease;
}
.tabs__panel.active { display: block; }

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

.tabs__label {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-accent);
    margin: 1.75rem 0 0.6rem;
}

.tabs__stack {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--color-text);
    line-height: 1.8;
}

.tabs__muted {
    color: var(--color-muted);
    font-size: 0.9rem;
    margin-top: 1rem;
}

/* ===== Post list ===== */
.post-list {
    list-style: none;
    display: flex;
    flex-direction: column;
}

.post-list__item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem 1.5rem;
    align-items: baseline;
    padding: 1.1rem 0;
    border-bottom: 1px solid var(--color-border);
}
.post-list__item:first-child { border-top: 1px solid var(--color-border); }

.post-list__title {
    font-weight: 500;
    color: var(--color-heading);
    font-size: 0.95rem;
    transition: color var(--transition);
}
.post-list__title:hover { color: var(--color-accent); text-decoration: none; }

.post-list__desc {
    grid-column: 1;
    font-size: 0.85rem;
    color: var(--color-muted);
    margin: 0;
}

.post-list__date {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--color-muted);
    white-space: nowrap;
}

.section__footer {
    margin-top: 2rem;
}

/* ===== Blog post ===== */
.post {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 4rem 2rem;
}

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

.post__tag {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--color-accent);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 1rem;
    display: block;
}

.post__header h1 { font-size: 2rem; margin-bottom: 0.75rem; }

.post__meta {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--color-muted);
}

/* Post content */
.post__content { line-height: 1.85; font-size: 1.02rem; }

.post__content h2,
.post__content h3 {
    color: var(--color-heading);
    text-transform: none;
    letter-spacing: normal;
    margin: 2.5rem 0 1rem;
}
.post__content h2 { font-size: 1.3rem; }
.post__content h3 { font-size: 1.05rem; }

.post__content p { margin-bottom: 1.4rem; }

.post__content a { color: var(--color-accent); }

.post__content pre {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}
.post__content code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    padding: 0.1em 0.4em;
    border-radius: 3px;
}
.post__content pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: inherit;
}

.post__content blockquote {
    border-left: 2px solid var(--color-accent);
    padding-left: 1.25rem;
    color: var(--color-muted);
    margin: 1.5rem 0;
    font-style: italic;
}

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

.post__content img {
    max-width: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
}

.post__content hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 2.5rem 0;
}

.post__footer {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

/* ===== Footer ===== */
.footer {
    border-top: 1px solid var(--color-border);
    padding: 2rem;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--color-muted);
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
    .hero { padding: 4rem 1.25rem 3rem; }
    .hero h1 { font-size: 2rem; }
    .section, .post { padding: 3rem 1.25rem; }
    .nav__inner { padding: 0 1.25rem; gap: 1rem; }
    .post-list__item { grid-template-columns: 1fr; }
    .post-list__date { display: none; }
}