/*
╔═══════════════════════════════════════════════════════════════════╗
║ MD CARDS - Blog Post Cards                                       ║
║ Screen-fill layout: cards always fill 100% of available stage    ║
╚═══════════════════════════════════════════════════════════════════╝
*/

/* ====================================================================
   TUNABLE VARIABLES - Change these to adjust card proportions
   ==================================================================== */

.md-cards-stage {
    /* Layout */
    --mdc-img-ratio:            50%;        /* image section height       */
    --mdc-min-holder-h:         240px;      /* min card height            */

    /* Image footer */
    --mdc-footer-h:             28px;       /* stats bar height           */
    --mdc-footer-font:          12px;       /* stats bar font size        */
    --mdc-footer-icon:          12px;       /* stats bar icon size        */

    /* Title */
    --mdc-title-h:              56px;       /* title area height          */
    --mdc-title-font:           16px;       /* title font size            */
    --mdc-title-lines:          2;          /* max title lines            */
    --mdc-title-line-h:         1.4;        /* title line-height          */

    /* Summary */
    --mdc-summary-font:         14px;       /* summary font size          */
    --mdc-summary-lines:        3;          /* max summary lines          */
    --mdc-summary-line-h:       1.6;        /* summary line-height        */
    --mdc-summary-pad:          0 20px;     /* summary padding            */

    /* Keywords */
    --mdc-kw-font:              11px;       /* keyword font size          */
    --mdc-kw-pad:               6px 20px;   /* keyword row padding        */

    /* Action bar */
    --mdc-actions-h:            36px;       /* action bar height          */
    --mdc-actions-icon:         13px;       /* action icon size           */
    --mdc-tag-h:                30px;       /* category tag height        */
    --mdc-tag-font:             11px;       /* category tag font size     */
    --mdc-tag-icon:             11px;       /* category tag icon size     */

    /* Overlay */
    --mdc-overlay-font:         20px;       /* "READ NOW!" font size      */
    --mdc-overlay-spacing:      4px;        /* letter-spacing             */

    /* Badge */
    --mdc-badge-font:           9px;        /* badge font size            */

    /* Fallback icon */
    --mdc-icon-fallback:        3.5rem;     /* fallback icon size         */
}

/* ====================================================================
   STAGE - Container that cards fill. MUST have explicit height.
   Applied by the renderer onto the target container.
   ==================================================================== */

.md-cards-stage {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
    font-size: 0;
}

/* ====================================================================
   CARD HOLDER - The screen-fill math
   ==================================================================== */

.md-card-holder {
    width: 25%;
    height: 50%;
    min-height: var(--mdc-min-holder-h);
    float: left;
    position: relative;
    overflow: hidden;
    font-size: 16px;
}

.md-card {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    cursor: pointer;
}

/* ====================================================================
   IMAGE SECTION - Top half of card
   ==================================================================== */

.md-card-img {
    width: 100%;
    height: var(--mdc-img-ratio);
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

.md-card-img-bg {
    height: 100%;
    width: 100%;
    background-size: cover;
    background-position: center;
    display: block;
    position: absolute;
    overflow: hidden;
    transition: all 0.4s ease-in-out;
    filter: grayscale(100%);
}

.md-card-img-icon {
    height: 100%;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--io-surface-raised), var(--io-surface-sunken));
    position: absolute;
}

.md-card-img-icon i {
    font-size: var(--mdc-icon-fallback);
    color: var(--io-accent-dim);
    opacity: 0.25;
}

/* ====================================================================
   HOVER OVERLAY - "READ NOW!"
   Class .md-no-codex prevents CODEX from scanning scramble targets
   ==================================================================== */

.md-card-overlay {
    height: 100%;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.3s ease-in-out;
    cursor: pointer;
    position: relative;
    z-index: 1;
}

.md-card-overlay a {
    font-family: Geo;
    font-size: 30px;
    letter-spacing: var(--mdc-overlay-spacing);
    text-transform: uppercase;
    user-select: none;
    cursor: pointer;
    color: var(--io-accent-bright);
    text-shadow: 0 0 30px var(--io-accent-glow);
}

.md-card-img-bg:has(.md-card-overlay:hover) {
    transform: scale(1.1);
    filter: grayscale(50%);
}

.md-card-overlay:hover {
    opacity: 1;
background-color: color-mix(in srgb, var(--io-surface-base) 90%, transparent);
backdrop-filter: blur(2px);
}

/* ====================================================================
   IMAGE FOOTER BAR
   ==================================================================== */

.md-card-img-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--mdc-footer-h);
background-color: color-mix(in srgb, var(--io-surface-base) 80%, transparent);
    font-family: var(--io-font-mono);
    user-select: none;
    line-height: var(--mdc-footer-h);
    font-size: var(--mdc-footer-font);
    padding: 0 8px;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.md-card-stat {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--io-text-tertiary);
    font-size: var(--mdc-footer-font);
    line-height: var(--mdc-footer-h);
}

.md-card-stat i {
    color: var(--io-accent-dim);
    font-size: var(--mdc-footer-icon);
}

.md-card-stats-left,
.md-card-stats-right {
    display: flex;
    gap: 12px;
}

/* ====================================================================
   CONTENT SECTION - Bottom half of card
   ==================================================================== */

.md-card-content {
    height: calc(100% - var(--mdc-img-ratio));
    width: 100%;
    background: var(--io-surface-base);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Title: 2 lines max, then ellipsis ── */
.md-card-title {
    width: 100%;
    flex-shrink: 0;
    padding: 8px 16px 0;
}

.md-card-title a {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: var(--mdc-title-lines);
    overflow: hidden;
    text-align: center;
    font-family: var(--io-font-primary);
    font-size: var(--mdc-title-font);
    font-weight: 700;
    line-height: var(--mdc-title-line-h);
    user-select: none;
    cursor: pointer;
    transition: color 0.3s ease-in-out;
    color: var(--io-text-primary);
}

.md-card-title a {
    background: linear-gradient(to right, var(--io-accent-bright) 50%, var(--io-text-primary) 50%);
    background-size: 200% 100%;
    background-position: 100% 0;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    transition: background-position 0.6s ease;
}

.md-card:hover .md-card-title a {
    background-position: 0% 0;
}

.md-card-title a:hover {
    color: #fff;
}

/* Card hover anywhere = image loses grayscale */
.md-card:hover .md-card-img-bg {
    filter: grayscale(0%);
}

/* Overlay hover specifically = zoom */
.md-card-img-bg:has(.md-card-overlay:hover) {
    transform: scale(1.1);
}

/* ── Summary: clamped ── */
.md-card-summary {
    flex: 1;
    width: 100%;
    padding: var(--mdc-summary-pad);
    padding-top: 18px;
    min-height: 0;
    overflow: hidden;
}

.md-card-summary-text {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: var(--mdc-summary-lines);
    overflow: hidden;
    font-family: var(--io-font-primary);
    font-size: var(--mdc-summary-font);
    line-height: var(--mdc-summary-line-h);
    color: var(--io-text-secondary);
    hyphens: auto;
    overflow-wrap: break-word;
}

/* ── Keywords row ── */
.md-card-keywords {
    width: 100%;
    padding: var(--mdc-kw-pad);
    font-family: var(--io-font-mono);
    font-size: var(--mdc-kw-font);
    text-align: center;
    user-select: none;
    color: var(--io-text-tertiary);
    letter-spacing: 0.5px;
    transition: color 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.md-card-keywords:hover {
    color: var(--io-accent);
}

/* ====================================================================
   BOTTOM ACTION BAR - sits below keywords, no overlap
   ==================================================================== */

.md-card-actions {
    width: 100%;
    height: var(--mdc-actions-h);
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    border-top: 1px solid var(--io-border-subtle);
}

.md-card-actions-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.md-card-actions-left i {
    font-size: var(--mdc-actions-icon);
    color: var(--io-text-tertiary);
    cursor: pointer;
    transition: color 0.2s;
}

.md-card-actions-left i:hover {
    color: #fff;
}

/* Category tag */
.md-card-tag {
    height: var(--mdc-tag-h);
    padding: 0 14px;
    background: var(--io-surface-sunken);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    gap: 7px;
    transition: all 0.2s;
}

.md-card-tag i {
    font-size: var(--mdc-tag-icon);
    color: var(--io-text-tertiary);
    transition: color 0.3s;
}

.md-card-tag span {
    font-size: var(--mdc-tag-font);
    font-family: var(--io-font-mono);
    color: var(--io-text-tertiary);
    transition: color 0.3s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.md-card-tag:hover i,
.md-card-tag:hover span {
    color: #fff;
}

/* ====================================================================
   BADGES
   ==================================================================== */

.md-card-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 3;
    font-family: var(--io-font-mono);
    font-size: var(--mdc-badge-font);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 3px 8px;
    user-select: none;
}

.md-card-badge-pinned {
    background: var(--io-accent);
    color: var(--io-on-accent);
}

.md-card-badge-draft {
    background: var(--io-warning, #f7c94c);
    color: #000;
}

/* ====================================================================
   EMPTY STATE
   ==================================================================== */

.md-cards-empty {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--io-space-lg);
    color: var(--io-text-tertiary);
}

.md-cards-empty i {
    font-size: 4rem;
    color: var(--io-accent);
    opacity: 0.2;
}

.md-cards-empty p {
    font-size: var(--io-text-lg);
}

/* ====================================================================
   RESPONSIVE
   ==================================================================== */

@media (max-width: 2199px) { .md-card-holder { width: 33.33%; } }
@media (max-width: 1599px) { .md-card-holder { width: 50%; } }
@media (max-width: 1023px) { .md-card-holder { width: 100%; } }

@media (max-width: 1023px) {
    .md-card-overlay a          { font-size: 18px; letter-spacing: 3px; }
    .md-card-title a            { font-size: 15px; }
    .md-card-summary-text       { font-size: 13px; }
}