/**
 * Student Projects Archive Styles
 * Program filter buttons with colors matching the design
 */

/* Force line break after program filters to separate them from enfoques */
.post-type-archive-proy_est .topics-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 13px;
}

/* Hide the divider between program and enfoques filters */
.post-type-archive-proy_est .filter-tax-divider {
    display: none !important;
}

/* Program filter button base styles */
.post-type-archive-proy_est .topic-button-filter[filter-type="programas"] {
    padding: 7.83px;
    min-width: 64.55px;
    font-family: 'Roboto Mono', monospace;
    font-weight: 700;
    font-size: 16.3px;
    color: #ffffff;
    text-transform: uppercase;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: 2px solid transparent;
    outline-offset: -2px;
}

.post-type-archive-proy_est .topic-button-filter[filter-type="programas"]:hover,
.post-type-archive-proy_est .topic-button-filter[filter-type="programas"]:focus {
    outline: none;
}

/* Specific colors for each program based on design - DEFAULT STATE */
.post-type-archive-proy_est .topic-button-filter[filter-name="dis"]:not([status="active"]):not(:hover):not(:focus) {
    background-color: #00CED1; /* cyan/aqua */
}

.post-type-archive-proy_est .topic-button-filter[filter-name="arq"]:not([status="active"]):not(:hover):not(:focus) {
    background-color: #000000; /* black */
}

.post-type-archive-proy_est .topic-button-filter[filter-name="mdis"]:not([status="active"]):not(:hover):not(:focus) {
    background-color: #FF00FF; /* magenta */
}

.post-type-archive-proy_est .topic-button-filter[filter-name="marq"]:not([status="active"]):not(:hover):not(:focus) {
    background-color: #0000FF; /* blue */
}

.post-type-archive-proy_est .topic-button-filter[filter-name="mam"]:not([status="active"]):not(:hover):not(:focus) {
    background-color: #FF4500; /* orange-red */
}

/* Hover and Active states - WHITE background with colored outline and colored text */
.post-type-archive-proy_est .topic-button-filter[filter-type="programas"]:hover,
.post-type-archive-proy_est .topic-button-filter[filter-type="programas"]:focus,
.post-type-archive-proy_est .topic-button-filter[filter-type="programas"][status="active"] {
    background-color: #ffffff !important;
    opacity: 1;
}

.post-type-archive-proy_est .topic-button-filter[filter-name="dis"]:hover,
.post-type-archive-proy_est .topic-button-filter[filter-name="dis"]:focus,
.post-type-archive-proy_est .topic-button-filter[filter-name="dis"][status="active"] {
    color: #00CED1;
    outline: 2px solid #00CED1;
    outline-offset: -2px;
}

.post-type-archive-proy_est .topic-button-filter[filter-name="arq"]:hover,
.post-type-archive-proy_est .topic-button-filter[filter-name="arq"]:focus,
.post-type-archive-proy_est .topic-button-filter[filter-name="arq"][status="active"] {
    color: #000000;
    outline: 2px solid #000000;
    outline-offset: -2px;
}

.post-type-archive-proy_est .topic-button-filter[filter-name="mdis"]:hover,
.post-type-archive-proy_est .topic-button-filter[filter-name="mdis"]:focus,
.post-type-archive-proy_est .topic-button-filter[filter-name="mdis"][status="active"] {
    color: #FF00FF;
    outline: 2px solid #FF00FF;
    outline-offset: -2px;
}

.post-type-archive-proy_est .topic-button-filter[filter-name="marq"]:hover,
.post-type-archive-proy_est .topic-button-filter[filter-name="marq"]:focus,
.post-type-archive-proy_est .topic-button-filter[filter-name="marq"][status="active"] {
    color: #0000FF;
    outline: 2px solid #0000FF;
    outline-offset: -2px;
}

.post-type-archive-proy_est .topic-button-filter[filter-name="mam"]:hover,
.post-type-archive-proy_est .topic-button-filter[filter-name="mam"]:focus,
.post-type-archive-proy_est .topic-button-filter[filter-name="mam"][status="active"] {
    color: #FF4500;
    outline: 2px solid #FF4500;
    outline-offset: -2px;
}

/* Behance Stamped Box - Top Left Positioning (First 2 Columns) */
.post-type-archive-proy_est .student-projects-behance-box.stamped-content {
    border: 2px solid var(--arqdis-magenta);
    background-image: url('../assets/patron-grid-magenta.svg');
    background-size: 40px auto;
    padding: 1em;

    position: absolute;
    left: 0; /* Position on the left (first 2 columns) */

    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: min-content 1fr;
    grid-auto-flow: dense;
    grid-column-gap: 30px;
    grid-row-gap: 15px;
}

.post-type-archive-proy_est .student-projects-behance-box .grid-title {
    color: var(--arqdis-magenta);
}

.post-type-archive-proy_est .student-projects-behance-box .grid-subtitle {
    color: var(--arqdis-blue);
}

.post-type-archive-proy_est .student-projects-behance-box p {
    grid-row: span 2;
}

.post-type-archive-proy_est .student-projects-behance-box a {
    background-color: var(--arqdis-blue);
    padding: 0.6em;
    display: block;
    transition: background-color 0.3s;
}

.post-type-archive-proy_est .student-projects-behance-box a:hover {
    background-color: var(--arqdis-magenta);
}

/* Responsive: make Behance box single-column on narrower screens to avoid overlap */
@media (max-width: 1500px) {
    /* Force stamped Behance box to single column width */
    .post-type-archive-proy_est .packery-layout-grid .stamped-content.double-width.student-projects-behance-box,
    .post-type-archive-proy_est .stamped-content.double-width.student-projects-behance-box {
        width: var(--grid-col-sz) !important; /* override global double-width rule */
    }

    /* Adjust internal layout to a single column */
    .post-type-archive-proy_est .student-projects-behance-box {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        grid-column-gap: 16px;
    }

    .post-type-archive-proy_est .student-projects-behance-box p {
        grid-row: auto;
    }
}

/* When the stamped box takes only one grid column (single-column layout),
   make it flow in document order and stack its internal elements. This
   uses the same breakpoint as the single-column width rule (1500px).
*/
@media (max-width: 1500px) {
    /* Remove absolute positioning on narrower screens to allow normal flow */
    .post-type-archive-proy_est .student-projects-behance-box.stamped-content {
        position: relative;
        left: auto;
        width: 100% !important;
        margin-bottom: var(--grid-row-gap, 15px);
    }

    /* Ensure stamped box doesn't overlap and flows naturally */
    .post-type-archive-proy_est .student-projects-behance-box.stamped-content {
        position: static;
        left: auto;
        width: 100% !important;
        margin-bottom: 15px;
    }

    /* Reduce padding to match mobile grid-header */
    .post-type-archive-proy_est .student-projects-behance-box {
        padding: var(--min-side-margin);
        grid-column-gap: 12px;
        grid-row-gap: 12px;
    }
    /* Ensure stamped box doesn't overlap and flows naturally */
    .post-type-archive-proy_est .student-projects-behance-box.stamped-content {
        position: static;
        left: auto;
        width: 100% !important;
        margin-bottom: 15px;
    }
    
    /* Reduce padding to match mobile grid-header */
    .post-type-archive-proy_est .student-projects-behance-box {
        padding: var(--min-side-margin);
        grid-column-gap: 12px;
        grid-row-gap: 12px;
    }

    /* On very small screens, stack the Behance box content vertically (title, text, button)
       so it matches the layout of other stamped boxes */
    .post-type-archive-proy_est .student-projects-behance-box {
        /* switch from grid to column flow for stacking */
        display: flex !important;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .post-type-archive-proy_est .student-projects-behance-box .grid-title {
        order: 1;
        margin: 0 0 6px 0;
    }

    .post-type-archive-proy_est .student-projects-behance-box .grid-subtitle {
        order: 2;
        margin: 0 0 8px 0;
    }

    .post-type-archive-proy_est .student-projects-behance-box nav {
        order: 3;
        width: 100%;
    }

    /* Make the button appear as a normal block-level CTA under the text */
    .post-type-archive-proy_est .student-projects-behance-box nav .grid-button {
        display: block !important;
        width: 100% !important; /* fill the available width inside the stamped box padding */
        box-sizing: border-box; /* ensure padding doesn't push beyond container */
        padding: 0.9em 0 !important; /* vertical padding, no horizontal so the button fills width */
        text-align: center !important; /* center the CTA label */
    }
}

/* ===== STUDENT PROJECT THUMBNAIL CARDS ===== */
/* Note: Base card styles (.student-project-card, .student-thumb-image, .student-thumb-title) 
   are now in the main style.css to be available globally across all grids */

/* ===== STUDENT PROJECT DETAIL CARD ===== */
.post-type-archive-proy_est .student-project-detail-card {
    background-color: #ffffff;
    box-shadow: 0px 0px 20px 2px rgba(0, 0, 0, 0.25);
    
    display: flex;
    flex-direction: column;
    
    /* Absolute positioning to place in top-right (last 2 columns) - will be overridden by JS for sticky behavior */
    position: absolute;
    right: 0;
    top: 0;
    
    /* Take up the full 2-column width (from Packery grid) - same as other double-width items */
    width: calc(var(--grid-col-sz)*2 + var(--grid-gutter-sz));
    
    /* Keep card at natural content height - no forced min-height */
    /* This prevents white space at the bottom */
    
    /* When sticky, will have max-height set by JS, and content should scroll */
    overflow-y: auto;
    overflow-x: hidden; /* Hide horizontal scrollbar */
    
    /* Smooth transition when position changes */
    transition: none; /* We'll handle this with JS for better control */
    
    /* Z-index to keep it above grid content but below the navigation menu */
    z-index: 10;
}

/* Hide scrollbar for the detail card */
.post-type-archive-proy_est .student-project-detail-card::-webkit-scrollbar {
    display: none;
}

.post-type-archive-proy_est .student-project-detail-card {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

/* Invisible blocker element that reserves space for Packery without visual white space */
.post-type-archive-proy_est .detail-card-spacer {
    position: absolute;
    right: 0;
    top: 0;
    /* Same width as the detail card - 2 columns + 1 gutter */
    width: calc(var(--grid-col-sz)*2 + var(--grid-gutter-sz));
    min-height: 120vh;
    pointer-events: none;
    z-index: -1;
    /* Invisible but takes up space for Packery stamping */
}

/* Inner wrapper for padding and gap - needed to maintain spacing when scrolling */
.post-type-archive-proy_est .student-project-detail-card > * {
    padding-left: 16px;
    padding-right: 16px;
}

.post-type-archive-proy_est .student-project-detail-card > :first-child {
    padding-top: 32px;
}

.post-type-archive-proy_est .student-project-detail-card > :last-child {
    padding-bottom: 32px;
}

.post-type-archive-proy_est .detail-card-gallery,
.post-type-archive-proy_est .detail-card-content {
    margin-bottom: 16px;
}

/* Gallery Section */
.detail-card-gallery {
    display: flex;
    gap: 10px;
    padding: 10px;
    align-items: center; /* Center thumbnails and main image vertically */
    justify-content: center; /* Center horizontally as well */
    margin-top: 32px;
}

.detail-card-main-image {
    flex: 1;
    position: relative;
    max-width: 600px; /* Limit the width to make the image smaller */
    display: flex;
    align-items: center; /* Center image vertically within container */
    justify-content: center; /* Center image horizontally */
}

.detail-card-main-image img {
    width: 100%;
    height: auto;
    max-height: 600px; /* Limit height to match max-width for square aspect ratio */
    display: block;
    object-fit: contain; /* Changed from cover to contain to preserve aspect ratio */
    transition: opacity 0.3s ease-in-out;
}

/* Navigation Arrows */
.detail-card-nav-arrows {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    opacity: 0;
    transition: opacity 0.3s;
}

.detail-card-main-image:hover .detail-card-nav-arrows {
    opacity: 1;
}

.detail-nav-arrow {
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.3s;
    padding: 0;
}

.detail-nav-arrow:hover {
    background-color: rgba(0, 0, 0, 0.9);
}

.detail-nav-arrow:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.detail-nav-arrow svg {
    width: 24px;
    height: 24px;
}

.detail-card-thumbnails {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 420px;
    overflow-y: auto;
}

/* Hide scrollbar for thumbnails */
.detail-card-thumbnails::-webkit-scrollbar {
    display: none;
}

.detail-card-thumbnails {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

.detail-card-thumbnails img {
    width: 69px;
    height: auto;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.3s ease-in-out, transform 0.2s ease-in-out;
    border: 2px solid transparent;
}

.detail-card-thumbnails img:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

.detail-card-thumbnails img.active {
    opacity: 1;
    border-color: transparent; /* Remove black border */
    transform: scale(1.1); /* Slightly larger when active */
}

/* Content Section */
.detail-card-content {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 53px;
}

.detail-card-info {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Topics/Tags */
.detail-card-topics {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.detail-card-topic {
    background-color: blue;
    padding: 7.83px;
    color: #ffffff;
    font-family: 'Roboto Mono', monospace;
    font-weight: 700;
    font-size: 16.3px;
    text-transform: uppercase;
    white-space: nowrap;
}

/* Title */
.detail-card-title {
    font-family: 'Roboto Mono', monospace;
    font-weight: 700;
    font-size: 26px;
    line-height: 32px;
    color: #000000;
    text-transform: uppercase;
    margin: 0;
}

/* Metadata - using global post-metadata styles matching h6.post-subtitle */
#detail-project-meta.post-metadata {
    font-family: 'Roboto Mono', monospace;
    font-weight: 700;
    font-size: 18px;
    line-height: 24px;
    color: #000000;
    text-transform: uppercase;
    margin: 0;
}

/* Override separator to add space before the vertical bar */
#detail-project-meta.post-metadata span:not(:last-child):after {
    content: ' | ';
}

/* Remove any special styling from program and course spans */
#detail-project-meta.post-metadata .detail-meta-program,
#detail-project-meta.post-metadata .detail-meta-course {
    color: #000000;
    font-style: normal;
}

/* Make links inside the detail card italic, but do not change the CTA button */
.post-type-archive-proy_est .student-project-detail-card a:not(.detail-card-button) {
    font-style: italic;
}

/* Authors */
.detail-card-authors {
    font-family: 'Roboto Mono', monospace;
    font-weight: 400;
    font-size: 1.5em;
    line-height: 32px;
    color: #000000;
    text-transform: uppercase;
    font-style: italic;
}

/* Description */
.detail-card-description {
    font-family: 'Work Sans', sans-serif;
    font-weight: 400;
    font-size: 18px;
    line-height: 32px;
    color: #000000;
}

.detail-card-description p {
    margin: 0;
    white-space: pre-wrap;
}

/* Call to Action Button */
.detail-card-cta {
    width: 100%;
}

.detail-card-button {
    background-color: blue;
    color: #ffffff;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    width: 100%;
    font-family: 'Roboto Mono', monospace;
    font-weight: 700;
    font-size: 26px;
    line-height: 32px;
    text-transform: uppercase;
    transition: background-color 0.3s;
}

.detail-card-button:hover {
    cursor: pointer;
    opacity: 0.9;
}

/* Hide detail card entirely on small screens (one-column layout) */
@media (max-width: 575px) {
    #project-detail-card,
    .student-project-detail-card {
        display: none !important;
    }
}
