/* ==========================================================================
   Blog Styles - Warm Academic Aesthetic
   Inspired by Transformer Circuits + Distill
   Typography follows Bringhurst principles
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Custom Properties
   -------------------------------------------------------------------------- */
:root {
    /* Colors */
    --color-bg: #faf9f5;
    --color-text: rgba(0, 0, 0, 0.8);
    --color-text-muted: rgba(0, 0, 0, 0.5);
    --color-accent: hsl(200, 50%, 25%);
    --color-accent-hover: hsl(200, 50%, 35%);
    --color-code-bg: #f4f1eb;
    --color-code-border: #e5e0d8;
    --color-rule: #d4d0c8;

    /* Typography - Bringhurst */
    --font-body: Georgia, Cambria, "Times New Roman", Times, serif;
    --font-heading: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    --font-code: "SF Mono", Consolas, "Liberation Mono", Menlo, Courier, monospace;

    --font-size-base: 18px;
    --line-height: 1.45;
    --measure: 38em; /* ~680px, targeting 66 characters */

    /* Modular scale 1.25 */
    --scale-1: 1.25em;
    --scale-2: 1.563em;
    --scale-3: 1.953em;
    --scale-4: 2.441em;
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: var(--font-size-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-body);
    line-height: var(--line-height);
}

/* --------------------------------------------------------------------------
   Header / Navigation
   -------------------------------------------------------------------------- */
.blog-header {
    padding: 1.5rem 1rem;
    max-width: var(--measure);
    margin: 0 auto;
}

.blog-header nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-heading);
    font-size: 0.9rem;
}

.blog-header a {
    color: var(--color-text);
    text-decoration: none;
}

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

.blog-header .site-name {
    font-weight: 500;
}

/* --------------------------------------------------------------------------
   Main Content Container
   -------------------------------------------------------------------------- */
main {
    max-width: var(--measure);
    margin: 0 auto;
    padding: 0 1rem 4rem;
}

/* --------------------------------------------------------------------------
   Article / Post
   -------------------------------------------------------------------------- */
article {
    margin-top: 2rem;
}

.post-header {
    margin-bottom: 3rem;
}

.post-title {
    font-family: var(--font-heading);
    font-size: var(--scale-4);
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin: 0 0 0.5rem;
}

.post-meta {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    color: var(--color-text-muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* --------------------------------------------------------------------------
   Typography - Headings
   -------------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 500;
    letter-spacing: -0.02em;
    margin-top: 2.5em;
    margin-bottom: 0.5em;
    line-height: 1.25;
}

h1 { font-size: var(--scale-4); font-weight: 600; }
h2 { font-size: var(--scale-3); }
h3 { font-size: var(--scale-2); }
h4 { font-size: var(--scale-1); }
h5, h6 { font-size: 1em; }

/* First heading after post header needs less top margin */
.post-content > h2:first-child {
    margin-top: 0;
}

/* --------------------------------------------------------------------------
   Track Links (YouTube icons on section headings)
   -------------------------------------------------------------------------- */
.track-link {
    display: inline-block;
    margin-left: 0.4em;
    opacity: 0;
    transition: opacity 0.2s ease;
    text-decoration: none;
    vertical-align: middle;
}

h2:hover .track-link {
    opacity: 0.5;
}

.track-link:hover {
    opacity: 1 !important;
}

.track-link svg {
    width: 0.6em;
    height: 0.6em;
    fill: var(--color-accent);
    vertical-align: baseline;
    position: relative;
    top: -0.1em;
}

/* --------------------------------------------------------------------------
   Typography - Body Elements
   -------------------------------------------------------------------------- */
p {
    margin: 0 0 1.25em;
}

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

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

strong {
    font-weight: 600;
}

em {
    font-style: italic;
}

/* --------------------------------------------------------------------------
   Lists
   -------------------------------------------------------------------------- */
ul, ol {
    margin: 0 0 1.25em;
    padding-left: 1.5em;
    line-height: 1.4;
}

li {
    margin-bottom: 0.35em;
}

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

/* --------------------------------------------------------------------------
   Blockquotes
   -------------------------------------------------------------------------- */
blockquote {
    margin: 1.5em 0;
    padding: 0.25em 0 0.25em 1.5em;
    border-left: 3px solid var(--color-accent);
    color: var(--color-text);
}

blockquote p {
    margin-bottom: 0.75em;
}

blockquote p:last-child {
    margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   Horizontal Rules
   -------------------------------------------------------------------------- */
hr {
    border: none;
    border-top: 1px solid var(--color-rule);
    margin: 3em 0;
    width: 100vw;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
}

/* --------------------------------------------------------------------------
   Code - Inline
   -------------------------------------------------------------------------- */
code {
    font-family: var(--font-code);
    font-size: 0.875em;
    background-color: var(--color-code-bg);
    padding: 0.15em 0.35em;
    border-radius: 3px;
}

/* --------------------------------------------------------------------------
   Code - Blocks
   -------------------------------------------------------------------------- */
pre {
    font-family: var(--font-code);
    font-size: 0.875em;
    line-height: 1.5;
    background-color: var(--color-code-bg);
    border: none;
    border-radius: 0;
    padding: 1.25em calc(50vw - var(--measure) / 2 + 1rem);
    margin: 1.5em 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100vw;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
}

pre code {
    background: none;
    padding: 0;
    font-size: inherit;
    display: block;
    max-width: var(--measure);
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
    font-size: 0.9em;
}

th, td {
    padding: 0.5em 0.75em;
    text-align: left;
    border-bottom: 1px solid var(--color-code-border);
}

th {
    font-family: var(--font-heading);
    font-weight: 500;
}

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

figure {
    margin: 2em 0;
}

figcaption {
    font-size: 0.85em;
    color: var(--color-text-muted);
    margin-top: 0.5em;
}

/* --------------------------------------------------------------------------
   Introduction
   -------------------------------------------------------------------------- */
.introduction {
    margin: 0 0 3em;
    padding: 2em calc(50vw - var(--measure) / 2 + 1rem);
    background: linear-gradient(180deg, var(--color-bg) 0%, #f5f3ef 100%);
    width: 100vw;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
}

.introduction > *:first-child {
    margin-top: 0;
}

.introduction > *:last-child {
    margin-bottom: 0;
}

@media (max-width: 600px) {
    .introduction {
        padding: 1.5em 1rem;
    }
}

/* --------------------------------------------------------------------------
   Conclusion
   -------------------------------------------------------------------------- */
.conclusion {
    margin: 3em 0 0;
    padding: 2em calc(50vw - var(--measure) / 2 + 1rem);
    background: linear-gradient(180deg, #f5f3ef 0%, var(--color-bg) 100%);
    width: 100vw;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
}

.conclusion > *:first-child {
    margin-top: 0;
}

.conclusion > *:last-child {
    margin-bottom: 0;
}

@media (max-width: 600px) {
    .conclusion {
        padding: 1.5em 1rem;
    }
}

/* --------------------------------------------------------------------------
   Post Footer
   -------------------------------------------------------------------------- */
.post-footer {
    margin-top: 4em;
    padding-top: 2em;
    border-top: 1px solid var(--color-rule);
}

.post-footer a {
    font-family: var(--font-heading);
    font-size: 0.9rem;
}

/* --------------------------------------------------------------------------
   Blog Index
   -------------------------------------------------------------------------- */
.blog-index h1 {
    font-family: var(--font-heading);
    font-size: var(--scale-3);
    font-weight: 600;
    margin-top: 1em;
    margin-bottom: 2em;
}

.post-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.post-list-item {
    margin-bottom: 2.5em;
}

.post-list-title {
    font-family: var(--font-heading);
    font-size: var(--scale-1);
    font-weight: 500;
    margin: 0 0 0.25em;
    line-height: 1.3;
}

.post-list-title a {
    color: var(--color-text);
}

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

.post-list-date {
    font-family: var(--font-heading);
    font-size: 0.8rem;
    color: var(--color-text-muted);
    letter-spacing: 0.03em;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 600px) {
    html {
        font-size: 17px;
    }

    .post-title {
        font-size: var(--scale-3);
    }

    pre {
        padding: 1em 1rem;
        font-size: 0.8em;
    }

    .highlight {
        padding: 0 1rem;
    }

    .highlight pre {
        padding: 1em 0;
    }
}

/* ==========================================================================
   Syntax Highlighting - Rouge
   Warm, muted theme complementing the paper aesthetic
   ========================================================================== */

.highlight {
    background-color: var(--color-code-bg);
    border: none;
    border-radius: 0;
    margin: 1.5em 0;
    width: 100vw;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
    padding: 0 calc(50vw - var(--measure) / 2 + 1rem);
}

.highlight pre {
    margin: 0;
    border: none;
    background: none;
    width: auto;
    position: static;
    left: auto;
    transform: none;
    padding: 1.25em 0;
    max-width: var(--measure);
}

/* Comment */
.highlight .c,
.highlight .c1,
.highlight .cm,
.highlight .cs {
    color: #7a8288;
    font-style: italic;
}

/* Keyword */
.highlight .k,
.highlight .kc,
.highlight .kd,
.highlight .kn,
.highlight .kp,
.highlight .kr,
.highlight .kt {
    color: #8b5a2b;
    font-weight: 500;
}

/* String */
.highlight .s,
.highlight .s1,
.highlight .s2,
.highlight .sb,
.highlight .sc,
.highlight .sd,
.highlight .se,
.highlight .sh,
.highlight .si,
.highlight .sr,
.highlight .ss,
.highlight .sx {
    color: #5a7a5a;
}

/* Number */
.highlight .m,
.highlight .mi,
.highlight .mf,
.highlight .mh,
.highlight .mo,
.highlight .il {
    color: #6a5a8a;
}

/* Name / Identifier */
.highlight .n,
.highlight .ni,
.highlight .nl {
    color: var(--color-text);
}

/* Name.Function */
.highlight .nf,
.highlight .fm {
    color: #4a6a8a;
}

/* Name.Class */
.highlight .nc,
.highlight .nn {
    color: #6a5a4a;
    font-weight: 500;
}

/* Name.Attribute */
.highlight .na {
    color: #5a6a7a;
}

/* Name.Builtin */
.highlight .nb {
    color: #7a5a6a;
}

/* Name.Variable */
.highlight .nv,
.highlight .vc,
.highlight .vg,
.highlight .vi {
    color: #5a5a7a;
}

/* Operator */
.highlight .o,
.highlight .ow {
    color: #666;
}

/* Punctuation */
.highlight .p {
    color: #555;
}

/* Error */
.highlight .err {
    color: #a03030;
    background-color: #fbe8e8;
}

/* Generic */
.highlight .gd {
    color: #903030;
    background-color: #fbe8e8;
}

.highlight .gi {
    color: #307030;
    background-color: #e8fbe8;
}

.highlight .gh {
    color: #333;
    font-weight: 600;
}

.highlight .gp {
    color: #666;
    font-weight: 500;
}

.highlight .gu {
    color: #666;
    font-weight: 500;
}
