/*
 * FM Business — shared V2 chrome (masthead + drawer).
 *
 * Used by every V2 page (homepage + all templates) so the publication has a
 * single masthead/drawer identity. Page-specific layout lives in home.css /
 * the template stylesheets.
 */

/* ---------- Sticky editorial island header ----------
 * The masthead is a dark editorial OBJECT, not a full-width news topbar:
 * sticky, offset from the viewport edges, aligned to the 1280px editorial
 * grid, soft rounded slab. It compacts slightly after scroll and hides on
 * scroll-down / reveals on scroll-up. Never covers content: it stays in flow,
 * so the page begins below it.
 */
.fm-home-header {
  position: sticky;
  top: var(--fm-island-top);
  z-index: 50;
  width: min(calc(100% - (var(--fm-island-side) * 2)), var(--fm-island-max));
  margin: var(--fm-island-top) auto 0;
  height: var(--fm-island-h);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 var(--fm-island-pad);
  background: var(--fm-surface-dark);
  color: var(--fm-on-dark);
  border: var(--fm-line-hairline) solid rgba(251, 250, 246, 0.14);
  border-radius: var(--fm-island-radius);
  transition: top var(--fm-motion-base) var(--fm-ease),
              height var(--fm-motion-base) var(--fm-ease),
              box-shadow var(--fm-motion-base) var(--fm-ease);
}
.fm-home-header.is-scrolled {
  height: var(--fm-island-h-compact);
  box-shadow: 0 12px 30px rgba(18, 22, 31, 0.16);
}
/* fully offscreen (island height + offset + clearance) */
.fm-home-header.is-hidden { top: calc(var(--fm-island-top) - var(--fm-island-h) - 48px); }

.fm-home-header__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  font-family: var(--fm-font-disp);
  font-size: 25px;
  font-weight: var(--fm-weight-bold);
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--fm-on-dark);
  text-decoration: none;
  white-space: nowrap;
}
.fm-home-header__brand::before {
  content: '';
  width: 10px;
  height: 10px;
  background: var(--fm-color-signal);
  flex: 0 0 auto;
}

.sh-header__nav { display: none; gap: 18px; margin-left: auto; align-items: center; }
.sh-header__navlink {
  font-family: var(--fm-font-data);
  font-size: 11px;
  font-weight: var(--fm-weight-medium);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fm-on-dark);
  text-decoration: none;
  white-space: nowrap;
  padding: 4px 0;
}
.sh-header__navnum { color: var(--fm-color-signal); margin-right: 7px; font-weight: var(--fm-weight-semibold); }
.sh-header__navlink:hover { text-decoration: underline; text-decoration-color: var(--fm-color-signal); text-underline-offset: 5px; }
.sh-header__navlink.is-active { color: var(--fm-color-signal); }
.sh-header__navlink.is-active .sh-header__navnum { color: var(--fm-on-dark); }

.sh-burger {
  margin-left: 0;
  width: 40px;
  height: 40px;
  border: 0;
  padding: 8px;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
}
.sh-burger__bar { display: block; height: 2px; width: 100%; background: var(--fm-on-dark); }
.sh-burger:focus-visible { outline: 2px solid var(--fm-color-signal); outline-offset: 2px; }

@media (min-width: 1280px) {
  .sh-header__nav { display: flex; }
  .sh-theme { margin-left: 0; }
}
@media (min-width: 1440px) {
  .sh-header__nav { gap: 22px; }
  .sh-header__navlink { font-size: var(--fm-type-micro); letter-spacing: 0.1em; }
}
/* Mobile island: side inset stays, radius steps down (never a pill), height
   stays proportionate so the wordmark + burger keep their 40px targets. */
@media (max-width: 480px) {
  .fm-home-header { height: 62px; border-radius: 20px; }
  .fm-home-header.is-scrolled { height: 54px; }
  .fm-home-header__brand { font-size: 22px; }
}


/* ---------- Island menu (drops down FROM the island) ----------
 * The panel is positioned against the header slab: same left/right edges, same
 * ink-soft surface + paper hairline, same radius language. Two stacked slabs —
 * never a full-page overlay. Desktop: rovatok + editorial side column.
 * Mobile: single scrollable column.
 */
.sh-menu {
  position: absolute;
  inset-block-start: calc(100% + 10px);
  inset-inline: 0;
  z-index: 49;
  background: var(--fm-surface-dark);
  color: var(--fm-on-dark);
  border: var(--fm-line-hairline) solid rgba(251, 250, 246, 0.14);
  border-radius: var(--fm-island-radius);
  box-shadow: 0 18px 44px rgba(18, 22, 31, 0.22);
  padding: 24px var(--fm-island-pad) 26px;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity var(--fm-motion-base) var(--fm-ease), transform var(--fm-motion-base) var(--fm-ease);
}
.sh-menu[hidden] { display: none; }
.sh-menu.is-open { opacity: 1; transform: none; }

.sh-menu__panel { display: grid; gap: 26px; }
@media (min-width: 900px) {
  .sh-menu__panel { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 52px; align-items: start; }
}

.sh-menu__sections { list-style: none; margin: 0; padding: 0; }
.sh-menu__sections li { border-bottom: var(--fm-line-hairline) solid rgba(216, 221, 227, 0.16); }
.sh-menu__sections a {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 14px;
  padding: 10px 0;
  color: inherit;
  text-decoration: none;
}
.sh-menu__sections a:hover .sh-menu__label { text-decoration: underline; text-decoration-color: var(--fm-color-signal); text-underline-offset: 4px; }
.sh-menu__num { font-family: var(--fm-font-data); font-size: 11px; letter-spacing: 0.1em; color: var(--fm-color-signal); }
.sh-menu__label { font-family: var(--fm-font-disp); font-size: 20px; font-weight: var(--fm-weight-semibold); letter-spacing: -0.015em; line-height: 1.2; }
.sh-menu__count { font-family: var(--fm-font-data); font-size: 11px; letter-spacing: 0.06em; color: var(--fm-on-dark-muted); }

.sh-menu__aside { display: grid; gap: 18px; align-content: start; padding-top: 4px; border-top: var(--fm-line-warn) solid var(--fm-color-signal); }
.sh-menu__mission { font-family: var(--fm-font-body); font-size: 14px; line-height: 1.55; color: var(--fm-on-dark-muted); margin: 0; }
.sh-menu__utility { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.sh-menu__utility a { font-family: var(--fm-font-data); font-size: var(--fm-type-micro); letter-spacing: 0.07em; text-transform: uppercase; color: var(--fm-on-dark); text-decoration: none; }
.sh-menu__utility a:hover { text-decoration: underline; text-decoration-color: var(--fm-color-signal); text-underline-offset: 3px; }

/* Theme mode toggle — same 40px target as the burger, sits next to it. */
.sh-theme {
  flex: 0 0 auto;
  width: var(--fm-layout-control);
  height: var(--fm-layout-control);
  margin-left: auto;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: var(--fm-radius-thumb);
  color: var(--fm-on-dark);
  cursor: pointer;
  transition: color var(--fm-motion-fast) var(--fm-ease), background-color var(--fm-motion-fast) var(--fm-ease);
}
.sh-theme:hover { color: var(--fm-color-signal); background: rgba(251, 250, 246, 0.08); }
.sh-theme:focus-visible { outline: 2px solid var(--fm-color-signal); outline-offset: 2px; }
.sh-theme__icon { display: none; }
.sh-theme__icon svg { display: block; }
/* light (default): moon = "switch to dark"; dark: sun = "switch to light" */
.sh-theme__icon--moon { display: block; }
:root[data-theme="dark"] .sh-theme__icon--moon { display: none; }
:root[data-theme="dark"] .sh-theme__icon--sun { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .sh-theme__icon--moon { display: none; }
  :root:not([data-theme]) .sh-theme__icon--sun { display: block; }
}

/* Aside blocks (pages + social) — the publication's own surfaces, hairline separated. */
.sh-menu__block { display: grid; gap: 12px; padding-top: 16px; border-top: var(--fm-line-hairline) solid rgba(216, 221, 227, 0.16); }
.sh-menu__block-title { margin: 0; font-family: var(--fm-font-data); font-size: 11px; font-weight: var(--fm-weight-semibold); letter-spacing: 0.14em; text-transform: uppercase; color: var(--fm-on-dark-muted); }
.sh-menu__pages { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.sh-menu__pages a { font-family: var(--fm-font-disp); font-size: 19px; font-weight: var(--fm-weight-semibold); letter-spacing: -0.015em; color: var(--fm-on-dark); text-decoration: none; }
.sh-menu__pages a:hover { text-decoration: underline; text-decoration-color: var(--fm-color-signal); text-underline-offset: 4px; }
.sh-menu__block .fm-social__link { border-color: rgba(251, 250, 246, 0.22); }

/* Burger reflects the open state. */
.sh-burger__bar { transition: transform var(--fm-motion-fast) var(--fm-ease), opacity var(--fm-motion-fast) var(--fm-ease); }
.sh-burger[aria-expanded='true'] .sh-burger__bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.sh-burger[aria-expanded='true'] .sh-burger__bar:nth-child(2) { opacity: 0; }
.sh-burger[aria-expanded='true'] .sh-burger__bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 899px) {
  .sh-menu { padding: 20px 22px 22px; }
  .sh-menu__panel { max-height: calc(100dvh - var(--fm-island-h) - 72px); overflow-y: auto; }
  .sh-menu__label { font-size: 18px; }
}



/* ---------- V2 page container ---------- */
.fm-page-main {
  max-width: var(--fm-layout-home);
  margin: 0 auto;
  padding: 0 var(--fm-gutter);
}

/* ---------- Editorial footer — dark colophon island ----------
 * The masthead island's terminal twin: same 1280px grid width and 24px side
 * inset, same ink-soft slab + paper hairline + 26px radius. A dark editorial
 * object floating on the paper that closes every page (the front page included,
 * below the FM Briefing band) — never a full-bleed bar.
 * Rows: publication statement | contact + social/feed, the legal line
 * (copyright · domain · tagline), and the utility navigation.
 */
.fm-footer {
  width: min(calc(100% - (var(--fm-island-side) * 2)), var(--fm-island-max));
  margin: 112px auto var(--fm-island-top);
  padding: 32px var(--fm-island-pad) 26px;
  background: var(--fm-surface-dark);
  color: var(--fm-on-dark);
  border: var(--fm-line-hairline) solid rgba(251, 250, 246, 0.14);
  border-radius: var(--fm-island-radius);
}
.fm-footer__top {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 26px 56px;
  align-items: start;
}
.fm-footer__identity { display: grid; gap: 12px; justify-items: start; }
.fm-footer__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--fm-font-disp);
  font-size: 24px;
  font-weight: var(--fm-weight-bold);
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--fm-on-dark);
  text-decoration: none;
}
.fm-footer__brand::before {
  content: '';
  width: 10px;
  height: 10px;
  background: var(--fm-color-signal);
  flex: 0 0 auto;
}
.fm-footer__brand:hover { text-decoration: underline; text-decoration-color: var(--fm-color-signal); text-underline-offset: 4px; }
.fm-footer__desc {
  margin: 0;
  max-width: 60ch;
  font-family: var(--fm-font-body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--fm-on-dark-muted);
}
.fm-footer__contact { display: grid; gap: 18px; justify-items: start; }
.fm-footer__mail {
  font-family: var(--fm-font-data);
  font-size: var(--fm-type-micro);
  letter-spacing: 0.06em;
  color: var(--fm-on-dark);
  text-decoration: none;
  border-bottom: var(--fm-line-hairline) solid rgba(251, 250, 246, 0.35);
  padding-bottom: 3px;
}
.fm-footer__mail:hover { color: var(--fm-color-signal); border-bottom-color: var(--fm-color-signal); }

/* Social / feed row — 40px targets, brand glyphs in paper, signal on hover. */
.fm-social {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.fm-social__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--fm-layout-control);
  height: var(--fm-layout-control);
  border: var(--fm-line-hairline) solid rgba(251, 250, 246, 0.22);
  border-radius: var(--fm-radius-thumb);
  color: var(--fm-on-dark);
  text-decoration: none;
  transition: color var(--fm-motion-fast) var(--fm-ease),
              background-color var(--fm-motion-fast) var(--fm-ease),
              border-color var(--fm-motion-fast) var(--fm-ease);
}
.fm-social__link:hover { color: var(--fm-color-ink); background: var(--fm-color-signal); border-color: var(--fm-color-signal); }
.fm-social__link:focus-visible { outline: 2px solid var(--fm-color-signal); outline-offset: 2px; }
.fm-social__svg { display: block; }

/* Legal line — copyright · domain · tagline. */
.fm-footer__legal {
  margin-top: 28px;
  padding-top: 18px;
  border-top: var(--fm-line-hairline) solid rgba(216, 221, 227, 0.16);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 20px;
  font-family: var(--fm-font-data);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--fm-on-dark-muted);
}
.fm-footer__copy { color: var(--fm-on-dark); }
.fm-footer__domain { color: var(--fm-color-signal); letter-spacing: 0.08em; }
.fm-footer__tagline { flex: 1 1 100%; }

/* Utility navigation */
.fm-footer__nav {
  margin-top: 18px;
  padding-top: 16px;
  border-top: var(--fm-line-hairline) solid rgba(216, 221, 227, 0.16);
}
.fm-footer__links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 30px;
}
.fm-footer__links a {
  font-family: var(--fm-font-data);
  font-size: var(--fm-type-micro);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fm-on-dark);
  text-decoration: none;
}
.fm-footer__links a:hover { color: var(--fm-color-signal); text-decoration: underline; text-decoration-color: var(--fm-color-signal); text-underline-offset: 3px; }

/* Tablet / mobile: the two-column top stacks, radius steps down (never a pill). */
@media (max-width: 900px) {
  .fm-footer__top { grid-template-columns: minmax(0, 1fr); gap: 24px; }
}
@media (max-width: 480px) {
  .fm-footer { margin-top: 72px; padding: 24px 22px 22px; border-radius: 20px; }
  .fm-footer__brand { font-size: 22px; }
  .fm-footer__links { gap: 10px 20px; }
}

/* Every V2 page clips full-bleed bands without creating a scroll container
   (so position: sticky keeps working). */
.fmb-page { overflow-x: clip; }

/* ---------- Sticky island clearance for in-page anchors ---------- */
[id] { scroll-margin-top: calc(var(--fm-island-h) + var(--fm-island-top) + 24px); }

/* ---------- Back to top — fixed bottom-right chrome ---------- */
.sh-to-top {
  position: fixed;
  inset-block-end: max(24px, calc(env(safe-area-inset-bottom, 0px) + 16px));
  inset-inline-end: 24px;
  z-index: 30; /* below the sticky island header (50) */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--fm-layout-control);
  height: var(--fm-layout-control);
  padding: 0;
  border: var(--fm-line-hairline) solid var(--fm-color-grid);
  border-radius: var(--fm-radius-thumb);
  background: var(--fm-surface);
  color: var(--fm-color-ink);
  box-shadow: var(--fm-shadow-soft);
  cursor: pointer;
  transition: color var(--fm-motion-fast) var(--fm-ease), background-color var(--fm-motion-fast) var(--fm-ease), border-color var(--fm-motion-fast) var(--fm-ease);
}
.sh-to-top[hidden] { display: none; }
.sh-to-top:hover,
.sh-to-top:focus-visible {
  border-color: var(--fm-color-ink);
  background: var(--fm-color-ink);
  color: var(--fm-color-paper);
}
.sh-to-top__icon { display: inline-flex; }

@media (max-width: 480px) {
  .sh-to-top {
    inset-block-end: max(18px, calc(env(safe-area-inset-bottom, 0px) + 12px));
    inset-inline-end: 18px;
  }
}

@media print {
  .sh-to-top { display: none !important; }
}
