/* ==========================================================================
   Services: "Tailored Services"
   Theme: the tailor's workroom, so it complements (not repeats) the hero.
   - section: soft linen weave
   - cards:   fabric swatches with a pinking-shear edge, stitched border
              and a swatch label
   - each swatch has a small framed window scene for the service; scenes
     settle in when revealed and move a little on hover
   Only transform / opacity / two registered custom properties animate.
   ========================================================================== */

/* Scene state comes from js/components/services.js (spring-animated):
   --s  : 0 closed, 0.7 dressed (in view), 1 showcase (hover / focus)
   --sw : sway in degrees, from the spring's velocity */

.services-section {
  position: relative;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 253, 248, 0.9), transparent 60%),
    repeating-linear-gradient(0deg, rgba(154, 112, 56, 0.035) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, rgba(154, 112, 56, 0.035) 0 1px, transparent 1px 4px),
    #f2eadd;
}

/* ---------- Card grid ----------
   Columns follow the number of visible services (data-count is set by
   js/components/services.js), so hiding one in js/data/services.js re-flows the grid. */
.svc-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  max-width: 28rem;
  margin-inline: auto;
}
@media (min-width: 768px) {
  .svc-grid { grid-template-columns: repeat(2, 1fr); max-width: 46rem; }
  .svc-grid[data-count="3"] { grid-template-columns: repeat(3, 1fr); max-width: 64rem; }
}
@media (min-width: 1024px) {
  .svc-grid { gap: 2.5rem; }
}
@media (min-width: 1280px) {
  .svc-grid[data-count="4"] { grid-template-columns: repeat(4, 1fr); max-width: 80rem; gap: 2rem; }
}

/* Stitched line under the heading */
.stitch-rule {
  position: relative;
  display: block;
  width: 132px;
  height: 8px;
  margin: 1.1rem auto 0;
  background: linear-gradient(90deg, var(--c-gold-dark) 50%, transparent 0) 0 50% / 8px 1px repeat-x;
}
.stitch-rule::before,
.stitch-rule::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--c-gold);
  transform: translateY(-50%);
}
.stitch-rule::before { left: -10px; }
.stitch-rule::after { right: -10px; }

/* ---------- Swatch card ---------- */
.svc-item { position: relative; }
/* Soft shadow as a separate, static layer behind the (masked) card.
   A filter on the wrapper would be re-rendered on every frame of the scene animation. */
.svc-item::before {
  content: "";
  position: absolute;
  inset: 12px 10px 0;
  z-index: 0;
  background: rgba(31, 58, 48, 0.3);
  filter: blur(16px);
  transform: translateY(14px);
  pointer-events: none;
}
/* lift the swatch; the wrapper's drop-shadow follows it */
.svc-card { transition: transform 0.9s cubic-bezier(0.22, 1, 0.36, 1); }
@media (hover: hover) {
  .svc-card:hover { transform: translateY(-6px); }
}

.svc-card {
  --pink: 9px; /* pinking tooth depth */
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 14px 14px calc(24px + var(--pink));
  background:
    repeating-linear-gradient(0deg, rgba(154, 112, 56, 0.025) 0 1px, transparent 1px 3px),
    #fffdf8;
  /* pinking-shear zigzag along the bottom */
  -webkit-mask:
    linear-gradient(#000 0 0) top / 100% calc(100% - var(--pink)) no-repeat,
    conic-gradient(from -45deg at 50% 100%, #000 90deg, #0000 0) bottom / calc(var(--pink) * 2) var(--pink) repeat-x;
  mask:
    linear-gradient(#000 0 0) top / 100% calc(100% - var(--pink)) no-repeat,
    conic-gradient(from -45deg at 50% 100%, #000 90deg, #0000 0) bottom / calc(var(--pink) * 2) var(--pink) repeat-x;
}
/* stitched border just inside the edge */
.svc-card::before {
  content: "";
  position: absolute;
  inset: 7px 7px calc(var(--pink) + 7px);
  border: 1px dashed rgba(154, 112, 56, 0.45);
  pointer-events: none;
}

.svc-card__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 2px 4px 10px;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--c-gold-dark);
}
.svc-card__head span:last-child {
  font-family: "Playfair Display", serif;
  font-style: italic;
  font-weight: 400;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  text-transform: none;
  color: rgba(23, 32, 28, 0.55);
}

/* ---------- Framed window ---------- */
.svc-window {
  padding: 5px;
  background: linear-gradient(145deg, #f6e4b8, var(--c-gold) 40%, var(--c-gold-dark));
  box-shadow: 0 10px 18px -12px rgba(60, 40, 15, 0.5);
}
.svc-window__scene {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  isolation: isolate;
  contain: layout paint style;   /* scene changes never touch the rest of the page */
  background: #f6ecd8;
  box-shadow: inset 0 0 0 1px rgba(90, 60, 20, 0.25), inset 0 6px 14px rgba(60, 40, 15, 0.22);
}

/* Daylight + window mullions behind the dressing */
.svc-view {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent calc(50% - 1px), rgba(154, 112, 56, 0.35) calc(50% - 1px) calc(50% + 1px), transparent 0),
    linear-gradient(0deg, transparent calc(46% - 1px), rgba(154, 112, 56, 0.35) calc(46% - 1px) calc(46% + 1px), transparent 0),
    radial-gradient(ellipse at 50% 40%, #fffdf6 0%, #f7ecd6 45%, #e8d6b2 100%);
}

/* Fine fabric grain over the whole scene */
.svc-grain {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  opacity: 0.1;                 /* plain alpha overlay: blend modes repaint everything beneath, every frame */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .8 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* ---- Scene: curtains (velvet drapes over an ivory sheer) ---- */
.svc-rod {
  position: absolute;
  z-index: 2;
  top: calc(8.33% - 2px);       /* lines up with the rings drawn in the SVG (y = 12.5 / 150) */
  left: 3%;
  right: 3%;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(#f6e4b8, var(--c-gold) 50%, var(--c-gold-dark));
  box-shadow: 0 2px 3px rgba(60, 40, 15, 0.35);
}
.svc-rod::before,
.svc-rod::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  transform: translateY(-50%);
  background: radial-gradient(circle at 35% 30%, #fff3d1, var(--c-gold) 50%, var(--c-gold-dark));
}
.svc-rod::before { left: -4px; }
.svc-rod::after { right: -4px; }

.svc-sheer {
  position: absolute;
  z-index: 1;
  top: 10.5%;
  bottom: 0;
  left: 8%;
  right: 8%;
  transform-origin: 50% 0;
  transform: skewX(calc(var(--sw, 0deg) * 0.6));
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.35), transparent 30%),
    repeating-linear-gradient(90deg,
      rgba(255, 253, 247, 0.62) 0 4px,
      rgba(236, 220, 192, 0.42) 4px 7px,
      rgba(255, 253, 247, 0.55) 7px 11px);
  box-shadow: inset 0 -3px 0 rgba(236, 220, 192, 0.7);
}

.svc-cur {
  position: absolute;
  z-index: 3;
  top: 0;
  bottom: 0;
  width: 34%;                   /* matches the 68:150 viewBox on a 4:3 scene */
  overflow: visible;
  backface-visibility: hidden;
  will-change: transform;
  /* --s 0 -> each panel covers half the window (1.47), 0.7 -> dressed (1), 1 -> gathered (0.8) */
  --gather: calc(1.47 - var(--s, 0) * 0.67);
}
.svc-cur--l { left: 0;  transform-origin: 0 0;    transform: scaleX(var(--gather)) skewX(var(--sw, 0deg)); }
.svc-cur--r { right: 0; transform-origin: 100% 0; transform: scaleX(var(--gather)) skewX(calc(var(--sw, 0deg) * -1)); }

/* ---- Scene: roman blind ---- */
.svc-blind {
  position: absolute;
  z-index: 2;
  top: 10%;
  left: 10%;
  right: 10%;
  height: calc(88% - var(--s, 0) * 66%);   /* down -> 42% in view -> 22% on hover */
  background:
    linear-gradient(180deg,
      rgba(255, 255, 255, 0.22) 0%, transparent 35%,
      rgba(20, 40, 32, 0.22) 88%, rgba(20, 40, 32, 0.4) 100%) 0 100% / 100% 30px repeat-y,
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 3px),
    var(--c-sage);
  box-shadow: 0 8px 12px -6px rgba(20, 40, 32, 0.45);
}
.svc-blind::before {
  /* headrail */
  content: "";
  position: absolute;
  top: -5px;
  left: -6px;
  right: -6px;
  height: 6px;
  border-radius: 2px;
  background: linear-gradient(#f6e4b8, var(--c-gold) 50%, var(--c-gold-dark));
}
.svc-blind__bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(#f6e4b8, var(--c-gold) 50%, var(--c-gold-dark));
}
/* gold pull-cord with an acorn toggle */
.svc-blind__cord {
  position: absolute;
  z-index: 3;
  top: 10%;
  right: calc(10% + 8px);
  width: 1px;
  height: 62%;
  background: var(--c-gold-dark);
}
.svc-blind__cord::after {
  content: "";
  position: absolute;
  bottom: -9px;
  left: 50%;
  width: 6px;
  height: 10px;
  border-radius: 3px 3px 4px 4px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, var(--c-gold-dark), #f6e4b8 45%, var(--c-gold));
}

/* ---- Scene: wallpaper (one drop hung, the next unrolling) ---- */
.svc-wall,
.svc-wall__roll {
  --motif: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='36' height='48' viewBox='0 0 36 48'><g fill='none' stroke='%23c49a5a' stroke-opacity='.55' stroke-width='1'><path d='M6 48V20a12 12 0 0 1 24 0v28'/><path d='M18 40c-4-5-4-11 0-16 4 5 4 11 0 16z'/></g><circle cx='18' cy='4' r='1.4' fill='%23c49a5a' fill-opacity='.6'/></svg>");
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--motif) 0 0 / 36px 48px, linear-gradient(180deg, #2a4a3d, var(--c-green));
}
.svc-wall { left: 0; right: 50%; }
.svc-wall__roll {
  left: 50%;
  right: 0;
  bottom: auto;
  height: calc(16% + var(--s, 0) * 84%);   /* rolled -> 75% in view -> full drop on hover */
  box-shadow: -1px 0 0 rgba(255, 255, 255, 0.12), -6px 0 10px -6px rgba(0, 0, 0, 0.5);
}
.svc-wall__roll::after {
  content: "";
  position: absolute;
  left: -2px;
  right: -2px;
  bottom: -9px;
  height: 18px;
  border-radius: 9px;
  background: linear-gradient(180deg, #3d6152, var(--c-green) 45%, var(--c-green-deep));
  box-shadow: 0 6px 10px rgba(20, 40, 32, 0.45);
}

/* ---- Scene: servicing (a linen panel being hemmed, with a measuring tape) ----
   The stitch line and the tape grow with --s: partly in view, fully on hover. */
.svc-panel {
  position: absolute;
  z-index: 2;
  top: 8.33%;                   /* hangs from the rod */
  left: 22%;
  right: 22%;
  bottom: 22%;
  transform-origin: 50% 0;
  transform: skewX(calc(var(--sw, 0deg) * 0.6));
  background:
    linear-gradient(to bottom, rgba(90, 60, 20, 0.3), transparent 14%),
    linear-gradient(90deg,
      rgba(120, 85, 35, 0.42) 0%,
      rgba(255, 255, 255, 0.34) 36%,
      rgba(255, 255, 255, 0.08) 58%,
      rgba(120, 85, 35, 0.42) 100%) 0 0 / 20% 100% repeat-x,
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.025) 0 1px, transparent 1px 3px),
    var(--c-linen);
  box-shadow: 0 6px 8px -4px rgba(60, 40, 15, 0.35);
}
.svc-panel__hem {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 16%;
  background: rgba(154, 112, 56, 0.2);
  border-top: 1px solid rgba(154, 112, 56, 0.55);
}
.svc-panel__hem::after {
  /* running stitch, drawn left to right */
  content: "";
  position: absolute;
  left: 6%;
  top: 46%;
  width: calc(var(--s, 0) * 88%);
  height: 2px;
  background: repeating-linear-gradient(90deg, var(--c-green) 0 5px, transparent 5px 9px);
}
.svc-tape {
  position: absolute;
  z-index: 3;
  left: 6%;
  bottom: 7%;
  width: calc(14% + var(--s, 0) * 80%);   /* unrolls as the card opens */
  height: 11px;
  border-radius: 2px 5px 5px 2px;
  background:
    linear-gradient(90deg, #5a3c14 1px, transparent 1px) 0 100% / 7px 4px repeat-x,
    linear-gradient(90deg, #5a3c14 1px, transparent 1px) 0 100% / 35px 7px repeat-x,
    linear-gradient(#f6e6bd, #e6cd8e);
  box-shadow: 0 2px 3px rgba(60, 40, 15, 0.35);
}
.svc-tape::after {
  /* metal end hook */
  content: "";
  position: absolute;
  right: -3px;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 1px;
  background: linear-gradient(#f6e4b8, var(--c-gold) 50%, var(--c-gold-dark));
}

/* Without JS the scenes simply sit in their dressed state */
.no-js .svc-window__scene { --s: 0.7; }

/* ---------- Card body ---------- */
.svc-card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  padding: 1.4rem 0.6rem 0;
}
.svc-card__title {
  font-family: "Playfair Display", serif;
  font-size: 1.6rem;
  line-height: 1.2;
  color: var(--c-green);
}
.svc-card__text {
  margin-top: 0.6rem;
  font-size: 0.9rem;
  line-height: 1.65;
  color: rgba(23, 32, 28, 0.62);
}
.svc-card__link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: auto;
  padding-top: 1.25rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--c-green);
  transition: color 0.3s ease;
}
.svc-card__link svg { width: 14px; height: 14px; color: var(--c-gold-dark); transition: transform 0.4s var(--ease-out); }
.svc-card__link:hover { color: var(--c-gold-dark); }
.svc-card__link:hover svg { transform: translateX(4px); }

/* ---------- CTA under the grid ---------- */
.services-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 4rem;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .svc-card { transition: none; }
}
