/*
 * Theory Theme — Custom Styles
 * Extends Slate base styles with:
 *   1. Fancy style guide design system (colors, typography, KG cards)
 *   2. Image card grid for the homepage post feed
 *   3. Social link buttons in the profile section
 */

/* ============================================================
   DESIGN TOKENS — Fancy palette
   ============================================================ */

:root {
    /* Brand colors */
    --f-accent:    var(--ghost-accent-color, #1e6040);
    --f-contrast:  #ffffff;
    --f-social-bg: #f3eadf;

    /* Surface colors (light mode) */
    --f-bg:        #f7f8f5;
    --f-surface:   #d9e0d2;
    --f-surface-2: #ccd5c3;

    /* Text colors (light mode) */
    --f-heading:   #1b1b1e;
    --f-text:      #1b1b1e;
    --f-meta:      #5f5f61;
    --f-border:    #d9e0d2;

    /* Typography */
    --f-font-heading: var(--gh-font-heading, "Neco", serif);
    --f-font-body:    var(--gh-font-body, "source-serif-pro", "Source Serif Pro", serif);
    --f-font-mono:    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

    /* Radii */
    --f-radius: 0.75rem;  /* 12px */
    --f-radius-fancy: 48% 52% 34% 66% / 52% 38% 62% 48%;
    --f-content-width: 42rem;
    --f-wide-width: 72rem;

    /* Override Slate's palette variables */
    --epcl-background-color:       var(--f-bg);
    --epcl-secondary-color:        var(--f-surface);
    --epcl-text-color:             var(--f-text);
    --epcl-titles-color:           var(--f-heading);
    --epcl-boxes-background-color: var(--f-bg);
    --epcl-border-color:           var(--f-border);
    --epcl-font-family:            var(--f-font-body);
    --epcl-title-font-family:      var(--f-font-heading);
}

/* Dark mode — toggled by Slate's JS (adds .dark to <html>) */
html.dark {
    --f-bg:        #1b1b1e;
    --f-surface:   #232326;
    --f-surface-2: #2b2b2d;
    --f-heading:   #f7f8f5;
    --f-text:      #f7f8f5;
    --f-meta:      #9d9da1;
    --f-border:    #232326;
    --f-contrast:  #1b1b1e;

    --epcl-background-color:       var(--f-bg);
    --epcl-text-color:             var(--f-text);
    --epcl-titles-color:           var(--f-heading);
    --epcl-secondary-color:        var(--f-surface);
    --epcl-boxes-background-color: var(--f-surface);
    --epcl-border-color:           var(--f-border);
}

/* ============================================================
   GLOBAL OVERRIDES
   ============================================================ */

body {
    background-color: var(--f-bg);
    color: var(--f-text);
    font-family: var(--f-font-body);
    font-weight: 400;
}

html.theory-lightbox-open {
    overflow: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--f-font-heading);
    font-weight: 500;
    color: var(--f-heading);
    letter-spacing: -0.025em;
}

#header {
    background-color: var(--f-bg);
    border-bottom: 1px solid var(--f-border);
    padding: 18px 0;
}

#header div.menu-wrapper {
    padding-top: 0;
    padding-bottom: 0;
}

#header .logo img {
    width: 170px;
    height: auto;
}

#footer {
    background-color: var(--f-bg);
    border-top: 1px solid var(--f-border);
    color: var(--f-text);
}

a { color: var(--f-text); }

input,
textarea,
select,
button {
    font-family: var(--f-font-body);
}

.epcl-button,
.button,
button[type="submit"],
input[type="submit"],
.submit,
.subscribe-form button,
.subscribe-form .submit {
    border-radius: 9999px !important;
    font-family: var(--f-font-body) !important;
    font-weight: 400 !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
    transition: opacity 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.epcl-button:hover,
.button:hover,
button[type="submit"]:hover,
input[type="submit"]:hover,
.submit:hover,
.subscribe-form button:hover,
.subscribe-form .submit:hover {
    opacity: 0.85;
}

input[type="text"],
input[type="email"],
input[type="url"],
input[type="search"],
textarea {
    border-radius: 9999px;
    border-color: var(--f-border);
    background-color: var(--f-bg);
    color: var(--f-text);
    font-family: var(--f-font-body);
}

/* ============================================================
   SINGLE POST
   ============================================================ */

#single.classic .featured-image {
    width: min(100vw - 40px, 1180px);
    margin: 0 50% 48px;
    transform: translateX(-50%);
}

#single.classic .featured-image img {
    width: 100%;
    aspect-ratio: 3 / 2;
    object-fit: cover;
    display: block;
}

#single.classic .featured-image-caption {
    max-width: 1180px;
    margin-left: auto;
    margin-right: auto;
}

#single.classic .main-article .post-content {
    background: rgba(255, 255, 255, 0.58);
    border-radius: var(--f-radius);
    margin-top: 2.5rem;
    padding: clamp(1.5rem, 4vw, 4rem);
}

html.dark #single.classic .main-article .post-content {
    background: rgba(255, 255, 255, 0.04);
}

@media screen and (max-width: 767px) {
    #single.classic .featured-image {
        width: 100%;
        margin: 0 0 30px;
        transform: none;
    }

    #single.classic .main-article .post-content {
        border-radius: 0;
        margin-left: -20px;
        margin-right: -20px;
        margin-top: 2rem;
        padding: 1.5rem 20px;
    }
}

/* ============================================================
   HOME HERO
   ============================================================ */

#home .sticky-container.section {
    padding-top: 0;
}

.home-hero-publication {
    min-height: 56vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    background-color: var(--f-bg);
    padding: 56px 20px 72px;
    box-sizing: border-box;
}

.home-hero-publication-logo {
    width: min(220px, 38vw);
    height: auto;
    display: block;
    margin-bottom: 22px;
}

.home-hero-publication-title {
    font-family: var(--f-font-heading);
    font-weight: 500;
    font-size: 3rem;
    line-height: 1;
    margin: 0;
    color: var(--f-heading);
    letter-spacing: -0.025em;
}

.home-hero-publication-text {
    max-width: 680px;
    margin: 22px auto 0;
    font-family: var(--f-font-body);
    font-size: 1.125rem;
    line-height: 1.4;
    color: var(--f-text);
}

.home-hero-publication .theory-social-links {
    margin-top: 24px;
    margin-bottom: 0;
}

@media screen and (max-width: 1200px) {
    #header {
        padding: 10px 0;
    }

    #header div.menu-wrapper {
        padding-top: 10px;
        padding-bottom: 10px;
    }

    #header .logo img {
        width: 150px;
    }

    .home-hero-publication {
        min-height: 48vh;
        padding-top: 40px;
        padding-bottom: 48px;
    }
}

@media screen and (max-width: 767px) {
    #header .logo {
        max-width: none;
    }

    #header .logo img {
        width: 140px;
    }

    .home-hero-publication {
        min-height: 44vh;
        padding-top: 32px;
        padding-bottom: 40px;
    }

    .home-hero-publication-logo {
        width: min(180px, 52vw);
    }

    .kg-gallery-container,
    .kg-gallery-row {
        gap: 0.5rem;
    }
}

/* ============================================================
   TAG ARCHIVE
   ============================================================ */

#archives .tag-description .epcl-flex {
    justify-content: center;
    text-align: center;
}

#archives .tag-description {
    margin-top: 0;
}

#archives .tag-description .left {
    text-align: center;
}

#archives .tag-description .left .title {
    white-space: normal;
}

#archives .tag-description .left .meta {
    margin-left: 0;
}

/* ============================================================
   POST CONTENT TYPOGRAPHY
   The post content in Slate is wrapped in .text.border-effect
   inside .main-article .post-content
   ============================================================ */

.text.border-effect {
    font-family: var(--f-font-body);
    font-size: 1.125rem;        /* 18px */
    line-height: 1.625;         /* relaxed */
    color: var(--f-text);
    max-width: var(--f-content-width);
    margin-left: auto;
    margin-right: auto;
}

.text.border-effect .kg-width-wide {
    width: min(100vw - 40px, var(--f-wide-width));
    max-width: none;
    margin-left: 50%;
    transform: translateX(-50%);
}

.text.border-effect .kg-width-full {
    width: min(100vw, 100%);
    max-width: none;
}

/* Headings */
.text.border-effect h1 {
    font-family: var(--f-font-heading);
    font-weight: 500;
    letter-spacing: -0.025em;
    color: var(--f-heading);
    font-size: 2.25rem;
    line-height: 1.11;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.text.border-effect h2 {
    font-family: var(--f-font-heading);
    font-weight: 500;
    letter-spacing: -0.025em;
    color: var(--f-heading);
    font-size: 1.875rem;
    line-height: 1.2;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.text.border-effect h3 {
    font-family: var(--f-font-heading);
    font-weight: 500;
    letter-spacing: -0.025em;
    color: var(--f-heading);
    font-size: 1.5rem;
    line-height: 1.33;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.text.border-effect h4 {
    font-family: var(--f-font-heading);
    font-weight: 500;
    letter-spacing: -0.025em;
    color: var(--f-heading);
    font-size: 1.25rem;
    line-height: 1.4;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.text.border-effect h5 {
    font-family: var(--f-font-heading);
    font-weight: 500;
    letter-spacing: -0.025em;
    color: var(--f-heading);
    font-size: 1.125rem;
    line-height: 1.56;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.text.border-effect h6 {
    font-family: var(--f-font-heading);
    font-weight: 500;
    letter-spacing: -0.025em;
    color: var(--f-heading);
    font-size: 1rem;
    line-height: 1.5;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

/* Adjacent headings collapse margin */
.text.border-effect h1 + h2,
.text.border-effect h2 + h3,
.text.border-effect h3 + h4,
.text.border-effect h4 + h5,
.text.border-effect h5 + h6 {
    margin-top: 0;
}

/* Paragraphs */
.text.border-effect p {
    margin-bottom: 2rem;
}

/* Links (not inside KG cards) */
.text.border-effect a:not(.kg-btn):not(.kg-bookmark-container):not(.kg-file-card-container):not(.kg-product-card-button):not(.kg-product-card-btn-accent) {
    color: inherit;
    text-decoration: underline;
    transition: opacity 0.15s ease;
}

.text.border-effect a:not(.kg-btn):not(.kg-bookmark-container):not(.kg-file-card-container):not(.kg-product-card-button):not(.kg-product-card-btn-accent):hover {
    opacity: 0.75;
}

/* Bold/strong */
.text.border-effect strong,
.text.border-effect b {
    font-weight: 500;
}

/* Blockquote — standard */
.text.border-effect blockquote:not(.kg-blockquote-alt) {
    color: var(--f-text);
    background: none;
    border: 0;
    border-radius: 0;
    border-left: 3px solid var(--f-accent);
    box-shadow: none;
    font-style: italic !important;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
    margin: 0 0 2rem;
    padding: 0 0 0 1.5rem;
    position: static;
    z-index: auto;
}

.text.border-effect blockquote:not(.kg-blockquote-alt)::after {
    content: none;
    display: none;
}

.text.border-effect blockquote:not(.kg-blockquote-alt) p,
.text.border-effect blockquote:not(.kg-blockquote-alt) em {
    font-family: inherit;
    font-style: inherit;
}

.text.border-effect blockquote:not(.kg-blockquote-alt) p {
    margin-bottom: 1rem;
}

.text.border-effect blockquote:not(.kg-blockquote-alt) p:last-child {
    margin-bottom: 0;
}

.text.border-effect blockquote:not(.kg-blockquote-alt) cite,
.text.border-effect blockquote:not(.kg-blockquote-alt) .kg-blockquote-citation {
    font-family: var(--f-font-heading);
    color: var(--f-heading);
}

/* Blockquote — large pull quote */
.text.border-effect .kg-blockquote-alt,
.kg-blockquote-alt {
    text-align: center;
    font-family: var(--f-font-heading);
    font-weight: 500;
    letter-spacing: 0;
    color: var(--f-heading);
    background: none;
    font-size: 1.875rem;
    line-height: 1.2;
    font-style: italic !important;
    margin: 2rem 0;
    padding: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    position: static;
    z-index: auto;
}

.text.border-effect .kg-blockquote-alt::after,
.kg-blockquote-alt::after {
    content: none;
    display: none;
}

.text.border-effect .kg-blockquote-alt p,
.text.border-effect .kg-blockquote-alt em,
.kg-blockquote-alt p,
.kg-blockquote-alt em {
    font-family: inherit;
    font-style: inherit;
}

@media (min-width: 640px) {
    .text.border-effect .kg-blockquote-alt,
    .kg-blockquote-alt {
        font-size: 2.25rem;
        line-height: 1.111;
    }
}

/* Inline code */
.text.border-effect code:not(pre code),
.text.border-effect kbd {
    background-color: var(--f-surface);
    padding: 0.125rem 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.25rem;
    font-family: var(--f-font-mono);
}

/* Code block */
.text.border-effect pre {
    border-radius: var(--f-radius);
    background-color: var(--f-surface);
    padding: 1.5rem;
    font-size: 0.875rem;
    line-height: 1.57;
    font-weight: 500;
    overflow-x: auto;
    font-family: var(--f-font-mono);
    margin-bottom: 2rem;
    direction: ltr;
}

.text.border-effect pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
}

/* Images */
.text.border-effect img:not(.kg-image):not(.kg-gallery-image img):not(.kg-bookmark-thumbnail img) {
    border-radius: var(--f-radius);
    background-color: var(--f-surface);
}

/* Figure captions */
.text.border-effect figcaption,
.text.border-effect .kg-card figcaption {
    text-align: center;
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--f-meta);
    margin-top: 0.75rem;
}

/* Tables */
.text.border-effect table {
    width: 100%;
    font-size: 1rem;
    display: block;
    overflow: auto;
    margin-bottom: 2rem;
    border-collapse: collapse;
}

.text.border-effect th,
.text.border-effect td {
    padding: 0.5rem 1rem;
    border: 1px solid var(--f-border);
}

.text.border-effect th {
    background-color: var(--f-surface);
    font-family: var(--f-font-heading);
    font-weight: 500;
    text-align: left;
}

/* Horizontal rule */
.text.border-effect hr {
    border: none;
    border-top: 1px solid var(--f-border);
    margin: 3rem 0;
}

/* Lists */
.text.border-effect ul,
.text.border-effect ol {
    padding-left: 1.5rem;
    margin-bottom: 2rem;
}

.text.border-effect li {
    margin-bottom: 0.5rem;
}

/* ============================================================
   KG CARD STYLES
   ============================================================ */

/* Shared card spacing */
.text.border-effect .kg-card {
    margin-bottom: 2rem;
}

/* --- Image Card --- */
.kg-image-card img,
.text.border-effect .kg-image {
    background-color: var(--f-surface);
}

.kg-image-card .theory-image-lightbox {
    cursor: zoom-in;
}

.kg-image-card:not(.kg-width-full):not(.kg-width-wide) img {
    border-radius: var(--f-radius);
}

.kg-image-card.kg-width-full img,
.kg-image-card.kg-width-wide img {
    width: 100%;
}

/* --- Gallery Card --- */
.kg-gallery-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.kg-gallery-row {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.kg-gallery-image {
    flex: 1;
    min-width: 0;
}

.kg-gallery-image img {
    border-radius: var(--f-radius);
    background-color: var(--f-surface);
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* --- Callout Cards --- */
.kg-callout-card {
    display: flex;
    column-gap: 0.75rem;
    align-items: flex-start;
    border-radius: var(--f-radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.kg-callout-emoji {
    font-size: 1.25rem;
    line-height: 1.6;
    flex-shrink: 0;
}

.kg-callout-text {
    font-size: 1rem;
    line-height: 1.6;
}

.kg-callout-card-white { border: 1px solid var(--f-border); }
.kg-callout-card-grey  { background-color: rgba(0, 0, 0, 0.06); }
.kg-callout-card-blue  { background-color: rgba(59, 130, 246, 0.10); }
.kg-callout-card-green { background-color: rgba(34, 197, 94, 0.10); }
.kg-callout-card-yellow{ background-color: rgba(234, 179, 8, 0.10); }
.kg-callout-card-red   { background-color: rgba(239, 68, 68, 0.10); }
.kg-callout-card-pink  { background-color: rgba(236, 72, 153, 0.10); }
.kg-callout-card-purple{ background-color: rgba(168, 85, 247, 0.10); }
.kg-callout-card-accent{
    background-color: var(--f-accent);
    color: var(--f-contrast);
}

html.dark .kg-callout-card-grey {
    background-color: rgba(255, 255, 255, 0.06);
}

/* --- Button Card --- */
.kg-button-card {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.kg-button-card.kg-align-left {
    justify-content: flex-start;
}

.kg-button-card .kg-btn,
.kg-button-card .kg-btn-accent {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--f-font-body);
    font-weight: 400;
    transition: opacity 0.15s ease;
    border-radius: 9999px;
    padding: 0.5rem 1.5rem;
    font-size: 1.125rem;
    line-height: 1.56;
    text-decoration: none;
    background-color: var(--f-accent);
    color: var(--f-contrast);
    cursor: pointer;
    border: none;
}

.kg-button-card .kg-btn:hover,
.kg-button-card .kg-btn-accent:hover {
    opacity: 0.85;
}

/* --- Bookmark Card --- */
.kg-bookmark-card {
    margin-bottom: 2rem;
}

.kg-bookmark-container {
    border-radius: var(--f-radius);
    background-color: var(--f-surface);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    text-decoration: none;
    color: var(--f-text);
    transition: opacity 0.15s ease;
}

.kg-bookmark-container:hover {
    opacity: 0.85;
}

@media (min-width: 640px) {
    .kg-bookmark-container {
        flex-direction: row;
    }
    .kg-bookmark-thumbnail {
        order: -9999;
    }
}

.kg-bookmark-content {
    padding: 1.5rem;
    flex: 1;
}

.kg-bookmark-title {
    font-family: var(--f-font-heading);
    font-weight: 500;
    letter-spacing: -0.025em;
    color: var(--f-heading);
    font-size: 1.25rem;
    line-height: 1.4;
}

.kg-bookmark-description {
    margin-top: 0.375rem;
    font-size: 0.875rem;
    line-height: 1.43;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.kg-bookmark-metadata {
    margin-top: 1rem;
    font-size: 0.75rem;
    color: var(--f-meta);
    display: flex;
    align-items: center;
    white-space: nowrap;
    width: 100%;
}

.kg-bookmark-icon {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    margin-right: 0.5rem;
}

.kg-bookmark-publisher::before {
    content: "•";
    padding: 0 0.5rem;
}

.kg-bookmark-metadata > span:last-child {
    text-overflow: ellipsis;
    overflow: hidden;
}

.kg-bookmark-thumbnail {
    aspect-ratio: 16 / 9;
    flex-grow: 1;
    position: relative;
    min-width: 33.333%;
}

.kg-bookmark-thumbnail img {
    position: absolute;
    inset: 0;
    background-color: var(--f-surface-2);
    object-fit: cover;
    width: 100%;
    height: 100%;
}

/* --- Product Card --- */
.kg-product-card {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.kg-product-card-container {
    width: 100%;
    max-width: 36rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, auto);
    gap: 1rem;
    border-radius: var(--f-radius);
    background-color: var(--f-surface);
    padding: 1.5rem;
}

.kg-product-card-image {
    grid-column: span 2;
    border-radius: var(--f-radius);
    background-color: var(--f-surface-2);
    overflow: hidden;
    width: 100%;
}

.kg-product-card-image img {
    width: 100%;
    display: block;
}

.kg-product-card-title-container {
    grid-column: span 2;
}

.kg-product-card-title {
    font-family: var(--f-font-heading);
    font-weight: 500;
    letter-spacing: -0.025em;
    color: var(--f-heading);
    font-size: 1.5rem;
    line-height: 1.33;
    margin: 0;
}

.kg-product-card-description {
    grid-column: span 2;
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 0.375rem;
}

.kg-product-card-description:empty { display: none; }

.kg-product-card-rating {
    display: flex;
    align-items: center;
    column-gap: 0.25rem;
    font-size: 1rem;
}

.kg-product-card-rating-star {
    width: 1em;
    height: 1em;
    opacity: 0.2;
}

.kg-product-card-rating-active { opacity: 1; }

.kg-product-card-rating-star svg {
    width: 100%;
    height: 100%;
    fill: var(--f-accent);
}

.kg-product-card-button,
.kg-product-card-btn-accent {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--f-font-body);
    font-weight: 400;
    transition: opacity 0.15s ease;
    border-radius: 9999px;
    padding: 0.5rem 1.5rem;
    font-size: 1.125rem;
    line-height: 1.56;
    text-decoration: none;
    background-color: var(--f-accent);
    color: var(--f-contrast);
    grid-column: span 2;
}

.kg-product-card-button:hover,
.kg-product-card-btn-accent:hover { opacity: 0.85; }

/* --- Toggle Card --- */
.kg-toggle-card {
    border-radius: var(--f-radius);
    background-color: var(--f-surface);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.kg-toggle-heading {
    z-index: 10;
    margin: -1.5rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    padding: 1.5rem;
    position: relative;
    list-style: none;
}

.kg-toggle-heading-text {
    font-family: var(--f-font-heading);
    font-weight: 500;
    letter-spacing: -0.025em;
    color: var(--f-heading);
    font-size: 1.25rem;
    line-height: 1.4;
    margin: 0;
}

.kg-toggle-heading svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8px;
    transition: rotate 0.2s ease;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
}

.kg-toggle-card[data-kg-toggle-state="open"] .kg-toggle-heading svg {
    rotate: -180deg;
}

.kg-toggle-content {
    height: 0;
    opacity: 0;
    overflow: hidden;
    transition: height 0.15s ease, opacity 0.15s ease;
}

.kg-toggle-card[data-kg-toggle-state="open"] .kg-toggle-content {
    height: auto;
    opacity: 1;
}

.kg-toggle-content > * { margin-top: 1rem; }

.kg-toggle-content a {
    color: inherit;
    text-decoration: underline;
    transition: opacity 0.15s ease;
}

.kg-toggle-content a:hover { opacity: 0.85; }

/* --- File Card --- */
.kg-file-card {
    margin-bottom: 2rem;
}

.kg-file-card-container {
    display: flex;
    border-radius: var(--f-radius);
    background-color: var(--f-surface);
    width: 100%;
    padding: 1rem;
    text-decoration: none;
    color: var(--f-text);
    transition: opacity 0.15s ease;
}

.kg-file-card-container:hover { opacity: 0.85; }

.kg-file-card-icon {
    width: 5rem;
    height: 5rem;
    border-radius: 48% 52% 34% 66% / 52% 38% 62% 48%;
    background-color: var(--f-surface-2);
    font-size: 1.5rem;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.kg-file-card-contents {
    flex: 1;
    padding: 0.5rem 1rem 0.5rem 0.5rem;
}

.kg-file-card-title {
    font-family: var(--f-font-heading);
    font-weight: 500;
    letter-spacing: -0.025em;
    color: var(--f-heading);
    font-size: 1.25rem;
    line-height: 1.4;
}

.kg-file-card-caption {
    margin-top: 0.375rem;
    font-size: 0.875rem;
    line-height: 1.43;
}

.kg-file-card-caption:empty { display: none; }

.kg-file-card-metadata {
    margin-top: 1rem;
    font-size: 0.75rem;
    color: var(--f-meta);
}

.kg-file-card-filesize { display: inline; }

.kg-file-card-filesize::before {
    content: "•";
    padding: 0 0.5rem;
    display: inline-block;
}

/* --- Audio Card --- */
.kg-audio-card {
    --seek-before-width: 0%;
    --volume-before-width: 100%;
    display: flex;
    column-gap: 1rem;
    border-radius: var(--f-radius);
    background-color: var(--f-surface);
    padding: 1rem;
    overflow: hidden;
    margin-bottom: 2rem;
    align-items: flex-start;
}

.kg-audio-thumbnail {
    width: 5rem;
    height: 5rem;
    border-radius: 48% 52% 34% 66% / 52% 38% 62% 48%;
    object-fit: cover;
    flex-shrink: 0;
    display: flex;
    align-self: flex-start;
    justify-content: center;
    align-items: center;
}

.kg-audio-thumbnail.placeholder {
    background-color: var(--f-surface-2);
    font-size: 1.5rem;
}

.kg-audio-player-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    padding: 0.25rem 0;
}

.kg-audio-title {
    font-family: var(--f-font-heading);
    font-weight: 500;
    letter-spacing: -0.025em;
    color: var(--f-heading);
    font-size: 1.25rem;
    line-height: 1.4;
}

.kg-audio-player {
    margin-top: 1rem;
    width: 100%;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    display: flex;
    align-items: center;
}

.kg-audio-hide { display: none !important; }

.kg-audio-current-time {
    min-width: 1.75rem;
    margin-left: 1rem;
    margin-right: 0.25rem;
}

.kg-audio-duration {
    margin-left: 0.25rem;
    margin-right: 1rem;
}

.kg-audio-playback-rate {
    margin-left: 0.5rem;
    margin-right: 1rem;
    cursor: pointer;
    background: none;
    border: none;
    font-size: 0.75rem;
    font-weight: 500;
    color: inherit;
    padding: 0;
}

.kg-audio-seek-slider,
.kg-audio-volume-slider {
    flex: 1;
    width: 100%;
    position: relative;
    appearance: none;
    background: transparent;
}

.kg-audio-seek-slider::before,
.kg-audio-volume-slider::before {
    content: "";
    position: absolute;
    left: 0;
    height: 0.25rem;
    width: var(--seek-before-width);
    background-color: var(--f-accent);
    border-radius: 9999px;
    pointer-events: none;
}

.kg-audio-volume-slider::before { width: var(--volume-before-width); }

.kg-audio-seek-slider::-webkit-slider-runnable-track,
.kg-audio-volume-slider::-webkit-slider-runnable-track {
    height: 0.25rem;
    cursor: pointer;
    background-color: var(--f-surface-2);
    border-radius: 9999px;
}

.kg-audio-seek-slider::-webkit-slider-thumb,
.kg-audio-volume-slider::-webkit-slider-thumb {
    appearance: none;
    width: 0.875rem;
    height: 0.875rem;
    transform: translateY(-0.3125rem);
    cursor: pointer;
    background-color: #ffffff;
    border: none;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.kg-audio-volume-slider {
    width: 5rem;
    margin-left: 0.25rem;
    flex: none;
}

/* --- Video Card --- */
.kg-video-card {
    border-radius: var(--f-radius);
    overflow: hidden;
    margin-bottom: 2rem;
    background-color: var(--f-surface-2);
}

.kg-video-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    padding: 0 !important;
}

.kg-video-overlay {
    position: absolute;
    inset: 0;
    z-index: 30;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(to bottom, rgba(0,0,0,0.3), transparent 50%);
    transition: opacity 0.15s ease;
}

.kg-video-large-play-icon {
    width: 4rem;
    height: 4rem;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 9999px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #ffffff;
    transition: opacity 0.15s ease;
}

.kg-video-large-play-icon svg { margin-left: 0.25rem; }

/* --- CTA Card --- */
.kg-cta-card {
    border-radius: var(--f-radius);
    background-color: var(--f-surface);
    padding: 2rem;
    margin-bottom: 2rem;
    text-align: center;
}

.kg-cta-card.kg-cta-bg-grey { background-color: rgba(0, 0, 0, 0.06); }
html.dark .kg-cta-card.kg-cta-bg-grey { background-color: rgba(255, 255, 255, 0.06); }

.kg-cta-card.kg-cta-minimal {
    padding: 1.5rem;
    text-align: left;
}

.kg-cta-content {
    max-width: 36rem;
    margin: 0 auto;
}

.kg-cta-sponsor-label-wrapper {
    margin-bottom: 1rem;
    font-size: 0.75rem;
    color: var(--f-meta);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kg-cta-text {
    font-size: 1rem;
    line-height: 1.6;
}

/* ============================================================
   IMAGE CARD GRID  (homepage post feed)
   ============================================================ */

.theory-card-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    padding: 40px 0 32px;
    max-width: var(--f-wide-width);
    margin: 0 auto;
}

.theory-card {
    border-radius: var(--f-radius);
    overflow: hidden;
    background: var(--f-surface);
    cursor: pointer;
    border: 1px solid var(--f-border);
    box-shadow: 0 24px 58px rgba(27, 27, 30, 0.24), 0 8px 18px rgba(27, 27, 30, 0.14);
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
    aspect-ratio: 2 / 3;
    min-height: 0;
}

.theory-card:hover {
    transform: translateY(-2px);
    border-color: var(--f-accent);
    box-shadow: 0 34px 78px rgba(27, 27, 30, 0.32), 0 12px 28px rgba(27, 27, 30, 0.18);
}

.theory-card-link {
    display: block;
    position: relative;
    width: 100%;
    height: 100%;
    text-decoration: none;
    color: #ffffff;
}

.theory-card-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: var(--f-surface-2);
    overflow: hidden;
    z-index: 1;
}

.theory-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.45s ease;
}

.theory-card:hover .theory-card-image img {
    transform: scale(1.03);
}

.theory-card-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 24px;
    padding: 24px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.58) 0%, rgba(0, 0, 0, 0.18) 44%, rgba(0, 0, 0, 0) 72%);
    color: #ffffff;
    z-index: 2;
}

.theory-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.theory-tag-pill {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #ffffff;
    background: rgba(27, 27, 30, 0.28);
    backdrop-filter: blur(12px) saturate(150%);
    text-decoration: none;
    line-height: 1.4;
    font-family: var(--f-font-body);
}

.theory-card-top .access-icon {
    position: static;
    color: #ffffff;
    background: rgba(27, 27, 30, 0.28);
    backdrop-filter: blur(12px) saturate(150%);
    border-radius: 9999px;
    width: 28px;
    height: 28px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.theory-card-top .access-icon svg {
    width: 16px;
    height: 16px;
}

.theory-card-bottom {
    max-width: none;
}

.theory-card-title {
    color: #ffffff;
    font-size: clamp(1.45rem, 2.15vw, 1.65rem);
    font-weight: 500;
    line-height: 1.12;
    margin: 0 0 6px;
    font-family: var(--f-font-heading);
    letter-spacing: -0.025em;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: visible;
}

.theory-card-excerpt {
    display: none;
}

.theory-card-date {
    display: block;
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.875rem;
    font-weight: 400;
    font-family: var(--f-font-body);
    text-transform: none;
    letter-spacing: 0;
}

.theory-card-fallback {
    background: linear-gradient(135deg, var(--f-accent) 0%, var(--f-surface-2) 100%);
}

.home-subscribe-panel {
    width: min(640px, 100%);
    margin: 36px auto 20px;
    text-align: center;
}

.home-subscribe-title {
    max-width: 620px;
    margin: 0 auto 22px;
    font-family: var(--f-font-heading);
    font-size: 2rem;
    font-weight: 500;
    line-height: 1.08;
    letter-spacing: -0.025em;
    color: var(--f-heading);
}

.home-subscribe-panel .subscribe-form {
    width: min(520px, 100%);
    margin: 0 auto;
}

.home-subscribe-panel .subscribe-form .form-group {
    margin: 0;
}

.home-subscribe-panel .subscribe-form .success-message,
.home-subscribe-panel .subscribe-form .error-detail {
    margin-top: 12px;
}

/* Grid responsive breakpoints */
@media (max-width: 1100px) {
    .theory-card-grid {
        max-width: 860px;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .theory-card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 18px;
    }
    .theory-card-overlay {
        padding: 20px;
        gap: 16px;
    }
    .theory-card-title { font-size: 1.55rem; }
}

@media (max-width: 480px) {
    .theory-card-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        max-width: 340px;
        padding-top: 28px;
    }

    .theory-card {
        aspect-ratio: 4 / 5;
        max-height: 440px;
    }

    .theory-card-overlay {
        padding: 16px;
        gap: 12px;
    }

    .theory-card-title {
        font-size: 1.3rem;
        line-height: 1.15;
        -webkit-line-clamp: 2;
    }

    .theory-tag-pill {
        padding: 3px 10px;
        font-size: 0.68rem;
    }

    .theory-card-date {
        font-size: 0.8rem;
    }
}

/* ============================================================
   SOCIAL LINKS — profile section
   ============================================================ */

.theory-social-links {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    margin: 16px 0 4px;
}

.theory-social-links:not(:has(a)) { display: none; }

.theory-social-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    text-decoration: none;
    color: var(--f-accent);
    background: var(--f-social-bg);
    transition: opacity 0.15s ease, background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
    box-shadow: none;
    flex-shrink: 0;
}

.theory-social-btn:hover {
    opacity: 1;
    color: var(--f-contrast);
    background: var(--f-accent);
    text-decoration: none;
    transform: translateY(-1px);
}

.theory-social-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    display: block;
}

.theory-social-facebook,
.theory-social-instagram,
.theory-social-strava {
    background: var(--f-social-bg);
    color: var(--f-accent);
}
