/*
  Cozy glassmorphic scrollbar system
  - Warm palette
  - Soft radius
  - Subtle transparency
*/

:root {
  --scroll-track: rgba(242, 235, 224, 0.52);
  --scroll-track-border: rgba(212, 165, 165, 0.24);
  --scroll-thumb-top: rgba(222, 184, 160, 0.72);
  --scroll-thumb-bottom: rgba(193, 122, 102, 0.72);
  --scroll-thumb-hover-top: rgba(222, 184, 160, 0.92);
  --scroll-thumb-hover-bottom: rgba(193, 122, 102, 0.92);
  --scroll-thumb-active-top: rgba(212, 165, 165, 0.96);
  --scroll-thumb-active-bottom: rgba(184, 120, 104, 0.96);
  --scroll-heart-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54z'/%3E%3C/svg%3E");
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(193, 122, 102, 0.75) rgba(242, 235, 224, 0.55);
}

/* Chromium + Safari */
::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}

::-webkit-scrollbar-track {
  background: var(--scroll-track);
  border: 1px solid var(--scroll-track-border);
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(253, 249, 244, 0.22);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--scroll-thumb-top) 0%, var(--scroll-thumb-bottom) 100%);
  border: 2px solid rgba(253, 249, 244, 0.5);
  border-radius: 12px;
  background-clip: padding-box;
  box-shadow: 0 4px 10px rgba(193, 122, 102, 0.24);
  transition: background 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--scroll-thumb-hover-top) 0%, var(--scroll-thumb-hover-bottom) 100%);
  box-shadow: 0 6px 14px rgba(193, 122, 102, 0.32);
  transform: scale(1.03);
}

::-webkit-scrollbar-thumb:active {
  background: linear-gradient(180deg, var(--scroll-thumb-active-top) 0%, var(--scroll-thumb-active-bottom) 100%);
  transform: none;
}

::-webkit-scrollbar-corner {
  background: rgba(242, 235, 224, 0.75);
}

/* Utilities */
.thin-scrollbar {
  scrollbar-width: thin;
}

.thin-scrollbar::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.thin-scrollbar::-webkit-scrollbar-thumb {
  border-width: 1px;
}

/*
  Heart indicator shape (WebKit):
  keep thumb hit area intact, but render the visible indicator as a heart mask.
  Fallback is the rounded glass thumb above when mask is unsupported.
*/
@supports ((-webkit-mask-image: url("")) or (mask-image: url(""))) {
  ::-webkit-scrollbar-thumb {
    border: 0;
    border-radius: 0;
    -webkit-mask-image: var(--scroll-heart-mask);
    mask-image: var(--scroll-heart-mask);
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: 95% 18px;
    mask-size: 95% 18px;
  }

  ::-webkit-scrollbar-thumb:hover {
    -webkit-mask-size: 100% 20px;
    mask-size: 100% 20px;
  }

  .thin-scrollbar::-webkit-scrollbar-thumb {
    -webkit-mask-size: 95% 14px;
    mask-size: 95% 14px;
  }
}

.invisible-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.invisible-scrollbar::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* Keep interactions calm for motion-sensitive users */
@media (prefers-reduced-motion: reduce) {
  ::-webkit-scrollbar-thumb {
    transition: none;
  }
}

/* Touch devices: slightly slimmer */
@media (hover: none) {
  ::-webkit-scrollbar {
    width: 9px;
    height: 9px;
  }

  /* Keep mobile rendering simple and stable. */
  ::-webkit-scrollbar-thumb {
    -webkit-mask-image: none;
    mask-image: none;
    border-radius: 999px;
    border: 1px solid rgba(253, 249, 244, 0.5);
  }
}
