/*
 * SBI Media Group - Public Site Overrides
 * Purpose: Improve alignment, typography rhythm, and cross-page consistency
 * Scope: Public-facing pages only (this file is NOT included in admin).
 */

:root {
  --public-content-max: 72ch;
  --public-heading-ls: -0.02em;
  --public-section-y: clamp(3.75rem, 6vw, 5.25rem);
  --public-section-y-lg: clamp(5.25rem, 8vw, 7.5rem);
  --public-text-color: var(--gray-700);
  --public-muted-color: var(--gray-600);
}

html { text-rendering: optimizeLegibility; }

body {
  color: var(--gray-900);
}

/* Typography alignment: keep the homepage hero headline feel everywhere */
h1, h2, h3 {
  letter-spacing: var(--public-heading-ls);
}

p {
  color: var(--public-text-color);
}

/* Homepage primary slider subheadline should be white (overrides global paragraph color) */
#primary-hero-carousel .primary-hero-slide p {
  color: rgba(255, 255, 255, 0.92) !important;
}

/* Homepage primary slider: reduce subheadline size on desktop so it stays on one line more often */
@media (min-width: 1024px) {
  #primary-hero-carousel .primary-hero-slide p {
    font-size: clamp(1.0625rem, 2.125vw, 1.4875rem) !important; /* 15% smaller than 1.25/2.5vw/1.75 */
  }
}

/* Dark background sections: force all text to white for readability */
:is(
  .bg-dark,
  .footer,
  .hero,
  .showcase-hero,
  .press-hero,
  .report-hero,
  section[style*="color: white"],
  section[style*="color:white"],
  div[style*="color: white"],
  div[style*="color:white"],
  section[style*="background: #000"],
  section[style*="background:#000"],
  section[style*="background: rgba(0,0,0"],
  section[style*="background:rgba(0,0,0"],
  div[style*="background: #000"],
  div[style*="background:#000"],
  div[style*="background: rgba(0,0,0"],
  div[style*="background:rgba(0,0,0"]
) {
  color: #fff;
}

:is(
  .bg-dark,
  .footer,
  .hero,
  .showcase-hero,
  .press-hero,
  .report-hero,
  section[style*="color: white"],
  section[style*="color:white"],
  div[style*="color: white"],
  div[style*="color:white"],
  section[style*="background: #000"],
  section[style*="background:#000"],
  section[style*="background: rgba(0,0,0"],
  section[style*="background:rgba(0,0,0"],
  div[style*="background: #000"],
  div[style*="background:#000"],
  div[style*="background: rgba(0,0,0"],
  div[style*="background:rgba(0,0,0"]
) :is(h1, h2, h3, h4, h5, h6) {
  color: #fff !important;
}

:is(
  .bg-dark,
  .footer,
  .hero,
  .showcase-hero,
  .press-hero,
  .report-hero,
  section[style*="color: white"],
  section[style*="color:white"],
  div[style*="color: white"],
  div[style*="color:white"],
  section[style*="background: #000"],
  section[style*="background:#000"],
  section[style*="background: rgba(0,0,0"],
  section[style*="background:rgba(0,0,0"],
  div[style*="background: #000"],
  div[style*="background:#000"],
  div[style*="background: rgba(0,0,0"],
  div[style*="background:rgba(0,0,0"]
) :is(p, li, small, .section-subtitle, .service-description) {
  color: rgba(255, 255, 255, 0.92) !important;
}

/* Only inherit color for normal links, not buttons */
:is(
  .bg-dark,
  .footer,
  .hero,
  .showcase-hero,
  .press-hero,
  .report-hero,
  section[style*="color: white"],
  section[style*="color:white"],
  div[style*="color: white"],
  div[style*="color:white"],
  section[style*="background: #000"],
  section[style*="background:#000"],
  section[style*="background: rgba(0,0,0"],
  section[style*="background:rgba(0,0,0"],
  div[style*="background: #000"],
  div[style*="background:#000"],
  div[style*="background: rgba(0,0,0"],
  div[style*="background:rgba(0,0,0"]
) :is(a:not(.btn), a:not(.btn):visited) {
  color: inherit !important;
}

/* White buttons should never have white text */
.btn-white,
a.btn.btn-white,
button.btn.btn-white {
  color: #111827 !important;
}

/* Homepage hero: CTA links are not always .btn, ensure white buttons read as black */
#primary-hero-carousel a[style*="background: white"],
#primary-hero-carousel a[style*="background:white"],
#primary-hero-carousel a[style*="background: #fff"],
#primary-hero-carousel a[style*="background:#fff"],
#primary-hero-carousel a[style*="background-color: white"],
#primary-hero-carousel a[style*="background-color:white"],
#primary-hero-carousel a[style*="background-color: #fff"],
#primary-hero-carousel a[style*="background-color:#fff"] {
  color: #111827 !important;
}

/* Fix any inline-styled white-on-white buttons */
:is(a.btn, button.btn, input.btn[type="submit"], input.btn[type="button"])[style*="background: white"][style*="color: white"],
:is(a.btn, button.btn, input.btn[type="submit"], input.btn[type="button"])[style*="background:white"][style*="color:white"],
:is(a.btn, button.btn, input.btn[type="submit"], input.btn[type="button"])[style*="background: #fff"][style*="color: #fff"],
:is(a.btn, button.btn, input.btn[type="submit"], input.btn[type="button"])[style*="background:#fff"][style*="color:#fff"],
:is(a.btn, button.btn, input.btn[type="submit"], input.btn[type="button"])[style*="background-color: white"][style*="color: white"],
:is(a.btn, button.btn, input.btn[type="submit"], input.btn[type="button"])[style*="background-color:white"][style*="color:white"],
:is(a.btn, button.btn, input.btn[type="submit"], input.btn[type="button"])[style*="background-color: #fff"][style*="color: #fff"],
:is(a.btn, button.btn, input.btn[type="submit"], input.btn[type="button"])[style*="background-color:#fff"][style*="color:#fff"] {
  color: #111827 !important;
}

/* More consistent section rhythm across pages */
.section { padding: var(--public-section-y) 0 !important; }
.section-lg { padding: var(--public-section-y-lg) 0 !important; }

.section-header {
  max-width: 900px;
  margin-bottom: 2.25rem;
}

.section-title {
  margin-bottom: 0.75rem;
  font-weight: 700;
}

.section-subtitle {
  max-width: var(--public-content-max);
  margin-left: auto;
  margin-right: auto;
}

.service-title {
  letter-spacing: var(--public-heading-ls);
}

.service-description {
  color: var(--public-muted-color);
}

/* Make "kicker" text and subtitles look deliberate */
.section-tag,
.hero-tag {
  letter-spacing: 0.14em;
}

/* Reduce occasional excessive hero spacing between headline and subheadline */
.hero-title,
.hero-subtitle {
  margin-bottom: 0.9rem;
}

/* Generic hero text blocks (many pages use inline styles) */
section[style*="min-height"] .container p,
section[style*="min-height"] .container .section-subtitle {
  max-width: var(--public-content-max);
}

/* Buttons: keep consistent vertical alignment and readable size */
.btn {
  line-height: 1.1;
}

/* Cleaner lists on public pages (some pages use bare <ul>) */
main ul,
main ol,
.section ul,
.section ol {
  list-style: none;
  padding-left: 0;
}

/* Improve readability on small screens */
@media (max-width: 768px) {
  .container { padding-left: 1rem; padding-right: 1rem; }
  .section-header { margin-bottom: 1.75rem; }

  /* Homepage: keep robot face visible on the Digital & AI Transformation slide */
  #primary-hero-carousel .primary-hero-slide-ai .primary-hero-bg-ai {
    background-position: center 18% !important;
  }

  /* Prevent AI slide content from overflowing/cropping on small screens */
  #primary-hero-carousel .primary-hero-slide-ai .primary-hero-content-ai {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    width: 100%;
  }

  #primary-hero-carousel .primary-hero-slide-ai h1 {
    max-width: 22ch;
    overflow-wrap: anywhere;
  }

  #primary-hero-carousel .primary-hero-slide-ai p {
    max-width: 44ch !important;
    margin-left: auto;
    margin-right: auto;
    overflow-wrap: anywhere;
  }
}

/* Contact page: prevent side-by-side squeeze on mobile */
.contact-page-grid {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 4rem;
  align-items: start;
}

.contact-form-card {
  background: #fff;
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
}

@media (max-width: 900px) {
  .contact-page-grid {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }
  .contact-form-card {
    padding: 1.5rem;
  }

  /* Adjust map height on tablets */
  .contact-page-grid iframe[title*="Office Location"] {
    height: 350px;
  }
}

@media (max-width: 520px) {
  .contact-form-card {
    padding: 1.25rem;
  }

  /* Adjust map height on mobile */
  .contact-page-grid iframe[title*="Office Location"] {
    height: 300px;
  }
}

/* Partners ticker */
.partners-section {
  padding: 8rem 12px 6rem 12px;
  background: #fff;
}

.partners-ticker {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  background: #f5f5f7;
  border: 1px solid rgba(0, 0, 0, 0.06);
  padding: 1.25rem 0;
  mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent);
  -webkit-mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent);
}

.partners-track {
  display: flex;
  align-items: center;
  gap: 2.5rem;
  flex-wrap: nowrap;
  width: max-content;
  will-change: transform;
  animation: partners-scroll 70s linear infinite;
}

.partners-ticker--js .partners-track {
  animation: none;
}

.partners-ticker:hover .partners-track {
  animation-play-state: paused;
}

.partner-logo {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.75rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.06);
  text-decoration: none;
  min-height: 56px;
  min-width: 140px;
}

.partner-logo img {
  display: block;
  height: 34px;
  width: auto;
  max-width: 170px;
  object-fit: contain;
  filter: grayscale(1);
  opacity: 0.9;
  transition: filter 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
}

.partner-logo:hover img {
  filter: grayscale(0);
  opacity: 1;
  transform: translateY(-1px);
}

@keyframes partners-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) {
  .partners-track { animation: none; }
  .partners-ticker { overflow-x: auto; }
  .partners-ticker::-webkit-scrollbar { display: none; }
}

/* Homepage hero CTAs: keep side-by-side on small screens (match other slides). */
@media (max-width: 520px) {
  #primary-hero-carousel .primary-hero-ctas {
    flex-wrap: nowrap !important;
    gap: 1rem !important;
  }

  #primary-hero-carousel .primary-hero-ctas a {
    padding: 0.9rem 1.4rem !important;
    font-size: 1.05rem !important;
  }
}
