/* Home page styles */

.home-page {
  --map-ink: var(--theme-text);
  --map-ink-soft: var(--theme-text-muted);
  --map-gold: var(--theme-accent);
  --map-gold-glow: var(--theme-glow);
  --map-gold-soft: var(--theme-accent-soft);
  --map-burgundy: #1f1f1f;
  --map-surface: var(--theme-surface);
  --map-surface-strong: var(--theme-surface-strong);
  --map-border: var(--theme-border);
  /* Map-specific tokens (fallbacks if not set on :root[data-theme]) */
  --map-base: rgba(255, 255, 255, 0.02);
  --map-emphasis-border: var(--map-ink);
  --map-emphasis-area: rgba(255,255,255,0.12);
  --map-label: var(--map-ink);
  --hero-region-height: 200vh;
  --hero-region-bottom: 0vh;
  --hero-sticky-top: 40vh;
  position: relative;
  isolation: isolate;
  overflow-x: visible;
  max-width: 100%;
  font-family: "Inter", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(180deg, rgba(8, 8, 8, 0.92), rgba(18, 18, 18, 0.82));

  /* ADD THESE 3 LINES FROM ABOUT.CSS */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.home-page::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.14), transparent 24%),
    radial-gradient(circle at 82% 14%, rgba(255, 255, 255, 0.1), transparent 20%),
    radial-gradient(circle at 68% 84%, rgba(255, 255, 255, 0.08), transparent 26%);
  opacity: 1;
  z-index: 0;
}

.home-page .navbar {
  z-index: 60;
}

.home-page .container,
.home-page .site-footer {
  overflow-x: clip;
  z-index: 1;
}

/* Scroll animations */
.scroll-element {
  animation: element-appear cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-timeline: view();
  animation-range: cover 20% cover 50%;
}

.scroll-slide-left {
  animation: slide-left cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-timeline: view();
  animation-range: cover 20% cover 50%;
}

.scroll-slide-right {
  animation: slide-right cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-timeline: view();
  animation-range: cover 20% cover 50%;
}

@keyframes element-appear {
  from {
    opacity: 0;
    transform: translateY(50px);
    filter: blur(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@keyframes hero-shrink {
  from {
    scale: 1;
  }

  to {
    scale: 0.3;
  }
}

@keyframes slide-left {
  from {
    opacity: 0;
    transform: translateX(-50px);
    filter: blur(4px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
    filter: blur(0);
  }
}

@keyframes slide-right {
  from {
    opacity: 0;
    transform: translateX(50px);
    filter: blur(4px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
    filter: blur(0);
  }
}

@keyframes hero-unmask {
  from {
    opacity: 0;
    transform: translateY(60px);
    clip-path: inset(100% 0 0 0);
  }

  to {
    opacity: 1;
    transform: translateY(0);
    clip-path: inset(0 0 0 0);
  }
}

@media (prefers-reduced-motion: reduce) {

  .scroll-element,
  .scroll-slide-left,
  .scroll-slide-right {
    animation: none;
    opacity: 1;
    transform: none;
    filter: none;
  }

  .home-page .container-hero {
    animation: none;
  }

  .home-page .stats {
    opacity: 1;
    transform: none;
    transition: none;
    pointer-events: auto;
  }
}

/* Hero */
.home-page .hero-region {
  position: relative;
  display: block;
  width: 100%;
  min-height: var(--hero-region-height);
  /* Change from height to min-height */
  padding-bottom: var(--hero-region-bottom);
  flex: 1 0 auto;
  /* Let it adapt inside the flex container safely */
}

.home-page .hero {
  position: -webkit-sticky;
  position: sticky;
  top: 40vh;
  align-self: flex-start;
  /* CRITICAL FIX: Forces sticky to work inside a flexbox on iOS */
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.home-page .container-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: clamp(500px, 100vmin, 100vw);
  container-type: inline-size;
  transform-origin: center 30%;
  animation:
    hero-unmask 1.2s cubic-bezier(0.16, 1, 0.3, 1) both,
    hero-shrink linear both;
  animation-timeline: auto, scroll();
  /* Start shrinking as soon as user scrolls, finish at 50vh */
  animation-range: auto, 0px 50vh;
}

.home-page .hero p {
  margin: 15px 0;
  font-family: "Bebas Neue", sans-serif;
  font-size: clamp(18px, 8cqw, 70px);
  letter-spacing: 2px;
}

.home-page .hero img {
  width: 100%;
  max-width: 100%;
  z-index: 1;
}

@media (max-width: 768px) {
  .home-page .hero {
    padding-top: 0;
    align-items: center;
  }
}

@media (min-width: 768px) and (max-width: 999px) {
  .home-page {
    --hero-region-height: 200vh;
    --hero-region-bottom: 0vh;
  }

  .home-page .hero {
    align-items: center;
  }
}

.home-page .search-bar {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 10px 24px rgba(0, 0, 0, 0.22),
    0 0 16px rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
}

.home-page .search-input {
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--theme-text);
  font-size: 1em;
}

.home-page .search-input::placeholder {
  color: var(--theme-text-muted);
}

.home-page .search-btn {
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.08));
  color: var(--theme-text);
  box-shadow: none;
}

.motto {
  font-family: "Bebas Neue";
}

/* Stats */
.home-page .stats {
  position: relative;
  z-index: 2;
}

.stats .container-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 80px;
  padding: 0 10%;
  margin: 0;
}

.stats .container-stats .available-lawyers-stats,
.stats .container-stats .available-firms-stats {
  width: 400px;
  padding: 20px 40px;
  border: 1px solid rgba(255, 255, 255, 0.212);
  border-radius: 30px;
  background: rgba(32, 32, 32, 0.418);
  backdrop-filter: blur(18px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  text-align: center;
}

.container-stats h1 {
  margin-bottom: 10px;
  font-family: "Bebas Neue";
  font-size: 40px;
  letter-spacing: 3px;
}

.container-stats span {
  font-family: "Bebas Neue";
  font-size: 90px;
}

@media (max-width: 767px) {
  .stats .container-stats {
    position: relative;
    padding: 0 10%;
    margin: 0;
    gap: 40px;
  }

  .stats .container-stats .available-lawyers-stats,
  .stats .container-stats .available-firms-stats {
    width: 280px;
    padding: 15px 30px;
  }
}

@media (min-width: 767px) and (max-width: 999px) {
  .stats .container-stats {
    padding: 0 8%;
    margin: 0;
    gap: 60px;
  }

  .stats .container-stats .available-lawyers-stats,
  .stats .container-stats .available-firms-stats {
    width: 340px;
    padding: 18px 35px;
  }
}

@media (min-width: 1000px) {
  .stats .container-stats {
    padding: 0 5%;
    margin: 0;
  }
}

/* Carousel */
.carousel {
  margin-top: 20vh;
}

.carousel h1 {
  color: #ffffff;
  font-family: "Bebas Neue", sans-serif;
  font-size: 40px;
  letter-spacing: 3px;
  text-align: center;
}

.carousel .card-container {
  display: flex;
  justify-content: center;
  margin-top: 1.7%;
}

.card-container .card-wrapper {
  position: relative;
  width: min(1100px, 100%);
  padding: 0 clamp(48px, 6vw, 72px);
  perspective: 1400px;
}

.card-list {
  position: relative;
  height: clamp(320px, 40vw, 380px);
  margin: 0;
  padding: 0;
  transform-style: preserve-3d;
}

.carousel-control {
  position: absolute;
  top: 50%;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(10, 10, 10, 0.5);
  color: #ffffff;
  cursor: pointer;
  transform: translateY(-50%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.carousel-control--prev {
  left: 0;
}

.carousel-control--next {
  right: 0;
}

.carousel-control__icon {
  font-size: 28px;
  line-height: 1;
}

.carousel-control--prev .carousel-control__icon {
  transform: rotate(180deg);
}

.carousel-control:hover {
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
  transform: translateY(-50%) scale(1.03);
}

.carousel-control:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: 3px;
}

.card-list .card-item {
  position: absolute;
  top: 50%;
  left: 50%;
  list-style: none;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-50%) translateZ(-220px) scale(0.82);
  transition: transform 0.8s ease, opacity 0.8s ease, filter 0.8s ease;
  will-change: transform, opacity;
}

.card-list .card-item.is-center {
  z-index: 3;
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(-50%) translateZ(0) scale(1);
  filter: none;
}

.card-list .card-item.is-left,
.card-list .card-item.is-right {
  z-index: 2;
  opacity: 0.7;
  pointer-events: auto;
  transform: translateX(calc(-50% - 230px)) translateY(-50%) translateZ(-140px) scale(0.9);
  filter: blur(0.2px);
}

.card-list .card-item.is-right {
  transform: translateX(calc(-50% + 230px)) translateY(-50%) translateZ(-140px) scale(0.9);
}

.card-list .card-item.is-far-left,
.card-list .card-item.is-far-right,
.card-list .card-item.is-hidden {
  z-index: 1;
  opacity: 0;
  pointer-events: none;
  transform: translateX(calc(-50% - 420px)) translateY(-50%) translateZ(-260px) scale(0.78);
}

.card-list .card-item.is-far-right {
  transform: translateX(calc(-50% + 420px)) translateY(-50%) translateZ(-260px) scale(0.78);
}

.card-item .div-carousel-loc,
.card-item .div-carousel-cat {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
}

.card-item .div-carousel-loc .lawyer-loc,
.card-item .div-carousel-cat .lawyer-cat {
  width: fit-content;
  padding: 5px 11px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50px;
  color: #ffffff;
  text-align: center;
  font-size: 15px;
  backdrop-filter: blur(18px) saturate(110%);
}

.card-item .div-carousel-loc .lawyer-loc {
  margin: 4px 8px 15px;
  background-color: rgba(141, 141, 141, 0.476);
}

.card-item .div-carousel-cat .lawyer-cat {
  margin: 4px;
  background-color: rgba(255, 255, 255, 0.08);
}

.card-link .card-content .lawyer-card__rating {
  display: flex;
  justify-content: center;
  margin-top: 13px;
}

.card-link .card-content .lawyer-card__rating .rating-value {
  color: #ffee00;
  font-family: "Bebas Neue";
  font-size: 25px;
  letter-spacing: 2px;
  text-shadow: 0 0 3px #ffee00;
}

.card-link .card-content .lawyer-card__rating .stars {
  margin-left: 5px;
  color: #ffee00;
  font-size: 21px;
  text-shadow: 0 0 3px #ffee00;
}

@media (max-width: 900px) {

  .carousel {
    margin-top: 15vh;
  }

  .card-list .card-item.is-left,
  .card-list .card-item.is-right {
    transform: translateX(calc(-50% - 170px)) translateY(-50%) translateZ(-120px) scale(0.88);
  }

  .card-list .card-item.is-right {
    transform: translateX(calc(-50% + 170px)) translateY(-50%) translateZ(-120px) scale(0.88);
  }
}

@media (max-width: 640px) {
  .card-list {
    height: clamp(280px, 60vw, 330px);
  }

  .carousel {
    margin-top: 15vh;
  }

  .carousel-control {
    width: 42px;
    height: 42px;
  }

  .carousel h1 {
    margin-bottom: 50px;
  }

  .card-list .card-item.is-left,
  .card-list .card-item.is-right {
    opacity: 0.5;
    transform: translateX(calc(-50% - 140px)) translateY(-50%) translateZ(-110px) scale(0.84);
  }

  .card-list .card-item.is-right {
    transform: translateX(calc(-50% + 140px)) translateY(-50%) translateZ(-110px) scale(0.84);
  }
}

@media (prefers-reduced-motion: reduce) {
  .card-list .card-item {
    transition-duration: 0.01ms;
  }
}

.card-list .card-item .card-link {
  display: block;
  width: clamp(300px, 70vw, 360px);
  height: auto;
  padding: 18px;
  border: 0 solid rgba(10, 10, 10, 0.166);
  border-radius: 30px;
  background: linear-gradient(180deg, rgb(66, 66, 66), rgb(15, 15, 15));
  box-shadow: 0 8px 32px 0 rgb(0, 0, 0);
  text-decoration: none;
  opacity: 100%;
  backdrop-filter: blur(50px) saturate(110%);
  -webkit-backdrop-filter: blur(18px) saturate(110%);
  transition: 0.3s ease;
}

.card-list .card-item .card-link:hover {
  border-color: rgba(255, 255, 255, 0.614);
  border-width: 1px;
  border-style: solid;
  transform: translateY(-7px);
  box-shadow: 0 8px 15px 0 rgb(0, 0, 0);
}

.card-list .card-item .card-link:hover .lawyer-name {
  text-shadow: 0 0 5px rgba(255, 255, 255, 0.742);
}

.card-list .card-item .card-link:hover .card-image {
  border: 2px solid rgba(255, 255, 255, 0.742);
}

.card-item .card-link .card-image {
  display: block;
  width: 120px;
  height: 120px;
  margin: 15px auto;
  border: 2px solid rgba(255, 255, 255, 0.407);
  border-radius: 50%;
  object-fit: cover;
}

.card-item .card-link .lawyer-name {
  color: rgb(255, 255, 255);
  text-align: center;
}

.card-item .card-link .card-button {
  width: 45px;
  height: 45px;
  margin: 30px 0 5px;
  border: 1px solid rgb(255, 255, 255);
  border-radius: 50%;
  background: none;
  color: rgb(255, 255, 255);
  cursor: pointer;
  transition: 0.5s ease;
}

.card-item .card-link:hover .card-button {
  background: rgb(255, 255, 255);
  color: rgb(0, 0, 0);
  transform: rotate(-45deg);
}

/* Map */
.home-map-section {
  width: 90%;
  margin: 8rem auto;
  padding: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.212);
  border-radius: 30px;
  background: linear-gradient(145deg, rgba(30, 30, 30, 0.5), rgba(15, 15, 15, 0.8));
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.home-map-section h2 {
  margin-top: 15px;
  margin-bottom: 1.5rem;
  color: #ffffff;
  font-family: "Bebas Neue", sans-serif;
  font-size: 40px;
  letter-spacing: 2px;
  text-align: center;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

#malaysia-map {
  width: 100% !important;
  height: 500px;
  min-height: 300px;
}

.mobile-map-hint {
  display: none;
}

@keyframes pulse-hint {

  0%,
  100% {
    opacity: 0.5;
  }

  50% {
    opacity: 1;
  }
}

@media (max-width: 768px) {
  .home-map-section {
    width: 95%;
    margin: 128px auto 0;
    padding: 1rem;
    border-radius: 20px;
  }

  .home-map-section h2 {
    margin-bottom: 0.5rem;
    font-size: 2rem;
  }

  #malaysia-map {
    height: 450px;
  }

  .mobile-map-hint {
    display: block;
    margin-top: 10px;
    margin-bottom: 20px;
    color: #94a3b8;
    font-family: sans-serif;
    font-size: 16px;
    letter-spacing: 0.5px;
    text-align: center;
    animation: pulse-hint 2.5s infinite;
  }
}

/* Map toggle */
.map-toggle-container {
  position: relative;
  z-index: 10;
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
}

.map-toggle-btn {
  padding: 8px 24px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
  cursor: pointer;
  font-family: "Inter", sans-serif;
  font-size: 18px;
  font-weight: 500;
  transition: all 0.3s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.map-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}

.map-toggle-btn.active {
  border-color: #ffffff;
  background: rgba(255, 255, 255, 0.11);
  color: #ffffff;
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.603);
}

/* Mobile performance overrides */
@media (max-width: 768px) {
  .home-page::before {
    position: absolute;
  }

  .scroll-element,
  .scroll-slide-left,
  .scroll-slide-right {
    animation-timeline: view();
    animation-range: cover 20% cover 50%;
  }

  .scroll-element {
    animation-name: element-appear-lite;
  }

  .scroll-slide-left {
    animation-name: slide-left-lite;
  }

  .scroll-slide-right {
    animation-name: slide-right-lite;
  }

  .home-page .container-hero {
    width: 100vw;
    max-width: 100vw;
    /* prevent any overflow */
    animation:
      hero-unmask-lite 0.9s cubic-bezier(0.16, 1, 0.3, 1) both,
      hero-shrink linear both;
    animation-timeline: auto, scroll();
    animation-range: auto, 0px 50vh;
  }

  @keyframes element-appear-lite {
    from {
      opacity: 0;
      transform: translateY(36px);
    }

    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  @keyframes slide-left-lite {
    from {
      opacity: 0;
      transform: translateX(-36px);
    }

    to {
      opacity: 1;
      transform: translateX(0);
    }
  }

  @keyframes slide-right-lite {
    from {
      opacity: 0;
      transform: translateX(36px);
    }

    to {
      opacity: 1;
      transform: translateX(0);
    }
  }

  @keyframes hero-unmask-lite {
    from {
      opacity: 0;
      transform: translateY(40px);
    }

    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .home-page .search-bar,
  .stats .container-stats .available-lawyers-stats,
  .stats .container-stats .available-firms-stats,
  .carousel-control,
  .card-item .div-carousel-loc .lawyer-loc,
  .card-item .div-carousel-cat .lawyer-cat,
  .card-list .card-item .card-link,
  .home-map-section,
  .map-toggle-btn {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .card-container .card-wrapper {
    perspective: none;
  }

  .card-list {
    transform-style: flat;
  }

  .card-list .card-item {
    transform: translateX(-50%) translateY(-50%) scale(0.9);
    filter: none;
    transition: transform 0.5s ease, opacity 0.5s ease;
  }

  .card-list .card-item.is-center {
    transform: translateX(-50%) translateY(-50%) scale(1);
  }

  .card-list .card-item.is-left,
  .card-list .card-item.is-right {
    transform: translateX(calc(-50% - 150px)) translateY(-50%) scale(0.92);
  }

  .card-list .card-item.is-right {
    transform: translateX(calc(-50% + 150px)) translateY(-50%) scale(0.92);
  }

  .card-list .card-item.is-far-left,
  .card-list .card-item.is-far-right,
  .card-list .card-item.is-hidden {
    transform: translateX(calc(-50% - 260px)) translateY(-50%) scale(0.82);
  }

  .card-list .card-item.is-far-right {
    transform: translateX(calc(-50% + 260px)) translateY(-50%) scale(0.82);
  }
}

/* ─── Light Mode Overrides ──────────────────────────────────────────────── */
[data-theme="light"] .home-map-section {
  border-color: rgba(0, 0, 0, 0.10);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.247), rgba(248, 244, 238, 0.70));
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

[data-theme="light"] .home-map-section h2 {
  color: var(--theme-text);
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .map-toggle-btn {
  border-color: rgba(0, 0, 0, 0.14);
  background: rgba(0, 0, 0, 0.04);
  color: var(--theme-text);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

[data-theme="light"] .map-toggle-btn:hover {
  background: rgba(0, 0, 0, 0.08);
  color: var(--theme-text);
}

[data-theme="light"] .map-toggle-btn.active {
  border-color: var(--theme-text);
  background: rgba(0, 0, 0, 0.10);
  color: var(--theme-text);
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .mobile-map-hint {
  color: var(--theme-text-muted);
}

/* Theme-specific map variables on the root element so JS can read them */
:root[data-theme="light"] {
  --map-border: #2b2b2b;
  --map-gold: #d4af37;
  --map-gold-glow: rgba(212,175,55,0.12);
  --map-base: rgba(0, 0, 0, 0.04);
  --map-emphasis-border: #1a1410;
  --map-emphasis-area: rgba(212,175,55,0.22);
  --map-label: #1a1410;
}

:root[data-theme="dark"] {
  /* Use a neutral, low-contrast border in dark mode (no gold outline) */
  --map-border: rgba(255, 255, 255, 0.06);
  --map-gold: rgba(212, 175, 55, 0.92);
  --map-gold-glow: rgba(212,175,55,0.06);
  --map-base: rgba(255, 255, 255, 0.02);
  --map-emphasis-border: #ffffff;
  --map-emphasis-area: rgba(255,255,255,0.12);
  --map-label: #ffffff;
}