/**
 * Post Archive Styles
 * Location: plugins/aktd-elements/assets/css/post-archive.css
 *
 * Styles for the filterable post archive: featured post, 2-column grid
 * (reuses the theme's .single-post-card component) and a plain list.
 *
 * @package AKT_Elements
 * @since 1.0.0
 */

/* Main Container */
.post-archive {
    padding: 0;
    max-width: 100%;
    margin: 0;
    font-family: "DM Sans", sans-serif;
}

/* Layout: reuses the shared .akt-row/.akt-col grid (theme style.css) but
   reverses the column ratio so the wide content column comes first. */
.post-archive .post-archive__row {
    grid-template-columns: 9fr 3fr;
    gap: 55px;
}

/* Title */
h2.post-archive__title {
    margin-bottom: 40px !important;
    text-align: left;
    color: var(--aktd-color-font);
    text-transform: uppercase;
}

@media (max-width: 768px) {
    h2.post-archive__title {
        margin-bottom: 20px !important;
    }
}

/* Filter Section (copies the Press Archive / Product Info filter styling) */
.post-archive__filter-label {
    font-size: 16px;
    font-weight: 700;
    color: var(--aktd-color-sidebar-meta);
    margin-bottom: 10px;
    line-height: 1.5;
}

.post-archive__filter-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.post-archive__filter-group {
    display: block;
    width: 100%;
}

.post-archive__filter-select {
    width: 100%;
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: 0;
    background-color: var(--aktd-color-dark-blue-10);
    font-size: 16px;
    font-weight: 500;
    line-height: 27px;
    color: var(--aktd-color-font);
    cursor: pointer;
    transition: border-color 0.3s ease;
    height: 47px;
    align-self: stretch;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 20px center;
    background-size: 12px 8px;
    padding-right: 52px;
}

.post-archive__filter-select::-ms-expand {
    display: none;
}

.post-archive__filter-select:hover,
.post-archive__filter-select:focus,
.post-archive__filter-select:active {
    outline: none;
    border-color: var(--aktd-color-hover-blue);
    background-color: var(--aktd-color-dark-blue-10) !important;
    color: var(--aktd-color-font) !important;
}

/* Results Container */
.post-archive__container {
    position: relative;
    min-height: 100px;
}

.post-archive__results {
    display: flex;
    flex-direction: column;
    gap: 55px;
}

/* Row 1: Featured Post */
.post-archive__featured-link {
    position: absolute;
    inset: 0;
    display: block;
    color: inherit;
    text-decoration: none !important;
}

.post-archive__featured-image {
    position: relative;
    aspect-ratio: 2.4 / 1;
    overflow: hidden;
    background: var(--aktd-color-dark-blue-10);
}

.post-archive__featured-image-element {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.post-archive__featured:hover .post-archive__featured-image-element,
.post-archive__featured:focus-within .post-archive__featured-image-element {
    transform: scale(1.1);
}

.post-archive__featured-gradient {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 72%;
    background: transparent linear-gradient(0deg, #334155 0%, #334155 22%, #334C5500 100%) 0% 0% no-repeat padding-box;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.post-archive__featured:hover .post-archive__featured-gradient,
.post-archive__featured:focus-within .post-archive__featured-gradient {
    opacity: 0;
}

.post-archive__featured-gradient-hover {
    position: absolute;
    inset: 0;
    background: transparent linear-gradient(0deg, #590098 0%, #0070B9A8 72%, #009FE354 100%) 0% 0% no-repeat padding-box;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.post-archive__featured:hover .post-archive__featured-gradient-hover,
.post-archive__featured:focus-within .post-archive__featured-gradient-hover {
    opacity: 1;
}

.post-archive__featured-categories {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.post-archive__badge {
    display: inline-block;
    padding: 3px 8px;
    border: 1px solid var(--aktd-color-category-text);
    background: var(--aktd-color-category-background);
    color: var(--aktd-color-category-text);
    font-family: "DM Sans", sans-serif;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.2;
    text-transform: uppercase;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.post-archive__badge:hover,
.post-archive__badge:focus-visible {
    background: var(--aktd-color-white);
    border-color: var(--aktd-color-category-background);
    color: var(--aktd-color-font);
}

.post-archive__featured-content {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 30px;
    color: var(--aktd-color-white);
}

.post-archive__featured-date {
    display: block;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--aktd-color-white);
}

.post-archive__featured-title,
.entry-content .post-archive__featured-title {
    margin: 0 0 8px !important;
    color: var(--aktd-color-white);
    font-family: "DM Sans", sans-serif;
    font-size: 30px;
    font-weight: 700;
    line-height: 1.25;
    text-transform: none;
}

/* Subtitle: the post's own H2, shown permanently whenever present. */
.post-archive__featured-subtitle {
    margin: 0;
    max-width: 640px;
    color: var(--aktd-color-white);
    font-size: 20px;
    font-weight: 600;
    line-height: 1.5;
}

/* Excerpt: first 100 characters of the content, revealed only on hover. */
.post-archive__featured-excerpt {
    margin: 0;
    max-width: 640px;
    color: var(--aktd-color-white);
    font-size: 16px;
    font-weight: 400;
    line-height: 1.5;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease, margin-top 0.3s ease;
}

.post-archive__featured:hover .post-archive__featured-excerpt,
.post-archive__featured:focus-within .post-archive__featured-excerpt {
    margin-top: 8px;
    max-height: 200px;
    opacity: 1;
}

/* Row 2/3: 2-column Grid (cards reuse the theme's .single-post-card component) */
.post-archive__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 55px;
}

/* Category badges are rendered as <button> here (clickable filter shortcuts),
   unlike the theme's <a> version, so they need the usual button reset.
   Scoped to .post-archive so the theme's related-posts cards in
   single.php (which still use a plain <a>) are unaffected. */
.post-archive .single-post-card__category {
    font-family: "DM Sans", sans-serif;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.post-archive .single-post-card__category:hover,
.post-archive .single-post-card__category:focus-visible {
    background: var(--aktd-color-white);
    border-color: var(--aktd-color-category-background);
    color: var(--aktd-color-font);
}

/* Category badge on the grid cards only: adds a visible border on top of the
   shared .single-post-card__category component (default border is transparent).
   Scoped to .post-archive__grid so the theme's related-posts cards in
   single.php keep their existing look. */
.post-archive__grid .single-post-card__category {
    position: relative;
    z-index: 1;
    background: var(--aktd-color-category-background);
    border: 1px solid var(--aktd-color-category-text);
    color: var(--aktd-color-category-text);
}

.post-archive__grid .single-post-card__meta time {
    font-size: 12px;
    color: var(--aktd-color-sidebar-meta);
}

.post-archive__grid .single-post-card__body {
    padding: 26px 41px;
}

.post-archive__grid .single-post-card__title {
    font-size: 20px;
    font-weight: 600;
    color: var(--aktd-color-sidebar-meta);
}

.post-archive__grid .single-post-card__title-link {
    text-decoration: none !important;
}

.post-archive__grid .single-post-card:hover .single-post-card__title-link,
.post-archive__grid .single-post-card__title-link:focus-visible {
    color: var(--aktd-color-hover-blue) !important;
}

/* Make the whole card clickable ("stretched link"): the title link's ::after
   is stretched to cover the entire card, so clicking anywhere (image,
   excerpt, meta, padding) opens the post - only the category button stays
   independently clickable above it via z-index. */
.post-archive__grid .single-post-card {
    position: relative;
    cursor: pointer;
}

.post-archive__grid .single-post-card__title-link::after {
    content: '';
    position: absolute;
    inset: 0;
}

/* Excerpt added to the reused .single-post-card component (not present in the
   theme's related-posts markup, so this addition does not affect it there). */
.single-post-card__excerpt {
    margin: 0 0 20px !important;
    color: var(--aktd-color-sidebar-meta);
    font-size: 16px;
    line-height: 1.5;
}

/* List Rows (no image): tighter spacing than the featured/grid rows above,
   since these are the 6th post onward. */
.post-archive__list {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.post-archive__list-item {
    position: relative;
    padding: 20px 26px;
    background: var(--aktd-color-ice);
    cursor: pointer;
}

.post-archive__list-title {
    display: block;
    margin-bottom: 10px;
    color: var(--aktd-color-font);
    font-family: "DM Sans", sans-serif;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.35;
    text-decoration: none !important;
}

/* Make the whole row clickable ("stretched link"), matching the grid cards
   above - only the category button stays independently clickable via z-index. */
.post-archive__list-title::after {
    content: '';
    position: absolute;
    inset: 0;
}

.post-archive__list-item .single-post-card__category {
    position: relative;
    z-index: 1;
}

.post-archive__list-item:hover .post-archive__list-title,
.post-archive__list-title:focus-visible {
    color: var(--aktd-color-hover-blue);
}

.post-archive__list-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 18px;
    color: var(--aktd-color-sidebar-meta);
    font-size: 12px;
}

/* No Results Message */
.post-archive__no-results {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 14px;
}

/* Responsive Design */
@media screen and (max-width: 1024px) {
    .post-archive__grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media screen and (max-width: 768px) {
    .post-archive__title {
        margin-bottom: 15px;
    }

    /* Filter column moves above the content column, with 50px between them.
       The shared .akt-row mobile rule (display:block !important) is overridden
       here so flex + column-reverse can flip the visual order without
       touching the DOM (filter markup stays after the content markup). */
    .post-archive .post-archive__row {
        display: flex !important;
        flex-direction: column-reverse;
        gap: 50px;
    }

    .post-archive__filters {
        margin-bottom: 0;
    }

    /* 50px between the featured post, the grid and the list. */
    .post-archive__results {
        gap: 50px;
    }

    .post-archive__grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 30px;
    }

    .post-archive__featured-image {
        aspect-ratio: 4 / 3;
    }

    .post-archive__featured-content {
        padding: 20px;
    }

    /* Full height on mobile instead of the desktop-only bottom 60%. */
    .post-archive__featured-gradient {
        top: 0;
        height: auto;
    }

    /* !important: the desktop rule also matches via a higher-specificity
       ".entry-content .post-archive__featured-title" selector (theme h3
       rule leakage guard), which would otherwise still win here since this
       is only a single class selector. */
    .post-archive__featured-title {
        font-size: 22px !important;
    }

    .post-archive__featured-subtitle {
        font-size: 16px;
    }

    .post-archive__grid .single-post-card__body {
        padding: 26px 21px;
    }

    .post-archive__grid .single-post-card__title {
        font-size: 22px;
        font-weight: 700;
    }

    .post-archive__list-title {
        font-size: 22px;
        font-weight: 600;
    }
}

/* Print Styles */
@media print {
    .post-archive__filters {
        display: none;
    }

    .post-archive__grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Accessibility */
.post-archive__filter-select:focus-visible,
.post-archive__list-title:focus-visible {
    outline: none;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .post-archive__filter-select {
        border: 1px solid #000;
    }

    .post-archive__list-title {
        text-decoration: underline;
    }
}
