/*==================================================
Heartwell Home Care — Website styles
Style: Warm Minimalism + Bento Grid
Palette: deep teal-navy (trust) + warm neutrals + mulberry-rose (care)
Type: Fraunces (display) + Public Sans (text)
==================================================*/

:root {
  --hw-ink: #12333F;
  --hw-harbor: #1B4A5A;
  --hw-harbor-700: #123845;
  --hw-oat: #F4EEE9;
  --hw-blush: #EFE1DC;
  --hw-mist: #CDE1E0;
  --hw-rose: #9E4459;
  --hw-rose-700: #853A4B;
  --hw-rose-ink: #8E4257;
  --hw-line: #E6DED5;

  /* Motion — strong custom curves (built-in easings feel weak) */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scrollbar-color: var(--hw-harbor) var(--hw-oat);
}

body {
  margin: 0;
  color: var(--hw-ink);
  background: #fff;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
}

/* Fraunces reads best with optical sizing on */
.font-display {
  font-optical-sizing: auto;
  font-weight: 400;
}

/* Body copy: comfortable measure + rhythm */
p {
  line-height: 1.65;
}

::-webkit-scrollbar {
  width: 10px;
}
::-webkit-scrollbar-track {
  background: var(--hw-oat);
}
::-webkit-scrollbar-thumb {
  background: var(--hw-harbor);
  border-radius: 99px;
  border: 2px solid var(--hw-oat);
}

/* ---------- Focus visibility ---------- */
:focus-visible {
  outline: 3px solid var(--hw-rose);
  outline-offset: 2px;
  border-radius: 4px;
}
.on-dark :focus-visible,
.bg-hw-harbor :focus-visible {
  outline-color: #fff;
}

/* ---------- Buttons ---------- */
.btn-primary,
.btn-on-dark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.75rem 1.5rem;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 0.975rem;
  line-height: 1;
  text-decoration: none;
  transition: background-color 0.18s ease, color 0.18s ease,
    transform 0.16s var(--ease-out), box-shadow 0.18s ease;
}

.btn-primary {
  background: var(--hw-rose);
  color: #fff;
  box-shadow: 0 10px 24px -12px rgba(158, 68, 89, 0.6);
}

.btn-on-dark {
  background: #fff;
  color: var(--hw-harbor);
}

@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover {
    background: var(--hw-rose-700);
    transform: translateY(-1px);
  }
  .btn-on-dark:hover {
    background: var(--hw-oat);
    transform: translateY(-1px);
  }
}

/* Press feedback — the interface confirms it heard the tap */
.btn-primary:active,
.btn-on-dark:active {
  transform: scale(0.97);
}

.btn-quiet {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 600;
  font-size: 0.975rem;
  color: var(--hw-harbor);
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: rgba(27, 74, 90, 0.35);
  transition: text-decoration-color 0.18s ease;
}
.btn-quiet:hover {
  text-decoration-color: var(--hw-harbor);
}

/* Text link with rose underline */
.link-rose {
  font-weight: 600;
  color: var(--hw-rose-ink);
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: rgba(158, 68, 89, 0.4);
  transition: text-decoration-color 0.18s ease;
}
.link-rose:hover {
  text-decoration-color: var(--hw-rose);
}

/* ---------- Eyebrow (rule + sentence-case label) ---------- */
.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--hw-harbor);
}
.eyebrow::before {
  content: "";
  width: 2rem;
  height: 1px;
  background: var(--hw-rose);
  flex: none;
}
.on-dark .eyebrow {
  color: var(--hw-mist);
}

/* ---------- Reveal on scroll / load ---------- */
.reveal {
  opacity: 1;
}
.js .reveal {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.5s var(--ease-out), transform 0.5s var(--ease-out);
  transition-delay: calc(var(--i, 0) * 55ms);
}
.js .reveal.is-in {
  opacity: 1;
  transform: none;
}

/* ---------- Service / linked tiles ---------- */
.tile-link {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  transition: box-shadow 0.2s ease, transform 0.2s var(--ease-out);
}
.tile-link .tile-media {
  overflow: hidden;
}
.tile-link .tile-media img {
  transition: transform 0.45s var(--ease-out);
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* Hover lift only where a real pointer exists — avoids sticky hover on touch */
@media (hover: hover) and (pointer: fine) {
  .tile-link:hover {
    transform: translateY(-2px);
  }
  .tile-link:hover .tile-media img {
    transform: scale(1.03);
  }
}
.tile-link:active {
  transform: scale(0.99);
}

/* ---------- Header ---------- */
/* The mount point must not form a box, or `position: sticky` on the
   header inside it has no range to travel and un-sticks immediately. */
#site-header {
  display: contents;
}

#mainHeader {
  transition: box-shadow 0.3s ease, background-color 0.3s ease;
}
#mainHeader.is-scrolled {
  box-shadow: 0 8px 30px -18px rgba(18, 51, 63, 0.35);
}

#navToggle:active {
  transform: scale(0.94);
}

/* ---------- Nav menus: origin-aware entrance ---------- */
/* Desktop dropdowns scale in from the trigger, not from centre. */
@keyframes hw-menu-in {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
[id$="MenuPanel"]:not(.hidden) {
  transform-origin: top left;
  animation: hw-menu-in 0.16s var(--ease-out);
}

/* Mobile nav + submenus ease down instead of snapping in. */
@keyframes hw-nav-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
#mobileNav:not(.hidden),
[id$="MobilePanel"]:not(.hidden) {
  animation: hw-nav-in 0.2s var(--ease-out);
}

/* ---------- Legacy form + job-description styles (used by inner pages) ---------- */
.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--hw-ink);
}
.form-input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--hw-line);
  padding: 10px 14px;
  background: #fff;
  color: var(--hw-ink);
  font-size: 15px;
}
.form-input:focus {
  outline: none;
  border-color: var(--hw-rose);
  box-shadow: 0 0 0 3px rgba(158, 32, 71, 0.2);
}

.job-description-content h2,
.job-description-content h3,
.job-description-content h4 {
  font-family: Fraunces, Georgia, serif;
  color: var(--hw-ink);
  font-size: 1.4rem;
  font-weight: 500;
  margin: 1.75rem 0 0.75rem;
}
.job-description-content p {
  margin-bottom: 1rem;
}
.job-description-content ul,
.job-description-content ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
  list-style-type: disc;
}
.job-description-content li {
  margin-bottom: 0.5rem;
}
.job-description-content strong {
  font-weight: 700;
}
.job-description-content a {
  color: var(--hw-rose-ink);
  text-decoration: underline;
}

/*==================================================
  MOTION LAYER
  Stat count-up, scroll-driven process stepper, scroll
  progress, back-to-top. Everything transform/opacity,
  reduced-motion-gated.
==================================================*/

/* ---------- Top scroll-progress indicator ---------- */
#scroll-progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--hw-rose);
  transform: scaleX(0);
  transform-origin: 0 50%;
  z-index: 60;
  pointer-events: none;
  will-change: transform;
}

/* ---------- Stat tiles + count-up ---------- */
.js .stat-tile {
  opacity: 0;
  transform: translateY(10px);
}
.js .stat-tile.is-in {
  opacity: 1;
  transform: none;
  transition: opacity 0.5s var(--ease-out), transform 0.5s var(--ease-out);
  transition-delay: calc(var(--i, 0) * 70ms);
}
[data-count] {
  font-variant-numeric: tabular-nums;
}

/* ---------- Process: scroll-driven stepper ---------- */
.process-step {
  transition: opacity 0.35s var(--ease-in-out);
}
@media (min-width: 768px) {
  .js .process-step[data-active="false"] {
    opacity: 0.3;
  }
}
[data-step-num] {
  display: inline-block;
  transition: opacity 0.25s var(--ease-out), transform 0.25s var(--ease-out);
}
.process-rail-fill {
  transition: height 0.12s linear;
}

/* ---------- Draw-on heart ---------- */
.js .heart-draw path {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}
.js .heart-draw.is-in path {
  animation: hw-draw 1s var(--ease-out) forwards;
}
.js .heart-draw.is-in path:nth-child(2) {
  animation-delay: 0.5s;
}
@keyframes hw-draw {
  to {
    stroke-dashoffset: 0;
  }
}

/* ---------- Back to top ---------- */
#to-top {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 55;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  width: 44px;
  border-radius: 9999px;
  background: var(--hw-harbor);
  color: #fff;
  box-shadow: 0 10px 26px -12px rgba(18, 51, 63, 0.5);
  opacity: 0;
  transform: translateY(0.75rem) scale(0.9);
  pointer-events: none;
  transition: opacity 0.2s var(--ease-out), transform 0.2s var(--ease-out),
    background-color 0.18s ease;
}
#to-top.is-visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
@media (hover: hover) and (pointer: fine) {
  #to-top:hover {
    background: var(--hw-harbor-700);
    transform: translateY(-2px);
  }
}
#to-top:active {
  transform: scale(0.94);
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .js .reveal,
  .js .stat-tile {
    opacity: 1 !important;
    transform: none !important;
  }
  .js .heart-draw path {
    stroke-dashoffset: 0 !important;
  }
  #scroll-progress {
    display: none;
  }
  .btn-primary:hover,
  .btn-on-dark:hover,
  .tile-link:hover {
    transform: none;
  }
}
