/* Public spacing rhythm. Keep controls, article measure, and media dimensions local. */
/* The homepage defines the public frame, section gaps and card insets. */
:root {
  --mf-public-frame: 1370px;
  --mf-public-gutter: 10px;
  --mf-public-page-inset: 8px;
  --mf-public-gap: clamp(8px, .85vw, 11px);
  --mf-public-panel-space: clamp(10px, 1vw, 12px);
  --mf-public-wide-inset: clamp(12px, 1.25vw, 18px);
}

@media (max-width: 700px) {
  :root { --mf-public-gutter: 8px; }
}

@media (min-width: 94rem) {
  :root { --mf-public-frame: 1440px; }
}

/* Set the outer gutter once. Preserve the reading width inside articles and profiles. */
html:root body:not(:where(
  .mf-admin-page, .mf-account-page, .mf-login-page, .mf-contributor-login-route,
  .mf-contributor-login-v2, .mf-contributor-dashboard, .mf-editor-page, .mf-editorial-console
)) :is(main#main-content, main#calendar, main.mf-template-main, main.mf-events-main):not(.layout-mosaic) {
  --mf-shell-section-space: var(--mf-public-panel-space);
  --mf-compact-hero-padding: var(--mf-public-wide-inset);
  --space-section: var(--mf-public-panel-space);
  --space-section-tight: var(--mf-public-panel-space);
  --space-hero: var(--mf-public-wide-inset);
  box-sizing: border-box;
  row-gap: var(--mf-public-gap);
}

/* Important declarations in this layer take precedence over legacy route density sheets. */
@layer mfOwnerCompact {
  html body:not(:where(.mf-admin-page, .mf-account-page, .mf-login-page, .mf-editor-page,
    .mf-contributor-login-route, .mf-contributor-login-v2, .mf-contributor-dashboard, .mf-editorial-console))
    :is(main#main-content, main#calendar, main.mf-template-main, main.mf-events-main):not(.layout-mosaic) {
    padding: var(--mf-public-page-inset) var(--mf-public-gutter) !important;
  }

  html body:is(.mf-shell-unified, .mf-page-shell, .mf-page-template, .stl-soccer-hub-page, .mf-people-page,
    .mf-calendar-page, [data-compact-page]):not(:where(.mf-admin-page, .mf-account-page, .mf-login-page,
    .mf-editor-page, .mf-contributor-login-route, .mf-contributor-login-v2, .mf-contributor-dashboard, .mf-editorial-console))
    :is(main#main-content, main#calendar, main.mf-template-main, main.mf-events-main):not(.layout-mosaic, .cv-root, .mf-map-public, .mf-route-map) {
    width: min(100%, var(--mf-public-frame)) !important;
    max-width: var(--mf-public-frame) !important;
    margin-inline: auto !important;
  }
}

@layer mfOwnerCompact {
  /* Legacy wrappers inside the page frame already have an outer gutter. */
  html:root body main:is(.mf-d2-home-main, .newsstand) > :is(.mf-d2-home-content, .ns-shell) {
    padding-inline: 0 !important;
  }

  /* Legacy pages stack sections with margins. Grid templates use their existing gap. */
  html:root body.mf-shell-unified main#main-content:not(.mf-template-main, .mf-events-main, .layout-mosaic)
    > :is(section, .mf-mc-shell, .mf-mc-hero, .mfpn-mast, .mfpn-directory, .desk-hero, .vd-hero, .usx-hero) {
    margin-block-end: var(--mf-public-gap) !important;
  }

  html:root body.mf-shell-unified main#main-content:not(.mf-template-main, .mf-events-main, .layout-mosaic)
    > :is(section, .mf-mc-shell, .mfpn-mast, .mfpn-directory):last-child {
    margin-block-end: 0 !important;
  }

  /* Shared panel components use the inset from the homepage's score and news panels. */
  html:root body.mf-shell-unified main#main-content :is(
    .stl-section, .mf-core-section, .mf-hs-section, .mf-hscl-section,
    .mf-mc-section, .mf-d2-section, .mf-hbcu-section, .mf-world-section,
    .mf-v22-section, .mf-afcon-v2-desk, .mf-africa-edition-rail, .mf-shape-feature--afcon,
    .citysc-hub-shell, .citysc-source-strip, .mfpn-mast, .mfpn-directory, .desk-section,
    .usx-section, .vd-section, .vd-reference-board, .mf-stats-frame, .mf-stats-intro
  ) {
    padding-block: var(--mf-public-panel-space) !important;
  }

  html:root body.mf-shell-unified main#main-content :is(
    .mf-stl-v3-hero, .mf-hbcal-hero, .mf-hbcu-hero, .mf-afcon-hero, .mf-core-hero,
    .desk-hero, .usx-hero, .vd-hero, .mf-ac-hero
  ) {
    padding-block: var(--mf-public-wide-inset) !important;
  }

  /* Match line wrapping and touch targets by changing insets, rather than control dimensions. */
  html body :is(.mf-template-panel, .mf-template-card, .mf-event-schedule-main) {
    padding-inline: var(--mf-public-panel-space) !important;
  }

  html body.mf-shell-unified main#main-content .mf-event-schedule-main {
    padding-block: var(--mf-public-panel-space) !important;
  }

}

/* Standalone tools, downloads and generated profiles may use a different landmark ID. */
@media screen {
  @layer mfOwnerCompact {
    html:root body:not(:where(.mf-admin-page, .mf-account-page, .mf-login-page,
      .mf-editor-page, .mf-editorial-console, .mf-contributor-login-route,
      .mf-contributor-login-v2, .mf-contributor-dashboard))
      :is(main, [role="main"]):not(:is(main main, main [role="main"], #main-content, #calendar,
        .mf-template-main, .mf-events-main, .layout-mosaic, .mf-admin-review)) {
      box-sizing: border-box;
      padding: var(--mf-public-page-inset) var(--mf-public-gutter) !important;
      row-gap: var(--mf-public-gap);
    }
  }
}

/* Apply the same frame to legacy route shells with stronger local selectors. */
@layer mfOwnerCompact {
  html:root body.site-app-ready.mf-page-shell:not(:where(.mf-admin-page, .mf-account-page,
    .mf-login-page, .mf-editor-page, .mf-contributor-login-route, .mf-contributor-login-v2,
    .mf-contributor-dashboard, .mf-editorial-console)) main#main-content:not(.layout-mosaic) {
    padding: var(--mf-public-page-inset) var(--mf-public-gutter) !important;
  }

  html:root body.site-app-ready.mf-page-shell[data-mf-compact-page] main#main-content:not(.layout-mosaic, .cv-root, .mf-map-public, .mf-route-map) {
    width: min(100%, var(--mf-public-frame)) !important;
    max-width: var(--mf-public-frame) !important;
    margin-inline: auto !important;
  }
}

/* Training has a separate shell. Reuse the spacing rhythm inside its existing sections. */
body[data-compact-page] main#main-content > :is(section, .subsection, .compact-page-shell) {
  margin-block-end: var(--mf-public-gap);
}

@media (max-width: 700px) {
  main.stl-section[style*="display:flex"]:has(> .mf-v44-strip) {
    flex-direction: column;
    align-items: stretch !important;
  }
}

html body.mf-shell-unified main :is(
  .mf-hbcu-section,
  .mf-mc-section,
  .mf-ocn--podcast,
  .mf-stats-intro,
  .mf-stats-frame,
  .mf-shape-feature--afcon,
  .mf-africa-edition-rail,
  .citysc-source-strip,
  .mf-event-schedule-main,
  .mf-article-follow,
  .mf-ref-reading-tools
),
html body.mf-shell-unified main.mf-media-studio > section {
  padding-block: var(--mf-public-panel-space) !important;
}

html body.mf-shell-unified main :is(
  .mf-core-hero__grid,
  .citysc-source-strip__grid,
  .mf-network-contributor__card
) {
  padding-block: var(--mf-public-panel-space) !important;
  gap: var(--mf-public-gap);
}

html body.mf-shell-unified main.mf-d2-home-main .mf-d2-home-content {
  padding-block: var(--mf-public-gap);
  row-gap: var(--mf-public-gap);
}

html body.mf-shell-unified main.mf-d2-home-main .desk-panel {
  padding-block: clamp(8px, .9vw, 12px);
}

html body.mf-shell-unified main > :is(.desk-section,.usx-section,.vd-section,.vd-reference-board) {
  padding-block: var(--mf-public-panel-space) !important;
}

html body.mf-shell-unified main :is(.mf-network-canada,.mf-network-policy) {
  margin-block: var(--mf-public-gap);
  padding-block: var(--mf-public-panel-space);
}

html body.mf-shell-unified main.newsstand .ns-shell {
  padding-block-end: var(--mf-public-wide-inset);
}

html body.mf-page-template main.mf-template-main {
  --mf-page-gap: var(--mf-public-gap);
  --mf-shell-section-space: var(--mf-public-panel-space);
}

html body.mf-page-template main.mf-template-main .mf-template-panel {
  padding-block: var(--mf-public-panel-space);
}

html body.mf-page-template main.mf-template-main .mf-template-hero {
  padding-block: var(--mf-public-wide-inset);
}

/* The standalone homepage and STL hub use the same spacing without a shared shell. */
main.modules.layout-mosaic {
  row-gap: var(--mf-public-gap);
  padding-block: var(--mf-public-page-inset);
}

body.stl-soccer-hub-page > main.shell > :is(.hero,.top-grid,.audience-grid,.coverage-grid,.people-grid) {
  margin-block-end: var(--mf-public-gap);
}

@media (min-width: 64rem) {
  body.stl-soccer-hub-page > .fixture-rail.shell {
    width: min(calc(100% - 24px), var(--mf-public-frame));
    max-inline-size: var(--mf-public-frame);
  }
}

@media (min-width: 94rem) {
  .preview-outer > .preview:has(> main.modules.layout-mosaic) {
    max-inline-size: var(--mf-public-frame);
  }
}

[data-home-network-highlights] .mf-home-network-mark {
  display: inline-block;
  inline-size: 22px;
  margin-inline-end: 5px;
  object-fit: contain;
  vertical-align: -.17em;
}
