/* ==========================================================================
   FORTAI — MASTER RESPONSIVE & CROSS-DEVICE DESIGN SYSTEM
   Optimised for Ultra-wide Desktops (1600px+), Laptops (1200px-1599px),
   Tablets (Landscape & Portrait 768px-1199px), and Mobile Phones (320px-767px)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. GLOBAL RESET, TOUCH CONTROLS & FLUID SCALING
   -------------------------------------------------------------------------- */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  box-sizing: border-box;
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

*, *::before, *::after {
  box-sizing: inherit;
}

body {
  overflow-x: hidden;
  max-width: 100vw;
  position: relative;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Touch Device Tactile Feedback & Tap Highlights */
@media (hover: none) and (pointer: coarse) {
  .card:hover,
  .role-card:hover,
  .portfolio-card:hover,
  .industry-card:hover,
  .principle-card:hover,
  .sg-pillar-card:hover,
  .platform-feature-card:hover,
  .about-pillar-card:hover,
  .about-value-card:hover {
    transform: none !important;
  }

  .btn:active,
  .filter-btn:active,
  .portfolio-card:active,
  .approach-card:active,
  .platform-feature-card:active,
  .crm-btn:active,
  .crm-tab-btn:active {
    transform: scale(0.97) !important;
    transition: transform 0.1s ease !important;
  }
}

/* Minimum Touch Target Sizes & Input iOS Fix */
button, a, input, select, textarea, .filter-btn, .carousel-country-tab, .nav-link {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

input, select, textarea {
  font-size: 16px !important; /* Prevents auto-zoom on iOS Safari */
}

/* Responsive Fluid Images & SVGs */
img, svg, video, canvas {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
}

/* --------------------------------------------------------------------------
   2. ULTRA-WIDE & HIGH-RESOLUTION SCREENS (min-width: 1600px)
   -------------------------------------------------------------------------- */
@media (min-width: 1600px) {
  .container,
  .nav-container,
  .footer-container {
    max-width: 1480px;
  }

  .hero-headline {
    font-size: 4.2rem;
  }

  .intro-statement {
    font-size: 2.75rem;
  }

  .portfolio-cards-grid {
    gap: 40px;
  }
}

/* --------------------------------------------------------------------------
   3. STANDARD LAPTOPS & DESKTOPS (1200px - 1599px)
   -------------------------------------------------------------------------- */
@media (max-width: 1400px) {
  .container,
  .nav-container,
  .footer-container {
    max-width: 1200px;
    padding-left: 28px;
    padding-right: 28px;
  }

  .nav-menu {
    gap: 22px;
  }
}

@media (max-width: 1200px) {
  :root {
    --container-padding-x: 24px;
    --section-padding-y: 90px;
  }

  .nav-menu {
    gap: 18px;
  }

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

  .approach-timeline {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }

  .footer-top-grid {
    grid-template-columns: 1.4fr 1fr 1fr 1fr;
    gap: 32px;
  }
}

/* --------------------------------------------------------------------------
   4. TABLETS (LANDSCAPE) & MEDIUM DEVICES (992px - 1199px)
   -------------------------------------------------------------------------- */
@media (max-width: 1199px) and (min-width: 992px) {
  .intro-grid {
    grid-template-columns: 1.1fr 0.9fr;
    gap: 36px;
  }

  .singapore-pillars-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }

  .industries-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
  }

  .principles-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }

  .portfolio-details {
    padding: 36px;
  }
}

/* --------------------------------------------------------------------------
   5. TABLETS (PORTRAIT) & SMALL LAPTOPS (max-width: 991px)
   -------------------------------------------------------------------------- */
@media (max-width: 991px) {
  :root {
    --section-padding-y: 75px;
    --container-padding-x: 24px;
  }

  /* --- Navigation Bar & Mobile Drawer --- */
  .site-header {
    padding: 12px 0;
    pointer-events: none;
    z-index: 1010;
  }

  .site-header.scrolled {
    padding: 8px 0;
  }

  .nav-container {
    padding: 8px 14px 8px 20px;
    pointer-events: auto !important;
    position: relative;
    z-index: 1011;
  }

  .nav-actions {
    display: flex !important;
    align-items: center;
    gap: 10px;
    pointer-events: auto !important;
    position: relative;
    z-index: 1012;
  }

  .nav-desktop-cta {
    display: none !important;
  }

  /* Razor-Sharp High-Contrast Mobile Hamburger Toggle */
  .nav-toggle {
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
    border-radius: 12px;
    background: #ffffff !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    filter: none !important;
    border: 1.5px solid rgba(111, 146, 118, 0.4) !important;
    box-shadow: 0 4px 14px rgba(18, 26, 24, 0.08) !important;
    cursor: pointer !important;
    pointer-events: auto !important;
    position: relative;
    z-index: 1030 !important;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  }

  .nav-toggle:hover {
    background: #fafaf7 !important;
    border-color: var(--color-sage-700) !important;
    box-shadow: 0 6px 18px rgba(18, 26, 24, 0.14) !important;
  }

  .nav-toggle:active {
    transform: scale(0.92) !important;
    background: #f0f4f1 !important;
  }

  .hamburger-bar {
    width: 22px;
    height: 2.5px;
    background-color: #0b1411 !important;
    border-radius: 3px;
    display: block;
    transform-origin: center;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
    pointer-events: none;
  }

  .hamburger-bar:not(:last-child) {
    margin-bottom: 4.5px;
  }

  .nav-toggle.active .bar-1 {
    transform: translateY(7px) rotate(45deg);
    background-color: #0b1411 !important;
  }

  .nav-toggle.active .bar-2 {
    opacity: 0;
    transform: scaleX(0);
  }

  .nav-toggle.active .bar-3 {
    transform: translateY(-7px) rotate(-45deg);
    background-color: #0b1411 !important;
  }

  .nav-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 320px;
    max-width: 85vw;
    height: 100vh;
    height: 100dvh;
    background: rgba(251, 251, 248, 0.98);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 24px 24px 36px;
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.25);
    border-left: 1px solid var(--border-subtle);
    transition: right 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1025 !important;
    pointer-events: auto !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .nav-menu.open {
    right: 0;
  }

  .nav-mobile-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    padding-bottom: 16px !important;
    margin-bottom: 20px !important;
    border-bottom: 1px solid rgba(111, 146, 118, 0.15) !important;
    pointer-events: auto !important;
    flex-shrink: 0 !important;
  }

  .nav-mobile-logo-img,
  .nav-mobile-logo,
  .nav-mobile-header img {
    height: 28px !important;
    max-height: 28px !important;
    width: auto !important;
    max-width: 130px !important;
    object-fit: contain !important;
    display: block !important;
    flex-shrink: 0 !important;
  }

  .nav-mobile-close {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    border-radius: 50% !important;
    background: var(--color-sage-50, #eef4f0) !important;
    border: 1px solid rgba(111, 146, 118, 0.25) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: var(--color-charcoal-900, #0c1412) !important;
    font-size: 1.5rem !important;
    line-height: 1 !important;
    cursor: pointer !important;
    pointer-events: auto !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    transition: background var(--transition-fast) !important;
  }

  .nav-mobile-close:hover,
  .nav-mobile-close:active {
    background: var(--color-sage-100) !important;
  }

  .nav-menu .nav-link {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-charcoal-900);
    width: 100%;
    padding: 14px 0;
    border-bottom: 1px solid rgba(111, 146, 118, 0.08);
    pointer-events: auto !important;
  }

  .nav-menu .nav-link::after {
    display: none;
  }

  .nav-menu .nav-cta-mobile {
    display: flex !important;
    width: 100%;
    margin-top: 24px;
    padding: 14px 24px;
    font-size: 1rem;
    justify-content: center;
    text-align: center;
    pointer-events: auto !important;
  }

  .nav-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(11, 17, 16, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1005 !important;
    opacity: 0;
    visibility: hidden;
    pointer-events: none !important;
    transition: opacity 0.3s ease, visibility 0.3s ease;
  }

  .nav-backdrop.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto !important;
  }

  body.no-scroll {
    overflow: hidden !important;
    touch-action: none;
  }

  /* --- Page Section Grids --- */
  .intro-grid,
  .contact-grid {
    grid-template-columns: 1fr;
    gap: 40px;
  }

  .portfolio-card,
  .portfolio-card:nth-child(even) {
    grid-template-columns: 1fr;
  }

  .portfolio-card:nth-child(even) .portfolio-visual {
    order: 0;
  }

  .portfolio-card:nth-child(even) .portfolio-details {
    order: 1;
  }

  .portfolio-visual {
    min-height: 280px;
  }

  .portfolio-details {
    padding: 32px 28px;
  }

  .approach-timeline {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  .footer-top-grid {
    grid-template-columns: 1fr 1fr;
    gap: 36px;
  }

  .singapore-pillars-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
}

/* --------------------------------------------------------------------------
   6. MOBILE DEVICES & SMARTPHONES (max-width: 767px)
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {
  :root {
    --container-padding-x: 18px;
    --section-padding-y: 60px;
    --section-padding-sm-y: 44px;
  }

  /* --- Hero Section --- */
  .hero-section {
    padding-top: 104px;
    padding-bottom: 48px;
    min-height: auto;
    align-items: flex-start;
  }

  .hero-visual-bg {
    opacity: 0.55;
  }

  .hero-img {
    object-position: 70% center;
    transform: scale(1.06);
  }

  .hero-overlay-mask {
    background: linear-gradient(
      180deg,
      rgba(250, 250, 247, 0.98) 0%,
      rgba(250, 250, 247, 0.92) 50%,
      rgba(250, 250, 247, 0.78) 80%,
      #fafaf7 100%
    );
  }

  .hero-bottom-transition {
    height: 120px;
  }

  .hero-wave-stream {
    height: 70px;
  }

  .hero-floating-tag {
    display: none !important;
  }

  .hero-headline {
    font-size: clamp(2rem, 7.5vw, 2.75rem);
    line-height: 1.14;
    margin-bottom: 14px;
    letter-spacing: -0.025em;
  }

  .hero-supporting-headline {
    font-size: 1.1rem;
    margin-bottom: 14px;
    line-height: 1.4;
  }

  .hero-desc {
    font-size: 0.95rem;
    line-height: 1.65;
    margin-bottom: 24px;
  }

  .hero-cta-group {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 32px;
  }

  .hero-cta-group .btn {
    width: 100%;
    padding: 14px 20px;
    justify-content: center;
  }

  .hero-metrics {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding-top: 20px;
  }

  .metric-item {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
  }

  .metric-value {
    font-size: 1.25rem;
  }

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

  /* --- Company Intro --- */
  .intro-statement {
    font-size: 1.75rem;
    line-height: 1.25;
  }

  .intro-pillars {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .pillar-item {
    padding: 16px;
  }

  /* --- Roles (What We Do) --- */
  .roles-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .role-card {
    padding: 24px 20px;
    min-height: auto;
  }

  /* --- Portfolio Section & Horizontal Swipe Tabs --- */
  .filter-tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px 18px 12px;
    margin-left: -18px;
    margin-right: -18px;
    margin-bottom: 28px;
    justify-content: flex-start;
    gap: 8px;
    scrollbar-width: none;
  }

  .filter-tabs::-webkit-scrollbar {
    display: none;
  }

  .filter-btn {
    flex-shrink: 0;
    padding: 9px 16px;
    font-size: 0.8125rem;
    white-space: nowrap;
    border-radius: var(--radius-full);
  }

  .portfolio-cards-grid {
    gap: 20px;
  }

  .portfolio-card {
    border-radius: var(--radius-xl);
  }

  .portfolio-visual {
    min-height: 220px;
  }

  .portfolio-details {
    padding: 22px 18px;
  }

  .portfolio-name {
    font-size: 1.5rem;
  }

  .portfolio-desc {
    font-size: 0.9375rem;
    margin-bottom: 18px;
  }

  .portfolio-tags {
    margin-bottom: 20px;
    gap: 6px;
  }

  .portfolio-tag {
    font-size: 0.75rem;
    padding: 4px 10px;
  }

  .portfolio-footer-action {
    padding-top: 16px;
  }

  .portfolio-footer-action .btn {
    width: 100%;
    justify-content: center;
  }

  /* --- Singapore & Regional Hubs Showcase --- */
  .carousel-country-tabs {
    gap: 8px;
    margin-bottom: 16px;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 6px;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .carousel-country-tab {
    padding: 8px 14px;
    font-size: 0.8rem;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .singapore-showcase {
    border-radius: var(--radius-lg);
    margin-top: 0;
  }

  .singapore-showcase-img {
    height: 260px;
    min-height: 220px;
  }

  .singapore-overlay-content {
    position: relative;
    padding: 22px 18px;
    background: rgba(18, 26, 24, 0.98);
    flex-direction: column;
    align-items: stretch;
  }

  .singapore-quote-title {
    font-size: 1.25rem;
  }

  .singapore-quote-text {
    font-size: 0.875rem;
  }

  .singapore-overlay-content .btn {
    width: 100%;
    margin-top: 12px;
    justify-content: center;
  }

  .singapore-pillars-grid {
    grid-template-columns: 1fr;
    gap: 14px;
    margin-top: 28px;
  }

  .sg-pillar-card {
    padding: 22px 18px;
  }

  /* --- Industries Grid --- */
  .industries-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .industry-card {
    padding: 24px 18px;
  }

  /* --- Our Approach Mobile Connected Flow --- */
  .approach-timeline {
    grid-template-columns: 1fr;
    gap: 14px;
  }

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

  /* --- Principles Grid --- */
  .principles-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .principle-card {
    padding: 24px 18px;
  }

  /* --- CTA Section --- */
  .cta-section {
    padding: 50px 0;
    min-height: auto;
  }

  .cta-container-glass {
    padding: 32px 18px;
    border-radius: var(--radius-xl);
  }

  .cta-headline {
    font-size: 1.75rem;
  }

  .cta-text {
    font-size: 0.95rem;
    margin-bottom: 20px;
  }

  .cta-buttons {
    flex-direction: column;
    width: 100%;
    gap: 10px;
  }

  .cta-buttons .btn {
    width: 100%;
    justify-content: center;
  }

  /* --- Contact Section --- */
  .form-row-2 {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .contact-form-card {
    padding: 24px 18px;
    border-radius: var(--radius-xl);
  }

  .contact-details-list {
    margin-top: 20px;
    gap: 18px;
  }

  .contact-detail-item {
    gap: 12px;
  }

  .contact-icon-circle {
    width: 38px;
    height: 38px;
  }

  .contact-detail-val {
    font-size: 0.9375rem;
  }

  /* --- Modal Adaptive Bottom Sheet --- */
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .modal-container {
    max-height: 90vh;
    width: 100%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }

  .modal-header-img {
    height: 150px;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }

  .modal-body {
    padding: 20px 18px;
  }

  .modal-title {
    font-size: 1.4rem;
  }

  .modal-desc {
    font-size: 0.9rem;
    margin-bottom: 18px;
  }

  .modal-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 18px;
  }

  .modal-feature-card {
    padding: 14px;
  }

  .modal-actions {
    flex-direction: column;
    width: 100%;
    gap: 10px;
  }

  .modal-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* --- Toast Position on Mobile --- */
  .toast-container,
  .toast-notification {
    left: 14px !important;
    right: 14px !important;
    bottom: 16px !important;
    max-width: calc(100vw - 28px) !important;
    width: auto !important;
  }

  .toast,
  .toast-notification {
    padding: 12px 16px;
    font-size: 0.85rem;
  }
}

/* --------------------------------------------------------------------------
   7. EXTRA SMALL MOBILE / NARROW SCREENS (max-width: 480px)
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  :root {
    --container-padding-x: 16px;
  }

  .brand-logo-img {
    height: 26px;
    max-width: 130px;
  }

  .hero-headline {
    font-size: 1.85rem;
  }

  .hero-metrics {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .footer-top-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }

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

  .footer-legal {
    justify-content: center;
    text-align: center;
    flex-direction: column;
    gap: 6px;
  }

  .footer-divider {
    display: none;
  }

  .form-submit-btn,
  .btn-lg {
    padding: 14px 18px !important;
    font-size: 0.9375rem !important;
  }
}
