/* =========================================================
   RESPONSIVE-PERFECT — FINAL MOBILE/TABLET SAFETY LAYER
   Goal: no horizontal overflow at any viewport width.
   Loaded last so it safely overrides earlier visual rules.
   ========================================================= */

html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

body {
  min-width: 0;
}

*, *::before, *::after {
  min-width: 0;
}

.container,
section,
main,
header,
footer,
.navbar,
.hero-shell,
.hero-copy,
.hero-media-v2,
.about-grid,
.about-media,
.services-grid,
.visa-grid,
.country-wrap,
.quote-grid,
.coaching-band,
.section-head,
.footer-top,
.detail-layout,
.service-page-grid,
.visa-cards,
.country-grid,
.coaching-grid,
.stat-grid {
  min-width: 0;
  max-width: 100%;
}

img, video, iframe, svg, canvas {
  max-width: 100%;
}

h1, h2, h3, h4, p, a, button, label, span, li {
  overflow-wrap: anywhere;
}

.btn,
.text-link,
.nav-contact,
.filter-btn {
  max-width: 100%;
}

/* Fixed floating navigation must always fit inside the viewport. */
.site-header {
  width: min(1160px, calc(100% - 32px));
  max-width: calc(100% - 32px);
}

.navbar {
  width: 100%;
  max-width: 100%;
}

/* Prevent desktop navigation from forcing the pill wider than the screen. */
.nav {
  min-width: 0;
  max-width: 100%;
}

/* =========================================================
   TABLET: 768–991px
   ========================================================= */
@media (max-width: 991px) {
  :root {
    --gutter: 24px;
  }

  .site-header {
    width: calc(100% - 28px);
    max-width: calc(100% - 28px);
  }

  .navbar {
    padding-inline: 12px;
  }

  .home-page .hero-v2 {
    margin-inline: 8px;
  }

  .home-page .hero-shell {
    width: min(100%, calc(100% - 2px));
  }

  .hero-media-v2 {
    width: calc(100% - 20px);
    margin-inline: 10px;
    min-height: 500px;
    height: 500px;
  }

  .hero-people-badge {
    left: 14px;
    max-width: calc(100% - 28px);
  }

  .tag-portugal { left: 8px; }
  .tag-canada { right: 8px; }

  .services-grid,
  .service-page-grid,
  .visa-cards,
  .country-grid,
  .coaching-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  .detail-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .detail-side {
    width: 100%;
  }

  .newsletter {
    min-width: 0;
    max-width: 100%;
  }
}

/* =========================================================
   MOBILE: 767px and below
   ========================================================= */
@media (max-width: 767px) {
  :root {
    --gutter: 16px;
    --radius-xl: 24px;
    --radius-lg: 20px;
    --radius-md: 15px;
  }

  .container {
    width: calc(100% - (var(--gutter) * 2));
    max-width: none;
  }

  .site-header {
    top: 8px;
    width: calc(100% - 20px);
    max-width: calc(100% - 20px);
  }

  .navbar {
    min-height: 50px;
    padding: 6px 7px 6px 12px;
    border-radius: 14px;
  }

  .logo {
    flex: 0 1 auto;
    min-width: 0;
  }

  .logo > span:last-child {
    white-space: nowrap;
  }

  .mobile-toggle {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
  }

  .mobile-menu {
    width: 100%;
    max-width: 100%;
    max-height: calc(100vh - 76px);
    overflow-y: auto;
    overflow-x: hidden;
  }

  .home-page .hero-v2 {
    margin-inline: 4px;
    padding-top: 76px;
    border-radius: 0 0 20px 20px;
  }

  .home-page .hero-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    width: 100%;
  }

  .home-page .hero-copy {
    padding: 30px 12px 4px;
  }

  .home-page .hero-copy h1 {
    font-size: clamp(40px, 12.5vw, 60px);
    line-height: .98;
    max-width: 100%;
  }

  .home-page .hero-copy p,
  .section-head p,
  .inner-hero p {
    max-width: 100%;
  }

  .hero-actions {
    width: 100%;
    align-items: stretch;
    gap: 12px;
  }

  .hero-actions .btn {
    width: 100%;
    max-width: 100%;
  }

  .rating-chip {
    width: auto;
    max-width: 100%;
    flex: 0 1 auto;
  }

  .hero-media-v2 {
    width: calc(100% - 24px);
    height: clamp(300px, 88vw, 390px);
    min-height: 0;
    margin-inline: 12px;
    border-radius: 18px;
  }

  .hero-media-v2 > img {
    width: 100%;
    height: 100%;
    max-width: none;
  }

  .hero-country-tag {
    max-width: calc(100% - 16px);
    white-space: normal;
    overflow-wrap: normal;
  }

  .tag-germany {
    top: -8px;
    right: 8px;
  }

  .tag-portugal {
    left: 8px;
    top: 42%;
  }

  .tag-canada {
    right: 8px;
    top: 42%;
  }

  .hero-people-badge {
    left: 8px;
    right: 8px;
    bottom: 10px;
    width: auto;
    max-width: calc(100% - 16px);
    flex-wrap: wrap;
  }

  .hero-people-badge span {
    max-width: 170px;
  }

  .home-page .section,
  .section {
    padding: 70px 0;
  }

  .section-head {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    margin-bottom: 38px;
  }

  .about-grid,
  .about-media,
  .visa-grid,
  .country-wrap,
  .quote-grid,
  .coaching-band,
  .detail-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .about-grid,
  .country-wrap,
  .visa-grid,
  .quote-grid,
  .coaching-band {
    gap: 34px;
  }

  .about-media {
    gap: 12px;
  }

  .about-media .image-frame:first-child,
  .about-media .image-frame:last-child {
    height: 300px;
    margin-bottom: 0;
  }

  .home-page .about-grid::before {
    width: 90vw;
    max-width: 520px;
    height: 180px;
    left: 5%;
    top: 8%;
  }

  .services-grid,
  .service-page-grid,
  .visa-cards,
  .country-grid,
  .coaching-grid,
  .blog-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .service-card,
  .service-page-card,
  .visa-card,
  .country-card,
  .coaching-card,
  .blog-card {
    width: 100%;
    min-width: 0;
  }

  .service-card {
    min-height: 330px;
  }

  .service-card h3,
  .service-page-card h3,
  .visa-card h3 {
    overflow-wrap: anywhere;
  }

  .visa-section {
    margin-inline: 0;
    border-radius: 22px;
  }

  .visa-section > .container {
    width: calc(100% - 32px);
  }

  .visa-map {
    min-height: 280px;
    height: 280px;
  }

  .visa-map img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .visa-stat {
    font-size: clamp(48px, 15vw, 64px);
  }

  .country-image {
    height: clamp(280px, 78vw, 360px);
  }

  .country-list {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .country-item {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .quote-card {
    padding: 28px 22px;
  }

  .quote-card blockquote {
    font-size: clamp(24px, 7vw, 34px);
  }

  .cta {
    width: 100%;
    padding: 40px 22px;
    border-radius: 22px;
  }

  .cta h2 {
    max-width: 100%;
  }

  .site-footer {
    margin-top: 62px;
    padding-top: 58px;
  }

  .footer-top {
    grid-template-columns: minmax(0, 1fr);
    gap: 30px;
  }

  .footer-col {
    min-width: 0;
  }

  .footer-col a,
  .footer-col p {
    overflow-wrap: anywhere;
  }

  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .newsletter {
    width: 100%;
    flex-direction: column;
    gap: 8px;
  }

  .newsletter input,
  .newsletter button {
    width: 100%;
    min-width: 0;
  }

  .inner-hero {
    padding-top: 38px;
  }

  .inner-hero h1 {
    max-width: 100%;
  }

  .inner-hero-art {
    width: 100%;
    height: clamp(210px, 62vw, 270px);
    margin-top: 30px;
    border-radius: 20px;
  }

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

  .stat-item {
    min-width: 0;
    padding: 20px 12px;
  }

  .stat-number {
    font-size: clamp(38px, 12vw, 52px);
  }

  .stat-label,
  .stat-copy {
    overflow-wrap: anywhere;
  }

  .service-page-card .image-frame,
  .country-card .image-frame {
    height: 220px;
  }

  .detail-layout {
    gap: 30px;
  }

  .detail-layout .image-frame {
    height: clamp(280px, 82vw, 470px) !important;
  }

  .detail-side {
    width: 100%;
    padding: 24px;
    border-radius: 20px;
  }

  .filter-btn {
    flex: 0 1 auto;
    max-width: 100%;
  }

  input,
  textarea,
  select {
    max-width: 100%;
  }
}

/* =========================================================
   SMALL PHONES: 480px and below
   ========================================================= */
@media (max-width: 480px) {
  :root {
    --gutter: 14px;
  }

  .site-header {
    width: calc(100% - 14px);
    max-width: calc(100% - 14px);
  }

  .navbar {
    padding-left: 10px;
  }

  .logo {
    font-size: 16px;
  }

  .logo-mark {
    width: 15px;
    height: 15px;
  }

  .mobile-toggle {
    flex-basis: 38px;
    width: 38px;
    height: 38px;
  }

  .home-page .hero-v2 {
    margin-inline: 2px;
  }

  .home-page .hero-copy {
    padding-inline: 10px;
  }

  .hero-actions {
    flex-direction: column;
  }

  .rating-chip {
    align-self: flex-start;
  }

  .hero-media-v2 {
    width: calc(100% - 18px);
    margin-inline: 9px;
    height: 310px;
  }

  .hero-country-tag {
    font-size: 9px;
    padding: 5px 7px;
  }

  .hero-people-badge {
    font-size: 9px;
  }

  .mini-avatars img {
    width: 21px;
    height: 21px;
  }

  h1 {
    font-size: clamp(39px, 13vw, 55px);
  }

  h2 {
    font-size: clamp(33px, 10.5vw, 48px);
  }

  .btn {
    min-height: 48px;
    padding-inline: 17px;
  }

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

  .stat-item,
  .stat-item:nth-child(-n+2) {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .stat-item:last-child {
    border-bottom: 0;
  }

  .country-list {
    grid-template-columns: minmax(0, 1fr);
  }

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

/* Ultra-small safety floor. */
@media (max-width: 340px) {
  .site-header {
    width: calc(100% - 10px);
    max-width: calc(100% - 10px);
  }

  .navbar {
    padding-left: 8px;
    padding-right: 5px;
  }

  .logo {
    font-size: 15px;
  }

  .mobile-toggle {
    flex-basis: 36px;
    width: 36px;
    height: 36px;
  }

  .hero-media-v2 {
    width: calc(100% - 14px);
    margin-inline: 7px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .site-header.is-scrolled .navbar,
  .btn:hover,
  .image-frame:hover img {
    transform: none !important;
  }
}
