/* ==========================================================================
   #s4 SERVICES — "The tools to actually run the place"  (CENTREPIECE)
   Layout archetype: FULL-BLEED device with the copy CENTERED ABOVE it.
   Deliberately distinct from neighbours: s1 full-bleed hero (laptop lid),
   s2 centered five-to-one converge, s3 split copy-left/device-right morph,
   and s5 (next) will be split device-LEFT. This section is the only one where
   the device sits wide and alone below a centered text block.

   Signature motion (ONE): the Fellside Pantry ops dashboard COMES ALIVE as the
   section scrolls through. A single scrubbed proxy (--life 0 -> 1) orchestrates
   the whole screen: KPI numbers count up, the 7-day takings line path-draws and
   its area fills, the top-seller bars grow, and the busiest-day cell ignites
   gold last. It reads as one staged "the place waking up" gesture, not a pile
   of separate tweens. This is the richest single animation on the page; no
   device rotation here on purpose, so all attention is on the data coming to
   life. Everything animated is transform / opacity / stroke-dashoffset only.

   Reduced motion / no-JS: the dashboard rests fully ALIVE (all figures at final
   values, line drawn, bars full, busiest cell already gold). Nothing hidden.
   ========================================================================== */

#s4 { overflow: clip; }

#s4 .s4-head {
  max-width: 760px;
  margin-inline: auto;
  text-align: center;
}
#s4 .s4-eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  margin-bottom: var(--sp-3);
}
#s4 .s4-eyebrow::before,
#s4 .s4-eyebrow::after {
  content: ""; width: 26px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-soft));
}
#s4 .s4-eyebrow::after {
  background: linear-gradient(90deg, var(--gold-soft), transparent);
}
#s4 .s4-title {
  font-size: var(--fs-h2);
  font-weight: 600; line-height: 1.08; letter-spacing: -0.01em;
  color: var(--ice); text-wrap: balance;
}
#s4 .s4-title .accent { color: var(--gold-bright); font-style: italic; font-weight: 500; }
#s4 .s4-lead {
  margin-top: var(--sp-3);
  margin-inline: auto;
  max-width: 56ch;
  color: var(--parchment-dim);
  font-size: var(--fs-lead);
  line-height: 1.5;
  text-wrap: pretty;
}

/* ---- STAGE: the wide full-bleed laptop ---------------------------------- */
#s4 .s4-stage {
  margin-top: clamp(40px, 6vw, 80px);
  position: relative;
}
/* subtle gold floor-glow under the centrepiece device */
#s4 .s4-stage::before {
  content: "";
  position: absolute;
  left: 50%; bottom: -6%;
  width: min(900px, 92%);
  height: 60%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse 60% 60% at 50% 100%, rgba(196,162,101,0.16), transparent 70%);
  filter: blur(6px);
  opacity: calc(0.35 + var(--life, 0) * 0.65);
  transition: opacity .6s var(--ease-out);
  pointer-events: none;
  z-index: 0;
}
#s4 .s4-stage .device-scene { position: relative; z-index: 1; }
#s4 .laptop { width: min(940px, 94vw); }
/* lid is open and static here: the data is the show, not the hardware */
#s4 .laptop__lid { transform: none; transition: none; }

/* live status row that sits above the device and mirrors the wake-up */
#s4 .s4-status {
  display: inline-flex; align-items: center; gap: 14px;
  margin-top: var(--sp-4);
  font-family: var(--font-mono);
  font-size: var(--fs-eyebrow);
  letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--steel);
}
#s4 .s4-status b { color: var(--ice); font-weight: 500; }
#s4 .s4-status .s4-status__sep { width: 1px; height: 12px; background: var(--hairline); }

/* ==========================================================================
   THE GREENSLATE KITCHEN OPS DASHBOARD  (LIGHT BRAND: .mb mb--greenslate)
   ----------------------------------------------------------------------------
   The screen is its own light/modern bistro product UI (sage + cream + brass),
   NOT the Beaufort-dark chrome. All colour comes from the shared mock-brand kit
   vars (--mb-*), never the dark tokens. The ANIMATION HOOKS are untouched: every
   class still derives its motion from the single --life 0..1 proxy exactly as
   before (count-ups via [data-count], line path-draw via --len/--life, area +
   dots fade, top-dish bars grow via --v + --life, busiest cell ignites LAST).
   Only the palette/typography are rebranded. A full ops surface: header strip,
   4 KPI cards, a tall 7-day takings chart with the busiest-day cell, top-dishes,
   hours-by-day mini grid, and the alerts rail.
   ========================================================================== */
#s4 .fp4 {
  height: 100%;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: clamp(8px, 1.4cqw, 14px);
  padding: clamp(12px, 2.4cqw, 22px);
  container-type: inline-size;
}

/* --- header strip --- */
#s4 .fp4-head {
  display: flex; align-items: center; gap: 12px;
  padding-bottom: clamp(8px, 1.4cqw, 12px);
  border-bottom: 1px solid var(--mb-line);
}
/* brand wordmark uses the kit's .mb-logo (Fraunces / sage) with a brass kicker */
#s4 .fp4-brand {
  font-size: clamp(13px, 2.6cqw, 19px);
}
#s4 .fp4-brand i {
  font-style: italic; font-weight: 500; color: var(--mb-accent-2);
}
#s4 .fp4-date {
  font-family: var(--mb-font-num); font-size: clamp(8.5px, 1.5cqw, 10.5px);
  letter-spacing: 1px; text-transform: uppercase; color: var(--mb-text-soft);
}
#s4 .fp4-cover {
  display: inline-flex; align-items: center; gap: 5px;
  margin-left: auto;
  font-family: var(--mb-font-num); font-size: clamp(9px, 1.6cqw, 11px);
  color: var(--mb-text-soft); font-variant-numeric: tabular-nums;
}
#s4 .fp4-cover svg { width: clamp(13px, 2.5cqw, 17px); height: auto; display: block; color: var(--mb-accent); }
#s4 .fp4-live {
  font-family: var(--mb-font-num); font-size: clamp(8px, 1.4cqw, 9.5px);
  letter-spacing: 1px; text-transform: uppercase; color: var(--mb-accent);
  background: color-mix(in srgb, var(--mb-accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--mb-accent) 32%, transparent);
  border-radius: 999px;
  padding: 3px 9px; display: inline-flex; align-items: center; gap: 6px;
}
#s4 .fp4-live::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--mb-accent); box-shadow: 0 0 8px color-mix(in srgb, var(--mb-accent) 80%, transparent);
  animation: fp4pulse 2.4s var(--ease-io) infinite;
}
@keyframes fp4pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* --- KPI row (4 cards) --- */
#s4 .fp4-kpis {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: clamp(8px, 1.4cqw, 12px);
}
#s4 .fp4-kpi {
  background: var(--mb-surface);
  border: 1px solid var(--mb-line);
  border-radius: var(--mb-radius);
  box-shadow: var(--mb-shadow);
  padding: clamp(8px, 1.6cqw, 14px);
  display: flex; flex-direction: column; gap: 5px;
}
#s4 .fp4-kpi .lbl {
  font-family: var(--mb-font-num); font-size: clamp(7.5px, 1.4cqw, 9.5px);
  letter-spacing: 1.1px; text-transform: uppercase; color: var(--mb-text-soft);
}
#s4 .fp4-kpi .val {
  font-family: var(--mb-font-num); font-weight: 600; font-variant-numeric: tabular-nums;
  font-size: clamp(18px, 4.4cqw, 30px); color: var(--mb-text); line-height: 1;
}
#s4 .fp4-kpi .dl {
  font-family: var(--mb-font-num); font-size: clamp(8px, 1.5cqw, 10px);
}
#s4 .fp4-kpi .dl.up { color: var(--mb-accent); }
#s4 .fp4-kpi .dl.flat { color: var(--mb-text-soft); }

/* --- main body: chart (wide) + side rail --- */
#s4 .fp4-body {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: clamp(8px, 1.6cqw, 14px);
  min-height: 0;
}
#s4 .fp4-panel {
  background: var(--mb-surface);
  border: 1px solid var(--mb-line);
  border-radius: var(--mb-radius);
  box-shadow: var(--mb-shadow);
  padding: clamp(8px, 1.6cqw, 14px);
  display: flex; flex-direction: column;
  min-height: 0;
}
#s4 .fp4-panel__title {
  display: flex; align-items: baseline; gap: 8px;
  font-family: var(--mb-font-num); font-size: clamp(8px, 1.5cqw, 10.5px);
  letter-spacing: 1.4px; text-transform: uppercase; color: var(--mb-text-soft);
  margin-bottom: clamp(6px, 1.2cqw, 10px);
}
#s4 .fp4-panel__title .pk {
  margin-left: auto; text-transform: none; letter-spacing: 0.5px;
  color: var(--mb-accent-2); font-size: 0.92em; font-weight: 600;
}

/* the 7-day takings chart (7 points; --life path-draws + area fills) */
#s4 .fp4-chart { flex: 1; min-height: 0; position: relative; }
#s4 .fp4-chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
#s4 .fp4-chart .grid line { stroke: var(--mb-line); stroke-width: 1; }
#s4 .fp4-chart .axis {
  font-family: var(--mb-font-num); font-size: 8px; fill: var(--mb-text-soft);
  letter-spacing: 0.5px;
}
#s4 .fp4-line {
  fill: none; stroke: var(--mb-accent-2); stroke-width: 2.4;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: var(--len, 1000);
  stroke-dashoffset: calc(var(--len, 1000) * (1 - var(--life, 0)));
}
#s4 .fp4-area {
  fill: url(#s4-area-grad);
  opacity: calc(max(0, (var(--life, 0) - 0.25)) / 0.75);
}
/* day dots ride along the line, fading in with life */
#s4 .fp4-dot { fill: var(--mb-surface); stroke: var(--mb-accent-2); stroke-width: 1.6;
  opacity: calc(max(0, (var(--life, 0) - 0.4)) / 0.6); }

/* busiest-day cell: ignites brass LAST (life > 0.78) */
#s4 .fp4-busiest-band {
  fill: color-mix(in srgb, var(--mb-accent-2) 10%, transparent);
  opacity: calc(max(0, (var(--life, 0) - 0.78)) / 0.22);
}
#s4 .fp4-busiest-ring {
  fill: none; stroke: var(--mb-accent-2); stroke-width: 2;
  opacity: calc(max(0, (var(--life, 0) - 0.78)) / 0.22);
  transform-box: fill-box; transform-origin: center;
  transform: scale(calc(0.4 + min(1, max(0, (var(--life,0) - 0.78)) / 0.22) * 0.6));
}
#s4 .fp4-busiest-dot {
  fill: var(--mb-accent-2);
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--mb-accent-2) 85%, transparent));
  opacity: calc(max(0, (var(--life, 0) - 0.78)) / 0.22);
}
#s4 .fp4-busiest-tag {
  font-family: var(--mb-font-num); font-size: 8.5px; font-weight: 600;
  fill: var(--mb-accent-2); letter-spacing: 0.5px;
  opacity: calc(max(0, (var(--life, 0) - 0.85)) / 0.15);
}

/* side rail: top dishes + hours-by-day + alerts */
#s4 .fp4-rail { display: flex; flex-direction: column; gap: clamp(8px, 1.4cqw, 12px); min-height: 0; }

#s4 .fp4-sellers { display: flex; flex-direction: column; gap: clamp(7px, 1.3cqw, 11px); }
#s4 .fp4-bar {
  display: grid;
  grid-template-columns: clamp(64px, 13cqw, 100px) 1fr clamp(20px, 4cqw, 28px);
  align-items: center; gap: clamp(7px, 1.4cqw, 10px);
}
#s4 .fp4-bar__name {
  font-family: var(--mb-font-body); font-size: clamp(8px, 1.5cqw, 10.5px);
  color: var(--mb-text); letter-spacing: 0.2px; font-weight: 500;
  display: flex; align-items: center; gap: 7px; white-space: nowrap;
}
#s4 .fp4-bar__track { position: relative; height: clamp(5px, 1cqw, 7px); border-radius: 999px; background: var(--mb-surface-2); overflow: hidden; }
#s4 .fp4-bar__fill {
  position: absolute; inset: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--mb-accent), var(--mb-accent-2));
  transform-origin: left center;
  transform: scaleX(calc(var(--v, 0) * clamp(0, calc((var(--life,0) - 0.3) / 0.5), 1)));
}
#s4 .fp4-bar__num {
  font-family: var(--mb-font-num); font-size: clamp(8.5px, 1.5cqw, 10px);
  color: var(--mb-text); text-align: right; font-variant-numeric: tabular-nums;
}

/* hours-by-day micro heatmap: the busiest cell glows brass */
#s4 .fp4-hours { margin-top: 2px; }
#s4 .fp4-hours__row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
#s4 .fp4-cell {
  aspect-ratio: 1 / 1; border-radius: 4px;
  background: var(--mb-surface-2);
  border: 1px solid transparent;
  position: relative;
  opacity: calc(0.4 + min(1, var(--life,0)) * 0.6);
}
#s4 .fp4-cell[data-heat="1"] { background: color-mix(in srgb, var(--mb-accent-2) 16%, var(--mb-surface-2)); }
#s4 .fp4-cell[data-heat="2"] { background: color-mix(in srgb, var(--mb-accent-2) 32%, var(--mb-surface-2)); }
#s4 .fp4-cell--peak {
  background: color-mix(in srgb, var(--mb-accent-2) 46%, var(--mb-surface-2)) !important;
  border-color: color-mix(in srgb, var(--mb-accent-2) calc(100% * min(1, max(0, (var(--life,0) - 0.78)) / 0.22)), transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--mb-accent-2) calc(100% * min(1, max(0, (var(--life,0) - 0.78)) / 0.22)), transparent),
              0 0 12px color-mix(in srgb, var(--mb-accent-2) calc(60% * min(1, max(0, (var(--life,0) - 0.78)) / 0.22)), transparent);
}
#s4 .fp4-days {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
  margin-top: 5px;
}
#s4 .fp4-days span {
  text-align: center;
  font-family: var(--mb-font-num); font-size: clamp(7px, 1.2cqw, 8.5px);
  color: var(--mb-text-soft); letter-spacing: 0.5px;
}
#s4 .fp4-days span.is-peak { color: var(--mb-accent-2); font-weight: 600; }

#s4 .fp4-alerts { display: flex; flex-direction: column; gap: 6px; margin-top: auto; }
#s4 .fp4-alert {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--mb-font-body); font-size: clamp(8px, 1.5cqw, 10.5px);
  color: var(--mb-text-soft);
  background: var(--mb-surface-2);
  border: 1px solid var(--mb-line);
  border-radius: 8px;
  padding: clamp(6px, 1.1cqw, 9px) clamp(8px, 1.4cqw, 11px);
}
#s4 .fp4-alert .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
#s4 .fp4-alert .dot--amber { background: var(--mb-accent-2); box-shadow: 0 0 7px color-mix(in srgb, var(--mb-accent-2) 70%, transparent); }
#s4 .fp4-alert .dot--cyan  { background: var(--mb-accent);   box-shadow: 0 0 7px color-mix(in srgb, var(--mb-accent) 60%, transparent); }

/* small "spark" tick mark before some dish names for texture */
#s4 .fp4-bar__name i {
  width: 5px; height: 5px; border-radius: 1px; background: var(--mb-accent-2); flex: none;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 900px) {
  #s4 .laptop { width: 96vw; }
}
@media (max-width: 720px) {
  /* On phones the dashboard simplifies: KPIs to 2x2, body stacks vertically.
     The laptop screen goes TALL (portrait) so the whole stack fits and the
     chart + busiest cell (the heart of the motion) stay fully visible. Let the
     grid rows size to content rather than crushing the chart into the lid. */
  #s4 .laptop { width: 94vw; }
  #s4 .laptop__display { aspect-ratio: auto; }
  #s4 .laptop__display .device__screen { height: auto; }
  #s4 .fp4 {
    gap: 10px; padding: 14px;
    grid-template-rows: auto auto auto;
  }
  #s4 .fp4-kpis { grid-template-columns: repeat(2, 1fr); }
  #s4 .fp4-body { grid-template-columns: 1fr; }
  #s4 .fp4-chart { min-height: 150px; }
  #s4 .fp4-alerts { margin-top: 4px; }
}
@media (max-width: 420px) {
  #s4 .fp4-kpi .val { font-size: 24px; }
}

/* ==========================================================================
   REDUCED MOTION + NO-JS resting state: dashboard fully alive.
   Force --life to 1 so all derived opacities/transforms land at final.
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  #s4 .s4-stage,
  #s4 .fp4-area, #s4 .fp4-line, #s4 .fp4-dot,
  #s4 .fp4-busiest-band, #s4 .fp4-busiest-ring, #s4 .fp4-busiest-dot,
  #s4 .fp4-busiest-tag, #s4 .fp4-bar__fill, #s4 .fp4-cell,
  #s4 .fp4-cell--peak, #s4 .fp4-kpi { --life: 1 !important; }
  #s4 .fp4-line { stroke-dashoffset: 0 !important; }
  #s4 .fp4-live::before { animation: none !important; }
}
/* no-JS guard: the inline script removes this once it can drive --life */
html.no-js #s4 .s4-stage { --life: 1; }
