/* ==========================================================================
   GSanmi — Mathematics notebook
   A "digital textbook" theme: Newsreader serif for prose, Inter for chrome,
   warm paper background, a single muted-teal accent, and textbook-style
   theorem environments. Light + dark mode.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Design tokens
   -------------------------------------------------------------------------- */
:root {
    /* Warm paper light mode */
    --paper:        #f7f4ec;   /* page background — soft warm off-white   */
    --surface:      #fffdf8;   /* cards, raised surfaces                  */
    --ink:          #232020;   /* near-black, faintly warm                */
    --ink-soft:     #555049;   /* secondary text / metadata               */
    --ink-faint:    #8c857b;   /* captions, muted labels                  */
    --rule:         #e3ddd0;   /* hairline dividers                       */
    --rule-strong:  #cfc7b6;   /* stronger dividers                       */

    /* Single accent — muted teal */
    --accent:       #2a6f6b;
    --accent-deep:  #205753;
    --accent-soft:  rgba(42, 111, 107, 0.10);  /* tints for blocks       */
    --accent-line:  rgba(42, 111, 107, 0.55);  /* left borders           */

    /* Code surface */
    --code-bg:      #f1ede2;
    --code-ink:     #34302a;

    /* Typography */
    --font-serif: 'Newsreader', Charter, 'Iowan Old Style', 'Source Serif 4', Georgia, 'Times New Roman', serif;
    --font-sans:  'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-mono:  'JetBrains Mono', 'SFMono-Regular', 'Cascadia Code', Consolas, 'Liberation Mono', Menlo, monospace;

    /* Rhythm */
    --measure: 38rem;          /* reading column ~68 chars                 */
    --sidebar-w: 17rem;
    --topbar-h: 3.5rem;
    --leading: 1.65;

    --radius: 8px;
    --shadow-soft: 0 1px 2px rgba(40, 35, 25, 0.04), 0 6px 22px rgba(40, 35, 25, 0.06);
    --transition: 160ms ease;
}

[data-theme="dark"] {
    --paper:        #16181a;   /* deep charcoal                            */
    --surface:      #1d2023;
    --ink:          #ece6da;   /* warm off-white                           */
    --ink-soft:     #b4ac9e;
    --ink-faint:    #857d70;
    --rule:         #2b2e31;
    --rule-strong:  #3a3e42;

    --accent:       #6fc0b7;
    --accent-deep:  #8ed3cb;
    --accent-soft:  rgba(111, 192, 183, 0.12);
    --accent-line:  rgba(111, 192, 183, 0.55);

    --code-bg:      #1f2225;
    --code-ink:     #d5cfc2;

    --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px rgba(0, 0, 0, 0.35);
}

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

html {
    font-size: 19px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--topbar-h) + 1rem);
}

body {
    font-family: var(--font-serif);
    font-optical-sizing: auto;
    line-height: var(--leading);
    color: var(--ink);
    background-color: var(--paper);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    transition: background-color var(--transition), color var(--transition);
}

::selection { background: var(--accent-soft); }

a {
    color: var(--accent);
    text-decoration: none;
    text-decoration-color: var(--accent-line);
    text-underline-offset: 0.15em;
    transition: color var(--transition);
}
a:hover { color: var(--accent-deep); text-decoration: underline; }

strong, b { font-weight: 600; }
em, i { font-style: italic; }

/* --------------------------------------------------------------------------
   Top bar
   -------------------------------------------------------------------------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.25rem;
    background: color-mix(in srgb, var(--paper) 88%, transparent);
    backdrop-filter: saturate(140%) blur(8px);
    -webkit-backdrop-filter: saturate(140%) blur(8px);
    border-bottom: 1px solid var(--rule);
}

.brand {
    font-family: var(--font-serif);
    font-weight: 500;
    font-size: 1.18rem;
    letter-spacing: -0.01em;
    color: var(--ink);
}
.brand:hover { color: var(--ink); text-decoration: none; }
.brand .brand-mark { color: var(--accent); }

.topbar-spacer { flex: 1; }

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-sans);
}

/* Language toggle */
.lang-toggle {
    display: inline-flex;
    border: 1px solid var(--rule-strong);
    border-radius: 999px;
    overflow: hidden;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.lang-toggle button {
    background: none;
    border: none;
    color: var(--ink-soft);
    padding: 0.28rem 0.6rem;
    cursor: pointer;
    font-family: inherit;
    font-weight: inherit;
    transition: background var(--transition), color var(--transition);
}
.lang-toggle button[aria-pressed="true"] {
    background: var(--accent);
    color: #fff;
}
[data-theme="dark"] .lang-toggle button[aria-pressed="true"] { color: #10211f; }

/* Theme toggle */
.theme-toggle, .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    border: 1px solid var(--rule-strong);
    border-radius: 999px;
    background: none;
    color: var(--ink-soft);
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition);
}
.theme-toggle:hover, .menu-toggle:hover { color: var(--accent); border-color: var(--accent-line); }
.theme-toggle svg, .menu-toggle svg { width: 1.05rem; height: 1.05rem; }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: inline; }

.menu-toggle { display: none; }

/* Search */
.search {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1 1 20rem;
    max-width: 24rem;
}
.search-icon {
    position: absolute;
    left: 0.75rem;
    width: 1rem;
    height: 1rem;
    color: var(--ink-faint);
    pointer-events: none;
}
.search input {
    width: 100%;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--rule-strong);
    border-radius: 999px;
    padding: 0.42rem 0.9rem 0.42rem 2.1rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.search input:focus {
    outline: none;
    border-color: var(--accent-line);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.search input::placeholder { color: var(--ink-faint); }
.search input::-webkit-search-cancel-button { cursor: pointer; }

.search-results {
    position: absolute;
    top: calc(100% + 0.55rem);
    left: 50%;
    transform: translateX(-50%);
    width: min(36rem, 92vw);
    max-height: 72vh;
    overflow-y: auto;
    padding: 0.35rem;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    z-index: 200;
}
.search-result {
    display: block;
    padding: 0.6rem 0.7rem;
    border-radius: 6px;
    color: var(--ink);
}
.search-result + .search-result { border-top: 1px solid var(--rule); }
.search-result:hover { background: var(--accent-soft); text-decoration: none; }
.sr-title { display: block; font-family: var(--font-serif); font-weight: 600; font-size: 1rem; }
.sr-lang {
    font-family: var(--font-sans);
    font-size: 0.62rem;
    color: var(--ink-faint);
    border: 1px solid var(--rule-strong);
    border-radius: 4px;
    padding: 0 0.32em;
    vertical-align: middle;
}
.sr-subject {
    display: block;
    font-family: var(--font-sans);
    font-size: 0.72rem;
    color: var(--accent);
    margin: 0.12rem 0 0.25rem;
}
.sr-snippet {
    display: block;
    font-family: var(--font-sans);
    font-size: 0.8rem;
    line-height: 1.45;
    color: var(--ink-soft);
}
.search-result mark {
    background: transparent;
    color: var(--accent-deep);
    font-weight: 600;
}
.search-empty {
    padding: 0.9rem;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: var(--ink-faint);
    text-align: center;
}

/* --------------------------------------------------------------------------
   Layout: sidebar + content
   -------------------------------------------------------------------------- */
.layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    align-items: start;
}

.sidebar {
    position: sticky;
    top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h));
    overflow-y: auto;
    padding: 2rem 1.25rem 3rem 1.75rem;
    border-right: 1px solid var(--rule);
    font-family: var(--font-sans);
    font-size: 0.86rem;
}

.sidebar .nav-home {
    display: block;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 1.4rem;
    font-size: 0.9rem;
}
.sidebar .nav-home:hover { color: var(--accent); }

.nav-vertical { margin-bottom: 1.3rem; }
.nav-vertical > .nav-vertical-title {
    display: block;
    font-weight: 700;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--ink-faint);
    margin-bottom: 0.5rem;
}
.nav-vertical > .nav-vertical-title:hover { color: var(--accent); }
.nav-vertical[data-active="true"] > .nav-vertical-title { color: var(--accent); }

.nav-subjects { list-style: none; }
.nav-subjects li { margin: 0; }
.nav-subjects a, .nav-subjects span {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.22rem 0.6rem;
    margin-left: -0.6rem;
    border-radius: 6px;
    color: var(--ink-soft);
    border-left: 2px solid transparent;
}
.nav-subjects a:hover {
    color: var(--accent);
    background: var(--accent-soft);
    text-decoration: none;
}
.nav-subjects a[aria-current="true"] {
    color: var(--accent);
    font-weight: 600;
    border-left-color: var(--accent);
    background: var(--accent-soft);
}
.nav-subjects .empty { color: var(--ink-faint); opacity: 0.65; }
.nav-subjects .count {
    font-size: 0.72rem;
    color: var(--ink-faint);
    font-variant-numeric: tabular-nums;
}

.sidebar-footer {
    margin-top: 2rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--rule);
    font-size: 0.78rem;
    color: var(--ink-faint);
}
.sidebar-footer a { color: var(--ink-soft); }

/* Content column */
.content {
    min-width: 0;
    padding: 2.5rem 2rem 5rem;
}
.container {
    max-width: var(--measure);
    margin: 0 auto;
}
.container--wide { max-width: 52rem; }

/* --------------------------------------------------------------------------
   Prose typography
   -------------------------------------------------------------------------- */
.prose { font-size: 1rem; }

.prose p { margin: 0 0 1.15em; }
.prose p, .prose li { hanging-punctuation: first; }

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-serif);
    font-weight: 600;
    line-height: 1.22;
    color: var(--ink);
    letter-spacing: -0.012em;
}

.prose h1 { font-size: 2.1rem; margin: 0 0 0.6em; }
.prose h2 {
    font-size: 1.5rem;
    margin: 2em 0 0.6em;
    padding-bottom: 0.25em;
    border-bottom: 1px solid var(--rule);
}
.prose h3 { font-size: 1.22rem; margin: 1.7em 0 0.5em; }
.prose h4 { font-size: 1.05rem; margin: 1.5em 0 0.4em; color: var(--ink-soft); }

.prose ul, .prose ol { margin: 0 0 1.15em 1.4em; }
.prose li { margin-bottom: 0.35em; }
.prose li > ul, .prose li > ol { margin-top: 0.35em; margin-bottom: 0.35em; }

.prose hr {
    border: none;
    border-top: 1px solid var(--rule-strong);
    margin: 2.5em auto;
    width: 40%;
}

.prose img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1.8em auto;
    border-radius: var(--radius);
}

/* Blockquotes */
.prose blockquote {
    margin: 1.6em 0;
    padding: 0.2em 0 0.2em 1.3em;
    border-left: 3px solid var(--accent-line);
    color: var(--ink-soft);
    font-style: italic;
}
.prose blockquote p:last-child { margin-bottom: 0; }

/* Links inside prose get the underline */
.prose a { text-decoration: underline; text-decoration-thickness: 1px; }

/* --------------------------------------------------------------------------
   Code
   -------------------------------------------------------------------------- */
code, kbd, samp {
    font-family: var(--font-mono);
    font-size: 0.86em;
}
.prose :not(pre) > code {
    background: var(--code-bg);
    color: var(--code-ink);
    padding: 0.12em 0.4em;
    border-radius: 4px;
}
.prose pre {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.55;
    background: var(--code-bg);
    color: var(--code-ink);
    padding: 1.1em 1.3em;
    margin: 1.6em 0;
    border-radius: var(--radius);
    border: 1px solid var(--rule);
    overflow-x: auto;
}
.prose pre code { background: none; padding: 0; font-size: inherit; }
.highlight { margin: 1.6em 0; }
.highlight pre { margin: 0; }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.prose table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.8em 0;
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
}
.prose th, .prose td {
    padding: 0.55em 0.9em;
    text-align: left;
    border-bottom: 1px solid var(--rule);
}
.prose thead th {
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--ink-soft);
    border-bottom: 2px solid var(--rule-strong);
}

/* --------------------------------------------------------------------------
   Footnotes & sidenotes
   -------------------------------------------------------------------------- */
.footnotes {
    margin-top: 3rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--rule);
    font-size: 0.88rem;
    color: var(--ink-soft);
}
.footnotes ol { margin-left: 1.2em; }
a.footnote, a.reversefootnote { text-decoration: none; }
sup a { font-variant-numeric: normal; }

/* Optional Tufte-style margin notes:
   <span class="sidenote">...</span>  — floats into the right margin on wide screens */
.sidenote {
    font-family: var(--font-sans);
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--ink-soft);
    display: block;
    margin: 0.6em 0;
    padding-left: 0.8em;
    border-left: 2px solid var(--rule-strong);
}
@media (min-width: 1280px) {
    .sidenote {
        float: right;
        clear: right;
        width: 13rem;
        margin-right: -15rem;
        margin-top: 0;
        padding-left: 0;
        border-left: none;
    }
}

/* --------------------------------------------------------------------------
   Theorem environments — the signature touch
   Authoring (Markdown):

     <div class="theorem" markdown="1">
     **Theorem 2.3.** Every Cauchy sequence in $\R$ converges.
     </div>

   Use class: definition | theorem | lemma | proposition | corollary
              | remark | example | proof
   -------------------------------------------------------------------------- */
.definition, .theorem, .lemma, .proposition, .corollary,
.remark, .example, .proof {
    margin: 1.7em 0;
    padding: 1em 1.25em 1em 1.4em;
    border-radius: var(--radius);
    border-left: 3px solid var(--accent-line);
    background: var(--accent-soft);
}
.definition > :last-child, .theorem > :last-child,
.lemma > :last-child, .proposition > :last-child,
.corollary > :last-child, .remark > :last-child,
.example > :last-child, .proof > :last-child { margin-bottom: 0; }

/* The opening bold run acts as the label: "Theorem 2.3." */
.definition > p:first-child > strong:first-child,
.theorem > p:first-child > strong:first-child,
.lemma > p:first-child > strong:first-child,
.proposition > p:first-child > strong:first-child,
.corollary > p:first-child > strong:first-child,
.remark > p:first-child > strong:first-child,
.example > p:first-child > strong:first-child,
.proof > p:first-child > strong:first-child {
    font-family: var(--font-sans);
    font-weight: 700;
    font-style: normal;
    letter-spacing: 0.01em;
    color: var(--accent-deep);
    margin-right: 0.15em;
}

/* Italic body for assertion-type results */
.theorem, .lemma, .proposition, .corollary { font-style: italic; }
.theorem > p:first-child > strong:first-child,
.lemma > p:first-child > strong:first-child,
.proposition > p:first-child > strong:first-child,
.corollary > p:first-child > strong:first-child { font-style: normal; }

/* Definitions, remarks, examples — softer, no fill, just a border */
.definition, .remark, .example {
    background: transparent;
    border-left-color: var(--rule-strong);
}
.definition > p:first-child > strong:first-child { color: var(--accent-deep); }
.remark, .example { color: var(--ink-soft); }
.remark > p:first-child > strong:first-child,
.example > p:first-child > strong:first-child { color: var(--ink); }

/* Proof: no fill, QED tombstone */
.proof {
    background: transparent;
    border-left-color: var(--rule-strong);
    font-style: normal;
}
.proof > p:first-child > strong:first-child { color: var(--ink-soft); font-style: italic; }
.proof::after {
    content: "\220E";          /* ∎ */
    display: block;
    text-align: right;
    margin-top: 0.2em;
    color: var(--ink-soft);
}

/* --------------------------------------------------------------------------
   MathJax — keep equations on-color, breathing room, mobile scroll
   -------------------------------------------------------------------------- */
mjx-container { color: var(--ink) !important; }
mjx-container[display="true"] {
    display: block;
    margin: 1.5em 0 !important;
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    padding: 0.4em 0.1em;
}
.prose mjx-container[display="false"] { vertical-align: baseline; }
mjx-container::-webkit-scrollbar { height: 6px; }
mjx-container::-webkit-scrollbar-thumb { background: var(--rule-strong); border-radius: 3px; }

/* --------------------------------------------------------------------------
   Post header & meta
   -------------------------------------------------------------------------- */
.post-header { margin-bottom: 2.2rem; }
.post-eyebrow {
    font-family: var(--font-sans);
    font-size: 0.74rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
    margin-bottom: 0.6rem;
}
.post-title {
    font-size: 2.25rem;
    line-height: 1.15;
    letter-spacing: -0.018em;
    margin-bottom: 0.45rem;
}
.post-subtitle {
    font-size: 1.18rem;
    font-style: italic;
    color: var(--ink-soft);
    margin-bottom: 1rem;
    line-height: 1.4;
}
.post-meta {
    font-family: var(--font-sans);
    font-size: 0.82rem;
    color: var(--ink-faint);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    align-items: center;
}
.post-meta .lang-badge {
    border: 1px solid var(--rule-strong);
    border-radius: 4px;
    padding: 0.05em 0.4em;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.post-tags {
    margin-top: 2.5rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--rule);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    color: var(--ink-faint);
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}
.tag {
    display: inline-block;
    padding: 0.16em 0.6em;
    border: 1px solid var(--rule-strong);
    border-radius: 999px;
    color: var(--ink-soft);
}
.tag:hover { border-color: var(--accent-line); color: var(--accent); }

/* Prev/next */
.post-nav {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--rule);
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-family: var(--font-sans);
    font-size: 0.9rem;
}
.post-nav a { max-width: 47%; color: var(--ink-soft); }
.post-nav a:hover { color: var(--accent); }
.post-nav .nav-dir {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-faint);
    margin-bottom: 0.15rem;
}
.post-nav .next { text-align: right; margin-left: auto; }

/* --------------------------------------------------------------------------
   Landing page — vertical cards
   -------------------------------------------------------------------------- */
.home-hero { margin-bottom: 2.8rem; }
.home-hero h1 {
    font-size: 2.6rem;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}
.home-hero .lede {
    font-size: 1.18rem;
    color: var(--ink-soft);
    font-style: italic;
    max-width: 34rem;
}

.vertical-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr));
    gap: 1.1rem;
}
.vcard {
    display: block;
    padding: 1.4rem 1.5rem;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    color: var(--ink);
    transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.vcard:hover {
    color: var(--ink);
    text-decoration: none;
    border-color: var(--accent-line);
    transform: translateY(-2px);
    box-shadow: var(--shadow-soft);
}
.vcard h2 {
    font-size: 1.3rem;
    margin-bottom: 0.35rem;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
}
.vcard .vcard-count {
    font-family: var(--font-sans);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-soft);
    border-radius: 999px;
    padding: 0.1em 0.6em;
}
.vcard .vcard-blurb { color: var(--ink-soft); font-size: 0.95rem; margin-bottom: 0.7rem; }
.vcard .vcard-subjects {
    font-family: var(--font-sans);
    font-size: 0.8rem;
    color: var(--ink-faint);
    line-height: 1.5;
}

/* --------------------------------------------------------------------------
   Vertical / listing pages
   -------------------------------------------------------------------------- */
.page-head { margin-bottom: 2.5rem; }
.page-head .eyebrow {
    font-family: var(--font-sans);
    font-size: 0.74rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
    margin-bottom: 0.5rem;
}
.page-head h1 { font-size: 2.3rem; margin-bottom: 0.4rem; }
.page-head .lede { color: var(--ink-soft); font-style: italic; font-size: 1.1rem; }

.subject-block { margin-bottom: 2.8rem; scroll-margin-top: calc(var(--topbar-h) + 1rem); }
.subject-block > h2 {
    font-size: 1.35rem;
    margin-bottom: 0.9rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--rule);
}
.subject-block .subject-empty {
    color: var(--ink-faint);
    font-style: italic;
    font-size: 0.95rem;
}

.entry-list { list-style: none; }
.entry {
    padding: 0.9rem 0;
    border-bottom: 1px solid var(--rule);
}
.entry:last-child { border-bottom: none; }
.entry .entry-title { font-size: 1.12rem; font-weight: 600; margin-bottom: 0.2rem; }
.entry .entry-title a { color: var(--ink); text-decoration: none; }
.entry .entry-title a:hover { color: var(--accent); }
.entry .entry-sub { color: var(--ink-soft); font-size: 0.96rem; margin-bottom: 0.25rem; }
.entry .entry-meta {
    font-family: var(--font-sans);
    font-size: 0.78rem;
    color: var(--ink-faint);
    font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.site-footer {
    border-top: 1px solid var(--rule);
    padding: 1.6rem 2rem;
    font-family: var(--font-sans);
    font-size: 0.8rem;
    color: var(--ink-faint);
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.site-footer a { color: var(--ink-soft); }
.site-footer a:hover { color: var(--accent); }

/* --------------------------------------------------------------------------
   Bilingual visibility — toggled via [data-lang] on <html>
   -------------------------------------------------------------------------- */
[data-lang="en"] .i18n-es,
[data-lang="es"] .i18n-en { display: none; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
.sidebar-backdrop { display: none; }

@media (max-width: 920px) {
    html { font-size: 18px; }
    .menu-toggle { display: inline-flex; }
    .layout { grid-template-columns: 1fr; }
    .search { flex: 1 1 auto; max-width: 20rem; }

    .sidebar {
        position: fixed;
        top: var(--topbar-h);
        left: 0;
        width: min(20rem, 82vw);
        height: calc(100vh - var(--topbar-h));
        background: var(--paper);
        border-right: 1px solid var(--rule);
        transform: translateX(-105%);
        transition: transform var(--transition);
        z-index: 90;
        box-shadow: var(--shadow-soft);
    }
    body.nav-open .sidebar { transform: translateX(0); }
    body.nav-open .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: var(--topbar-h) 0 0 0;
        background: rgba(0,0,0,0.35);
        z-index: 80;
    }
    .content { padding: 2rem 1.3rem 4rem; }
}

@media (max-width: 560px) {
    html { font-size: 17px; }
    .post-title { font-size: 1.8rem; }
    .home-hero h1 { font-size: 2.1rem; }
    .brand { font-size: 1.05rem; }
    .lang-toggle { display: none; }   /* keep top bar uncluttered on phones */
    .topbar-spacer { display: none; }
    .search { max-width: none; margin-left: 0.5rem; }
    .content { padding: 1.6rem 1.1rem 3.5rem; }
    .vertical-grid { grid-template-columns: 1fr; }
}

/* --------------------------------------------------------------------------
   Print
   -------------------------------------------------------------------------- */
@media print {
    .topbar, .sidebar, .site-footer, .post-nav, .menu-toggle { display: none !important; }
    .layout { grid-template-columns: 1fr; }
    body { background: #fff; color: #000; }
    .content { padding: 0; }
    a { color: #000; text-decoration: none; }
}

/* --------------------------------------------------------------------------
   Syntax highlighting (Rouge) — warm, low-contrast academic palette
   -------------------------------------------------------------------------- */
.highlight .c, .highlight .c1, .highlight .cm, .highlight .cs, .highlight .ch { color: #8a857b; font-style: italic; }
.highlight .cp, .highlight .cpf { color: #9a6a2f; font-weight: 600; }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kp, .highlight .kr { color: var(--accent-deep); font-weight: 600; }
.highlight .kt { color: #2f6f8f; font-weight: 600; }
.highlight .bp, .highlight .kc { color: #7a4fa3; font-weight: 600; }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sb, .highlight .se,
.highlight .sh, .highlight .si, .highlight .sx, .highlight .sr, .highlight .ss { color: #9a6a2f; }
.highlight .sc { color: #a5402f; }
.highlight .sd { color: #8a857b; font-style: italic; }
.highlight .m, .highlight .mi, .highlight .mf, .highlight .mh, .highlight .mo, .highlight .mb, .highlight .il { color: #a5402f; }
.highlight .nf, .highlight .fm { color: #2f6f8f; }
.highlight .nc { color: #2f6f8f; font-weight: 600; }
.highlight .nb { color: #7a4fa3; }
.highlight .nn { color: #2f6f8f; }
.highlight .nd { color: #7a4fa3; }
.highlight .o, .highlight .ow { color: var(--ink-soft); }
.highlight .n, .highlight .na, .highlight .ni, .highlight .nl, .highlight .no,
.highlight .nt, .highlight .nv, .highlight .vc, .highlight .vg, .highlight .vi, .highlight .vm { color: var(--code-ink); }
.highlight .err { color: #cc0000; }

[data-theme="dark"] .highlight .kt { color: #7fb6d6; }
[data-theme="dark"] .highlight .nf, [data-theme="dark"] .highlight .fm,
[data-theme="dark"] .highlight .nc, [data-theme="dark"] .highlight .nn { color: #7fb6d6; }
[data-theme="dark"] .highlight .bp, [data-theme="dark"] .highlight .kc,
[data-theme="dark"] .highlight .nb, [data-theme="dark"] .highlight .nd { color: #c2a0e0; }
[data-theme="dark"] .highlight .s, [data-theme="dark"] .highlight .s1, [data-theme="dark"] .highlight .s2,
[data-theme="dark"] .highlight .cp { color: #d8a86a; }
[data-theme="dark"] .highlight .m, [data-theme="dark"] .highlight .mi, [data-theme="dark"] .highlight .mf,
[data-theme="dark"] .highlight .sc { color: #e0907e; }

/* --------------------------------------------------------------------------
   Legacy section pages (maths.html, zkp.html, posts.html, real-analysis.html …)
   kept reachable but not yet migrated to the vertical layout. These styles
   make the old .category-page / .post-list markup look at home in the theme.
   -------------------------------------------------------------------------- */
.category-page, .legacy {
    max-width: 52rem;
    margin: 0 auto;
    font-family: var(--font-serif);
}
.category-page > h1 { font-size: 2.3rem; margin-bottom: 0.4rem; }
.category-page .description {
    color: var(--ink-soft);
    font-style: italic;
    font-size: 1.1rem;
    margin-bottom: 2rem;
}
.category-page .post-list { list-style: none; margin: 0; }
.category-page .post-list-item {
    padding: 0.9rem 0;
    border-bottom: 1px solid var(--rule);
}
.category-page .post-list-item:last-child { border-bottom: none; }
.category-page .post-list-title { font-size: 1.12rem; font-weight: 600; margin-bottom: 0.2rem; }
.category-page .post-list-title a { color: var(--ink); }
.category-page .post-list-title a:hover { color: var(--accent); }
.category-page .post-meta {
    font-family: var(--font-sans);
    font-size: 0.8rem;
    color: var(--ink-faint);
    display: block;
    margin-bottom: 0.25rem;
}
.category-page .post-excerpt { color: var(--ink-soft); font-size: 0.96rem; }
.category-page .category {
    display: inline-block;
    font-family: var(--font-sans);
    font-size: 0.7rem;
    color: var(--ink-soft);
    border: 1px solid var(--rule-strong);
    border-radius: 999px;
    padding: 0.05em 0.55em;
    margin-left: 0.3em;
}
