/**
 * Smartphone / tablet responsive overrides.
 * Loaded after style.css. PC layout (≥992px) is left unchanged visually.
 */

/* Respect system motion preference (content must not stay at opacity:0) */
@media (prefers-reduced-motion: reduce) {
  .animatable,
  .animatable.fade-in-left,
  .animatable.fade-in-right,
  .animatable.loaded {
    opacity: 1;
    transform: none;
  }

  .marquee-container .marquee-content {
    animation: none;
  }
}

/*
 * Clip only — does not change painted PC layout.
 * Needed because .welcome .container { display:flex } and entrance transforms
 * can extend descendants a few dozen pixels past the viewport (document scrollWidth).
 */
.welcome,
.info,
.vision-mission,
.team-members,
.companies,
.classroom,
.desc-columns,
.partners,
.why-choose,
.marquee-container,
#contact > .container,
#about > .info,
#csfe > .welcome {
  overflow-x: clip;
}

.marquee-container {
  width: 100%;
  max-width: 100%;
}

/* Honeypot: visually hidden + non-interactive (markup also uses tabindex="-1" + aria-hidden) */
#contact .hp-field {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  border: 0;
  white-space: nowrap;
  pointer-events: none;
}

#contact .hp-field input,
#contact .hp-field label {
  pointer-events: none;
}

#contact form,
#contact .card-body {
  position: relative;
}

/* Dim page behind open mobile menu (created/removed in common.js) */
.nav-backdrop {
  display: none;
}

/* -------------------------------------------------------------------------- */
/* Shared tablet/phone overrides (< lg / Bootstrap navbar collapse)           */
/* -------------------------------------------------------------------------- */
@media (max-width: 991.98px) {
  /* Override global `* { transition: 0.5s }` so revealed content reaches full opacity quickly */
  .animatable {
    transition: opacity 0.35s ease, transform 0.45s ease;
  }

  .fade-in-left,
  .fade-in-right {
    transform: translateY(40px);
  }

  .animatable.loaded.fade-in-left,
  .animatable.loaded.fade-in-right {
    transform: translateY(0) translateX(0) scale(1);
  }

  /* Header: compact top bar + usable hamburger (Bootstrap collapses < lg) */
  header .nav-top {
    padding: 6px 0;
    font-size: 11px;
  }

  header .nav-top .info-area {
    flex-wrap: wrap;
    gap: 6px 14px;
    justify-content: flex-start;
  }

  header .nav-top .info-area .info-single:nth-child(1),
  header .nav-top .info-area .info-single:nth-last-child(1) {
    margin-right: 0;
    margin-left: 0;
  }

  header .nav-top .info-area .info-single.nav-top-address {
    display: none;
  }

  header .nav-top .info-area .info-single.social {
    margin-left: auto;
    font-size: 16px;
  }

  header nav.navbar {
    height: auto;
    min-height: 72px;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }

  header nav .navbar-brand img {
    width: 160px;
    height: auto;
  }

  header .navbar-toggler {
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    padding: 0.55rem 0.7rem;
    width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
  }

  header .navbar-toggler:focus {
    box-shadow: 0 0 0 0.2rem rgba(1, 90, 255, 0.25);
  }

  header .navbar-toggler .navbar-toggler-icon {
    width: 1.35em;
    height: 1.35em;
  }

  header .navbar-collapse {
    width: 100%;
  }

  header .navbar-collapse.show,
  header .navbar-collapse.collapsing {
    margin-top: 0.75rem;
    padding: 0.75rem 0.25rem 1.1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    background-color: #fff;
    border-radius: 0 0 12px 12px;
    /* Keep full menu reachable on short / landscape screens */
    max-height: calc(100vh - 5.5rem);
    max-height: calc(100dvh - 5.5rem);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  header nav .navbar-nav {
    align-items: stretch;
    gap: 2px;
  }

  header nav .navbar-nav .nav-item {
    padding: 0;
  }

  header nav .navbar-nav .nav-item .nav-link {
    padding: 0.85rem 0.75rem;
    min-height: 48px;
    display: flex;
    align-items: center;
    font-size: 16px;
    border-radius: 8px;
  }

  header nav .navbar-nav .nav-item .nav-link:hover,
  header nav .navbar-nav .nav-item .nav-link:focus {
    background-color: rgba(1, 90, 255, 0.06);
  }

  header nav .navbar-nav .nav-item .nav-link.active {
    color: #015aff;
    background-color: rgba(1, 90, 255, 0.08);
  }

  .mobile-nav-meta {
    display: block;
    margin-top: 1rem;
    padding: 1rem 0.75rem 0;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    font-size: 13px;
    line-height: 1.6;
    color: #333;
  }

  .mobile-nav-meta a {
    color: #015aff;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 44px;
  }

  .mobile-nav-meta .mobile-nav-address {
    margin-top: 0.35rem;
    color: #555;
  }

  /* Shrink behavior: keep usable header on tablet/phone */
  .shrink .nav-top {
    height: auto;
    padding: 4px 0;
    overflow: hidden;
  }

  .shrink nav.navbar {
    height: auto;
    min-height: 64px;
  }

  .shrink nav .navbar-brand img {
    width: 130px;
  }

  body.nav-open {
    overflow: hidden;
  }

  body.nav-open .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 8; /* header is z-index 9 */
    background: rgba(0, 0, 0, 0.28);
    border: 0;
    padding: 0;
    cursor: pointer;
  }

  @media (orientation: landscape) and (max-height: 500px) {
    header .navbar-collapse.show,
    header .navbar-collapse.collapsing {
      max-height: calc(100vh - 4.25rem);
      max-height: calc(100dvh - 4.25rem);
      padding-bottom: 0.5rem;
    }

    header nav .navbar-nav .nav-item .nav-link {
      min-height: 40px;
      padding-top: 0.55rem;
      padding-bottom: 0.55rem;
    }

    .mobile-nav-meta a {
      min-height: 36px;
    }
  }

  /* Page hero banners */
  .page {
    padding: 160px 20px 56px;
  }

  .page h1 {
    font-size: 1.65rem;
    line-height: 1.45;
    word-break: break-word;
  }

  .page h1 .en {
    display: block;
    font-size: 0.95em;
    margin-bottom: 0.25rem;
  }

  /* Sections & type */
  section {
    padding: 64px 0;
  }

  section small {
    letter-spacing: 4px;
    margin-bottom: 12px;
  }

  section h1,
  section h2 {
    font-size: 1.5rem;
    line-height: 1.45;
  }

  section h3 {
    font-size: 1.25rem;
    line-height: 1.45;
  }

  .btn-primary {
    width: 100%;
    max-width: 280px;
    height: 52px;
    margin-top: 20px;
  }

  .btn-primary.mx-auto {
    display: flex;
  }

  /* Footer: keep Bootstrap container side gutters (do not use padding: Y 0) */
  footer .f-content.container {
    padding-top: 48px;
    padding-bottom: 36px;
    padding-left: var(--bs-gutter-x, 0.75rem);
    padding-right: var(--bs-gutter-x, 0.75rem);
  }

  footer .f-content .f-column {
    padding-right: calc(var(--bs-gutter-x, 0.75rem) * 0.5);
    padding-left: calc(var(--bs-gutter-x, 0.75rem) * 0.5);
    margin-bottom: 36px;
  }

  footer .f-content .f-column:last-child {
    margin-bottom: 0;
  }

  footer .f-content .logo {
    width: 150px;
  }

  footer .f-content .social-icons {
    margin-top: 24px;
    gap: 18px;
  }

  footer .f-content .social-icons a {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  footer .f-content h6 {
    margin-bottom: 16px;
    font-size: 1rem;
  }

  footer .f-content ul li a {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
  }

  footer .copyright {
    padding: 16px 12px;
    line-height: 1.5;
  }

  /* Marquee */
  .marquee-container .marquee-content {
    font-size: clamp(48px, 14vw, 72px);
  }

}

/* -------------------------------------------------------------------------- */
/* Smartphone layout (< 768px)                                                */
/* -------------------------------------------------------------------------- */
@media (max-width: 767.98px) {
  body {
    font-size: 15px;
    line-height: 1.75;
    background-size: cover;
    background-position: center top;
  }

  /* Comfortable Japanese reading margins inside Bootstrap containers */
  .container,
  .container-fluid > .container {
    padding-left: 16px;
    padding-right: 16px;
  }

  .products .container,
  .partners .container,
  .desc-columns .container,
  .team-members .container,
  #csfe .welcome .container {
    padding-left: 16px;
    padding-right: 16px;
  }

  /* Hide utility top bar; contact lives in the mobile menu */
  header .nav-top {
    display: none;
  }

  header nav.navbar {
    min-height: 64px;
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
  }

  header nav .navbar-brand img {
    width: 140px;
  }

  .carousel {
    padding-top: 64px;
  }

  .carousel-item {
    max-height: 52vw;
    min-height: 200px;
  }

  .carousel-item picture {
    display: block;
    width: 100%;
  }

  .carousel-item img {
    width: 100%;
    height: 52vw;
    min-height: 200px;
    max-height: 280px;
    object-fit: cover;
    object-position: center center;
  }

  .carousel-control-prev,
  .carousel-control-next {
    width: 12%;
  }

  /* Companies intro card */
  .companies {
    margin-top: -48px;
    padding: 0 12px;
  }

  .companies .company-single {
    width: 100%;
    padding: 28px 20px;
    border-radius: 16px;
  }

  .companies .company-single .company-logo {
    height: 52px;
    margin-bottom: 16px;
  }

  .companies .company-single p {
    text-align: left;
    font-size: 14px;
    line-height: 1.75;
  }

  .companies .btn-area {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .companies .btn-area .btn-primary {
    width: 100%;
    max-width: none;
    margin-top: 0;
  }

  /* Welcome / two-column content */
  .welcome .container {
    display: block;
  }

  .welcome .container .row .welcome-img,
  .welcome .welcome-img,
  #about .info .row .info-img,
  #about .quality-controll img,
  #about .quality-assurance .image img {
    width: 100%;
    max-width: 100%;
    height: auto;
    margin-bottom: 1.5rem;
  }

  .welcome .container .row > [class*="col-"] {
    margin-bottom: 0.5rem;
  }

  #csfe .welcome.reverse .welcome-img {
    float: none;
  }

  #csfe .welcome {
    padding: 56px 0;
  }

  #csfe .welcome p i {
    font-size: 20px;
    margin-right: 8px;
  }

  /* Desc columns → stacked cards */
  .desc-columns {
    padding-top: 0;
    padding-left: 12px;
    padding-right: 12px;
  }

  .desc-columns .descComments .desc-wrapper {
    flex-direction: column;
    gap: 28px;
  }

  .desc-columns .descComments .desc-wrapper .desc-slide {
    width: 100%;
    padding: 0 8px;
  }

  .desc-columns .descComments .desc-wrapper .desc-slide:before,
  .desc-columns .descComments .desc-wrapper .desc-slide:after {
    display: none;
  }

  .desc-columns .descComments .desc-wrapper .desc-slide i {
    font-size: 56px;
  }

  .desc-columns .descComments .desc-wrapper .desc-slide small {
    letter-spacing: 2px;
    display: block;
    line-height: 1.6;
  }

  .desc-columns .btn-primary {
    margin-top: 36px;
  }

  /* Classroom band */
  .classroom .container-fluid {
    padding: 0 20px;
  }

  .classroom .container-fluid .row .right {
    padding-left: 0;
    padding-top: 28px;
  }

  .classroom .container-fluid .row .right h2,
  .classroom .container-fluid .row .right h3 {
    font-size: 1.45rem;
  }

  .classroom .container-fluid .row .right ul {
    padding-left: 1.2rem;
    margin-bottom: 0;
  }

  .classroom .container-fluid .row .right ul li {
    font-size: 15px;
    line-height: 1.8;
  }

  /* Partners */
  .partners {
    padding-left: 12px;
    padding-right: 12px;
  }

  .partners p {
    width: 100%;
  }

  .partners .swiper {
    height: auto;
    min-height: 64px;
  }

  .partners .swiper .swiper-slide img {
    max-width: 180px;
    height: auto;
  }

  /* Comments (if re-enabled) */
  .comments .swiperComments .swiper-wrapper .swiper-slide {
    padding: 0 12px;
  }

  .comments .swiperComments .swiper-wrapper .swiper-slide:before,
  .comments .swiperComments .swiper-wrapper .swiper-slide:after {
    display: none;
  }

  /* About / Why Sri Lanka shared patterns */
  #about .info.container,
  #about .info {
    padding-left: 16px;
    padding-right: 16px;
  }

  #about .vision-mission .vision,
  #about .vision-mission .mission,
  #about .vision-mission .values {
    padding: 48px 24px;
  }

  #about .vision-mission .vision ul,
  #about .vision-mission .mission ul,
  #about .vision-mission .values ul {
    padding-left: 1.1rem;
  }

  #about .why-choose {
    padding-left: 12px;
    padding-right: 12px;
  }

  #about .why-choose .row dl {
    gap: 48px;
    margin-top: 24px;
  }

  #about .why-choose .row dl .dl-row,
  #about .why-choose .row dl .dl-row:nth-child(even) {
    flex-direction: column;
    align-items: stretch;
  }

  #about .why-choose .row dl .dl-row .dl-img-wrapper,
  #about .why-choose .row dl .dl-row:nth-child(even) .dl-img-wrapper {
    padding-left: 28px;
    padding-right: 0;
    justify-content: flex-start;
    margin-bottom: 16px;
    width: 100%;
  }

  #about .why-choose .row dl .dl-row:nth-child(even) .dl-img-wrapper span {
    left: 0;
    right: auto;
  }

  #about .why-choose .row dl .dl-row .dl-img-wrapper .dl-img,
  #about .why-choose .row dl .dl-row:nth-child(even) .dl-img-wrapper .dl-img {
    width: calc(100% - 40px);
    border-radius: 24px 48px 24px 48px;
  }

  #about .why-choose .row dl .dl-row .dl-img-wrapper span {
    min-width: 56px;
    max-width: 56px;
    min-height: 56px;
    max-height: 56px;
    font-size: 28px;
  }

  #about .why-choose .row dl .dl-row .info,
  #about .why-choose .row dl .dl-row:nth-child(even) .info {
    padding-left: 0;
    width: 100%;
  }

  #about .why-choose .row dl .dl-row dt {
    font-size: 16px;
    line-height: 1.5;
  }

  #about .why-choose .categories h1,
  #about .why-choose .categories h2 {
    margin-bottom: 32px;
    font-size: 1.35rem;
    line-height: 1.45;
  }

  #about .why-choose .categories .grid-img-wrapper {
    gap: 20px 0;
  }

  #about .why-choose .categories .grid-img-wrapper .img-grid {
    width: 50%;
    padding: 0 8px;
  }

  #about .why-choose .categories .grid-img-wrapper .img-grid h5 {
    font-size: 0.95rem;
    margin-top: 8px;
  }

  #about .research .box {
    padding: 28px 20px;
  }

  /* Team */
  .team-members .member-single {
    margin-bottom: 40px;
  }

  .team-members .member-single .left {
    padding: 20px;
    border-radius: 24px;
    margin-bottom: 20px;
  }

  .team-members .member-single .left.small {
    padding: 8px;
    margin-bottom: 12px;
  }

  .team-members .member-single .left .member-img {
    border-radius: 18px;
    margin-bottom: 12px;
  }

  .team-members .member-single .right {
    padding-left: 0;
  }

  .team-members .member-single .right h4 {
    font-size: 1.25rem;
  }

  .team-members .member-single .col-lg-6 {
    margin-bottom: 28px;
  }

  /* Contact */
  #contact .container > .row {
    --bs-gutter-x: 1rem;
  }

  #contact .left {
    padding-right: 0;
    margin-bottom: 36px;
  }

  #contact .left h1,
  #contact .left h2 {
    font-size: 1.45rem;
    line-height: 1.4;
  }

  #contact .left h3,
  #contact .left h4 {
    font-size: 1.05rem;
    line-height: 1.55;
  }

  #contact .left ul.contact-info li {
    font-weight: 500;
    line-height: 1.6;
    word-break: break-word;
  }

  #contact .right .card {
    padding: 24px 18px;
    border-radius: 16px;
  }

  #contact .right .card .card-body form .form-wrapper i {
    top: 46px;
    right: 16px;
  }

  #contact .right .card .card-body form .form-control {
    height: 52px;
    text-indent: 8px;
    font-size: 16px; /* avoid iOS zoom */
  }

  #contact .right .card .card-body form select.form-control {
    padding-right: 2rem;
  }

  #contact .right .card .card-body form textarea.form-control {
    height: 140px;
    padding-top: 14px;
  }

  #contact .right .card .card-body .btn-primary {
    width: 100%;
    max-width: none;
  }

  /* Turnstile host (explicit render chooses compact vs flexible in contact-us.php) */
  #contact .cf-turnstile-host {
    width: 100%;
    max-width: 100%;
    min-height: 65px;
  }

  #contact .cf-turnstile-host iframe {
    max-width: 100%;
  }

  /* Training photo grid already 2-col; keep comfortable gaps */
  #csfe.education-training-page .training-photo-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 1.75rem;
  }

  /* Products page leftovers */
  #products .category-menu {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
  }

  #products .category-menu .category-title {
    margin-right: 0;
  }

  #gallery .gallery a {
    width: calc((100% - 3px) / 2);
  }
}

/* -------------------------------------------------------------------------- */
/* Extra-narrow phones                                                        */
/* -------------------------------------------------------------------------- */
@media (max-width: 374.98px) {
  header nav .navbar-brand img {
    width: 118px;
  }

  .page {
    padding: 140px 14px 44px;
  }

  .page h1 {
    font-size: 1.4rem;
  }

  .companies .company-single {
    padding: 22px 16px;
  }

  #about .why-choose .categories .grid-img-wrapper .img-grid {
    width: 50%;
    padding: 0 4px;
  }

  #contact .right .card {
    padding: 20px 14px;
  }

  .carousel-item,
  .carousel-item img {
    min-height: 180px;
  }
}

/* -------------------------------------------------------------------------- */
/* Tablet polish (768–991): keep content readable without PC redesign         */
/* -------------------------------------------------------------------------- */
@media (min-width: 768px) and (max-width: 991.98px) {
  .carousel {
    padding-top: 110px;
  }

  .carousel-item img {
    max-height: 420px;
    object-fit: cover;
    width: 100%;
  }

  .companies {
    margin-top: -72px;
  }

  .companies .company-single {
    width: 90%;
    padding: 40px;
  }

  .companies .btn-area {
    flex-wrap: wrap;
  }

  .desc-columns .descComments .desc-wrapper {
    flex-wrap: wrap;
    justify-content: center;
  }

  .desc-columns .descComments .desc-wrapper .desc-slide {
    width: 50%;
    padding: 0 24px 32px;
  }

  .desc-columns .descComments .desc-wrapper .desc-slide:nth-child(3) {
    width: 60%;
  }

  .desc-columns .descComments .desc-wrapper .desc-slide:before,
  .desc-columns .descComments .desc-wrapper .desc-slide:after {
    display: none;
  }

  .classroom .container-fluid {
    padding: 0 40px;
  }

  .classroom .container-fluid .row .right {
    padding-left: 32px;
  }

  .classroom .container-fluid .row .right h2,
  .classroom .container-fluid .row .right h3 {
    font-size: 28px;
  }

  #about .vision-mission .vision,
  #about .vision-mission .mission,
  #about .vision-mission .values {
    padding: 56px 40px;
  }

  #about .why-choose .row dl .dl-row {
    flex-wrap: wrap;
  }

  #about .why-choose .categories .grid-img-wrapper .img-grid {
    width: 33.333%;
  }

  #contact .left {
    padding-right: 24px;
    margin-bottom: 32px;
  }

  #contact .right .card {
    padding: 36px;
  }

  .partners p {
    width: 90%;
  }

  .mobile-nav-meta {
    display: none;
  }
}

