/**
 * CUPRUM INFRASTRUCTURE PRIVATE LIMITED
 * Comprehensive Mobile & Responsive Engine
 * Fully optimized for Ultra-compact (320px), Standard Mobile (375-430px),
 * Tablet Portrait (768px), Tablet Landscape (1024-1120px), and Laptops (1280px).
 */

/* ==========================================================================
   1. Laptop & Small Desktop (<= 1280px)
   ========================================================================== */
@media (max-width: 1280px) {
  .container {
    padding-left: 24px;
    padding-right: 24px;
  }

  .nav-menu {
    gap: 22px;
  }

  .nav-link {
    font-size: 0.875rem;
  }

  .brand-logo-img {
    max-width: 195px;
    height: 54px;
  }

  .header-actions .btn-quote {
    padding: 10px 18px;
    font-size: 0.875rem;
  }

  .top-bar-left {
    display: none;
  }

  .top-bar .container {
    justify-content: center;
  }

  .top-bar-right {
    justify-content: center;
  }
}

/* ==========================================================================
   2. Medium Displays & Tablet Landscape (<= 1120px)
   ========================================================================== */
@media (max-width: 1120px) {
  :root {
    --header-height: 76px;
    --header-height-scrolled: 64px;
  }

  .top-bar-left {
    display: none;
  }

  .top-bar .container {
    justify-content: center;
  }

  .top-bar-right {
    justify-content: center;
  }

  .section {
    padding: 85px 0;
  }

  .section-lg {
    padding: 95px 0;
  }

  /* Navigation: Show Hamburger, Hide Desktop Bar */
  .nav-menu {
    display: none !important;
  }

  .hamburger-btn {
    display: flex !important;
  }

  .header-actions .btn-quote {
    display: none !important; /* Accessible inside mobile drawer */
  }

  /* Grid Adjustments */
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-12 {
    grid-template-columns: 1fr;
  }

  .hero-slide-content {
    max-width: 90%;
  }

  .masonry-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .gallery-item.tall {
    height: 440px;
  }

  /* Process Timeline Horizontal Adjustments */
  .timeline-horizontal {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 32px 16px;
  }

  .timeline-horizontal::before {
    display: none;
  }
}

/* ==========================================================================
   3. Intermediate Tablets (<= 991px)
   ========================================================================== */
@media (max-width: 991px) {
  .detail-layout,
  .legal-layout {
    grid-template-columns: 1fr;
    gap: 40px;
  }

  .detail-sidebar,
  .legal-sidebar {
    position: static !important;
    width: 100%;
  }

  .contact-cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-scroll-indicator {
    display: none !important;
  }
}

/* ==========================================================================
   4. Tablet Portrait & Large Phones (<= 768px)
   ========================================================================== */
@media (max-width: 768px) {
  :root {
    --header-height: 72px;
    --header-height-scrolled: 60px;
  }

  .section {
    padding: 65px 0;
  }

  .section-sm {
    padding: 45px 0;
  }

  .section-lg {
    padding: 80px 0;
  }

  .container {
    padding-left: 20px;
    padding-right: 20px;
  }

  /* Typography Fluid Scaling */
  h1 {
    font-size: clamp(2rem, 6.5vw, 2.75rem);
    line-height: 1.15;
  }

  h2 {
    font-size: clamp(1.65rem, 5vw, 2.15rem);
    line-height: 1.22;
  }

  h3 {
    font-size: clamp(1.25rem, 3.5vw, 1.55rem);
  }

  p.lead {
    font-size: 1.05rem;
    line-height: 1.65;
  }

  .section-header {
    margin-bottom: 32px;
  }

  /* Section Header Flex Wrapping on Tablet/Mobile: Fixes side-by-side squished title & paragraph */
  .section-header.flex,
  .section-header.justify-between,
  .flex.section-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 14px !important;
  }

  .section-header > div:first-child,
  .section-header > .reveal-up:first-child,
  .section-header > div[style*="max-width"] {
    width: 100% !important;
    max-width: 100% !important;
  }

  .section-header > div > p,
  .section-header > .reveal-up > p {
    max-width: 100% !important;
    width: 100% !important;
    margin-top: 10px !important;
    font-size: 0.95rem !important;
    line-height: 1.65 !important;
  }

  .section-header-actions {
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 12px !important;
    margin-top: 6px !important;
  }

  .section-header-actions .btn {
    width: 100% !important;
    text-align: center !important;
    justify-content: center !important;
  }

  .header-nav-circle {
    display: none !important;
  }

  /* All Multi-column Grids Collapse to Single Column */
  .grid-2,
  .grid-3,
  .grid-4,
  .contact-cards-grid {
    grid-template-columns: 1fr !important;
    gap: 24px;
  }

  /* Grid-12 Stack on Tablet & Mobile (HOW WE WORK section) */
  .grid-12 {
    display: flex !important;
    flex-direction: column !important;
    gap: 28px !important;
  }

  .grid-12 > * {
    width: 100% !important;
    grid-column: auto !important;
  }

  /* Hero Slider on Tablet & Mobile */
  .hero-slider-section {
    height: auto !important;
    min-height: 560px;
  }

  .hero-slide {
    padding: 60px 0 70px 0;
    align-items: center;
  }

  .hero-slide-content {
    max-width: 100%;
    padding: 20px 0 40px 0;
  }

  .hero-slide-title {
    font-size: clamp(1.95rem, 6vw, 2.75rem);
    line-height: 1.15;
    margin-bottom: 18px;
  }

  .hero-slide-desc {
    font-size: 1rem;
    line-height: 1.65;
    margin-bottom: 28px;
  }

  /* Hide Desktop Slider Arrows on Touch Devices */
  .hero-nav-btn {
    display: none !important;
  }

  .hero-pagination {
    bottom: 22px !important;
  }

  /* Inner Hero Section */
  .inner-hero {
    min-height: 230px;
    padding: 50px 0;
  }

  .inner-hero-title {
    font-size: clamp(1.85rem, 5.5vw, 2.35rem);
    margin-bottom: 12px;
  }

  .breadcrumb {
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.8125rem;
    margin-bottom: 10px;
  }

  /* About Media & Floating Card Integration */
  .about-main-img {
    min-height: auto;
    height: 340px;
    object-fit: cover;
  }

  .about-media-wrapper {
    overflow: visible;
  }

  .about-floating-card {
    position: relative !important;
    bottom: auto !important;
    right: auto !important;
    max-width: 100% !important;
    margin-top: 18px;
    box-shadow: var(--shadow-card);
    border-radius: 14px;
    padding: 24px 20px;
  }

  /* Process Timeline: Connected Vertical Step Cards with Connected Copper Line */
  .timeline-horizontal {
    display: flex !important;
    flex-direction: column !important;
    gap: 26px !important;
    position: relative !important;
    padding-left: 0 !important;
    margin-top: 32px !important;
    margin-bottom: 24px !important;
  }

  .timeline-horizontal::before {
    content: "" !important;
    display: block !important;
    position: absolute !important;
    top: 22px !important;
    bottom: 22px !important;
    left: 21px !important;
    right: auto !important;
    width: 2px !important;
    height: auto !important;
    background: linear-gradient(180deg, var(--color-primary), var(--color-primary-light)) !important;
    z-index: 1 !important;
  }

  .timeline-step {
    display: grid !important;
    grid-template-columns: 44px 1fr !important;
    column-gap: 18px !important;
    row-gap: 4px !important;
    align-items: start !important;
    position: relative !important;
    width: 100% !important;
    text-align: left !important;
  }

  .timeline-step-badge {
    grid-column: 1 !important;
    grid-row: 1 / span 2 !important;
    position: relative !important;
    top: auto !important;
    left: auto !important;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    border-radius: 50% !important;
    background: var(--color-white) !important;
    border: 2px solid var(--color-primary) !important;
    color: var(--color-primary) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-family: var(--font-heading) !important;
    font-size: 0.9375rem !important;
    font-weight: 800 !important;
    margin: 0 !important;
    z-index: 2 !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08) !important;
  }

  .timeline-step-title {
    grid-column: 2 !important;
    grid-row: 1 !important;
    font-size: 1.05rem !important;
    font-weight: 700 !important;
    margin: 0 !important;
    padding-top: 2px !important;
    color: var(--color-heading) !important;
  }

  .timeline-step-desc {
    grid-column: 2 !important;
    grid-row: 2 !important;
    font-size: 0.875rem !important;
    line-height: 1.6 !important;
    color: var(--color-body) !important;
    margin: 0 !important;
  }

  /* Process Media Preview Card (HOW WE WORK image section) */
  .process-media-card,
  [style*="height: 380px"] {
    height: 230px !important;
    border-radius: var(--radius-md) !important;
    overflow: hidden !important;
  }

  .process-media-card img,
  [style*="height: 380px"] img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
  }

  .play-btn-circle {
    width: 56px !important;
    height: 56px !important;
    box-shadow: 0 6px 20px rgba(184, 115, 51, 0.4) !important;
  }

  .play-btn-circle svg,
  .play-btn-circle i {
    width: 20px !important;
    height: 20px !important;
  }

  .play-btn-circle + span,
  .process-media-card span {
    font-size: 0.9375rem !important;
    text-align: center !important;
    padding: 0 16px !important;
  }

  /* Quality & Safety Section */
  .quality-image-wrapper {
    height: 320px;
    overflow: visible;
  }

  .quality-floating-badge {
    position: relative !important;
    bottom: auto !important;
    left: auto !important;
    margin: -32px 12px 0 12px;
    max-width: calc(100% - 24px) !important;
    padding: 14px 18px;
    z-index: 3;
    box-shadow: var(--shadow-dark);
  }

  /* Working Gallery Masonry Grid */
  .masonry-grid {
    grid-template-columns: 1fr !important;
    gap: 18px;
  }

  .gallery-item,
  .gallery-item.tall,
  .gallery-item.wide {
    height: 250px !important;
    grid-row: span 1 !important;
    grid-column: span 1 !important;
  }

  .gallery-cta-card {
    height: 220px;
    padding: 30px 20px;
  }

  /* Lightbox Controls on Mobile */
  .lightbox-modal {
    padding: 16px;
  }

  .lightbox-btn {
    width: 44px;
    height: 44px;
  }

  .lightbox-prev {
    left: 10px;
  }

  .lightbox-next {
    right: 10px;
  }

  .lightbox-close {
    position: fixed !important;
    top: 14px !important;
    right: 14px !important;
    width: 44px;
    height: 44px;
    font-size: 1.75rem;
    z-index: calc(var(--z-modal) + 2);
  }

  .lightbox-caption-text {
    font-size: 0.9375rem;
    padding: 0 12px;
  }

  /* Footer Layout */
  .global-footer .grid-4 {
    grid-template-columns: 1fr !important;
    gap: 36px;
  }

  .footer-bottom .container {
    flex-direction: column;
    text-align: center;
    gap: 14px;
  }

  .footer-legal-links {
    justify-content: center;
    gap: 18px;
  }

  /* CTA Skyline Banner */
  .cta-banner-section {
    padding: 75px 0;
  }

  .cta-banner-title {
    font-size: clamp(1.75rem, 5vw, 2.35rem);
    margin-bottom: 16px;
  }

  .cta-banner-desc {
    font-size: 0.95rem;
    line-height: 1.65;
    margin-bottom: 30px;
  }

  /* Vision & Mission Cards */
  .vision-card {
    padding: 32px 24px;
  }

  .vision-card-title {
    font-size: 1.35rem;
  }

  .vision-card-quote-mark {
    font-size: 4rem;
    top: 10px;
    right: 18px;
  }

  /* Service Card & Project Card Adjustments */
  .service-card-media,
  .project-card-media {
    height: 220px;
  }

  .service-card-body,
  .project-card-body {
    padding: 24px 20px;
  }
}

/* ==========================================================================
   5. Phablets & Landscape Mobile (<= 640px)
   ========================================================================== */
@media (max-width: 640px) {
  /* Hide landline phone in top bar so mobile phone + email fit cleanly */
  .top-bar-right a[href*="01140114225"],
  .top-bar-right a[href*="01140114225"] + .top-bar-divider {
    display: none !important;
  }

  .top-bar-right {
    gap: 14px;
    width: 100%;
    justify-content: center;
    flex-wrap: nowrap;
  }

  .top-bar-item {
    font-size: 0.775rem;
    overflow-wrap: break-word;
  }

  /* Section Header Actions Wrap Cleanly */
  .section-header-actions {
    width: 100%;
    justify-content: flex-start;
    margin-top: 14px;
  }

  .section-header-actions .btn {
    width: 100%;
  }

  .header-nav-circle {
    display: none !important;
  }

  /* Responsive Corporate Information Table on about.html */
  .card-premium table {
    display: block;
    width: 100%;
  }

  .card-premium table tbody {
    display: block;
    width: 100%;
  }

  .card-premium table tr {
    display: flex;
    flex-direction: column;
    padding: 14px 0;
    border-bottom: 1px solid var(--color-border-subtle);
  }

  .card-premium table tr:last-child {
    border-bottom: none;
  }

  .card-premium table td {
    display: block;
    width: 100% !important;
    padding: 2px 0 !important;
  }

  .card-premium table td:first-child {
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-primary) !important;
    margin-bottom: 2px;
  }

  .card-premium table td:last-child {
    font-size: 0.9375rem;
    line-height: 1.5;
    word-break: break-word;
  }

  /* Hero & CTA Actions Stack */
  .hero-actions,
  .cta-banner-actions {
    flex-direction: column;
    width: 100%;
    gap: 12px;
  }

  .hero-actions .btn,
  .cta-banner-actions .btn {
    width: 100%;
    min-height: 48px;
  }
}

/* ==========================================================================
   6. Standard Mobile Phones (<= 480px)
   ========================================================================== */
@media (max-width: 480px) {
  :root {
    --header-height: 64px;
    --header-height-scrolled: 56px;
    --topbar-height: 28px;
  }

  header {
    top: 0;
  }

  header.scrolled .top-bar {
    margin-top: calc(-1 * var(--topbar-height, 28px));
  }

  .section {
    padding: 50px 0;
  }

  .section-sm {
    padding: 36px 0;
  }

  .section-lg {
    padding: 60px 0;
  }

  .container {
    padding-left: 16px;
    padding-right: 16px;
  }

  /* Brand Logo Sizing */
  .brand-logo-img {
    height: 42px;
    max-width: 155px;
  }

  .main-header.scrolled .brand-logo-img {
    height: 36px;
    max-width: 135px;
  }

  .hamburger-btn {
    width: 44px;
    height: 44px;
    padding: 6px;
  }

  /* Top Information Bar */
  .top-bar {
    font-size: 0.75rem;
    padding: 3px 0;
  }

  .top-bar-right {
    gap: 10px;
    width: 100%;
    justify-content: center;
  }

  .top-bar-item {
    font-size: 0.75rem;
    gap: 5px;
    white-space: nowrap;
  }

  .top-bar-item i,
  .top-bar-item svg {
    width: 12px;
    height: 12px;
  }

  .top-bar-divider {
    height: 10px;
    opacity: 0.4;
  }

  /* Hero Headings and Descriptions */
  .hero-slide {
    padding: 45px 0 65px 0;
  }

  .hero-slide-title {
    font-size: clamp(1.75rem, 6.8vw, 2.2rem);
    line-height: 1.16;
    letter-spacing: -0.02em;
    margin-bottom: 14px;
  }

  .hero-slide-desc {
    font-size: 0.9375rem;
    line-height: 1.6;
    margin-bottom: 22px;
  }

  .hero-slide-eyebrow {
    font-size: 0.75rem;
    margin-bottom: 14px;
    letter-spacing: 0.12em;
  }

  .hero-highlights {
    gap: 8px;
  }

  .hero-highlight-capsule {
    padding: 6px 12px;
    font-size: 0.75rem;
    gap: 6px;
  }

  .hero-highlight-capsule i,
  .hero-highlight-capsule svg {
    width: 13px;
    height: 13px;
  }

  /* Buttons & Touch Targets */
  .btn {
    padding: 12px 20px;
    font-size: 0.875rem;
    min-height: 46px;
  }

  /* Filter Buttons (Gallery & Projects) */
  .gallery-filters {
    gap: 8px;
    margin-bottom: 28px;
    justify-content: center;
  }

  .filter-btn {
    padding: 7px 15px;
    font-size: 0.8125rem;
    min-height: 38px;
  }

  /* Card Layouts */
  .card-premium,
  .card-dark {
    padding: 24px 18px;
    border-radius: 14px;
  }

  .service-card-media,
  .project-card-media {
    height: 200px;
  }

  .service-card-body,
  .project-card-body {
    padding: 20px 16px;
  }

  .service-card-title,
  .project-card-title {
    font-size: 1.2rem;
  }

  .service-card-desc,
  .project-card-desc {
    font-size: 0.875rem;
    line-height: 1.6;
    margin-bottom: 18px;
  }

  .service-card-number {
    font-size: 1.8rem;
    bottom: 10px;
    right: 14px;
  }

  /* Form Inputs (16px prevents iOS zoom) */
  .form-group {
    margin-bottom: 18px;
  }

  .form-control {
    font-size: 1rem !important; /* Exactly 16px prevents iOS zoom */
    padding: 12px 14px;
    min-height: 48px;
    border-radius: var(--radius-sm);
  }

  .form-label {
    font-size: 0.8125rem;
    margin-bottom: 6px;
  }

  /* Mobile Nav Drawer */
  .mobile-nav-drawer {
    width: 86vw;
    max-width: 320px;
    padding: 24px 18px;
  }

  .mobile-nav-header {
    padding-bottom: 16px;
    margin-bottom: 18px;
  }

  .mobile-nav-close {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    font-size: 1.75rem;
  }

  .mobile-nav-links {
    gap: 10px;
    margin-bottom: 24px;
  }

  .mobile-nav-link {
    font-size: 1.05rem;
    padding: 10px 0;
  }

  .mobile-nav-contact {
    padding-top: 18px;
    font-size: 0.8125rem;
  }

  /* Process Timeline on Mobile */
  .timeline-horizontal {
    padding-left: 0 !important;
    gap: 22px !important;
  }

  .timeline-step {
    grid-template-columns: 40px 1fr !important;
    column-gap: 14px !important;
  }

  .timeline-step-badge {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    font-size: 0.875rem !important;
  }

  .timeline-horizontal::before {
    left: 19px !important;
  }

  .timeline-step-title {
    font-size: 1rem !important;
  }

  /* Process Media Preview Card (HOW WE WORK) */
  .process-media-card,
  [style*="height: 380px"] {
    height: 200px !important;
  }

  .play-btn-circle {
    width: 48px !important;
    height: 48px !important;
  }

  .play-btn-circle svg,
  .play-btn-circle i {
    width: 16px !important;
    height: 16px !important;
  }

  .play-btn-circle + span,
  .process-media-card span {
    font-size: 0.85rem !important;
  }

  /* Accordions */
  .accordion-header {
    padding: 16px 18px;
    font-size: 0.95rem;
    gap: 12px;
  }

  .accordion-body {
    padding: 0 18px 18px;
    font-size: 0.875rem;
  }

  /* Floating Back to Top Button */
  .back-to-top {
    bottom: 16px;
    right: 16px;
    width: 42px;
    height: 42px;
  }

  .back-to-top svg {
    width: 18px;
    height: 18px;
  }

  /* Detail Layout & Sidebars */
  .detail-layout,
  .legal-layout {
    gap: 30px;
  }

  .sidebar-card {
    padding: 22px 18px;
  }

  .sidebar-title {
    font-size: 1.15rem;
  }

  .facts-list {
    gap: 12px;
  }

  .fact-item {
    padding-bottom: 10px;
  }

  .fact-label {
    font-size: 0.75rem;
  }

  .fact-value {
    font-size: 0.9375rem;
  }

  /* Legal Content */
  .legal-sidebar {
    padding: 18px 16px;
  }

  .legal-content h2 {
    font-size: 1.3rem;
    margin-top: 28px;
  }

  .legal-notice-box {
    padding: 14px 16px;
    font-size: 0.875rem;
  }
}

/* ==========================================================================
   7. Ultra-Compact Mobile (<= 360px - iPhone SE, small Galaxy, KaiOS)
   ========================================================================== */
@media (max-width: 360px) {
  .container {
    padding-left: 12px;
    padding-right: 12px;
  }

  /* On ultra-compact screens, hide the email from top bar to ensure zero side-scrolling */
  .top-bar-right a[href^="mailto:"],
  .top-bar-right a[href^="mailto:"] + .top-bar-divider,
  .top-bar-divider {
    display: none !important;
  }

  .top-bar {
    font-size: 0.725rem;
  }

  .top-bar-right {
    gap: 6px;
    justify-content: center;
  }

  .top-bar-item {
    font-size: 0.725rem;
    gap: 4px;
  }

  .top-bar-item i,
  .top-bar-item svg {
    width: 11px;
    height: 11px;
  }

  .brand-logo-img {
    height: 38px;
    max-width: 135px;
  }

  .main-header.scrolled .brand-logo-img {
    height: 32px;
    max-width: 120px;
  }

  /* Headings */
  h1 {
    font-size: 1.75rem;
  }

  h2 {
    font-size: 1.45rem;
  }

  h3 {
    font-size: 1.18rem;
  }

  .hero-slide-title {
    font-size: 1.65rem;
  }

  /* Cards & Spacing */
  .card-premium,
  .card-dark {
    padding: 20px 14px;
  }

  .btn {
    padding: 11px 16px;
    font-size: 0.8125rem;
  }

  /* Timeline */
  .timeline-horizontal {
    padding-left: 0 !important;
    gap: 20px !important;
  }

  .timeline-step {
    grid-template-columns: 36px 1fr !important;
    column-gap: 12px !important;
  }

  .timeline-step-badge {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    font-size: 0.8125rem !important;
  }

  .timeline-horizontal::before {
    left: 17px !important;
  }

  /* Process Media Preview Card (HOW WE WORK) */
  .process-media-card,
  [style*="height: 380px"] {
    height: 175px !important;
  }

  .play-btn-circle {
    width: 44px !important;
    height: 44px !important;
  }

  .play-btn-circle svg,
  .play-btn-circle i {
    width: 14px !important;
    height: 14px !important;
  }

  .play-btn-circle + span,
  .process-media-card span {
    font-size: 0.8125rem !important;
  }

  /* Drawer width */
  .mobile-nav-drawer {
    width: 90vw;
    padding: 20px 14px;
  }

  /* Ensure long words break safely */
  * {
    overflow-wrap: break-word;
  }
}
