﻿/*
 * Aviva Spirit mobile fixes
 * Load after /css/style.css and /assets/aviva-articles.css.
 */

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

body {
  margin: 0;
  background: #faf8f3;
  color: #2c2823;
  font-family: 'Prompt', 'Noto Sans Thai', system-ui, sans-serif;
}

a {
  text-decoration: none;
}

ul,
ol {
  margin: 0;
  padding: 0;
}

img {
  display: block;
  height: auto;
}
img,
video,
iframe {
  max-width: 100%;
}

.site-header {
  z-index: 1000;
  overflow: visible;
}

.site-header > .logo,
.site-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  position: relative;
  z-index: 1002;
}

.site-header > .logo img,
.site-logo img {
  width: auto !important;
  max-width: min(190px, 48vw) !important;
  object-fit: contain;
}

.nav-toggle {
  position: relative;
  z-index: 1002;
  min-width: 44px;
  min-height: 44px;
  touch-action: manipulation;
}

body.nav-open {
  overflow: hidden;
  touch-action: none;
}

@media (max-width: 967px) {
  .site-header,
  .header-inner {
    height: 60px;
  }

  .site-header > .logo,
  .site-logo {
    height: 60px;
    margin-left: 1rem;
  }

  .header-inner .site-logo {
    margin-left: 0;
  }

  .site-header > .nav-toggle {
    position: absolute;
    top: 8px;
    right: max(12px, env(safe-area-inset-right, 0px));
  }

  .site-logo img,
  .site-header > .logo img {
    max-height: 46px !important;
  }

  .site-nav {
    position: fixed !important;
    inset: 0 0 0 auto;
    width: min(100vw, 420px);
    height: 100vh;
    height: 100svh;
    max-height: 100svh;
    padding: calc(72px + env(safe-area-inset-top, 0px)) 16px
      max(24px, env(safe-area-inset-bottom, 0px));
    background: #faf8f3;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    transform: translate3d(0, -8px, 0);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.22s cubic-bezier(0.32, 0.72, 0, 1),
      opacity 0.18s ease, visibility 0s linear 0.22s;
    z-index: 1001;
    box-shadow: -24px 0 60px rgba(26, 23, 20, 0.16);
  }

  .site-nav.open {
    transform: translate3d(0, 0, 0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: transform 0.22s cubic-bezier(0.32, 0.72, 0, 1),
      opacity 0.18s ease, visibility 0s;
  }

  .site-nav > li,
  .site-nav > a {
    width: 100%;
    text-align: left;
  }

  .site-nav a,
  .site-nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 46px;
    width: 100%;
    padding: 0.82rem 1rem;
    color: #2c2823;
    font-size: 1rem;
    line-height: 1.45;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
    text-decoration: none;
    border-bottom: 1px solid rgba(44, 40, 35, 0.07);
  }

  .site-nav a.active,
  .site-nav a[aria-current="page"],
  .site-nav-link[aria-current="page"] {
    color: #a48111;
  }

  .site-nav .nav-cta,
  .nav-cta {
    justify-content: center;
    margin: 1rem 0 0;
    min-height: 48px;
    border-bottom: 0;
    color: #fff !important;
    text-align: center;
  }

  .has-dropdown > .site-nav-link .caret {
    flex: 0 0 auto;
    margin-left: 0.5rem;
    transition: transform 0.2s ease;
  }

  .has-dropdown.open > .site-nav-link .caret {
    transform: rotate(180deg);
  }

  .dropdown {
    display: block !important;
    max-height: 0;
    width: 100%;
    padding: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    background: #f5f1e8;
    transition: max-height 0.24s ease, opacity 0.18s ease, padding 0.18s ease;
  }

  .has-dropdown:hover .dropdown {
    max-height: 0;
    padding: 0;
    opacity: 0;
    pointer-events: none;
  }

  .has-dropdown.open > .dropdown {
    max-height: 70vh;
    padding: 0.35rem 0;
    opacity: 1;
    pointer-events: auto;
  }

  .dropdown a {
    min-height: 44px;
    padding: 0.72rem 1.25rem 0.72rem 1.75rem;
    font-size: 0.94rem;
    line-height: 1.45;
    color: #6b6358;
    border-bottom: 0;
  }

  .hero {
    min-height: min(680px, 78svh);
    align-items: flex-end;
  }

  .hero-bg {
    background-position: center top;
    transform: none !important;
  }

  .hero-overlay {
    background:
      linear-gradient(180deg, rgba(26, 23, 20, 0.12) 0%, rgba(26, 23, 20, 0.78) 72%),
      linear-gradient(90deg, rgba(26, 23, 20, 0.2), rgba(26, 23, 20, 0.08));
  }

  .hero-content {
    width: 100%;
    max-width: 34rem;
    padding: 8rem 1.2rem 2.5rem;
  }

  .hero-content h1,
  .page-banner h1,
  .article-hero h1,
  .blog-index h1 {
    letter-spacing: 0;
    overflow-wrap: anywhere;
    text-wrap: balance;
  }

  .hero-subtitle,
  .article-content,
  .article-body,
  .blog-card-excerpt,
  .blog-index-card small {
    overflow-wrap: anywhere;
  }

  .hero-buttons,
  .cta-buttons,
  .cta-actions {
    width: 100%;
  }

  .hero-buttons .btn,
  .cta-buttons .btn,
  .cta-actions .btn {
    width: 100%;
    max-width: 320px;
    white-space: normal;
    line-height: 1.35;
    min-height: 48px;
  }

  .blog-index {
    width: min(100% - 1.25rem, 1180px);
    padding-top: 2rem;
  }

  .blog-index-grid {
    gap: 1rem;
  }

  .blog-index-card {
    grid-template-rows: minmax(170px, 48vw) auto auto;
  }

  .blog-index-card span {
    font-size: 1rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
  }

  .article-shell {
    width: min(100% - 1.25rem, 1180px);
  }

  .article-body,
  .article-content,
  .page-content,
  .product-description {
    font-size: 0.98rem;
    line-height: 1.85;
  }

  .article-body p,
  .article-content p,
  .page-content p,
  .product-description p {
    line-height: 1.85;
  }
}

@media (max-width: 560px) {
  .hero {
    min-height: min(620px, 82svh);
  }

  .hero-bg {
    background-position: center 16%;
  }

  .hero-content {
    padding: 7rem 1rem 2rem;
  }

  .hero-content h1 {
    font-size: clamp(1.45rem, 8vw, 1.8rem);
  }

  .product-cat-row,
  .product-grid,
  .feature-grid,
  .trust-features,
  .stats-row {
    grid-template-columns: 1fr;
  }

  .product-cat-card {
    aspect-ratio: 16 / 11;
  }

  .article-hero {
    min-height: auto;
  }

  .article-hero .hero-content {
    padding-top: 6rem;
  }

  .article-body {
    padding: 1.15rem;
  }
}

@media (min-width: 968px) {
  .site-header > .logo {
    margin-left: max(1rem, calc((100vw - 1200px) / 2));
  }

  .site-header > .site-nav {
    margin-right: max(1rem, calc((100vw - 1200px) / 2));
  }

  .site-header > .site-nav > a {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.7rem;
    color: #2c2823;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
  }

  .site-header > .site-nav > a.active,
  .site-header > .site-nav > a[aria-current="page"] {
    color: #a48111;
  }

  .site-header > .site-nav > .nav-cta {
    margin-left: 0.25rem;
    padding: 0.55rem 1.2rem;
    color: #fff !important;
  }
}


/* Legacy article/category header desktop rescue */
@media (min-width: 968px) {
  .site-header > .logo {
    position: absolute;
    top: 50%;
    left: max(1rem, calc((100vw - 1200px) / 2));
    height: 68px;
    margin: 0 !important;
    transform: translateY(-50%);
  }

  .site-header > .logo img {
    max-width: 200px !important;
    max-height: 48px !important;
  }

  .site-header > .nav-toggle {
    display: none !important;
  }

  .site-header > .site-nav {
    position: absolute !important;
    top: 0;
    right: max(1rem, calc((100vw - 1200px) / 2));
    left: auto;
    width: auto !important;
    max-width: calc(100vw - 260px);
    height: 68px !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 0;
    overflow: visible !important;
    list-style: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: none !important;
  }

  .site-header > .site-nav,
  .site-header > .site-nav ul {
    list-style: none !important;
  }

  .site-header > .site-nav > li {
    display: block;
    width: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
    text-align: left;
  }

  .site-header > .site-nav > li::marker {
    content: "";
  }

  .site-header > .site-nav > a,
  .site-header > .site-nav > li > a,
  .site-header > .site-nav .site-nav-link {
    display: inline-flex !important;
    align-items: center;
    width: auto !important;
    min-height: 0;
    padding: 0.5rem 0.7rem !important;
    border: 0 !important;
    color: #2c2823;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
    text-align: left;
    text-decoration: none;
    white-space: nowrap;
  }

  .site-header > .site-nav > a.active,
  .site-header > .site-nav > a[aria-current="page"],
  .site-header > .site-nav > li > a[aria-current="page"] {
    color: #a48111;
  }

  .site-header > .site-nav > .nav-cta,
  .site-header > .site-nav > li > .nav-cta {
    margin: 0 0 0 0.25rem !important;
    padding: 0.55rem 1.2rem !important;
    color: #fff !important;
  }

  .site-header > .site-nav .has-dropdown {
    position: relative;
  }

  .site-header > .site-nav .dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 260px;
    max-height: none;
    padding: 0.5rem 0;
    background: #fff;
    border: 1px solid rgba(44, 40, 35, 0.07);
    border-radius: 8px;
    box-shadow: 0 12px 40px rgba(44, 40, 35, 0.08), 0 4px 12px rgba(44, 40, 35, 0.04);
    display: none !important;
    opacity: 1;
    pointer-events: auto;
    text-align: left;
    z-index: 1003;
  }

  .site-header > .site-nav .has-dropdown:hover > .dropdown,
  .site-header > .site-nav .has-dropdown.open > .dropdown {
    display: block !important;
  }

  .site-header > .site-nav .dropdown a {
    display: block !important;
    width: 100% !important;
    padding: 0.55rem 1.5rem !important;
    color: #6b6358;
    font-size: 0.88rem;
    line-height: 1.4;
    white-space: normal;
  }
}

/* Full header fallback: keeps the nav usable even if the main stylesheet is late or missing */
.site-nav,
.site-nav ul {
  margin: 0;
  padding: 0;
  list-style: none !important;
}

.site-nav > li {
  list-style: none !important;
}

.site-nav > li::marker {
  content: "";
}

@media (min-width: 968px) {
  .site-header {
    position: sticky;
    top: 0;
    height: 68px;
    background: rgba(250, 248, 243, 0.97);
    border-bottom: 1px solid rgba(44, 40, 35, 0.07);
  }

  .site-header .header-inner {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    height: 68px !important;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
  }

  .site-header .header-inner .site-logo {
    display: flex;
    align-items: center;
    height: 68px;
    margin: 0 !important;
    flex: 0 0 auto;
  }

  .site-header .header-inner .site-logo img {
    width: auto !important;
    max-width: 200px !important;
    max-height: 48px !important;
    object-fit: contain;
  }

  .site-header .header-inner .nav-toggle {
    display: none !important;
  }

  .site-header .header-inner .site-nav {
    position: static !important;
    width: auto !important;
    height: auto !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 0 !important;
    overflow: visible !important;
    list-style: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: none !important;
    transition: none !important;
  }

  .site-header .header-inner .site-nav > li {
    display: block !important;
    width: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
    text-align: left;
  }

  .site-header .header-inner .site-nav > li::marker {
    content: "";
  }

  .site-header .header-inner .site-nav a,
  .site-header .header-inner .site-nav .site-nav-link {
    display: block !important;
    width: auto !important;
    min-height: 0 !important;
    padding: 0.5rem 0.7rem !important;
    border: 0 !important;
    color: #2c2823;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
    text-align: left;
    text-decoration: none;
    white-space: nowrap;
  }

  .site-header .header-inner .site-nav a:hover,
  .site-header .header-inner .site-nav a.active,
  .site-header .header-inner .site-nav a[aria-current="page"] {
    color: #a48111;
  }

  .site-header .header-inner .site-nav .nav-cta {
    display: inline-block !important;
    margin: 0 0 0 0.25rem !important;
    padding: 0.55rem 1.2rem !important;
    background: #a48111;
    border-radius: 9999px;
    color: #fff !important;
    font-weight: 600;
  }

  .site-header .header-inner .site-nav .has-dropdown {
    position: relative;
  }

  .site-header .header-inner .site-nav .dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 260px;
    max-height: none !important;
    padding: 0.5rem 0 !important;
    background: #fff;
    border: 1px solid rgba(44, 40, 35, 0.07);
    border-radius: 8px;
    box-shadow: 0 12px 40px rgba(44, 40, 35, 0.08), 0 4px 12px rgba(44, 40, 35, 0.04);
    display: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    text-align: left;
    z-index: 1003;
  }

  .site-header .header-inner .site-nav .has-dropdown:hover > .dropdown,
  .site-header .header-inner .site-nav .has-dropdown.open > .dropdown {
    display: block !important;
  }

  .site-header .header-inner .site-nav .dropdown a {
    display: block !important;
    width: 100% !important;
    padding: 0.55rem 1.5rem !important;
    color: #6b6358;
    font-size: 0.88rem;
    line-height: 1.4;
    white-space: normal;
  }
}

@media (max-width: 967px) {
  .site-header .header-inner {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    height: 60px !important;
    padding: 0 1rem;
  }
}

/* Homepage mobile overflow fixes */
@media (max-width: 768px) {
  main,
  .section,
  .section-lg,
  .container,
  .container-wide {
    max-width: 100%;
    overflow-x: clip;
  }

  .press-logos {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.75rem !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    overflow: hidden !important;
  }

  .press-logo-card {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 86px;
    padding: 0.75rem !important;
    overflow: hidden !important;
  }

  .press-logo-card img {
    width: auto !important;
    max-width: 100% !important;
    max-height: 68px !important;
    height: auto !important;
    object-fit: contain;
  }

  .gallery-carousel {
    width: 100% !important;
    max-width: 100vw !important;
    overflow: hidden !important;
    padding-left: 1rem !important;
    padding-right: 0 !important;
  }

  .gallery-track {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding-right: 1rem !important;
  }

  .gallery-card {
    width: min(82vw, 320px) !important;
  }
}

/* Homepage product/service mobile card fixes */
@media (max-width: 768px) {
  .product-cat-row {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.85rem !important;
    width: 100% !important;
    max-width: 100% !important;
    aspect-ratio: auto !important;
    align-items: stretch !important;
    overflow: visible !important;
  }

  .product-cat-card {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    aspect-ratio: 4 / 5 !important;
    min-height: 0 !important;
    overflow: hidden !important;
    border-radius: 10px !important;
  }

  .product-cat-card img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
  }

  .product-cat-label {
    padding: 1.6rem 0.75rem 0.75rem !important;
    min-height: auto !important;
    max-height: 62% !important;
    overflow: hidden !important;
  }

  .product-cat-tag,
  .product-cat-desc {
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-break: normal !important;
    text-overflow: clip !important;
  }

  .product-cat-tag {
    font-size: clamp(0.9rem, 4.2vw, 1.05rem) !important;
    line-height: 1.25 !important;
    margin-bottom: 0.15rem !important;
  }

  .product-cat-desc {
    display: -webkit-box !important;
    overflow: hidden !important;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    font-size: clamp(0.72rem, 3.4vw, 0.85rem) !important;
    line-height: 1.35 !important;
  }

  .trust-panels {
    display: grid !important;
    grid-template-columns: 1fr !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden !important;
  }

  .trust-panels .trust-panel,
  .trust-panel {
    min-height: 260px !important;
    width: 100% !important;
    max-width: 100% !important;
    align-items: flex-end !important;
    overflow: hidden !important;
  }

  .trust-panel-content {
    width: 100% !important;
    max-width: 100% !important;
    padding: 4.5rem 1rem 1rem !important;
    background: linear-gradient(
      to top,
      rgba(26, 23, 20, 0.86),
      rgba(26, 23, 20, 0.48) 62%,
      transparent
    ) !important;
    overflow: hidden !important;
  }

  .trust-panel-content h4,
  .trust-panel-content p {
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-break: normal !important;
    text-overflow: clip !important;
  }

  .trust-panel-content h4 {
    font-size: clamp(1rem, 4.8vw, 1.18rem) !important;
    line-height: 1.28 !important;
    margin-bottom: 0.35rem !important;
  }

  .trust-panel-content p {
    margin: 0 !important;
    font-size: clamp(0.82rem, 3.7vw, 0.95rem) !important;
    line-height: 1.5 !important;
  }
}

@media (max-width: 400px) {
  .product-cat-row {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
    aspect-ratio: auto !important;
  }

  .product-cat-card {
    aspect-ratio: 16 / 11 !important;
  }

  .product-cat-label {
    padding: 1.75rem 1rem 0.85rem !important;
  }

  .trust-panels .trust-panel,
  .trust-panel {
    min-height: 245px !important;
  }
}
