/* Tablets (Landscape & Desktop defaults) */
@media (max-width: 1025px) {

  /* --- FIX: PREVENT HORIZONTAL SCROLL --- */
  html, body {
    overflow-x: hidden;
    width: 100%;
    position: relative;
  }
  
  .background-about {
    background: url(../img/other/bg-about-tablet.png) no-repeat center
      center/cover;
    background-color: #fff;
  }

  .background-about {
  --grid-size: 28px;
  --grid-line: rgba(0,0,0,0.06);
  background:
    linear-gradient(0deg, var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size), var(--grid-size) var(--grid-size);
  background-color:#fff;
}

  #contacts a {
    text-decoration: underline;
    color: rgba(1, 64, 105, 0.8);
  }

  /* Navbar */
  #navbar .nav-container {
    padding: 0 50px;
    width: 100%; /* Ensure container fits */
  }
  
  #navbar .nav-logo {
    display: none;
  }

  #navbar .services {
    display: block;
  }

  #navbar {
    width: 100%; /* FIX: Was max-width: 1025px, caused issues on smaller tablets */
    max-width: 100%;
  }

  .show {
    visibility: visible;
    opacity: 1;
    transition: 0.6s;
  }

  .hide {
    visibility: hidden;
    opacity: 0;
    transition: 0.6s;
  }

  #navbar .nav-container ul li:hover ul {
    opacity: 0;
    left: 0px;
    max-height: 0px;
  }

  .burger-menu {
    display: none;
  }

  #navbar .nav-container .service-menu_nav {
    opacity: 0;
    border-radius: 0 0 5px 5px;
    right: 100%;
    overflow-y: auto;
  }

  #navbar .nav-container .service-menu_active .service-menu_nav {
    opacity: 1;
    right: 0px;
    max-height: 700px;
  }

  /* Hide service-menu for displays < 1024px */
  #navbar .service-menu {
    display: inline;
  }

  #navbar .service-menu-desktop {
    display: none;
    max-height: 0px;
  }

  /* Showcase */
  #showcase .logo-showcase {
    margin-top: 90px;
    width: 200px;
  }

  #showcase .logo-iso {
    /* margin-bottom: 90px; */
    width: 150px;
  }

  #showcase h1 {
    font-size: 80px;
  }

  #showcase h3 {
    font-size: 40px;
    width: 500px;
  }

  #showcase .border-bottom {
    width: 500px;
  }

  /* About */
  #leverans-baltic-introduction .introduction {
    width: 100%; /* FIX: Was max-width 1025px */
    max-width: 100%;
    padding: 27px 20px;
    height: auto; /* Allow height to grow if needed */
    min-height: 800px;
  }

  #leverans-baltic-introduction .logo {
    display: none;
  }

  .slide-footer {
    top: -25px;
  }

  .slide-footer .footer-items {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding-left: 100px;
    letter-spacing: 20px;
  }

  #ship-layout {
    display: none;
  }

  /* Gallery */
  #gallery .gallery-img {
    transition: none;
    -webkit-transition: none;
    -moz-transition: none;
    -o-transition: none;
    -ms-transition: none;
  }

  #gallery .gallery-img:hover {
    box-shadow: none;
    -webkit-box-shadow: none;
    -moz-box-shadow: none;
    transform: none;
    -moz-transform: none; /* Для Firefox */
    -ms-transform: none; /* Для IE */
    -webkit-transform: none; /* Для Safari, Chrome, iOS */
    -o-transform: none; /* Для Opera */
    z-index: 0;
    position: relative;
  }

  /* Certificates */
  #certificates {
    height: 100%;
  }

  #certificates h2 {
    text-align: center;
    font-size: 45px;
    font-weight: 300;
    padding: 25px 0 0 0;
  }

  .certificates-container {
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .certificates-container img {
    margin: 10%;
    width: 80%;
  }

  /* Contacts */
  #contacts {
    /* Adjusted Grid: A bit smaller, B smaller, C larger */
    grid-template-columns: 0.4fr 0.8fr 1.8fr;
    
    /* FIX: Add box sizing to prevent grid overflow */
    width: 100%;
    box-sizing: border-box;
    overflow: hidden; /* Cut off any rogue positioning */

    /* Move Section A to the left by reducing padding */
    padding-left: 15px; 
    padding-right: 15px;
  }

  /* --- FONT SIZE ADJUSTMENT (10% Smaller) --- */
  #contacts .section-a p,
  #contacts .section-a a,
  #contacts .section-a div {
      font-size: 25px !important; /* Reduced from 28px */
  }
  
  #contacts .section-b p,
  #contacts .section-b span {
      font-size: 25px !important; /* Reduced from 28px */
      color: red; /* Kept existing color */
  }
  
  #contacts .section-c h3 {
      font-size: 27px !important; /* Reduced from 30px */
  }
  
  #contacts .section-c a,
  #contacts .section-c p {
      font-size: 22px !important; /* Reduced from 25px */
  }
  /* ------------------------------------------- */

  #contacts .section-b i {
    position: relative;
    right: 20px;
  }

  #contacts .section-c {
    position: relative;
    left: 35px;
  }

  #contacts .section-b .technical {
    left: 0px;
    bottom: 20px;
    width: 200px;
    text-align: center;
  }

  #contacts .section-b .navigation-safety {
    left: -24px;
  }

  #contacts .section-b .navigation-safety p {
    display: flex;
  }

  #contacts .section-b .assistant {
    left: -30px;
  }

  #contacts .section-b .accountant {
    left: 0px;
    bottom: 20px;
  }

  /* fonts */
  #contacts .section-b .technical i {
    left: -90px;
    top: 20px;
  }

  #contacts .section-b .navigation-safety i {
    left: -30px;
  }

  #contacts .section-b .assistant i {
    left: 180px;
  }

  #contacts .section-b .accountant i {
    left: -10px;
    top: 0px;
  }

  #contacts .sponsor {
    position: relative;
    left: 70px;
    top: -50px;
    width: 350px;
    text-align: center;
  }

  #contacts .logo-contacts {
    position: relative;
    top: 60px;
  }
}

/* === KEY CHANGE HERE: Changed 770px to 821px to capture iPad Air Portrait (820px) === */
@media (max-width: 821px) {
  .background-contacts {
    background: url(../img/other/tablet-contacts.png) no-repeat center
      center/cover;
    background-color: #fff;
  }

  /* Navbar */
  #navbar {
    width: 100%;
    max-width: 100%; /* FIX: Was 770px */
  }

  /* Showcase */
  #showcase .logo-showcase {
    margin-top: 90px;
    width: 180px;
  }

  #showcase .logo-iso {
    /* margin-bot: 90px; */
    width: 130px;
  }

  #showcase h1 {
    font-size: 60px;
  }

  #showcase h3 {
    font-size: 30px;
    width: 400px;
  }

  #showcase .border-bottom {
    width: 380px;
  }

  /* About */
  #leverans-baltic-introduction {
    padding: 8px 20px;
    height: auto;
    min-height: 990px;
  }

  #leverans-baltic-introduction .introduction {
    width: 100%;
    max-width: 100%; /* FIX: Was 750px */
  }

  #leverans-baltic-introduction .logo {
    display: none;
  }

  .slide-footer {
    display: none;
  }

  #ship-layout {
    display: none;
  }

  .certificates-container {
    display: flex;
    flex-direction: column;
  }

  /* Contacts */
  #contacts {
    grid-template-columns: 1fr;
    padding: 0;
    height: 2300px;
    /* FIX: The padding-left was 170px, which forces width > 100% on small screens */
    padding-left: 20px; 
    padding-right: 20px;
    box-sizing: border-box;
    width: 100%;
  }

  .logo-contacts {
    display: none;
  }

  #contacts .section-a {
    position: relative;
    top: 46px;
    left: auto; /* FIX: Remove fixed left positioning */
    margin: 0 auto; /* Center it */
    width: 100%;
    max-width: 300px;
  }

  #contacts .section-b {
    position: relative;
    width: 100%;
    max-width: 350px;
    right: 0;
    left: 0;
    margin: 0 auto;
  }

  #contacts .section-c {
    position: relative;
    bottom: 700px;
    left: 0;
    width: 100%;
    max-width: 350px;
    margin: 0 auto;
  }

  .section-b i {
    transform: rotate(90deg);
    color: #333;
  }

  #contacts .section-b .technical {
    position: relative;
    top: 145px;
    left: 0; /* Centered via margin/parent */
    color: red;
    text-align: center;
    width: 100%;
    display: flex;
    justify-content: center;
  }

  #contacts .section-b .navigation-safety {
    position: relative;
    top: 350px;
    left: 0;
    color: red;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  #contacts .section-b .navigation-safety p {
    display: flex;
  }

  #contacts .section-b .assistant {
    position: relative;
    top: 535px;
    left: 0;
    color: red;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  #contacts .section-b .accountant {
    position: relative;
    top: 760px;
    left: 0;
    color: red;
    text-align: center;
  }

  #contacts .section-c .name-mail-1,
  #contacts .section-c .name-mail-2,
  #contacts .section-c .name-mail-3,
  #contacts .section-c .name-mail-4 {
    margin-top: 250px;
    position: relative;
    left: 0;
    text-align: center;
  }

  #contacts .sponsor {
    position: relative;
    top: 940px;
    left: 0;
    text-align: center;
    width: 100%;
    margin: 0 auto;
  }

  /* Reset odd positioning for icons that might push width */
  #contacts .section-b .technical i,
  #contacts .section-b .navigation-safety i,
  #contacts .section-b .assistant i,
  #contacts .section-b .accountant i {
    left: auto;
    right: auto;
    position: relative;
    margin: 10px auto;
  }
  
  /* === ВИПРАВЛЕННЯ КОНТАКТІВ ДЛЯ ПЛАНШЕТА (Now includes iPad Portrait 820px) === */
#contacts {
  display: flex !important;
  flex-direction: column !important; /* Ставить A, B, C у стовпчик */
  grid-template-columns: 1fr !important; /* Вимикає grid */
  height: auto !important;
  padding: 40px 20px !important; /* Даємо трохи повітря, але менше ніж було */
}

#contacts .section-a,
#contacts .section-b,
#contacts .section-c {
  position: static !important;
  width: 100% !important;
  bottom: auto !important;
  left: auto !important;
  right: auto !important;
  margin-bottom: 40px !important;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Скидаємо всі дивні позиції всередині .section-b */
#contacts .section-b .technical,
#contacts .section-b .navigation-safety,
#contacts .section-b .assistant,
#contacts .section-b .accountant,
#contacts .sponsor {
  position: static !important;
  left: auto !important; top: auto !important;
  width: 100% !important;
  text-align: center !important;
  margin-top: 20px;
}

#contacts .section-b i {
  transform: none !important;
  position: static !important;
  margin-left: 10px !important; margin-top: 0 !important;
}

#contacts .section-c div {
    text-align: center !important;
}
}

@media (max-width: 541px) {
  /* Navbar */
  #navbar {
    max-width: 100%; /* FIX */
  }

  #navbar .nav-container {
    width: 100%;
    max-width: 100%; /* FIX */
    padding: 0;
    font-size: 15px;
    display: flex;
    flex-direction: column-reverse;
    justify-content: space-around;
  }

  #navbar .services ul li {
    padding: 3px 0; /* FIX: large padding caused overflow */
    width: 100%;
    text-align: center;
  }

  #navbar .nav-info ul li a {
    padding: 5px 10px;
  }

  /* dropdown-menu */
  #navbar .services ul li ul {
    flex-direction: column;
    position: absolute;
    right: 0; /* FIX */
    left: 0; /* FIX */
    top: 0px;
    text-align: center;
    height: 100vh;
    width: 100%;
  }

  #navbar .services ul li ul li {
    padding: 11px 0;
  }

  #navbar .services ul li ul div:last-child {
    position: relative;
    right: 0; /* FIX */
  }

  /* Showcase */
  #showcase h3 {
    margin: 0 5px;
  }

  #showcase .logo-showcase {
    margin-top: 90px;
    width: 120px;
  }

  #showcase .logo-isp {
    /* margin-bot: 90px; */
    width: 120px;
  }
  #showcase h1 {
    font-size: 40px;
  }

  #showcase h3 {
    font-size: 20px;
    width: 250px;
  }

  #showcase .border-bottom {
    width: 250px;
  }

  /* About */
  #leverans-baltic-introduction {
    padding: 5px 20px;
    height: auto;
    min-height: 1470px;
  }

  #leverans-baltic-introduction .introduction {
    width: 100%;
    max-width: 521px;
  }

  .certificates-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }

  /* Contacts */
  #contacts {
    grid-template-columns: 1fr;
    padding: 0;
    height: auto;
    padding-left: 15px;
    padding-right: 15px;
  }
}