:root {
    --navy:        #0f2c4f;   /* brand + headings */
    --navy-strong: #0a1f3a;
    --text:        #23313f;   /* body text */
    --muted:       #62748a;   /* secondary text */
    --accent:      #e8620c;   /* orange accent */
    --accent-weak: #fbe9dc;
    --link:        #14477f;   /* dark-blue links */
    --border:      #e7ebf0;
    --border-mid:  #d7dee7;
    --surface:     #ffffff;
    --surface-alt: #f6f8fb;
    --maxw:        1200px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.65;
    color: var(--text);
    background: var(--surface);
    font-size: 17px;
}

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

main {
    max-width: var(--maxw);
    margin: 48px auto;
    padding: 0 20px;
}

/* ---------- Header bar ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.88);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 12px rgba(15, 44, 79, 0.05);
}

.header-inner {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

/* ---------- Brand (top-left) ---------- */
.brand {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.brand-link {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.brand-link:hover { text-decoration: none; }

.header-logo {
    height: 34px;
    width: auto;
    display: block;
}

.brand-title {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--navy);
    transition: color 0.15s ease;
}

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

.brand-tagline {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--muted);
    margin-top: 2px;
}

/* ---------- Hamburger toggle (mobile only, CSS-only) ---------- */
/* Checkbox is visually hidden but stays focusable/announced; the <label>
   is the visible button. Both hidden on desktop, shown in the mobile query. */
.nav-toggle {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

.nav-toggle-btn {
    display: none; /* revealed at the mobile breakpoint */
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 42px;
    height: 42px;
    padding: 9px;
    border: 1px solid var(--border-mid);
    border-radius: 10px;
    background: var(--surface);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.nav-toggle-bar {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--navy);
    border-radius: 2px;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

/* ---------- Nav (top-right) ---------- */
.main-nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    flex-wrap: wrap;
}

.nav-item {
    position: relative;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.15s ease, background 0.15s ease;
}

.main-nav > .nav-item:hover,
.nav-dropdown-toggle:hover {
    color: var(--navy);
    background: var(--surface-alt);
    text-decoration: none;
}

/* Dropdown (one level, CSS-only, opens on hover / keyboard focus) */
.nav-dropdown {
    position: relative;
    display: inline-flex;
}

.nav-dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.nav-caret {
    font-size: 0.7em;
    opacity: 0.7;
}

.nav-submenu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    min-width: 180px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(15, 44, 79, 0.12);
    z-index: 200;
}

/* Invisible bridge across the gap so hover isn't lost between toggle and menu */
.nav-submenu::before {
    content: "";
    position: absolute;
    top: -8px;
    left: 0;
    right: 0;
    height: 8px;
}

.nav-dropdown:hover > .nav-submenu,
.nav-dropdown:focus-within > .nav-submenu {
    display: block;
}

.nav-submenu .nav-item {
    display: block;
    text-align: left;
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--navy);
    border-radius: 6px;
    white-space: nowrap;
}

.nav-submenu .nav-item:hover {
    background: var(--accent-weak);
    color: var(--accent);
}

/* ---------- Typography / content ---------- */
h1, h2, h3, h4 {
    color: var(--navy);
    line-height: 1.25;
}

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

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

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 32px 0;
}

/* ---------- Posts ---------- */
.post {
    padding: 22px 24px;
    margin-top: 18px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.post:hover {
    border-color: var(--border-mid);
    box-shadow: 0 6px 24px rgba(15, 44, 79, 0.07);
}

.post-meta {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.post-title {
    margin: 4px 0 10px;
    font-size: 1.35rem;
}

.post-title a { color: var(--navy); }
.post-title a:hover { color: var(--accent); text-decoration: none; }

.post-content { color: var(--text); }

/* ---------- Code ---------- */
pre {
    background: var(--surface-alt);
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow-x: auto;
    white-space: pre-wrap;
    font-size: 0.9em;
}

code {
    background: var(--surface-alt);
    padding: 0.15em 0.4em;
    border-radius: 5px;
    font-size: 0.9em;
}

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

/* ---------- Footer ---------- */
footer {
    max-width: var(--maxw);
    margin: 72px auto 40px;
    padding: 24px 20px 0;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
}

footer p {
    font-size: 0.75rem;
    margin: 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .header-inner {
        flex-wrap: wrap;
        align-items: center;
        gap: 12px;
    }

    /* Push the hamburger to the far right, keep the brand on the left */
    .brand { margin-right: auto; }

    /* Show the hamburger button */
    .nav-toggle-btn { display: inline-flex; }
    .nav-toggle-btn:hover {
        background: var(--surface-alt);
        border-color: var(--muted);
    }
    /* Keyboard focus ring lands on the visible button */
    .nav-toggle:focus-visible ~ .nav-toggle-btn {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
    }

    /* Collapsed by default; nav drops to a full-width panel below the bar */
    .main-nav {
        flex-basis: 100%;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        gap: 2px;
        margin-left: 0;
        max-height: 0;
        opacity: 0;
        overflow: hidden;
        transition: max-height 0.25s ease, opacity 0.2s ease;
    }
    .nav-toggle:checked ~ .main-nav {
        max-height: 80vh;
        opacity: 1;
        overflow-y: auto;
        padding-top: 6px;
    }

    /* Full-width, tappable rows */
    .nav-item {
        display: block;
        padding: 12px;
        font-size: 0.85rem;
        border-radius: 8px;
    }

    /* Dropdowns flow inline (no hover on touch) — children shown indented */
    .nav-dropdown { display: block; }
    .nav-caret { display: none; }
    .nav-submenu {
        display: block;
        position: static;
        min-width: 0;
        margin: 0 0 0 12px;
        padding: 0;
        background: transparent;
        border: none;
        border-radius: 0;
        box-shadow: none;
    }
    .nav-submenu::before { display: none; }
    .nav-submenu .nav-item { padding: 10px 12px; }

    /* Animate the bars into an "X" when open */
    .nav-toggle:checked ~ .nav-toggle-btn .nav-toggle-bar:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }
    .nav-toggle:checked ~ .nav-toggle-btn .nav-toggle-bar:nth-child(2) {
        opacity: 0;
    }
    .nav-toggle:checked ~ .nav-toggle-btn .nav-toggle-bar:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    .brand-tagline { display: none; }
}
