/* -------------- Pytorch demystified series (shared across all posts) ---------------- */

.pytorch-step-row {
    display: flex;
    align-items: center;
    gap: 30px;
    margin-bottom: 20px;
}

.pytorch-step-text {
    flex: 1 1 45%;
    min-width: 0;
}

.pytorch-step-figs {
    flex: 1 1 55%;
    min-width: 0;
}

.pytorch-step-img {
    width: 95%;
}

/*
 * pytorch-step-row-compact: tighter gap between text and figure, with the
 * figure claiming the space that frees up, and the row itself flush against
 * the surrounding text (plain divs otherwise inherit a global 2% side margin).
 */
.pytorch-step-row.pytorch-step-row-compact {
    gap: 15px;
    margin-left: 0;
    margin-right: 0;
}

.pytorch-step-row-compact .pytorch-step-text {
    flex: 1 1 40%;
    margin-left: 0;
    margin-right: 0;
}

.pytorch-step-row-compact .pytorch-step-figs {
    flex: 1 1 60%;
    margin-left: 0;
    margin-right: 0;
}

.pytorch-optional {
    margin: 30px 0;
    border: 1px solid var(--color-article-date);
    border-radius: 6px;
    padding: 0 20px 20px 20px;
}

.pytorch-optional-summary {
    cursor: pointer;
    list-style: none;
    padding: 15px 0;
}

.pytorch-optional-summary::-webkit-details-marker {
    display: none;
}

.pytorch-optional-summary h4 {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.pytorch-optional-summary h4::before {
    content: "\25B8";
    display: inline-block;
    transition: transform 0.2s ease;
}

.pytorch-optional[open] .pytorch-optional-summary h4::before {
    transform: rotate(90deg);
}

.pytorch-optional-collapse-bar {
    position: sticky;
    top: 40px;
    z-index: 500;
    display: flex;
    justify-content: center;
    padding: 8px 0;
    margin: 0 0 10px 0;
    background: var(--color-bg);
}

.pytorch-optional-collapse-btn {
    background-color: var(--color-chrome-bg);
    color: var(--color-chrome-text);
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    font-size: 0.9em;
    cursor: pointer;
}

.pytorch-optional-collapse-btn:hover {
    opacity: 0.85;
}

h4.heading-spaced {
    margin-top: 20px;
}

/*
 * Summary tile for each optimization step: before/after/speedup/commit.
 * Reuses the same background/shadow tokens as .blog-index-div, but static
 * (no hover effects) since this sits inline within an article, not a list.
 */
.pytorch-opt-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    max-width: 900px;
    margin: 20px auto;
    padding: 16px 24px;
    border-radius: 8px;
    background-color: var(--color-blog-odd);
    box-shadow: 4px 6px 16px var(--color-blog-shadow);
}

.pytorch-opt-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pytorch-opt-stat-label {
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-article-date);
}

.pytorch-opt-stat-value {
    font-size: 1.1em;
    font-weight: 600;
}

/* start tables */
.pytorch-table-wrap {
    overflow-x: auto;
    margin: 20px 0;
}

.pytorch-reg-table {
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
    border-collapse: collapse;
    font-size: 0.95em;
}

.pytorch-reg-table caption {
    caption-side: top;
    font-style: italic;
    color: var(--color-font-figure);
    margin-bottom: 8px;
}

.pytorch-reg-table th,
.pytorch-reg-table td {
    border: 1px solid var(--color-article-date);
    padding: 6px 12px;
    text-align: center;
    white-space: nowrap;
}

.pytorch-reg-table th {
    background-color: var(--color-blog-odd);
}

.pytorch-reg-table tbody tr:nth-child(even) td {
    background-color: var(--color-blog-even);
}
/* end tables */

@media (hover: none) and (pointer: coarse) and (orientation: portrait) {
    .pytorch-step-row {
        flex-direction: column;
        gap: 10px;
    }

    .pytorch-step-row.pytorch-step-row-compact {
        gap: 10px;
    }

    .pytorch-step-img {
        width: 87%;
    }

    .pytorch-optional-collapse-bar {
        top: 55px;
    }

    .pytorch-opt-summary {
        gap: 16px;
        padding: 14px 18px;
    }
}

/* click to zoom configs, e.g. for nsight and perf images */
.pytorch-zoom-overlay {
    position: fixed;
    inset: 0;
    margin: 0; /* override the site-wide 2% div margin, which would otherwise gap 3 edges */
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    cursor: zoom-out;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.pytorch-zoom-overlay.pytorch-zoom-open {
    opacity: 1;
}

.pytorch-zoom-overlay img {
    max-width: 95vw;
    max-height: 95vh;
    width: auto;
    height: auto;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
    transform: scale(0.85);
    transition: transform 0.25s ease;
}

.pytorch-zoom-overlay.pytorch-zoom-open img {
    transform: scale(1);
}

body.pytorch-zoom-lock {
    overflow: hidden;
}
/* end of click to zoom configs */
