/* ============================================================
   maccaba v2 — Liquid Glass
   ============================================================ */

/* ---------- TOKENS ---------- */
:root {
    --maxw: 1280px;
    --gutter: clamp(1.25rem, 4vw, 3rem);
    --radius: 24px;
    --radius-sm: 14px;
    --radius-pill: 999px;
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "SF Pro Text", system-ui, sans-serif;
    --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

html[data-theme="light"] {
    --bg-base:        #FAFAFC;
    --bg-grad-1:      #E8E4FF;
    --bg-grad-2:      #FFE4EC;
    --bg-grad-3:      #DDF1FF;
    --surface:        rgba(255, 255, 255, 0.55);
    --surface-strong: rgba(255, 255, 255, 0.75);
    --surface-border: rgba(255, 255, 255, 0.7);
    --surface-hover:  rgba(255, 255, 255, 0.7);
    --text-primary:   #0A0A0F;
    --text-secondary: #4A4A55;
    --text-tertiary:  #8A8A95;
    --accent:         #0066FF;
    --accent-hover:   #0052CC;
    --shadow-soft:    0 8px 32px rgba(15, 15, 30, 0.08);
    --shadow-glass:   0 12px 48px rgba(15, 15, 30, 0.12), inset 0 1px 0 rgba(255,255,255,0.6);
    --highlight-top:    rgba(255,255,255,0.45);
    --highlight-bottom: rgba(255,255,255,0.10);
    --solid-fallback: #FFFFFFEE;
}

html[data-theme="dark"] {
    --bg-base:        #08080C;
    --bg-grad-1:      #1A1A3E;
    --bg-grad-2:      #2D1B4E;
    --bg-grad-3:      #0E2A4E;
    --surface:        rgba(255, 255, 255, 0.06);
    --surface-strong: rgba(255, 255, 255, 0.10);
    --surface-border: rgba(255, 255, 255, 0.12);
    --surface-hover:  rgba(255, 255, 255, 0.10);
    --text-primary:   #F5F5FA;
    --text-secondary: #B0B0BA;
    --text-tertiary:  #70707A;
    --accent:         #4D9FFF;
    --accent-hover:   #6BB0FF;
    --shadow-soft:    0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-glass:   0 12px 48px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.08);
    --highlight-top:    rgba(255,255,255,0.16);
    --highlight-bottom: rgba(255,255,255,0.04);
    --solid-fallback: #14141Cee;
}

/* ---------- RESET ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
img, svg, video { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }

/* ---------- BODY ---------- */
body {
    background: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 1.0625rem;
    line-height: 1.6;
    font-feature-settings: "cv11", "ss01", "ss03";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    transition: background-color 400ms var(--ease), color 400ms var(--ease);
}

/* ---------- TYPOGRAPHY HELPERS ---------- */
.kicker {
    display: inline-block;
    font-size: 0.8125rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    margin-bottom: 0.75rem;
}

/* ---------- SKIP LINK ---------- */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 200;
    padding: 0.75rem 1rem;
    background: var(--accent);
    color: #fff;
    border-radius: 12px;
    font-weight: 600;
}
.skip-link:focus { left: 1rem; top: 1rem; }

/* ============================================================
   GLASS LAYER
   ============================================================ */
.glass {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-glass);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    isolation: isolate;
    transition:
        background 0.3s var(--ease),
        transform 0.3s var(--ease),
        box-shadow 0.3s var(--ease),
        border-color 0.3s var(--ease);
}

/* Specular highlight — a soft top-edge sheen */
.glass::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background: linear-gradient(
        180deg,
        var(--highlight-top) 0%,
        transparent 30%,
        transparent 70%,
        var(--highlight-bottom) 100%
    );
    mix-blend-mode: overlay;
    z-index: 1;
}
.glass > * { position: relative; z-index: 2; }

/* Refractive variant — only where supported */
@supports (backdrop-filter: url(#glass-distortion)) or (-webkit-backdrop-filter: url(#glass-distortion)) {
    .glass--refractive {
        backdrop-filter: url(#glass-distortion) blur(12px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
    }
}

/* Text-heavy cards bump opacity in light mode for AA contrast over a pale gradient */
html[data-theme="light"] .card,
html[data-theme="light"] .post-frame,
html[data-theme="light"] .contact-panel,
html[data-theme="light"] .error-panel {
    background: var(--surface-strong);
}

/* ============================================================
   BACKDROP LAYER
   ============================================================ */
.backdrop {
    position: absolute;
    inset: 0;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}
.backdrop .blob {
    position: absolute;
    width: 70vmax;
    height: 70vmax;
    border-radius: 50%;
    filter: blur(80px) saturate(140%);
    opacity: 0.65;
    will-change: transform;
}
html[data-theme="dark"] .backdrop .blob { opacity: 0.55; filter: blur(90px) saturate(170%); }

.backdrop .blob-1 { background: var(--bg-grad-1); top: -20%; left: -10%; animation: drift-a 28s var(--ease) infinite alternate; }
.backdrop .blob-2 { background: var(--bg-grad-2); bottom: -25%; right: -15%; animation: drift-b 32s var(--ease) infinite alternate; }
.backdrop .blob-3 { background: var(--bg-grad-3); top: 35%; left: 30%; animation: drift-c 24s var(--ease) infinite alternate; }

@keyframes drift-a { from { transform: translate(0, 0) scale(1); } to { transform: translate(8%, 6%) scale(1.05); } }
@keyframes drift-b { from { transform: translate(0, 0) scale(1); } to { transform: translate(-6%, -4%) scale(1.08); } }
@keyframes drift-c { from { transform: translate(0, 0) scale(1); } to { transform: translate(4%, -8%) scale(1.04); } }

/* Hero gets an extra warm glow in dark mode */
html[data-theme="dark"] .backdrop-hero::after {
    content: "";
    position: absolute;
    top: 10%; right: 10%;
    width: 40vmax; height: 40vmax;
    border-radius: 50%;
    background: radial-gradient(circle at center, rgba(255, 180, 90, 0.08), transparent 60%);
    pointer-events: none;
}

/* ============================================================
   TOP NAV
   ============================================================ */
.topnav {
    position: fixed;
    top: 1.25rem;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    justify-content: center;
    pointer-events: none;
}

.topnav-bar {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 0.5rem 0.75rem 0.5rem 1.25rem;
    border-radius: var(--radius-pill);
    height: 56px;
    max-width: calc(100% - 2rem);
    width: max-content;
}

.topnav-logo {
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.04em;
    padding: 0 0.4rem;
    color: var(--text-primary);
}

.topnav-links {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}
.topnav-links a {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.85rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: var(--radius-pill);
    transition: color 0.2s var(--ease), background 0.2s var(--ease);
}
.topnav-links a:hover {
    color: var(--text-primary);
    background: var(--surface-hover);
}
.topnav-links li[data-active] a,
.topnav-links a[data-current] {
    color: var(--text-primary);
}
.topnav-links li[data-active] a::after,
.topnav-links a[data-current]::after {
    content: "";
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px; height: 4px;
    background: var(--accent);
    border-radius: 50%;
}

/* Theme toggle */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    border-radius: 50%;
    color: var(--text-secondary);
    transition: color 0.2s var(--ease), background 0.2s var(--ease);
}
.theme-toggle:hover { color: var(--text-primary); background: var(--surface-hover); }

.theme-icon { display: none; }
html[data-theme="light"] .theme-icon--moon { display: block; }
html[data-theme="dark"] .theme-icon--sun { display: block; }

/* Mobile hamburger */
.topnav-toggle {
    display: none;
    width: 40px; height: 40px;
    border-radius: 50%;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    color: var(--text-secondary);
    transition: color 0.2s var(--ease), background 0.2s var(--ease);
}
.topnav-toggle:hover { color: var(--text-primary); background: var(--surface-hover); }
.topnav-toggle-bar {
    display: block;
    width: 18px; height: 1.5px;
    background: currentColor;
    border-radius: 2px;
    transition: transform 0.3s var(--ease), opacity 0.3s var(--ease);
}
.topnav.is-open .topnav-toggle-bar:nth-child(1) { transform: translateY(3.25px) rotate(45deg); }
.topnav.is-open .topnav-toggle-bar:nth-child(2) { transform: translateY(-3.25px) rotate(-45deg); }

.topnav-mobile {
    pointer-events: auto;
    position: fixed;
    inset: 5rem 1rem auto 1rem;
    padding: 1.25rem;
    border-radius: var(--radius);
    display: none;
    flex-direction: column;
}
.topnav.is-open .topnav-mobile { display: flex; }
.topnav-mobile-links {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.topnav-mobile-links a {
    display: block;
    padding: 0.85rem 1rem;
    font-size: 1.0625rem;
    font-weight: 500;
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    min-height: 44px;
    display: flex;
    align-items: center;
}
.topnav-mobile-links a:hover { background: var(--surface-hover); }

@media (max-width: 767px) {
    .topnav-links { display: none; }
    .topnav-toggle { display: flex; }
}

/* ============================================================
   SECTIONS
   ============================================================ */
.section {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding: clamp(5rem, 10vh, 8rem) 0;
    overflow: hidden;
}
.section-frame {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 var(--gutter);
}

.section-head {
    margin-bottom: clamp(2rem, 5vh, 3.5rem);
}
.section-title {
    font-size: clamp(2rem, 5vw, 4rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin: 0;
    color: var(--text-primary);
}

.empty-state {
    padding: 1.75rem 1.5rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
    border-radius: var(--radius);
    text-align: center;
}
.empty-state em {
    color: var(--accent);
    font-style: normal;
    font-weight: 500;
}

/* ============================================================
   HERO
   ============================================================ */
.section-hero {
    padding-top: clamp(7rem, 16vh, 10rem);
}
.hero-frame {
    text-align: left;
}
.hero-title {
    font-size: clamp(3rem, 8vw, 7rem);
    font-weight: 600;
    letter-spacing: -0.04em;
    line-height: 1;
    margin: 0;
    color: var(--text-primary);
}
.hero-tagline {
    margin: 1.25rem 0 0;
    font-size: clamp(0.875rem, 1.4vw, 1.0625rem);
    font-weight: 600;
    color: var(--text-secondary);
    max-width: 42ch;
    line-height: 1.4;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}


/* ============================================================
   CARD GRIDS
   ============================================================ */
.card-grid { display: grid; gap: 1.25rem; }
.card-grid--projects { grid-template-columns: 1fr; }
.card-grid--videos   { grid-template-columns: 1fr; }
.card-grid--podcasts { grid-template-columns: 1fr; }
.card-grid--music    { grid-template-columns: 1fr; }
.card-grid--archive  { grid-template-columns: 1fr; }

@media (min-width: 700px) {
    .card-grid--projects,
    .card-grid--videos,
    .card-grid--podcasts,
    .card-grid--archive { grid-template-columns: 1fr 1fr; }
    .card-grid--music   { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1100px) {
    .card-grid--music   { grid-template-columns: 1fr 1fr 1fr; }
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    overflow: hidden;
    border-radius: var(--radius);
    transform: translateZ(0);
}
.card-link {
    display: flex;
    flex-direction: column;
    height: 100%;
    color: inherit;
}
.card-image {
    position: relative;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    border-radius: calc(var(--radius) - 4px);
    margin: 0.5rem 0.5rem 0;
}
.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s var(--ease);
}
.card-image-vignette {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(180deg, transparent 60%, rgba(0,0,0,0.18) 100%);
    mix-blend-mode: multiply;
    border-radius: inherit;
}
html[data-theme="dark"] .card-image-vignette { background: linear-gradient(180deg, transparent 60%, rgba(0,0,0,0.4) 100%); }

.card-body {
    padding: 1.25rem 1.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    flex: 1;
}
.card-body--meta-only { padding-top: 1.5rem; }
.card-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--text-primary);
}
.card-excerpt {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Tech chips */
.tech-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.25rem;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: color 0.2s var(--ease), background 0.2s var(--ease);
    text-decoration: none;
}
.pill:hover { color: var(--text-primary); background: var(--surface-hover); }
.pill-tech { font-feature-settings: "tnum"; }

/* CTA inside card body */
.card-cta {
    margin-top: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: 500;
    transition: gap 0.2s var(--ease);
}
.card:hover .card-cta { gap: 0.7rem; color: var(--accent-hover); }

/* hover behavior on cards (lift + refractive) */
@media (hover: hover) {
    .card:hover {
        transform: translateY(-2px);
        background: var(--surface-hover);
    }
    .card.is-hovered.glass {
        box-shadow: var(--shadow-glass), 0 16px 56px rgba(0,0,0,0.06);
    }
    .card:hover .card-image img { transform: scale(1.03); }
}

/* ============================================================
   CTA card (GitHub link at end of projects)
   ============================================================ */
.cta-card {
    margin-top: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    padding: 1.5rem 1.75rem;
    border-radius: var(--radius);
    color: var(--text-primary);
    transition: transform 0.3s var(--ease), background 0.3s var(--ease);
}
.cta-card-label { font-size: 1.125rem; font-weight: 600; letter-spacing: -0.01em; }
.cta-card-arrow { color: var(--accent); display: inline-flex; transition: transform 0.3s var(--ease); }
.cta-card:hover { transform: translateY(-2px); }
.cta-card:hover .cta-card-arrow { transform: translateX(4px); color: var(--accent-hover); }

/* ============================================================
   VIDEO CARD / LITE-YT
   ============================================================ */
.card-video {
    overflow: hidden;
}
.card-video--featured {
    grid-column: 1 / -1;
}
.card-video-frame {
    position: relative;
    aspect-ratio: 16 / 9;
    background: rgba(0,0,0,0.4);
    cursor: pointer;
    border-radius: calc(var(--radius) - 4px);
    margin: 0.5rem 0.5rem 0;
    overflow: hidden;
}
.card-video-poster {
    width: 100%; height: 100%;
    object-fit: cover;
    transition: transform 0.6s var(--ease), filter 0.3s var(--ease);
}
.card-video-frame:hover .card-video-poster { transform: scale(1.03); filter: brightness(0.9); }

.lite-yt-play {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 64px; height: 64px;
    border-radius: 50%;
    color: var(--accent);
    display: grid; place-items: center;
    transition: transform 0.25s var(--ease), background 0.25s var(--ease);
}
.lite-yt-play:hover { transform: translate(-50%, -50%) scale(1.08); }
.lite-yt-play svg { margin-left: 3px; }

.card-video-frame.is-playing .lite-yt-play,
.card-video-frame.is-playing .card-video-poster { display: none; }
.card-video-frame iframe {
    position: absolute;
    inset: 0;
    width: 100%; height: 100%;
    border: 0;
    border-radius: inherit;
}
.card-video-body { padding: 1rem 1.5rem 1.5rem; }

/* ============================================================
   PODCAST / MUSIC EMBEDS
   ============================================================ */
.card-embed-host:empty { display: none; }
.card-embed-host iframe {
    width: 100%;
    border: 0;
    border-radius: calc(var(--radius) - 4px);
    display: block;
    margin: 0.5rem 0.5rem 0;
    width: calc(100% - 1rem);
}

.card-linkout {
    display: grid;
    grid-template-columns: minmax(120px, 35%) 1fr;
    gap: 0;
    align-items: stretch;
    color: inherit;
}
.card-linkout-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: calc(var(--radius) - 4px) 0 0 calc(var(--radius) - 4px);
    margin: 0.5rem 0 0.5rem 0.5rem;
    aspect-ratio: 1 / 1;
    height: auto;
}
.card-linkout--vertical {
    grid-template-columns: 1fr;
}
.card-linkout--vertical .card-linkout-cover {
    aspect-ratio: 1 / 1;
    border-radius: calc(var(--radius) - 4px) calc(var(--radius) - 4px) 0 0;
    margin: 0.5rem 0.5rem 0;
    width: calc(100% - 1rem);
    height: auto;
}

@media (max-width: 600px) {
    .card-linkout {
        grid-template-columns: 1fr;
    }
    .card-linkout .card-linkout-cover {
        aspect-ratio: 16 / 9;
        border-radius: calc(var(--radius) - 4px) calc(var(--radius) - 4px) 0 0;
        margin: 0.5rem 0.5rem 0;
        width: calc(100% - 1rem);
    }
}

/* ============================================================
   CONTACT
   ============================================================ */
.section-contact {
    min-height: auto;
    padding: clamp(5rem, 12vh, 9rem) 0 clamp(3rem, 6vh, 5rem);
}
.contact-frame { text-align: center; }
.contact-panel {
    max-width: 720px;
    margin: 0 auto;
    padding: clamp(2rem, 4vw, 3rem);
    text-align: center;
}
.contact-kicker { margin-bottom: 1.5rem; }
.contact-email {
    display: inline-block;
    font-size: clamp(1.5rem, 4vw, 1.875rem);
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    border-bottom: 2px solid transparent;
    transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
    word-break: break-word;
    line-height: 1.2;
}
.contact-email:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.contact-email-placeholder {
    margin: 0;
    color: var(--text-tertiary);
    font-size: 0.95rem;
}
.contact-divider {
    margin: 2rem auto;
    width: 40px;
    height: 1px;
    background: var(--surface-border);
    border: 0;
}
.contact-socials {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}
.footer-line {
    margin: 2.5rem auto 0;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-tertiary);
    letter-spacing: 0.04em;
}

/* ============================================================
   POST / PAGE
   ============================================================ */
.post-page { min-height: 100vh; padding: clamp(7rem, 14vh, 10rem) 0 clamp(4rem, 8vh, 7rem); }
.post-frame {
    max-width: 760px;
    margin: 0 auto;
    padding: clamp(2rem, 4vw, 3rem);
    border-radius: var(--radius);
}

.post-back {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
    transition: color 0.2s var(--ease);
}
.post-back:hover { color: var(--accent); }

.post-kicker { color: var(--accent); margin-bottom: 1rem; }

.post-title {
    margin: 0 0 1rem;
    font-size: clamp(2rem, 4.5vw, 3rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.1;
    color: var(--text-primary);
}
.post-excerpt {
    margin: 0 0 1.25rem;
    font-size: 1.125rem;
    color: var(--text-secondary);
    line-height: 1.5;
}
.post-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    color: var(--text-tertiary);
    font-size: 0.8125rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    margin-bottom: 2rem;
    font-variant-numeric: tabular-nums;
}
.post-feature {
    margin: 0 0 2rem;
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.post-feature img { width: 100%; }
.post-feature figcaption {
    margin-top: 0.5rem;
    font-size: 0.8125rem;
    color: var(--text-tertiary);
    letter-spacing: 0.04em;
}

.post-content {
    font-size: 1.0625rem;
    line-height: 1.7;
    color: var(--text-primary);
}
.post-content > * + * { margin-top: 1.25rem; }
.post-content h2, .post-content h3, .post-content h4 {
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.25;
    margin-top: 2.5rem;
}
.post-content h2 { font-size: 1.625rem; }
.post-content h3 { font-size: 1.25rem; }
.post-content a { color: var(--accent); border-bottom: 1px solid transparent; transition: border-color 0.2s var(--ease); }
.post-content a:hover { border-bottom-color: var(--accent); }
.post-content blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1.25rem;
    color: var(--text-secondary);
    margin: 2rem 0;
    font-style: italic;
}
.post-content code {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    background: var(--surface-strong);
    border: 1px solid var(--surface-border);
    border-radius: 6px;
    padding: 0.1rem 0.4rem;
    font-size: 0.9em;
}
.post-content pre {
    background: rgba(0,0,0,0.7);
    color: #F5F5FA;
    padding: 1.25rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
}
.post-content pre code { background: transparent; border: 0; padding: 0; color: inherit; }
.post-content img { width: 100%; border-radius: var(--radius-sm); }

.kg-image-card, .kg-embed-card { margin: 2rem 0; }
.kg-bookmark-card { margin: 2rem 0; border: 1px solid var(--surface-border); border-radius: var(--radius-sm); padding: 1rem; }
.kg-width-wide {
    width: 100vw;
    max-width: calc(100vw - 2rem);
    margin-left: 50%;
    transform: translateX(-50%);
}
.kg-width-full {
    width: 100vw;
    max-width: 100vw;
    margin-left: 50%;
    transform: translateX(-50%);
}
@media (min-width: 1100px) {
    .kg-width-wide { max-width: 1100px; }
    .kg-width-full { max-width: 1400px; }
}

.post-canonical {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2.5rem;
    padding: 0.6rem 1rem;
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: 500;
}
.post-canonical:hover { color: var(--accent-hover); }

/* Custom-font admin support */
:root { --gh-font-heading: var(--font); --gh-font-body: var(--font); }
body { font-family: var(--gh-font-body, var(--font)); }
.hero-title, .section-title, .card-title, .post-title, .error-code,
.post-content h2, .post-content h3, .post-content h4 {
    font-family: var(--gh-font-heading, var(--font));
}

/* ============================================================
   ARCHIVE / ERROR
   ============================================================ */
.section-archive { padding-top: clamp(7rem, 14vh, 10rem); }
.tag-description {
    color: var(--text-secondary);
    margin: 0 0 2rem;
    max-width: 60ch;
}

.section-error { min-height: 90vh; }
.error-frame { display: grid; place-items: center; }
.error-panel {
    max-width: 480px;
    padding: clamp(2rem, 5vw, 3rem);
    text-align: center;
}
.error-code {
    font-size: clamp(4rem, 12vw, 7rem);
    font-weight: 600;
    letter-spacing: -0.04em;
    line-height: 1;
    margin: 0.5rem 0;
    color: var(--text-primary);
}
.error-message { color: var(--text-secondary); margin: 0 0 1.75rem; }
.error-panel .pill { color: var(--accent); }

/* ============================================================
   REVEAL ON SCROLL
   ============================================================ */
.reveal {
    opacity: 0;
    transform: translateY(1.5rem);
    transition: opacity 600ms var(--ease), transform 600ms var(--ease);
}
.reveal.is-visible { opacity: 1; transform: none; }

/* ============================================================
   FOCUS RINGS
   ============================================================ */
:focus { outline: none; }
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 4px;
}
.glass:focus-visible,
.card:focus-visible,
.card-link:focus-visible,
.pill:focus-visible,
.theme-toggle:focus-visible,
.topnav-toggle:focus-visible,
.cta-card:focus-visible {
    outline-offset: 3px;
    border-radius: inherit;
}

/* ============================================================
   ACCESSIBILITY OVERRIDES
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    .reveal { opacity: 1; transform: none; }
    .backdrop .blob { animation: none !important; }
}

@media (prefers-reduced-transparency: reduce) {
    .glass {
        background: var(--solid-fallback) !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
    .glass--refractive { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
    .glass::before { display: none; }
    .backdrop { display: none; }
}

/* Low-power devices: strip animation + refractive */
html[data-low-power="true"] .backdrop .blob { animation: none !important; }
html[data-low-power="true"] .glass--refractive { backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%); }

/* ============================================================
   VIEW TRANSITIONS (cross-page morphs in Chromium)
   ============================================================ */
@view-transition { navigation: auto; }

/* Theme toggle wipes from the toggle button outward */
::view-transition-old(root),
::view-transition-new(root) { animation-duration: 320ms; }

@media (prefers-reduced-motion: reduce) {
    @view-transition { navigation: none; }
}

/* ============================================================
   VISUALLY HIDDEN (a11y helper)
   ============================================================ */
.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ============================================================
   RELATED BLOCK (post.hbs cross-medium)
   ============================================================ */
.related {
    max-width: 760px;
    margin: clamp(2.5rem, 6vh, 4rem) auto 0;
    padding: 0 var(--gutter);
    position: relative;
    z-index: 2;
}
.related-title {
    font-size: 0.8125rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    margin: 0 0 1rem;
}
.related-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}
@media (min-width: 700px) {
    .related-grid { grid-template-columns: 1fr 1fr; }
}
.related-item {
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: transform 0.3s var(--ease), background 0.3s var(--ease);
}
.related-item:hover { transform: translateY(-1px); }
.related-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem;
    color: inherit;
}
.related-image {
    flex-shrink: 0;
    width: 56px; height: 56px;
    overflow: hidden;
    border-radius: 10px;
    background: var(--surface-strong);
}
.related-image img { width: 100%; height: 100%; object-fit: cover; }
.related-meta { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.related-kicker { margin: 0; }
.related-name {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ============================================================
   SITE FOOTER
   ============================================================ */
.site-footer {
    position: relative;
    z-index: 2;
    padding: clamp(2rem, 5vh, 3.5rem) 0 clamp(1.5rem, 3vh, 2.5rem);
    color: var(--text-tertiary);
    font-size: 0.8125rem;
    text-align: center;
    border-top: 1px solid var(--surface-border);
    margin-top: clamp(3rem, 8vh, 5rem);
}
.site-footer-frame {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 var(--gutter);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}
.site-footer-meta {
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    align-items: center;
}
.site-footer-meta a {
    color: var(--text-secondary);
    transition: color 0.2s var(--ease);
}
.site-footer-meta a:hover { color: var(--accent); }
.site-footer-feeds { font-size: 0.8125rem; }
.site-footer-feeds summary {
    cursor: pointer;
    color: var(--text-secondary);
    list-style: none;
    user-select: none;
}
.site-footer-feeds summary::-webkit-details-marker { display: none; }
.site-footer-feeds summary:hover { color: var(--accent); }
.site-footer-feed-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: center;
    margin-top: 0.75rem;
}
.site-footer-feed-list a {
    padding: 0.3rem 0.7rem;
    border-radius: var(--radius-pill);
    background: var(--surface);
    border: 1px solid var(--surface-border);
    color: var(--text-secondary);
    transition: color 0.2s var(--ease), background 0.2s var(--ease);
}
.site-footer-feed-list a:hover { color: var(--accent); background: var(--surface-hover); }

/* ============================================================
   CMD-K PALETTE
   ============================================================ */
.cmdk {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: grid;
    place-items: start center;
    padding-top: 18vh;
    opacity: 0;
    transition: opacity 200ms var(--ease);
}
.cmdk.is-open { opacity: 1; }
.cmdk[hidden] { display: none; }
.cmdk-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.35);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
html[data-theme="dark"] .cmdk-backdrop { background: rgba(0,0,0,0.65); }

.cmdk-panel {
    position: relative;
    width: min(620px, calc(100vw - 2rem));
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    border-radius: var(--radius);
    overflow: hidden;
    z-index: 1;
    transform: translateY(-8px) scale(0.98);
    transition: transform 240ms var(--ease);
}
.cmdk.is-open .cmdk-panel { transform: none; }

.cmdk-search {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--surface-border);
}
.cmdk-icon { color: var(--text-tertiary); flex-shrink: 0; }
.cmdk-input {
    flex: 1;
    border: 0;
    background: transparent;
    font: 500 1rem/1.4 var(--font);
    color: var(--text-primary);
    outline: none;
    min-width: 0;
}
.cmdk-input::placeholder { color: var(--text-tertiary); font-weight: 400; }

.cmdk-kbd, .cmdk-footer kbd {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.7rem;
    padding: 0.15rem 0.45rem;
    border-radius: 6px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    color: var(--text-tertiary);
}

.cmdk-results {
    overflow-y: auto;
    flex: 1;
    padding: 0.4rem;
}
.cmdk-result {
    border-radius: var(--radius-sm);
}
.cmdk-result a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.65rem 0.85rem;
    color: var(--text-primary);
    border-radius: inherit;
    transition: background 120ms var(--ease);
}
.cmdk-result.is-active a,
.cmdk-result a:hover { background: var(--surface-hover); }
.cmdk-result.is-active a { box-shadow: 0 0 0 1px var(--accent) inset; }
.cmdk-result-title {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cmdk-result-hint {
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.cmdk-empty {
    padding: 2rem;
    text-align: center;
    color: var(--text-tertiary);
}
.cmdk-empty p { margin: 0; }

.cmdk-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.65rem 1rem;
    border-top: 1px solid var(--surface-border);
    font-size: 0.75rem;
    color: var(--text-tertiary);
}
.cmdk-footer kbd { padding: 0.05rem 0.4rem; font-size: 0.65rem; margin-right: 0.25rem; }

.cmdk-trigger {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 80;
    width: 44px; height: 44px;
    border-radius: 50%;
    background: var(--surface-strong);
    border: 1px solid var(--surface-border);
    color: var(--text-secondary);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    box-shadow: var(--shadow-soft);
    display: grid;
    place-items: center;
    transition: color 0.2s var(--ease), transform 0.2s var(--ease);
}
.cmdk-trigger:hover { color: var(--text-primary); transform: scale(1.05); }
@media (min-width: 768px) {
    .cmdk-trigger { display: none; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 767px) {
    .topnav { top: 0.75rem; }
    .topnav-bar { padding: 0.4rem 0.5rem 0.4rem 1rem; }
    .hero-title { letter-spacing: -0.03em; }
    .post-frame { padding: 1.5rem; }
    .contact-panel { padding: 1.75rem 1.5rem; }
}

/* Mobile: drop the third backdrop blob to save GPU */
@media (max-width: 767px) {
    .backdrop .blob-3 { display: none; }
}

/* Disable refractive variant when no fine pointer (touch-only mobile) */
@media (pointer: coarse) {
    .glass--refractive {
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
    }
}
