/* ==========================================================================
   KTVC THEME – DEPARTMENTS SECTION STYLES
   ========================================================================== */

/* ==========================================================================
   1. DEPARTMENTS GRID
   ========================================================================== */
.dept-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-6);
}

.dept-grid--archive {
    grid-template-columns: repeat(3, 1fr);
}

/* ==========================================================================
   2. DEPARTMENT CARD
   ========================================================================== */
.dept-card {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    border: var(--border-width) solid var(--border-color);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-base), box-shadow var(--transition-base);
    position: relative;
}

.dept-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg);
}

/* Coloured top accent bar driven by --dept-color CSS variable */
.dept-card__accent {
    height: 4px;
    background: var(--dept-color, var(--color-primary));
    width: 100%;
    flex-shrink: 0;
}

/* Expand accent bar on hover */
.dept-card:hover .dept-card__accent {
    height: 6px;
}

/* ==========================================================================
   3. CARD ICON
   ========================================================================== */
.dept-card__icon-wrap {
    display: flex;
    justify-content: center;
    padding-top: var(--space-8);
    padding-bottom: var(--space-2);
}

.dept-card__icon {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-xl);
    background: color-mix(in srgb, var(--dept-color, var(--color-primary)) 10%, white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    color: var(--dept-color, var(--color-primary));
    transition: all var(--transition-base);
    border: 2px solid color-mix(in srgb, var(--dept-color, var(--color-primary)) 20%, white);
}

/* Fallback for browsers without color-mix */
@supports not (color: color-mix(in srgb, red 10%, white)) {
    .dept-card__icon {
        background: rgba(120, 4, 3, 0.08);
        border-color: rgba(120, 4, 3, 0.15);
    }
}

.dept-card:hover .dept-card__icon {
    background: var(--dept-color, var(--color-primary));
    color: var(--color-white);
    transform: scale(1.08) rotate(-4deg);
}

/* ==========================================================================
   4. CARD BODY
   ========================================================================== */
.dept-card__body {
    padding: var(--space-5) var(--space-6);
    flex: 1;
    display: flex;
    flex-direction: column;
    text-align: center;
}

.dept-card__title {
    font-size: var(--text-lg);
    font-weight: var(--font-bold);
    margin-bottom: var(--space-3);
    line-height: var(--leading-tight);
}

.dept-card__title a {
    color: var(--color-heading);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.dept-card__title a:hover {
    color: var(--dept-color, var(--color-primary));
}

.dept-card__excerpt {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    line-height: var(--leading-loose);
    margin-bottom: var(--space-5);
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ==========================================================================
   5. DEPT STATS ROW
   ========================================================================== */
.dept-card__stats {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--space-4);
    padding: var(--space-4) 0;
    border-top: var(--border-width) solid var(--border-color);
    border-bottom: var(--border-width) solid var(--border-color);
    margin-bottom: var(--space-4);
}

.dept-stat {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    color: var(--color-text-muted);
}

.dept-stat i {
    font-size: 0.65rem;
    color: var(--dept-color, var(--color-primary));
}

.dept-stat strong {
    color: var(--color-heading);
    font-weight: var(--font-bold);
}

/* ==========================================================================
   6. DEPT CONTACT LINKS
   ========================================================================== */
.dept-card__contact {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.dept-contact-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    text-decoration: none;
    transition: color var(--transition-fast);
    word-break: break-all;
}

.dept-contact-link i {
    font-size: 0.65rem;
    color: var(--dept-color, var(--color-primary));
    flex-shrink: 0;
}

.dept-contact-link:hover {
    color: var(--dept-color, var(--color-primary));
}

/* ==========================================================================
   7. CARD FOOTER LINK
   ========================================================================== */
.dept-card__footer {
    padding: var(--space-4) var(--space-6);
    border-top: var(--border-width) solid var(--border-color);
    background: var(--color-off-white);
    display: flex;
    justify-content: center;
}

.dept-card__link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    font-weight: var(--font-semi);
    font-family: var(--font-heading);
    color: var(--dept-color, var(--color-primary));
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: gap var(--transition-fast), color var(--transition-fast);
}

.dept-card__link i {
    font-size: 0.75rem;
    transition: transform var(--transition-fast);
}

.dept-card__link:hover {
    gap: var(--space-3);
    color: var(--dept-color, var(--color-primary));
}

.dept-card__link:hover i {
    transform: translateX(4px);
}

/* ==========================================================================
   8. SINGLE DEPARTMENT PAGE
   ========================================================================== */
.single-dept-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: var(--space-10);
    align-items: start;
}

.single-dept-content {
    min-width: 0; /* prevent grid blowout */
}

/* Hero with dept color override */
.dept-page-hero {
    background: linear-gradient(
        135deg,
        var(--dept-color, var(--color-primary)) 0%,
        var(--color-primary-dark) 100%
    );
}

/* Large icon in single dept hero */
.dept-page-hero__icon {
    font-size: 3.5rem;
    color: rgba(255,255,255,.25);
    margin-bottom: var(--space-4);
    display: block;
}

/* Courses sub-section inside single dept */
.dept-courses-section {
    margin-top: var(--space-12);
    padding-top: var(--space-8);
    border-top: 2px solid var(--border-color);
}

.dept-courses-section__title {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--text-2xl);
    color: var(--color-heading);
    margin-bottom: var(--space-8);
}

.dept-courses-section__title i {
    color: var(--color-primary);
}

/* Override grid for courses inside dept page — 2 cols max */
.single-dept-content .courses-grid {
    grid-template-columns: repeat(2, 1fr);
}

/* ==========================================================================
   9. RESPONSIVE — TABLET (max 1024px)
   ========================================================================== */
@media (max-width: 1024px) {

    .dept-grid,
    .dept-grid--archive {
        grid-template-columns: repeat(2, 1fr);
    }

    .single-dept-layout {
        grid-template-columns: 1fr;
    }

    .single-dept-content .courses-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ==========================================================================
   10. RESPONSIVE — MOBILE (max 768px)
   ========================================================================== */
@media (max-width: 768px) {

    .dept-grid,
    .dept-grid--archive {
        grid-template-columns: 1fr;
    }

    .dept-card__body {
        text-align: left;
    }

    .dept-card__icon-wrap {
        justify-content: flex-start;
        padding-left: var(--space-6);
    }

    .dept-card__stats {
        justify-content: flex-start;
    }

    .dept-card__contact {
        align-items: flex-start;
    }

    .dept-card__footer {
        justify-content: flex-start;
    }

    .dept-page-hero__icon {
        font-size: 2.5rem;
    }

    .single-dept-content .courses-grid {
        grid-template-columns: 1fr;
    }
}
