/* services page: own rules from home-sample/services-sample-3 */
/* =================== Services page (sample 3) =================== */
  :root { --hdr: 110px; }
  html { scroll-padding-top: calc(var(--hdr) + 24px); }

  /* ---------- First screen: the headline and all eight services, with no scrolling ----------
     The opening fills exactly one screen below the header (svh = the phone's screen with its toolbars
     showing). The services grid takes whatever height is left and shares it between its rows. If a
     screen is too short for everything, the script below drops extras in this order until it fits:
     the intro paragraph (fit-1), smaller descriptions (fit-2), no descriptions (fit-3), then tighter
     spacing (fit-4). */
  .hero--s3 .wrap {
    display: flex; flex-direction: column; gap: clamp(18px, 3.6vh, 44px);
    /* --fold-top = where the page content starts (blue info line + header), set by the script below */
    min-height: calc(100vh - var(--fold-top, 150px)); min-height: calc(100svh - var(--fold-top, 150px));
    padding-top: clamp(16px, 3.4vh, 44px); padding-bottom: clamp(16px, 3.4vh, 40px);
  }
  /* headline on the left, the intro paragraph on the right, sharing the headline's last baseline.
     No buttons here: the sticky header's Book an Appointment button is always on screen. */
  /* just the headline, centered */
  .fold-head { text-align: center; }
  .hero--s3 h1 { font-size: clamp(2.3rem, min(4.6vw, 7.4vh), 4.4rem); max-width: none; text-wrap: balance; }

  .fold-grid {
    flex: 1 1 auto; list-style: none; margin: 0; padding: 0;
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: 1fr;
    border-top: 1px solid var(--deep); position: relative; z-index: 1;
  }
  .fold-grid li { display: flex; min-height: 0; background: var(--cream); border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); }
  .fold-grid li:nth-child(4n+1) { border-left: 0; }
  /* each service: icon beside its name, the approved description underneath */
  .cell {
    position: relative; flex: 1; display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto 1fr;
    align-content: start; column-gap: 14px; row-gap: clamp(8px, 1.4vh, 14px);
    padding: clamp(12px, 2.6vh, 28px) clamp(14px, 1.5vw, 22px); text-decoration: none; color: var(--warm);
    transition: background-color .3s ease;
  }
  .cell .top { display: flex; align-self: center; }
  .cell .ic { width: clamp(32px, 5vh, 44px); height: auto; aspect-ratio: 1; flex: none; }
  .cell .n { display: none; }
  .cell .nm { align-self: center; }
  .cell .d { grid-column: 1 / -1; padding-bottom: 18px; }
  .cell .nm {
    font-family: var(--display); font-variation-settings: "SOFT" 100, "opsz" 72; font-weight: 650; letter-spacing: -0.01em;
    font-size: clamp(1.12rem, min(1.7vw, 2.9vh), 1.5rem); line-height: 1.15; color: var(--deep);
  }
  .cell .nm span { background: linear-gradient(var(--swell), var(--swell)) no-repeat 0 88% / 0% 30%; transition: background-size .5s var(--ease-out); }
  .cell .d { font-size: .94rem; line-height: 1.5; }
  .cell .go { position: absolute; right: clamp(14px, 1.7vw, 26px); bottom: clamp(12px, 2.4vh, 26px); width: 18px; height: 18px; color: var(--current); opacity: .35; translate: -6px 0; transition: opacity .3s ease, translate .4s var(--ease-out); }
  .cell:hover, .cell:focus-visible { background: var(--white); }
  .cell:hover .nm span, .cell:focus-visible .nm span { background-size: 100% 30%; }
  .cell:hover .go, .cell:focus-visible .go { opacity: 1; translate: 0 0; }
  .cell:focus-visible { outline: 3px solid var(--swell); outline-offset: -3px; }

  /* desktop: icon on its own line with the arrow opposite, then the name, then the description,
     so every name in a row starts on the same line */
  @media (min-width: 1000.02px) {
    .cell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto 1fr; row-gap: clamp(6px, 1.2vh, 12px); padding: clamp(16px, 3vh, 32px) clamp(16px, 1.7vw, 26px); }
    .cell .top { align-self: start; margin-bottom: clamp(2px, .8vh, 10px); }
    .cell .ic { width: clamp(30px, 4.4vh, 40px); }
    .cell .nm { align-self: start; font-size: clamp(1.08rem, min(1.42vw, 2.7vh), 1.36rem); text-wrap: balance; }
    .cell .d { grid-column: 1; padding-bottom: 0; max-width: 34ch; }
    .cell .go { top: clamp(18px, 3.2vh, 36px); bottom: auto; right: clamp(16px, 1.7vw, 26px); }
    .fit-2 .cell { row-gap: 5px; }
    .fit-2 .cell .top { margin-bottom: 0; }
    .fit-3 .cell { grid-template-rows: auto auto; }
  }

  .fit-1 .hero-lede { display: none; }
  .fit-2 .cell { padding-top: 10px; padding-bottom: 10px; row-gap: 6px; }
  .fit-2 .cell .d { font-size: .86rem; line-height: 1.4; padding-bottom: 0; }
  .fit-2 .cell .go { display: none; }
  .fit-3 .cell .d { display: none; }
  .fit-3 .cell { grid-template-rows: auto; align-content: center; }
  .fit-4 .wrap { gap: 10px; padding-top: 12px; padding-bottom: 12px; }
  .fit-4 .cell { padding-top: 6px; padding-bottom: 6px; }

  /* the services arrive one after another and their icons draw in */
  .motion .fold-grid li { opacity: 0; transform: translateY(14px); transition: opacity .7s var(--ease-out), transform .8s var(--ease-out); transition-delay: calc(.55s + var(--i, 0) * .07s); }
  .hero-in .fold-grid li { opacity: 1; transform: none; }
  .motion .fold-grid .ic path, .motion .fold-grid .ic circle { stroke-dasharray: 1; stroke-dashoffset: 1; }
  .motion .fold-grid .ic [fill="#F8CC48"] { fill-opacity: 0; }
  .hero-in .fold-grid .ic path, .hero-in .fold-grid .ic circle { animation: s3-draw 1.1s var(--ease-out) forwards; animation-delay: calc(.8s + var(--i, 0) * .08s); }
  .hero-in .fold-grid .ic [fill="#F8CC48"] { animation: s3-draw 1.1s var(--ease-out) forwards, s3-fill .5s ease forwards; animation-delay: calc(.8s + var(--i, 0) * .08s), calc(1.4s + var(--i, 0) * .08s); }

  /* Hallway photo, opening the "closer look" section */
  .s3-photo { margin: 0 0 clamp(40px, 6vw, 72px); position: relative; }
  .s3-photo .frame { border-radius: 28px; overflow: hidden; background: var(--glide-soft); }
  .s3-photo img { width: 100%; height: auto; aspect-ratio: 21 / 8; object-fit: cover; object-position: 50% 62%; }
  .s3-photo figcaption { display: flex; align-items: center; gap: 12px; margin-top: 14px; font-size: .95rem; line-height: 1.4; }
  .s3-photo figcaption .doors { display: inline-flex; gap: 5px; flex: none; }
  .s3-photo figcaption .doors i { width: 9px; height: 14px; border-radius: 5px 5px 2px 2px; }
  .s3-photo figcaption .doors i:nth-child(1) { background: var(--pulse); }
  .s3-photo figcaption .doors i:nth-child(2) { background: var(--swell); }
  .s3-photo figcaption .doors i:nth-child(3) { background: var(--ripple); }
  .motion .s3-photo img { transform: scale(1.1); transition: transform 2.2s var(--ease-out); }
  .motion .s3-photo.in img { transform: none; }

  /* ---------- The services: pinned panel + scrolling list ---------- */
  .s3 { position: relative; padding: 24px 0 120px; }
  .s3-head { display: flex; justify-content: space-between; align-items: end; gap: 24px 48px; flex-wrap: wrap; padding-bottom: 28px; border-bottom: 2px solid var(--deep); }
  .s3-head h2 { font-size: clamp(2.2rem, 3.6vw, 3.1rem); }
  .s3-head p { margin: 0; max-width: 42ch; font-size: 1.08rem; }

  .s3-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 0 96px; align-items: start; }

  .rail { position: sticky; top: calc(var(--hdr) + 40px); padding-top: 48px; }
  .rail-stage { position: relative; width: 210px; aspect-ratio: 1; }
  .rail-ring { position: absolute; inset: 0; width: 100%; height: 100%; rotate: -90deg; overflow: visible; }
  .rail-ring circle { fill: none; stroke-width: 1.4; }
  .rail-ring .trk { stroke: var(--line); }
  .rail-ring .prog { stroke: var(--current); stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: .875; transition: stroke-dashoffset .8s var(--ease-out); }
  .rail-knob { position: absolute; inset: 0; transition: rotate .8s var(--ease-out); rotate: 45deg; }
  .rail-knob::after { content: ""; position: absolute; left: 50%; top: 1%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: var(--swell); box-shadow: 0 0 0 4px var(--cream); }
  .rail-disc { position: absolute; inset: 13%; border-radius: 50%; background: var(--white); box-shadow: 0 24px 40px -30px rgba(76,28,8,.45); display: grid; place-items: center; }
  .rail-ic { grid-area: 1 / 1; width: 44%; height: auto; opacity: 0; transform: scale(.82); transition: opacity .45s ease, transform .6s var(--ease-out); }
  .rail-ic.is-on { opacity: 1; transform: none; }
  .rail-ic.redraw path, .rail-ic.redraw circle { stroke-dasharray: 1; animation: s3-draw 1s var(--ease-out) both; }
  .rail-ic.redraw [fill="#F8CC48"] { animation: s3-draw 1s var(--ease-out) both, s3-fill .5s ease .55s both; }
  @keyframes s3-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
  @keyframes s3-fill { from { fill-opacity: 0; } to { fill-opacity: 1; } }

  .rail-count { display: flex; align-items: baseline; gap: 8px; margin: 26px 0 2px; font-family: var(--display); font-variation-settings: "SOFT" 100, "opsz" 144; color: var(--deep); font-variant-numeric: tabular-nums; }
  .rail-count b { font-weight: 650; font-size: 2.6rem; line-height: 1; letter-spacing: -0.02em; }
  .rail-count span { font-size: 1.1rem; color: var(--warm); }
  .rail-group { margin: 0 0 22px; font-weight: 600; color: var(--current); }

  .rail-nav ol { list-style: none; margin: 0; padding: 18px 0 0; border-top: 1px solid var(--line); display: grid; gap: 2px; }
  .rail-nav a { position: relative; display: block; padding: 5px 0 5px 0; text-decoration: none; font-size: .98rem; line-height: 1.35; color: var(--warm); transition: color .25s ease, padding-left .4s var(--ease-out); }
  .rail-nav a::before { content: ""; position: absolute; left: 0; top: 50%; width: 0; height: 3px; margin-top: -1.5px; border-radius: 2px; background: var(--swell); transition: width .4s var(--ease-out); }
  .rail-nav a:hover { color: var(--deep); }
  .rail-nav a.is-on { color: var(--deep); font-weight: 700; padding-left: 26px; }
  .rail-nav a.is-on::before { width: 16px; }

  .s3-list { min-width: 0; }
  .grp { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin: 0; padding: 64px 0 14px; border-bottom: 1px solid var(--deep);
    font-size: 1.05rem; line-height: 1.3; letter-spacing: 0; font-family: var(--body); font-weight: 700; color: var(--deep); }
  .grp:first-child { padding-top: 48px; }
  .grp small { font: 500 .95rem/1 var(--display); font-variation-settings: "SOFT" 100, "opsz" 36; color: var(--warm); font-variant-numeric: tabular-nums; }

  .item { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 0 12px; padding: 44px 0 48px; border-bottom: 1px solid var(--line); scroll-margin-top: calc(var(--hdr) + 24px); }
  .item .n { padding-top: .55rem; font: 600 1rem/1 var(--display); font-variation-settings: "SOFT" 100, "opsz" 36; color: var(--current); font-variant-numeric: tabular-nums; }
  .item .ic { display: none; }
  .item h3 { font-size: clamp(2rem, 3.2vw, 2.75rem); line-height: 1.08; }
  .item h3 span { background: linear-gradient(var(--swell), var(--swell)) no-repeat 0 88% / 0% 30%; transition: background-size .7s var(--ease-out); padding: 0 .04em; }
  .item p { margin: 16px 0 0; font-size: 1.16rem; line-height: 1.6; max-width: 46ch; }
  .item .more { display: flex; flex-wrap: wrap; gap: 6px 28px; margin-top: 18px; }
  .item:hover h3 span, .item.is-active h3 span { background-size: 100% 30%; }

  /* focus follows the scroll on desktop: the service in the middle of the screen is in full color */
  @media (min-width: 1000.02px) {
    .spot .item { transition: opacity .5s ease; }
    .spot .item:not(.is-active):not(:hover):not(:focus-within) { opacity: .42; }
  }


  @media (prefers-reduced-motion: reduce) {
    .item h3 span, .rail-nav a, .rail-nav a::before, .rail-knob, .rail-ring .prog { transition: none; }
  }

  @media (max-width: 1100px) { .s3-grid { grid-template-columns: 260px minmax(0, 1fr); gap: 0 64px; } .rail-stage { width: 180px; } }
  /* short laptop screens: the pinned panel drops its jump list so it always fits */
  @media (min-width: 1000.02px) and (max-height: 760px) { .rail-nav { display: none; } .rail { top: calc(var(--hdr) + 24px); } }

  /* tablets and phones: two columns of services, icon beside the name */
  @media (max-width: 1000px) {
    .hero--s3 h1 { font-size: clamp(2.1rem, min(7vw, 6.4vh), 3.6rem); }
    .fold-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .fold-grid li:nth-child(4n+1) { border-left: 1px solid var(--line); }
    .fold-grid li:nth-child(2n+1) { border-left: 0; }
    .cell { grid-template-rows: auto auto; align-content: center; row-gap: 4px; padding: clamp(8px, 1.6vh, 20px) 14px; }
    .cell .top { grid-row: 1 / span 2; }
    .cell .go { display: none; }
    .cell .ic { width: clamp(28px, 4.4vh, 40px); }
    .cell .nm { font-size: clamp(1rem, min(2.6vw, 2.6vh), 1.3rem); align-self: end; }
    .cell .d { grid-column: 2; font-size: .92rem; line-height: 1.45; padding-bottom: 0; }
    .fit-3 .cell .nm { align-self: center; }
    .s3-photo img { aspect-ratio: 16 / 8; }
    .s3-grid { grid-template-columns: 1fr; }
    .rail { display: none; }
    .item { grid-template-columns: 52px minmax(0, 1fr); padding: 32px 0 36px; }
    .item .n { display: none; }
    .item .ic { display: block; width: 40px; height: 40px; margin-top: 2px; }
    .item > div { grid-column: 2; grid-row: 1; }
  }
  @media (max-width: 620px) {
    .cell { column-gap: 10px; padding-left: 8px; padding-right: 8px; }
    .fold-grid li:nth-child(2n+1) .cell { padding-left: 0; }
    .cell .d { display: none; }                  /* phones: names only; the details follow below */
    .cell .nm { font-size: clamp(.98rem, 4.4vw, 1.12rem); align-self: center; }
    .s3-photo img { aspect-ratio: 4 / 3; }
    .s3 { padding-bottom: 80px; }
    .s3-head { padding-bottom: 22px; }
    .grp { padding-top: 48px; }
    .grp:first-child { padding-top: 32px; }
    .item { grid-template-columns: 44px minmax(0, 1fr); padding: 26px 0 30px; }
    .item .ic { width: 34px; height: 34px; }
    .item h3 { font-size: clamp(1.6rem, 7.4vw, 2rem); }
    .item p { font-size: 1.04rem; margin-top: 10px; }
  }
