/* ======================== */
/*        GLOBAL STYLES     */
/* ======================== */

/* General Styles */
body, html {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f4f4;
    height: 100%;
    box-sizing: border-box;
    
    touch-action: manipulation; /* Safer default for buttons etc. */
    overscroll-behavior: contain; /* optional: prevent scroll chaining on mobile */
}

/* Prevent Body Scroll When Modal is Open */
body.modal-open {
    overflow: hidden;
}

body:not(.modal-open) {
    touch-action: pan-x pan-y;
}

/* Title Styles */
h2 {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 20px;
    padding-top: 10px;
    color: #005288;
    text-decoration: underline;
    text-decoration-thickness: 0.5px;
    text-align: center;
}

/* ======================== */
/*       LAYOUT STYLES      */
/* ======================== */

/* Layout Container */
.table-container {
    aspect-ratio: 16 / 9;   
    width: 95%; 
    height: 600px;
    max-width: 1500px;      
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: nowrap;
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Adjusted widths for better balance */
.spec-table {
    flex: 1 1 60%;
    max-width: 55%;
}

/* Media Grid Container */
.media-grid-container {
    min-height: 200px;
    width: 100%;
    max-height: 500px;
    overflow-y: auto;
}

/* Scrollable Table */
.scrollable-container {
    max-height: 500px;
    overflow-y: auto;
}

/* ======================== */
/*        TABLE STYLES      */
/* ======================== */

/* General Table Styles */
table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

table, th, td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

table td {
    padding: 8px 12px;
    border: 1px solid #ddd;
    text-align: left;
}

table tr.headline td {
    background-color: #D6D6D6;
    font-weight: bold;
}

/* Media Column */
.media-column {
    width: 50%;
}

/* Adjust the first column (labels) to a smaller width */
td:first-child {
    width: 35%;
    padding-right: 10px;
}

/* Metric column */
.metric {
    display: inline-block;
    width: 30%;
    text-align: left;
    padding: 4px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Imperial column */
.imperial {
    display: inline-block;
    float: right;
    width: 30%;
    text-align: right;
    padding: 4px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.depth-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.depth-list li {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
}

/* ======================== */
/*   SINGLE-COLUMN MEDIA GRID  */
/* ======================== */
.specs-page.single-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 10px;
}

.specs-page.single-column .media-column {
    width: 100% !important;
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.specs-page.single-column .media-grid {
    display: grid !important;
    grid-template-columns: repeat(var(--grid-columns, 3), 1fr) !important;
    gap: 15px !important;
    justify-content: center !important;
    width: 100% !important;
    max-width: 1400px !important;
    overflow-y: auto !important;
    padding: 10px 0 !important;
}

.specs-page.single-column .grid-item {
    width: calc(100% / var(--grid-columns, 3)) !important;
    max-width: 350px !important;
    aspect-ratio: 16/9 !important;
    margin: 0 auto !important;
}

/* ======================== */
/*   MEDIA GRID & FILTERING */
/* ======================== */

/* Isotope Filter Buttons */
.filter-buttons button {
    padding: 5px;
    margin: 0 1px;
    cursor: pointer;
    border-radius: 5px;
    transition: background-color 0.3s, transform 0.2s;
    font-size: 13px;
    white-space: nowrap;
    flex-shrink: 0;
    border: 1px solid #ddd;
    background-color: #fff;
}

.filter-buttons::-webkit-scrollbar {
    display: none;
}

.filter-buttons button:hover {
    transform: scale(1.05);
    background-color: #D6D6D6;
}

.filter-buttons button.active {
    font-weight: bold;
    background-color: #D6D6D6;
}

/* Media Grid */
.media-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    padding: 10px;
    max-height: 480px;
    overflow-y: auto;
    min-height: 500px;
}

/* Individual Grid Items */
.grid-item {
    width: calc(33.33% - 20px);
    max-width: 150px;
    aspect-ratio: 16 / 9; 
    margin: 2px;
    overflow: hidden;
}

.grid-item.isotope-hidden {
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.3s, transform 0.3s ease-in-out;
    pointer-events: none;
}

.grid-item img, 
.grid-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

.grid-item:hover {
    transform: scale(1.05);
}

/* Icon Tag for Video/Image */
.icon-tag {
    position: absolute;
    top: 5px;
    left: 5px;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 5px;
    font-size: 12px;
    border-radius: 5px;
    z-index: 2;
}

.video-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2em;
    color: white;
    z-index: 5;
}

/* ======================== */
/*       MODAL STYLES       */
/* ======================== */

.modal {
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.8);
}

.modal-content {
    position: relative;
    width: 85%;
    height: 85%;
    max-width: 1728px;
    max-height: 972px;
    margin: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 12px;
    background: #000; /* keep the rounded corners visible */
}

#zoom-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    overflow: visible; /* allow media to scale without being cut */
}

#zoom-container img,
#zoom-container video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* scale down to fit modal, no cropping */
    border-radius: 12px; /* matches modal corners */
}

/* Close Button */
.close {
    position: absolute;
    top: 30px;
    right: 30px;
    font-size: 25px;
    font-weight: bold;
    color: #fff;
    background: rgba(192,192,192,0.25);
    border-radius: 50%;
    width: 45px;  
    height: 45px; 
    text-align: center;
    line-height: 46px;
    cursor: pointer;
    z-index: 1001;
    border: none;
}

.close:hover,
.close:focus {
    background-color: rgba(0, 0, 0, 0.7);
}

/* Modal media - images/videos fit bounds, PDFs unaffected */
.modal-content img,
.modal-content video {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

/* Shared class for video/img */
.media-item {
    display: none;
}

.media-item.open {
    display: block;
}

/* Index display (optional) */
#media-index-display {
    position: fixed;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 5px;
}

/* Modal navigation arrows */
#modal-prev, #modal-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 35px;
    z-index: 1001;
}

#modal-prev { left: 60px; }
#modal-next { right: 60px; }

#modal-prev:hover, #modal-next:hover {
    background: rgba(0, 0, 0, 0.8);
}

/* Smaller screen modal */
@media (max-width: 768px) {
    #modal-prev,
    #modal-next,
    .close {
        width: 32px;
        height: 32px;
        font-size: 18px;
        top: 20px;
    }

    #modal-prev { left: 20px; }
    #modal-next { right: 20px; }
    .close { right: 20px; }
}

#specsOverlay {
    will-change: opacity, transform;
    backface-visibility: hidden;
    transform: translateZ(0);
}

/* Add spacing around single-column media grid items */
.specs-page.single-column .media-grid {
    gap: 15px !important;
    padding: 10px;
}

.specs-page.single-column .grid-item {
    margin: 5px !important;
    width: calc(100% / var(--grid-columns, 3) - 10px) !important;
}
