/* ==========================================================================
   COMPANY SPECIFIC CSS (Inherited from product.css)
   ========================================================================== */

.product {
    display: grid;
    grid-template-columns: 35% 1fr;
    grid-template-areas:
        "title title"
        "gallery description"
        "gallery details"
        ". ."
        "related related";
    gap: 1rem;
    grid-auto-rows: auto;
    align-items: start;
    margin-bottom: 2em;
}

@media (max-width:768px) {
    .product {
        display: flex;
        flex-direction: column;
    }
}

/* Titles */
.product_titles {
    grid-area: title;
    order: 1;
    text-align: center;
    margin-block: 1em;
    align-self: center;
}
.product_title,
.product_subtitle {
    text-wrap: balance;
}
.product_title {
    margin: 0;
    font-size: 2em;
}
.product_subtitle {
    font-size: 1.5em;
    font-weight: 300;
    letter-spacing: .3em;
    margin: 0;
    word-break: keep-all;
}

/* Global Hidden Utility */
.visually-hidden {
    display: none;
}

/* Gallery / Logo Area */
.woocommerce-product-gallery {
    grid-area: gallery;
    grid-row: 2 / span 3;
    order: 3;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100% !important;
    opacity: 1;
}

.company-logo-wrapper {
    text-align: center;
    border-radius: 6px;
}

.company-logo-wrapper .wp-post-image {
    display: inline-block;
    
    /* 1. Let the image determine its own natural size to preserve aspect ratio */
    width: auto;
    height: auto;
    
    /* 2. Set strict maximum boundaries so it never overflows */
    max-width: 100%; /* (Optional: change back to 400px if you want a hard cap) */
    max-height: 16em;
    
    /* 3. Bulletproof aspect-ratio protection */
    object-fit: contain;
    
    border-radius: 4px;
}

.company-logo-fallback {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    aspect-ratio: 1/1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.5;
}

.company-logo-fallback-icon {
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    font-size: 4em;
}

/* Summary / History */
.summary {
    grid-area: description;
    order: 2;
    padding: 0 !important;
    margin: 0 !important;
    clear: none !important;
    float: none !important;
    width: 100% !important;
}
.summary p {
    margin-bottom: 0;
    font-weight: 300;
}
.summary, .item-details {
    font-size: 0.9em;
}

/* Details / Datasheet */
.item-details {
    grid-area: details;
    order: 4;
}
.item-details h2, .related h2 {
    font-size: 1.25rem !important;
    text-align: center;
    margin-bottom: 0.5em !important;
    margin-top: 1em;
}

/* Link Animations */
.woocommerce-product-details__short-description a,
.item-details-description a {
    color: var(--text-color) !important;
    text-decoration: none !important;
    padding: 0 0.1em;
    background-image: 
        linear-gradient(var(--accent-color), var(--accent-color)),
        linear-gradient(var(--wc-secondary), var(--wc-secondary));
    background-position: 0% 100%, 0% 100%;
    background-repeat: no-repeat, no-repeat;
    background-size: 0% 1px, 100% 20%;
    transition: background-size 0.3s ease, color 0.3s ease;
}
.woocommerce-product-details__short-description a:hover,
.item-details-description a:hover {
    background-size: 100% 1px, 100% 20%;
    color: var(--accent-color) !important;
}

/* Datasheet Table Layout */
table.woocommerce-product-attributes {
    margin: 0;
    font-size: 0.9em;
}
table.datasheet th {
    width: 12em;
    white-space: nowrap; 
}
table.datasheet td,
table.datasheet th {
    padding: .3em .5em;
}
table.datasheet tbody tr th {
    background-color: inherit;
    background: linear-gradient(to left, rgba(128,128,128,.10) , transparent);
    padding-inline-start: 10vw;
}
table.datasheet tbody tr:nth-child(2n) th {
    background-color: inherit;
    background: linear-gradient(to left, rgba(128,128,128,.01) , transparent);
}
table.datasheet tbody tr td {
    background-color: inherit;
    background: linear-gradient(to right, rgba(128,128,128,.10) , transparent);
}
table.datasheet tbody tr:nth-child(2n) td {
    background-color: inherit;
    background: linear-gradient(to right, rgba(128,128,128,.01) , transparent);
}

table.datasheet ul {
    list-style: none;
    margin: 0;
    padding: 0;
}
table.datasheet li {
    display: inline-block;
    margin: 0;
    padding: 0;
}

/* Icons */
table.datasheet span::before, 
table.datasheet th::before,
table.datasheet td::before,
table.datasheet li::before,
table.datasheet ul::before {    
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    display: inline-block;
    width: 1.5em;
    text-align: center;
    margin-inline-end: 0.25em;
}

/* Specific Company Icons */
.pa-legal-name th::before { content: "\f02b"; }
.pa-status th::before { content: "\f071"; }
.pa-item-type th::before { content: "\f61f"; }
.pa-release-date th::before { content: "\f073"; }
.pa-territory th::before { content: "\f024"; }
.pa-series th::before { content: "\f6ad"; }
.pa-external-links th::before { content: "\f0c1"; }

table.datasheet .active::before { content: "\f058"; color: #28a745; }
table.datasheet .historical::before { content: "\f057"; color: #dc3545; }

/* Flags */
.pa-territory .pa-value li::before {
    content: "";
    display: inline-block;
    width: 1.6em;
    margin-inline-end: 0.25em;
    height: 1.0em; 
    vertical-align: -0.1em; 
    background-size: contain; 
    background-repeat: no-repeat;
    background-position: center center;
    border-radius: 2px;
    box-shadow: inset 0 0 0 1px rgba(128, 128, 128, 0.25);
    filter: saturate(0%) contrast(50%);
    transition: filter 0.3s ease;
}
.pa-territory .pa-value li:hover::before { filter: saturate(100%) contrast(100%); }

table.datasheet li.argentina::before { background-image: var(--flag-ar); }
table.datasheet li.australia::before { background-image: var(--flag-au); }
table.datasheet li.austria::before { background-image: var(--flag-at); }
table.datasheet li.belgium::before { background-image: var(--flag-be); }
table.datasheet li.brazil::before { background-image: var(--flag-br); }
table.datasheet li.canada::before { background-image: var(--flag-ca); }
table.datasheet li.china::before { background-image: var(--flag-cn); }
table.datasheet li.czech-republic::before { background-image: var(--flag-cz); }
table.datasheet li.denmark::before { background-image: var(--flag-dk); }
table.datasheet li.eu::before { background-image: var(--flag-eu); }
table.datasheet li.finland::before { background-image: var(--flag-fi); }
table.datasheet li.france::before { background-image: var(--flag-fr); }
table.datasheet li.germany::before { background-image: var(--flag-de); }
table.datasheet li.hong-kong::before { background-image: var(--flag-hk); }
table.datasheet li.hungary::before { background-image: var(--flag-hu); }
table.datasheet li.india::before { background-image: var(--flag-in); }
table.datasheet li.indonesia::before { background-image: var(--flag-id); }
table.datasheet li.ireland::before { background-image: var(--flag-ie); }
table.datasheet li.italy::before { background-image: var(--flag-it); }
table.datasheet li.japan::before { background-image: var(--flag-jp); }
table.datasheet li.korea::before { background-image: var(--flag-kr); }
table.datasheet li.south-korea::before { background-image: var(--flag-kr); }
table.datasheet li.malaysia::before { background-image: var(--flag-my); }
table.datasheet li.mexico::before { background-image: var(--flag-mx); }
table.datasheet li.netherlands::before { background-image: var(--flag-nl); }
table.datasheet li.new-zealand::before { background-image: var(--flag-nz); }
table.datasheet li.norway::before { background-image: var(--flag-no); }
table.datasheet li.palestine::before { background-image: var(--flag-ps); }
table.datasheet li.philippines::before { background-image: var(--flag-ph); }
table.datasheet li.poland::before { background-image: var(--flag-pl); }
table.datasheet li.portugal::before { background-image: var(--flag-pt); }
table.datasheet li.russia::before { background-image: var(--flag-ru); }
table.datasheet li.singapore::before { background-image: var(--flag-sg); }
table.datasheet li.spain::before { background-image: var(--flag-es); }
table.datasheet li.sweden::before { background-image: var(--flag-se); }
table.datasheet li.switzerland::before { background-image: var(--flag-ch); }
table.datasheet li.taiwan::before { background-image: var(--flag-tw); }
table.datasheet li.thailand::before { background-image: var(--flag-th); }
table.datasheet li.ukraine::before { background-image: var(--flag-ua); }
table.datasheet li.united-kingdom::before { background-image: var(--flag-gb); }
table.datasheet li.united-states::before { background-image: var(--flag-us); }
table.datasheet li.vietnam::before { background-image: var(--flag-vn); }

.external_link_official-site .ext-link::before { content: "\e066"; font-family: "Font Awesome 5 Free"; font-weight: 900;}

/* Related (Portfolio) */
.related {
    grid-area: related;
    order: 5;
    width: 100%;
}

.portfolio-section {
    margin-bottom: 3rem;
    width: 100%;
}

.portfolio-section-heading {
    font-size: 1.25rem;
    text-align: center;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--wc-secondary);
    padding-bottom: 0.3em;
}

.portfolio-section-subheading {
    font-weight: 300;
    opacity: 0.6;
    font-size: 0.8em;
}

/* ==========================================================================
   ARCHIVE CSS INJECTION FOR THE PORTFOLIO GRID (From archive.css)
   ========================================================================== */
.company-entity .itemloop {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(clamp(12vw, 30%, 180px), 1fr));
    gap: 1rem;
    padding: 0;
    margin: 0;
    list-style: none;
}
.company-entity .itemloop a {
    max-width: 20em;
    margin: auto;
}

/* HIGH SPECIFICITY OVERRIDE TO BLOCK WOOCOMMERCE INJECTION */
.company-entity .itemloop .itemloop-item-image img {
    max-height: 100% !important;
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
    display: block !important;
    transition: all 0.5s ease;
    transform: scale(0.98);
}

.company-entity .itemloop .itemloop-item-image img:hover {
    transform: scale(1);
}

/* Neutralize Storefront's legacy ratio code */
.company-entity .itemloop-item-image img.wp-post-image {
    margin-bottom: 0 !important;
}