/* =========================================================================
   EventuallyWrong.com — custom styles layered over quark2.
   Direction: minimal & modern, with one characterful "case file" accent
   (the Rule 51 card). This file loads AFTER quark2's theme.css, so these
   rules win on conflicts. quark2 already provides Cal Sans (headings),
   Inter (body), light/dark, and the --q2-* accent variables.
   ========================================================================= */

/* ---- Brand tokens -------------------------------------------------------- */
:root {
    --ew-manila:      #fbf6ea;   /* case-file "paper" */
    --ew-manila-edge: #e7dcc2;
    --ew-ink:         #7a4a12;   /* stamped label ink */
    --ew-ink-strong:  #5c3809;
    --ew-measure:     42rem;     /* comfortable reading width */
}
:root[data-theme='dark'] {
    --ew-manila:      #241f17;
    --ew-manila-edge: #3a3122;
    --ew-ink:         #e8b877;
    --ew-ink-strong:  #f2c98a;
}

/* ---- Wordmark (header logo override) ------------------------------------ */
.navbar-brand.wordmark {
    display: inline-flex;
    gap: 0.35ch;
    font-weight: 600;
    font-size: 1.15rem;
    letter-spacing: -0.01em;
    text-decoration: none;
}
.navbar-brand.wordmark .wm-b { color: var(--q2-accent, #0F766E); }

/* ---- Footer -------------------------------------------------------------- */
.ew-footer { text-align: center; }
.ew-footer-copy { margin: 0; font-size: 0.9rem; color: var(--q2-text-muted, #6b7280); }
.ew-social {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.1rem;
    margin-bottom: 0.6rem;
}
.ew-social a, .ew-social-discord {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    text-decoration: none;
    color: var(--q2-text-muted, #6b7280);
}
.ew-social a:hover { color: var(--q2-accent, #0F766E); }
.ew-social i { font-size: 1.2rem; }
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---- Home ---------------------------------------------------------------- */
.home { max-width: var(--ew-measure); margin-inline: auto; }

.home-hero { text-align: center; padding: 2.5rem 0 0.5rem; }
.home-title {
    font-size: clamp(2.2rem, 6vw, 3.4rem);
    line-height: 1.05;
    letter-spacing: -0.02em;
    margin: 0 0 0.5rem;
}
.home-tagline {
    max-width: 34rem;
    margin: 0 auto;
    font-size: clamp(1.05rem, 2.5vw, 1.3rem);
    line-height: 1.5;
    color: var(--q2-text-muted, #6b7280);
    text-wrap: balance;
}

.home-prose { font-size: 1.075rem; line-height: 1.7; }
.home-prose h2 { margin-top: 2.5rem; letter-spacing: -0.01em; }

/* ---- Rule 51 "case file" card ------------------------------------------- */
.rule51 {
    position: relative;
    max-width: 30rem;
    margin: 2.5rem auto;
    padding: 1.25rem 1.5rem 1.1rem;
    background: var(--ew-manila);
    border: 1px solid var(--ew-manila-edge);
    border-radius: 4px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03),
                0 14px 32px -20px rgba(0, 0, 0, 0.4);
    transform: rotate(-0.6deg);
}
.rule51::before { /* evidence-tab / punch hint */
    content: "";
    position: absolute;
    top: -7px;
    left: 1.5rem;
    width: 44px;
    height: 14px;
    background: var(--ew-manila-edge);
    border-radius: 2px;
    opacity: 0.7;
}
.rule51-tag {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ew-ink);
}
.rule51-number { font-weight: 700; color: var(--ew-ink-strong); }
.rule51-quote {
    margin: 0.5rem 0 0.4rem;
    padding: 0;
    border: 0;
    font-family: "Cal Sans", system-ui, sans-serif;
    font-size: 1.6rem;
    line-height: 1.15;
    color: inherit;
    quotes: "\201C" "\201D";
}
.rule51-quote::before { content: open-quote; opacity: 0.4; }
.rule51-quote::after  { content: close-quote; opacity: 0.4; }
.rule51-caption {
    margin: 0;
    font-size: 0.85rem;
    color: var(--q2-text-muted, #6b7280);
}

/* ---- Author card (modest headshot placement) ---------------------------- */
.author-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    max-width: var(--ew-measure);
    margin: 3rem auto 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--q2-border, rgba(128, 128, 128, 0.25));
}
.author-portrait {
    flex: none;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
}
.author-name { margin: 0; font-weight: 600; }
.author-note {
    margin: 0.1rem 0 0;
    font-size: 0.95rem;
    color: var(--q2-text-muted, #6b7280);
}

/* ---- Section pages (shared) --------------------------------------------- */
.projects { max-width: 48rem; margin-inline: auto; }
.section-head { margin: 1.5rem 0 0.5rem; }
.section-head h1 { letter-spacing: -0.02em; margin-bottom: 0.25rem; }
.section-intro { color: var(--q2-text-muted, #6b7280); font-size: 1.075rem; }

/* ---- Project cards ------------------------------------------------------- */
.project-list {
    display: grid;
    gap: 1.25rem;
    margin-top: 1.75rem;
}
.project-card {
    padding: 1.25rem 1.4rem;
    border: 1px solid var(--q2-border, rgba(128, 128, 128, 0.22));
    border-radius: 8px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.project-card:hover {
    border-color: var(--q2-accent, #0F766E);
    box-shadow: 0 10px 30px -22px rgba(0, 0, 0, 0.5);
}
.project-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    flex-wrap: wrap;
}
.project-title { margin: 0; font-size: 1.3rem; letter-spacing: -0.01em; }
.project-title a { text-decoration: none; }
.project-title a:hover { text-decoration: underline; }
.project-meta {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--q2-text-muted, #6b7280);
}
.project-meta span {
    padding: 0.15rem 0.55rem;
    border: 1px solid var(--q2-border, rgba(128, 128, 128, 0.22));
    border-radius: 999px;
}
.project-summary { margin: 0.7rem 0 0; line-height: 1.6; }
.project-note {
    margin: 0.9rem 0 0;
    padding: 0.65rem 0.9rem;
    border-left: 3px solid var(--ew-ink, #7a4a12);
    border-radius: 0 4px 4px 0;
    background: var(--ew-manila, #fbf6ea);
    font-size: 0.92rem;
    line-height: 1.55;
}
.project-note :first-child { margin-top: 0; }
.project-note :last-child { margin-bottom: 0; }
.project-links { margin: 0.9rem 0 0; }
.project-repo-link { font-weight: 600; text-decoration: none; }
.project-repo-link:hover { text-decoration: underline; }

/* ---- Talks: landing list ------------------------------------------------- */
.talks { max-width: 48rem; margin-inline: auto; }
.talk-list { display: grid; gap: 1.25rem; margin-top: 1.75rem; }
.talk-card {
    padding: 1.1rem 1.3rem;
    border: 1px solid var(--q2-border, rgba(128, 128, 128, 0.22));
    border-radius: 8px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.talk-card:hover {
    border-color: var(--q2-accent, #0F766E);
    box-shadow: 0 10px 30px -22px rgba(0, 0, 0, 0.5);
}
.talk-card-title { margin: 0; font-size: 1.25rem; letter-spacing: -0.01em; }
.talk-card-title a { text-decoration: none; }
.talk-card-title a:hover { text-decoration: underline; }
.talk-card-subtitle { margin: 0.1rem 0 0.15rem; color: var(--q2-text-muted, #6b7280); }
.talk-summary { margin: 0.5rem 0 0; line-height: 1.6; }

/* ---- Talks: single talk page -------------------------------------------- */
.talk { max-width: 52rem; margin-inline: auto; }
.talk-subtitle { margin: 0.15rem 0 0; font-size: 1.2rem; font-weight: 400; color: var(--q2-text-muted, #6b7280); }
.talk-submitted { margin: 0.35rem 0 0; font-size: 0.85rem; color: var(--q2-text-muted, #6b7280); }
.talk-meta {
    margin: 0.2rem 0 0;
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--q2-text-muted, #6b7280);
}
.talk-abstract { margin-top: 1.25rem; font-size: 1.075rem; line-height: 1.7; }

/* Embedded reveal.js deck — responsive 16:9 */
.talk-deck { margin: 1.75rem 0; }
.deck-embed {
    position: relative;
    aspect-ratio: 16 / 9;
    width: 100%;
    border: 1px solid var(--q2-border, rgba(128, 128, 128, 0.22));
    border-radius: 8px;
    overflow: hidden;
    background: #000;
}
.deck-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.deck-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 0.6rem 0 0;
}
.deck-fullscreen { font-weight: 600; text-decoration: none; }
.deck-fullscreen:hover { text-decoration: underline; }
.deck-hint { font-size: 0.85rem; color: var(--q2-text-muted, #6b7280); }
.deck-placeholder {
    padding: 2rem;
    text-align: center;
    border: 1px dashed var(--q2-border, rgba(128, 128, 128, 0.35));
    border-radius: 8px;
    color: var(--q2-text-muted, #6b7280);
}

/* Talk code / resources */
.talk-links, .talk-resources { margin-top: 2rem; }
.talk-links h2, .talk-resources h2 { font-size: 1.15rem; letter-spacing: -0.01em; margin-bottom: 0.4rem; }
.link-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.4rem; }
.link-list a { text-decoration: none; font-weight: 500; }
.link-list a:hover { text-decoration: underline; }

/* ---- Podcast ------------------------------------------------------------- */
.podcast { max-width: 52rem; margin-inline: auto; }
.pod-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1.75rem;
}
.pod-card {
    border: 1px solid var(--q2-border, rgba(128, 128, 128, 0.22));
    border-radius: 10px;
    overflow: hidden;
    background: var(--q2-surface, transparent);
}
.pod-embed {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    padding: 0;
    border: 0;
    cursor: pointer;
    background: #000;
}
.pod-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.pod-play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: rgba(0, 0, 0, 0.12);
    transition: background 0.15s ease;
}
.pod-embed:hover .pod-play { background: rgba(0, 0, 0, 0.32); }
.pod-play i {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3.2rem;
    height: 3.2rem;
    padding-left: 0.2rem;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    font-size: 1.15rem;
}
.pod-iframe { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; }
.pod-info { padding: 1rem 1.1rem 1.15rem; }
.pod-role {
    display: inline-block;
    margin-bottom: 0.45rem;
    padding: 0.12rem 0.55rem;
    border: 1px solid var(--q2-accent, #0F766E);
    border-radius: 999px;
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--q2-accent, #0F766E);
}
.pod-title { margin: 0 0 0.25rem; font-size: 1.15rem; letter-spacing: -0.01em; }
.pod-title a { text-decoration: none; }
.pod-title a:hover { text-decoration: underline; }
.pod-meta { margin: 0; font-size: 0.85rem; color: var(--q2-text-muted, #6b7280); }

/* ---- Blog: landing list -------------------------------------------------- */
.blog { max-width: 44rem; margin-inline: auto; }
.post-list { display: grid; gap: 2rem; margin-top: 1.75rem; }
.post-card-title { margin: 0 0 0.2rem; font-size: 1.4rem; letter-spacing: -0.01em; }
.post-card-title a { text-decoration: none; }
.post-card-title a:hover { text-decoration: underline; }
.post-card-meta {
    margin: 0 0 0.45rem;
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--q2-text-muted, #6b7280);
}
.post-card-summary { margin: 0 0 0.5rem; line-height: 1.6; }
.post-card-more { font-weight: 600; text-decoration: none; }
.post-card-more:hover { text-decoration: underline; }

/* ---- Blog: single post --------------------------------------------------- */
.post { max-width: 42rem; margin-inline: auto; }
.post-header { margin: 1.5rem 0 0.5rem; }
.post-title { margin: 0 0 0.4rem; font-size: clamp(2rem, 5vw, 2.8rem); line-height: 1.1; letter-spacing: -0.02em; }
.post-byline { margin: 0; font-size: 0.95rem; color: var(--q2-text-muted, #6b7280); }
/* A revised chapter is the one thing a returning reader is scanning for, so the
   updated date carries the accent while the byline around it stays muted. */
.post-updated { color: var(--q2-accent, #0F766E); font-weight: 600; }
.post-dek {
    margin: 1.5rem 0;
    padding-left: 1.1rem;
    border-left: 3px solid var(--q2-accent, #0F766E);
    font-size: 1.2rem;
    line-height: 1.5;
    color: var(--q2-text-muted, #6b7280);
}
.post-body { font-size: 1.075rem; line-height: 1.75; }
.post-body h2 { margin-top: 2.6rem; font-size: 1.55rem; letter-spacing: -0.01em; }
.post-body h3 { margin-top: 2rem; font-size: 1.2rem; }
.post-body blockquote {
    margin: 1.5rem 0;
    padding-left: 1.1rem;
    border-left: 3px solid var(--q2-border, rgba(128, 128, 128, 0.3));
    color: var(--q2-text-muted, #6b7280);
    font-style: italic;
}
/* Code blocks are always dark, in both themes — they should read as a terminal,
   not as a highlighted note. */
.post-body pre {
    overflow-x: auto;
    margin: 1.5rem 0;
    padding: 1rem 1.15rem;
    border-radius: 8px;
    background: #1b1f27;
    color: #f4f7fb;
    font-size: 0.9rem;
    line-height: 1.55;
}
:root[data-theme='dark'] .post-body pre {
    background: #15181e;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.post-body :not(pre) > code {
    padding: 0.1em 0.35em;
    border-radius: 4px;
    background: rgba(128, 128, 128, 0.16);
    font-size: 0.9em;
}
.post-body pre code { padding: 0; background: none; }
.post-body img { max-width: 100%; height: auto; }
.post-body hr { margin: 2.5rem 0; border: 0; border-top: 1px solid var(--q2-border, rgba(128, 128, 128, 0.3)); }
.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 2.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--q2-border, rgba(128, 128, 128, 0.25));
}
.post-tag {
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 0.72rem;
    color: var(--q2-text-muted, #6b7280);
}

/* ---- PHP 9 section -------------------------------------------------------- */
.php9-banner {
    margin: 1.5rem 0 0;
    padding: 0.55rem 0.9rem;
    border: 1px solid color-mix(in srgb, var(--q2-accent) 30%, transparent);
    border-radius: 8px;
    background: color-mix(in srgb, var(--q2-accent) 7%, transparent);
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--q2-text-muted, #6b7280);
}
.php9-banner a {
    color: var(--q2-accent);
    font-weight: 600;
    white-space: nowrap;
}

.chapter-nav {
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    margin-top: 2.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--q2-divider, rgba(128, 128, 128, 0.25));
}
.chapter-nav a {
    max-width: 48%;
    font-weight: 600;
    text-decoration: none;
    color: var(--q2-accent);
}
.chapter-nav a:hover { text-decoration: underline; }
.chapter-nav-next { margin-left: auto; text-align: right; }
.chapter-nav-dir {
    display: block;
    margin-bottom: 0.15rem;
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--q2-text-muted, #6b7280);
}
