/* Custom Product Tabs — Frontend Styles */

.cpt-tab-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--cpt-gap, 24px);
    align-items: start;
    margin-bottom: 1.5em;
}

.cpt-tab-layout.cpt-has-media {
    grid-template-columns: minmax(0, max-content) minmax(0, max-content);
    justify-content: start;
}

@media (max-width: 900px) {
    .cpt-tab-layout.cpt-has-media {
        grid-template-columns: 1fr;
    }
}

.cpt-tab-text {
    min-width: 0;
}

.cpt-tab-media {
    min-width: 0;
}

.cpt-media-stack {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.cpt-media-item {
    min-width: 0;
}

/* Horizontal file layout: files sit side by side; each file's pages stack
   vertically inside its column. */
.cpt-media-stack.cpt-files-horizontal {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
}

.cpt-media-stack.cpt-files-horizontal .cpt-media-item {
    /* No flex-grow: a lone file (or an orphan on the last wrap row) should
       stay the same width as its siblings instead of ballooning. */
    flex: 0 1 300px;
    min-width: 200px;
    max-width: 100%;
}

.cpt-media-stack.cpt-files-horizontal .cpt-media-pages {
    grid-template-columns: 1fr;
}

/* Give the media pane more room when files run horizontally. */
.cpt-tab-layout.cpt-has-media.cpt-media-horizontal {
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
}

/* Must follow the rule above: same specificity, so source order makes the
   mobile collapse win for horizontal-layout tabs too. */
@media (max-width: 900px) {
    .cpt-tab-layout.cpt-has-media.cpt-media-horizontal {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .cpt-media-stack.cpt-files-horizontal {
        flex-direction: column;
    }

    .cpt-media-stack.cpt-files-horizontal .cpt-media-item {
        min-width: 0;
        /* Column direction: the 300px basis would apply to height. */
        flex: 0 1 auto;
    }
}

.cpt-media-header {
    margin-bottom: 10px;
    font-size: 14px;
    line-height: 1.4;
}

.cpt-media-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: inherit;
    text-decoration: underline;
}

.cpt-media-link:hover {
    text-decoration: none;
}

.cpt-external-icon {
    font-size: 0.9em;
    opacity: 0.7;
    transform: translateY(-1px);
}

.cpt-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;
}

/* Thumbnail grid: 2 columns by default, 3 on wider tab panes. */
.cpt-media-pages {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

@media (min-width: 1400px) {
    .cpt-media-pages {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.cpt-thumb-link {
    display: block;
    line-height: 0;
    border-radius: 3px;
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.cpt-thumb-link:hover,
.cpt-thumb-link:focus {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.cpt-thumb-link:focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.cpt-media-page,
.cpt-media-image {
    display: block;
    width: 100%;
    height: auto;
    background: #fff;
}

.cpt-media-loading {
    color: #888;
    font-style: italic;
    padding: 20px;
    text-align: center;
    grid-column: 1 / -1;
}

.cpt-media-truncated {
    color: #666;
    font-size: 13px;
    font-style: italic;
    text-align: center;
    padding: 8px;
    grid-column: 1 / -1;
}

.cpt-media-error {
    color: #a00;
    font-size: 13px;
    padding: 10px;
    background: #fff5f5;
    border: 1px solid #fcc;
    border-radius: 3px;
    grid-column: 1 / -1;
}

.cpt-tab-files h4 {
    margin: 1em 0 0.5em;
}

.cpt-tab-files ul {
    list-style: disc;
    padding-left: 1.5em;
}
