/* ============================================================
   Kolo Innovate - Comprehensive Responsive Fixes
   Mobile-first approach: fixes for all viewport sizes
   Loaded AFTER kolo.css to ensure overrides take effect
   ============================================================ */

/* ---- Base Mobile-First Reset ---- */
*,
*::before,
*::after {
    -webkit-tap-highlight-color: transparent;
}

img, video, svg {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Override height:auto for card images that need to fill their container */

/* Ensure card action buttons (Enroll, Learn More) sit above floating
   toggles (dark-mode, lite-mode, WhatsApp, back-to-top) so they remain
   clickable on all viewports. */
.sactions { position: relative; z-index: 1000; overflow: visible; }
.cd-hero-cta, .cd-enroll { position: relative; z-index: 1000; }
.hp-svc-media img,
.grow-media img,
.project-card .project-img img {
    height: 100% !important;
}

/* Prevent horizontal overflow on all pages */
html {
    overflow-x: clip;
    -webkit-text-size-adjust: 100%;
}
body {
    /* overflow-x: clip (NOT hidden) - `hidden` turns <body> into a scroll
       container when <html> has a non-visible overflow (see html above),
       which silently breaks position:sticky on the navbar site-wide. */
    overflow-x: clip;
    min-height: 100vh;
    min-height: 100dvh;
}

/* ---- Touch Targets (minimum 44x44px) ---- */
/* Scope min-height to primary interactive elements only. Applying it to
   ALL anchors and buttons breaks compact UI like the topbar and footer.
   NOTE: checkboxes/radios must NOT get min-height - stretching the 19px
   control renders a vertical sliver. Their 44px tap target is the LABEL
   (the click proxy), padded below; page CSS may pad further. */
.btn,
.nav-link,
.dropdown-item,
.form-control,
.form-select {
    min-height: 44px;
}

/* Compact Bootstrap variants keep their designed heights - the blanket
   44px above stretched .btn-sm icon buttons (e.g. the copy button on
   enrollment-success) and any form-control-sm/select-sm into oversized
   controls. Bootstrap's own padding drives their height. */
.btn-sm,
.btn-group-sm > .btn,
.form-control-sm,
.form-select-sm {
    min-height: 0;
}

.form-check .form-check-input {
    min-height: 0;
    margin-left: 0;
    margin-top: 0;
    flex: none;
}
.form-check-label {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    margin-left: 4px;
}
.form-check {
    padding-left: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-link {
    padding: 12px 8px !important;
}

/* ---- Ultra-Small Phones (320px - 359px) ---- */
@media (max-width: 359px) {
    .container {
        padding-left: 12px;
        padding-right: 12px;
    }
    .hero-carousel .hero-title {
        font-size: 1.6rem;
        letter-spacing: -0.5px;
    }
    .hero-carousel .hero-subtitle {
        font-size: 0.88rem;
    }
    .hero-carousel .carousel-caption {
        left: 5%;
        right: 5%;
        bottom: 12%;
    }
    .section-title {
        font-size: 1.4rem;
    }
    .section-label {
        font-size: 0.7rem;
        padding: 4px 12px;
    }
    .btn-gold.btn-lg,
    .btn-primary-custom.btn-lg {
        padding: 10px 20px;
        font-size: 0.85rem;
    }
    .top-bar-info {
        column-gap: 8px;
    }
    .top-bar-item {
        font-size: 0.7rem;
        flex: none;
    }
    .navbar-brand img {
        height: 42px !important;
        max-width: 170px !important;
    }
    .navbar-tagline {
        font-size: 0.45rem;
        letter-spacing: 1.2px;
    }
}

/* ---- Small Phones (360px - 413px) ---- */
@media (min-width: 360px) and (max-width: 413px) {
    .hero-carousel .hero-title {
        font-size: 1.75rem;
    }
    .hero-carousel .carousel-caption {
        bottom: 14%;
    }
    .section-title {
        font-size: 1.45rem;
    }
}

/* ---- Standard Mobile (414px - 575px) ---- */
@media (min-width: 414px) and (max-width: 575.98px) {
    .hero-carousel .hero-title {
        font-size: 1.9rem;
    }
}

/* ---- All Mobile (max-width: 575.98px) ---- */
@media (max-width: 575.98px) {
    /* Stack the top bar on phones: contact items on line 1, auth/social on
       line 2, address hidden - single-line nowrap was crushing the phone
       number and email into ~45px slivers. Applies to every ≤575px band
       (359 / 360–413 / 414–575) so no phone width slips through. */
    .top-bar-inner {
        flex-wrap: wrap;
        row-gap: 2px;
        justify-content: center;
    }
    .top-bar-address {
        display: none;
    }
    .top-bar-info,
    .top-bar-aside {
        justify-content: center;
    }
    /* Ensure floating buttons don't overlap footer content */
    .footer { padding-bottom: 0; }
    .footer-bottom { padding-right: 60px; }
    .footer .footer-contact li { word-break: break-word; }
    .footer .footer-contact a { word-break: break-all; white-space: normal; }

    /* Footer phone two-column grid: align each link row as flex so long
       labels ("Technology Solutions", "Training & Capacity Dev.", contact
       lines) wrap cleanly beside the chevron instead of double-wrapping
       around it and inflating the row height. */
    .footer-link-list li {
        display: flex;
        align-items: flex-start;
        line-height: 1.45;
    }
    .footer-link-list li i {
        margin-top: 0.45em;
        margin-right: 8px;
    }
    .footer-link-list a {
        flex: 1;
        min-width: 0;
        overflow-wrap: break-word;
    }
    .footer .col-6 {
        padding-left: 10px;
        padding-right: 10px;
    }

    /* Hero adjustments */
    .hero-carousel .carousel-item {
        min-height: 480px;
    }
    .hero-carousel .hero-badge {
        font-size: 0.68rem;
        padding: 6px 14px;
    }
    .hero-carousel .hero-tagline {
        font-size: 0.75rem;
    }
    .hero-pills {
        gap: 8px 12px;
    }
    .hero-pills span {
        font-size: 0.7rem;
    }
    .hero-buttons {
        flex-direction: column;
        gap: 10px !important;
    }
    .hero-buttons .btn {
        width: 100%;
        text-align: center;
    }

    /* Stats */
    .stat-number {
        font-size: 1.2rem;
    }
    .stat-suffix {
        font-size: 1.3rem;
    }
    .stat-label {
        font-size: 0.58rem;
    }
    .stat-icon {
        font-size: 0.85rem;
    }

    /* Sections */
    .section-padding {
        padding: 32px 0;
    }
    .section-title {
        font-size: 1.5rem;
    }
    .section-subtitle {
        font-size: 0.9rem;
    }

    /* Cards */
    .hp-svc-media {
        height: 160px;
    }
    .grow-media {
        height: 150px;
    }
    .overview-media img {
        min-height: 220px;
    }

    /* Featured banner */
    .featured-banner .container {
        padding: 14px 12px;
    }
    .featured-title {
        font-size: 0.95rem;
    }

    /* CTA section */
    .cta-final-inner h2 {
        font-size: 1.3rem;
    }

    /* WhatsApp float */
    .whatsapp-float {
        width: 44px;
        height: 44px;
        font-size: 1.3rem;
        bottom: 20px;
        left: 16px;
        right: auto;
    }

    /* Back to top */
    .back-to-top {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
        bottom: 76px;
        right: 16px;
    }

    /* Footer */
    .footer {
        padding-top: 36px;
    }
    .footer h5 {
        font-size: 1rem;
        margin-bottom: 8px;
    }
    .footer h5::after {
        width: 28px;
    }
    .footer-brand-name {
        font-size: 1.1rem;
    }
    .footer-logo-circle {
        width: 44px;
        height: 44px;
        padding: 6px;
    }
    .footer .small {
        margin-bottom: 4px;
        font-size: 0.82rem;
    }
    .social-icon {
        width: 34px;
        height: 34px;
        font-size: 0.8rem;
    }
    .footer-link-list li {
        margin-bottom: 3px;
    }

    /* Forms */
    .form-control,
    .form-select {
        font-size: 16px !important; /* Prevent iOS zoom */
    }

    /* Tables - horizontal scroll */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Mobile menu improvements */
    .navbar-collapse {
        max-height: 70vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Service hero */
    .svc-hero {
        padding: 44px 0 60px;
    }
    .svc-hero h1 {
        font-size: 1.6rem;
    }

    /* Certificate sheet */
    .cert-sheet {
        padding: 20px 14px;
    }
    .cs-title {
        font-size: 1rem;
        letter-spacing: 3px;
    }
    .cs-name {
        font-size: 1.3rem;
    }
    .cs-meta {
        gap: 16px;
    }

    /* Verify page */
    .verify-hero h1 {
        font-size: 1.3rem;
    }
    .verify-card-body {
        padding: 20px 16px;
    }
}

/* ---- Tablets (576px - 991px) ---- */
@media (min-width: 576px) and (max-width: 991.98px) {
    .hero-carousel .hero-title {
        font-size: 2.2rem;
    }
    .hero-carousel .carousel-item {
        min-height: 560px;
    }
    .section-title {
        font-size: 1.8rem;
    }

    /* Footer: 2-column layout on tablet */
    .footer .row > [class*="col-lg"] {
        flex: 0 0 50%;
        max-width: 50%;
    }
    .footer .row > .col-12 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    .footer-bottom { padding-right: 50px; }
}

/* ---- Small Laptops (992px - 1199px) ---- */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .hero-carousel .hero-title {
        font-size: 3rem;
    }
}

/* ---- Large Desktops (1440px+) ---- */
@media (min-width: 1440px) {
    .container {
        max-width: 1320px;
    }
}

/* ---- Touch Device Optimizations ---- */
@media (hover: none) and (pointer: coarse) {
    /* Larger tap targets on touch devices */
    .btn {
        min-height: 48px;
    }
    .nav-link {
        padding: 14px 10px !important;
    }
    .dropdown-item {
        padding: 12px 16px;
    }
    .filter-pill {
        padding: 12px 20px;
    }
    /* Disable hover effects on touch */
    .hp-svc-card:hover,
    .grow-card:hover,
    .project-card:hover,
    .sol-card:hover,
    .why-feature:hover {
        transform: none;
    }
}

/* ---- Dark Mode Responsive Fixes ---- */
@media (max-width: 575.98px) {
    html.dark-mode .featured-banner .container {
        background: var(--bg-card);
    }
}

/* ---- Mobile floating buttons: smaller, less obtrusive ---- */
@media (max-width: 480px) {
    .whatsapp-float {
        width: 38px !important;
        height: 38px !important;
        font-size: 1.1rem !important;
        bottom: 12px !important;
        left: 10px !important;
        right: auto !important;
    }
    .back-to-top {
        width: 34px !important;
        height: 34px !important;
        font-size: .95rem !important;
        bottom: 56px !important;
        right: 12px !important;
    }
    .dark-mode-toggle {
        width: 34px !important;
        height: 34px !important;
        font-size: .95rem !important;
        top: 60px !important;
        right: 10px !important;
        bottom: auto !important;
    }
    .lite-mode-toggle {
        width: 34px !important;
        height: 34px !important;
        font-size: .95rem !important;
        top: 100px !important;
        right: 10px !important;
        bottom: auto !important;
    }
    /* Toggles now at top-right - no cookie banner offset needed */
}

/* ---- Print Styles ---- */
@media print {
    .navbar, .top-bar, .whatsapp-float, .back-to-top,
    .cookie-consent, .newsletter-toast, #preloader {
        display: none !important;
    }
    body {
        background: #fff !important;
        color: #000 !important;
    }
    .hero-carousel .carousel-item {
        min-height: auto !important;
        height: auto !important;
    }
}

/* ---- Safe Area (notch phones) ---- */
@supports (padding-top: env(safe-area-inset-top)) {
    .top-bar {
        padding-top: env(safe-area-inset-top);
    }
    .whatsapp-float {
        bottom: calc(20px + env(safe-area-inset-bottom));
    }
    .back-to-top {
        bottom: calc(76px + env(safe-area-inset-bottom));
    }
}

/* ---- Focus Visible (Accessibility) ---- */
/* No border-radius here: forcing radius 4px squared off round elements
   (icon buttons, floating toggles) whenever they received keyboard focus. */
:focus-visible {
    outline: 3px solid var(--secondary, #119DA4);
    outline-offset: 2px;
}

/* ---- Reduced Motion ---- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .partner-scroll-track {
        animation: none !important;
    }
}

/* ---- High Contrast Mode ---- */
@media (forced-colors: active) {
    .btn-gold,
    .btn-primary-custom,
    .btn-secondary-custom {
        border: 2px solid currentColor;
    }
}

/* ============================================================
   PERFORMANCE - Image & Video Optimizations
   ============================================================ */

/* Prevent CLS: give images a default aspect ratio container */
img:not([width]):not([height]):not(.card-img-top) {
    max-width: 100%;
    height: auto;
}

/* Hero images: prevent layout shift */
.hero-carousel .carousel-item {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Card images: consistent aspect ratio - homepage only */
.hp-svc-media img,
.grow-media img,
.project-card .project-img img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    position: absolute !important;
    inset: 0 !important;
    display: block !important;
}

/* Blog card images - must NOT be absolute (parent has no fixed height) */
.card-img-top {
    width: 100%;
    height: auto;
    object-fit: cover;
    display: block;
}

/* Partner logos: prevent layout shift */
.partner-logo-item img {
    height: 44px;
    width: auto;
    object-fit: contain;
}
@media (max-width: 767.98px) {
    .partner-logo-item img {
        height: 32px;
    }
}

/* Video containers: maintain 16:9 aspect ratio. The padding-bottom hack
   applies to the .player-video WRAPPER only - its children are absolutely
   positioned inside it. .lesson-video-player is a standalone <video> element
   (player.php), NOT a child of .player-video: grouping it here gave it
   position:absolute + height:100% of no positioned ancestor. It keeps its
   natural flow height (player.php styles max-height:70vh itself). */
.player-video {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 */
    overflow: hidden;
}
.player-video iframe,
.player-video video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Ensure images don't overflow their containers */
.overview-media,
.why-image-wrap,
.svc-hero-img,
.it-intro-img,
.it-featured .fimg,
.cta-logo-plate {
    overflow: hidden;
}

/* Thumbnail images in admin: consistent size */
.thumb,
.img-thumb,
.logo-thumb,
.avatar-thumb {
    object-fit: cover;
    border-radius: 8px;
}

/* Lazy-loaded image fade-in effect */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s ease;
}
img[loading="lazy"].loaded,
img[loading="lazy"][src] {
    opacity: 1;
}
/* Fallback: ensure images are visible even without JS */
@media (prefers-reduced-motion: reduce) {
    img[loading="lazy"] {
        opacity: 1;
        transition: none;
    }
}
