/* ==========================================================
   MAIN STREET FITNESS — SINGLE-SCREEN HOMEPAGE
   The Service Orbit IS the homepage. Four grid rows, viewport-bound,
   no conventional content below the orbit.
   Loaded only by index.html.
   ========================================================== */

.msf-home {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  /* 100vw would include the scrollbar; 100% will not. */
  width: 100%;
  min-width: 0;
}
.msf-home > * { min-width: 0; min-height: 0; }

/* ---------- row 1: disclosure (compact, never animated, never dismissed) --- */
.msf-home .msf-demo-banner { position: static; }
.msf-home .msf-demo-banner__inner {
  padding-block: var(--space-2);
  font-size: var(--text-xs);
  line-height: 1.35;
}

/* ---------- row 2: header ---------- */
.msf-home .msf-header { position: static; background: rgba(9, 9, 10, .86); }
.msf-home .msf-header__inner { min-height: 62px; }
.msf-home .msf-brand__name { font-size: var(--text-md); }
.msf-home .msf-nav a { min-height: 44px; padding-inline: var(--space-2); font-size: var(--text-xs); }

/* ---------- row 3: the stage ---------- */
.msf-home__stage {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: var(--msf-black);
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  align-items: center;
  padding: clamp(.35rem, 1.2vh, 1.1rem) var(--msf-gutter);
}

/* Wallpaper: a real supplied gym photograph, decorative only.
   Its own layer — never opacity on the stage, which would fade the controls. */
.msf-home__stage::before {
  content: "";
  position: absolute; inset: 0; z-index: -2;
  background-image: url("../img/gym-wallpaper-1024.jpg");
  background-image: image-set(
    url("../img/gym-wallpaper-1024.avif") type("image/avif"),
    url("../img/gym-wallpaper-1024.webp") type("image/webp"),
    url("../img/gym-wallpaper-1024.jpg") type("image/jpeg"));
  background-size: cover;
  background-position: 50% 46%;
  background-repeat: no-repeat;
  /* Tuned against the actual photograph: the brick and the dumbbell rack stay
     legible, but nothing competes with the constellation. */
  filter: grayscale(.06) saturate(.94) contrast(1.02) brightness(.86);
  transform: scale(1.03);
}
@media (max-width: 700px) {
  .msf-home__stage::before {
    background-image: url("../img/gym-wallpaper-640.jpg");
    background-image: image-set(
      url("../img/gym-wallpaper-640.avif") type("image/avif"),
      url("../img/gym-wallpaper-640.webp") type("image/webp"),
      url("../img/gym-wallpaper-640.jpg") type("image/jpeg"));
    background-position: 56% 46%;
  }
}

/* Scrim: guarantees contrast for node labels over every part of the photo. */
.msf-home__stage::after {
  content: "";
  position: absolute; inset: 0; z-index: -1;
  /* Light touch only: the gym must stay visible (concept target). Contrast for
     the labels comes from each medallion's own scrim, not from burying the room. */
  background:
    radial-gradient(circle at 50% 46%,
      rgba(9, 9, 10, .10) 0%, rgba(9, 9, 10, .30) 58%, rgba(9, 9, 10, .68) 100%),
    linear-gradient(180deg,
      rgba(9, 9, 10, .34), rgba(122, 30, 37, .07) 46%, rgba(9, 9, 10, .52));
}

/* Forced colours: the wallpaper drops out; the interface must still read. */
@media (forced-colors: active) {
  .msf-home__stage::before, .msf-home__stage::after { display: none; }
}

/* ---------- orbit scale on the home stage ---------- */
/* Bound by the SHORTER axis so the ring fills the stage without colliding
   with the header or footer. Tuned by visual QA at each viewport. */
.msf-home .msf-orb {
  padding-block: 0;
  display: grid;
  place-items: center;
  position: relative;
  --stage-size: min(calc(100svh - 22rem), 92vw, 42rem);
}
.msf-home .msf-orb { height: 100%; }

/* Narrow screens: the chrome must not eat the stage. Touch targets stay 44px;
   only padding, type size and wrapping tighten. */
@media (max-width: 520px) {
  .msf-home .msf-demo-banner__inner { font-size: var(--text-xs); padding-block: var(--space-1); }
  .msf-home .msf-header__inner { min-height: 0; padding-block: var(--space-1); gap: var(--space-1); }
  .msf-home .msf-brand { padding: var(--space-1) 0; }
  .msf-home .msf-brand__name { font-size: var(--text-xs); }
  .msf-home .msf-brand__sub { font-size: var(--text-xs); letter-spacing: .1em; }
  .msf-home .msf-nav { width: 100%; justify-content: space-between; }
  .msf-home .msf-nav a { padding-inline: var(--space-1); font-size: var(--text-xs); letter-spacing: .06em; }
  .msf-home__footer { font-size: var(--text-xs); padding-block: var(--space-1); min-height: 40px; gap: var(--space-2); }
  .msf-home__footeracts { gap: var(--space-3); }
  .msf-home__hint { display: none; }   /* the controls are self-evident at this size */
}

/* ---------- minimal controls ----------
   Inside the radio group so the counter can be revealed by the SAME :checked
   authority as the selected node (C9): a JS-written counter can disagree with
   CSS-driven selection whenever scripting is blocked or slow. */
.msf-home .msf-orb { padding-bottom: 3.4rem; }
.msf-home__controls {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: center;
  gap: var(--space-3); flex-wrap: wrap;
}
.msf-home__count {
  font-family: var(--msf-font-display); font-weight: 800;
  font-size: var(--text-xs); letter-spacing: var(--track-eyebrow); color: var(--msf-white);
  min-width: 3.6rem; text-align: center;
  font-variant-numeric: tabular-nums;
}
.msf-count__total { color: var(--msf-steel); }
.msf-home__hint {
  font-size: var(--text-xs); letter-spacing: .16em; text-transform: uppercase;
  color: var(--msf-steel);
}

/* ---------- row 4: footer ---------- */
.msf-home__footer {
  border-top: 1px solid var(--msf-border);
  background: rgba(9, 9, 10, .9);
  padding: var(--space-2) var(--msf-gutter);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); flex-wrap: wrap;
  font-size: var(--text-xs); color: var(--msf-muted);
  min-height: 44px;
}
.msf-home__footer a { color: var(--msf-white); text-decoration: none; }
.msf-home__footer a:hover { color: var(--msf-red); }
.msf-home__footeracts { display: flex; gap: var(--space-4); flex-wrap: wrap; }

/* ---------- capability detail: NO-JAVASCRIPT path ----------
   One compact layer, revealed for the selected radio by generated CSS.
   Hidden once scripting is confirmed, because the dialog takes over. */
.msf-cap-inline {
  display: none;
  position: absolute;
  left: 50%; bottom: clamp(.5rem, 2vh, 1.1rem);
  translate: -50% 0;
  width: min(30rem, calc(100% - 2rem));
  background: rgba(20, 20, 22, .93);
  border: 1px solid var(--msf-border);
  border-radius: var(--msf-radius);
  padding: var(--space-3) var(--space-4);
  z-index: 5;
}
.msf-cap-inline p { font-size: var(--text-xs); }
.msf-cap-inline .msf-orb__title { font-size: var(--text-md); }
html.msf-has-js .msf-cap-inline { display: none !important; }

/* ---------- capability detail: JAVASCRIPT overlay ---------- */
.msf-cap-dialog {
  border: 1px solid var(--msf-border);
  background: rgba(20, 20, 22, .96);
  color: var(--msf-white);
  border-radius: var(--msf-radius);
  padding: clamp(1.1rem, 3vw, 1.7rem);
  width: min(30rem, calc(100% - 2rem));
  max-height: min(80svh, 40rem);
  overflow-y: auto;
  box-shadow: 0 30px 80px -30px #000, 0 0 0 1px rgba(0, 0, 0, .6);
}
@supports (backdrop-filter: blur(6px)) {
  .msf-cap-dialog { background: rgba(20, 20, 22, .82); backdrop-filter: blur(10px); }
}
.msf-cap-dialog::backdrop { background: rgba(9, 9, 10, .74); }
.msf-cap-dialog__head { display: flex; justify-content: space-between; gap: var(--space-4); align-items: flex-start; }
.msf-cap-dialog__close {
  min-width: 44px; min-height: 44px; flex: none;
  background: transparent; color: var(--msf-white);
  border: 1px solid var(--msf-border); border-radius: var(--msf-radius);
  cursor: pointer; font-size: var(--text-md);
}
.msf-cap-dialog__close:hover { border-color: var(--msf-red); color: var(--msf-red); }
.msf-cap-dialog h2 {
  font-size: var(--text-lg);
  text-transform: uppercase; line-height: 1.1;
}
.msf-cap-dialog p { margin-top: var(--space-2); }
.msf-cap-dialog .msf-orb__act { margin-top: var(--space-4); }

/* Desktop: sit the panel to the side so the orbit stays visible behind it. */
@media (min-width: 900px) {
  .msf-cap-dialog {
    margin: 0 0 0 auto;
    height: 100%;
    max-height: none;
    width: min(28rem, 40vw);
    border-radius: 0;
    border-block: 0; border-right: 0;
  }
}
/* Mobile: bottom sheet, respecting safe-area insets. */
@media (max-width: 899px) {
  .msf-cap-dialog {
    margin: auto auto 0;
    width: 100%;
    max-width: none;
    border-radius: var(--msf-radius) var(--msf-radius) 0 0;
    padding-bottom: calc(1.2rem + env(safe-area-inset-bottom, 0px));
  }
}

/* ---------- ACCESSIBILITY ESCAPE ----------
   The one-screen effect is the standard case, not a cage. When the viewport is
   too short for the composition — high zoom, increased text size, short
   landscape — the shell releases its height and scrolls instead of clipping. */
@media (max-height: 620px), (max-width: 340px) {
  /* Release the height so nothing is clipped, but never the width: a
     horizontal scrollbar is a defect, a vertical one is the escape. */
  .msf-home { min-height: 0; height: auto; overflow-x: hidden; overflow-y: visible; }
  .msf-home__stage { overflow-x: hidden; overflow-y: visible; }
  body.msf-home { overflow-y: auto; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .msf-home__stage::before { transform: none; }
}


/* ---------- visitor-task spinner ---------- */
.msf-cap-caption {
  position: absolute; left: 0; right: 0; bottom: 5.6rem;
  text-align: center; font-size: var(--text-lg);
  color: var(--msf-white); padding-inline: var(--space-4);
}
.msf-cap-actions {
  position: absolute; left: 0; right: 0; bottom: 2.5rem;
  display: flex; justify-content: center;
}
.msf-home .msf-orb { padding-bottom: 8.2rem; }
.msf-orb__nodelabel { max-width: 92%; }
@media (max-width: 560px) {
  .msf-cap-caption { position: static; margin-top: var(--space-2); font-size: var(--text-xs); }
  .msf-cap-actions { position: static; margin-top: var(--space-2); }
  .msf-home .msf-orb { padding-bottom: var(--space-5); }
  .msf-home .msf-orb__hub { width: min(34vw, 8.4rem); }
  .msf-cap-actions .msf-btn { min-height: 46px; }
}


/* C2: below 390px the caption duplicates the action beneath it; drop it
   rather than shrinking the hub. */
/* D2: below 390px the whole spacing scale steps down one notch. Removes no
   function and no legibility — spacing is the compressible dimension. */
@media (max-width: 389px) {
  :root {
    --space-2:  .25rem;   /* was .5   */
    --space-3:  .5rem;    /* was .75  */
    --space-4:  .75rem;   /* was 1    */
    --space-5:  1rem;     /* was 1.5  */
    --space-6:  1.5rem;   /* was 2    */
    --space-7:  2rem;     /* was 2.5  */
    --space-8:  2.5rem;   /* was 3    */
    --space-9:  3rem;     /* was 4    */
  }
  .msf-cap-caption { display: none; }
  .msf-cap-actions { position: static; margin-top: var(--space-2); }
  .msf-home .msf-orb { padding-bottom: var(--space-4); }
  .msf-home__controls { margin-top: var(--space-2); }
}
