/* Theme-owned compatibility layer for persisted pre-theme editorial markup.
 * Loaded only when a singular Page/Post contains legacy .mg-* components.
 * Uses the current mgt design tokens so old content stays visually consistent
 * without restoring presentation ownership to the retired redesign plugin.
 */

body.mgt-legacy-components {
  --mg-ink: var(--mgt-ink, #17201c);
  --mg-copy: #34433c;
  --mg-teal: var(--mgt-forest, #09664d);
  --mg-teal-dark: var(--mgt-forest-deep, #064b39);
  --mg-mint: var(--mgt-mint, #e4f2eb);
  --mg-sand: #f3f1e9;
  --mg-sun: var(--mgt-sun, #f3c651);
  --mg-line: var(--mgt-line, #dfe4df);
  --mg-white: var(--mgt-paper, #fff);
  --mg-shadow: var(--mgt-shadow, 0 24px 64px rgba(17, 32, 25, 0.12));
  --mg-shadow-soft: var(--mgt-shadow-sm, 0 8px 26px rgba(17, 32, 25, 0.07));
  --mg-radius: var(--mgt-radius-lg, 1.65rem);
  --mg-reading: var(--wp--style--global--content-size, 760px);
}

body.mgt-legacy-components .mgt-main,
body.mgt-legacy-components .wp-block-post-content {
  width: 100%;
  max-width: none;
}

body.mgt-legacy-components .mg-shell {
  width: min(var(--mgt-wide, 1280px), calc(100% - (2 * var(--mgt-gutter, 24px))));
  margin-inline: auto;
}

/* Wide shells carry the visual composition; prose keeps the theme reading measure. */
body.mgt-legacy-components :where(
  .mg-hero-grid > div > p:not(.mg-eyebrow),
  .mg-section > .mg-shell > p,
  .mg-section-head > p:not(.mg-eyebrow),
  .mg-notice > p,
  .mg-toc details > p,
  .mg-day-navigation > p,
  .mg-transit-times > p,
  .mg-budget-calculator > p,
  .mg-cta > p,
  .mg-check-list
) {
  max-width: min(100%, var(--mg-reading));
}

body.mgt-legacy-components :where(.mg-hero, .mg-compact-hero, .mg-section) {
  position: relative;
  width: 100%;
}

body.mgt-legacy-components .mg-hero {
  overflow: hidden;
  padding: clamp(3.5rem, 7vw, 6.5rem) 0;
  background:
    radial-gradient(circle at 8% 12%, rgba(243, 198, 81, 0.18), transparent 34%),
    radial-gradient(circle at 92% 88%, rgba(9, 102, 77, 0.14), transparent 38%),
    var(--mg-sand);
}

body.mgt-legacy-components .mg-hero-grid,
body.mgt-legacy-components .mg-compact-hero-grid,
body.mgt-legacy-components .mg-showcase {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(22rem, 0.98fr);
  gap: clamp(2rem, 6vw, 5rem);
  align-items: center;
}

body.mgt-legacy-components .mg-compact-hero {
  padding: clamp(3.2rem, 7vw, 5.5rem) 0;
  background: var(--mg-sand);
}

body.mgt-legacy-components :where(.mg-hero h1, .mg-compact-hero h1) {
  max-width: 16ch;
  margin: 0 0 1.2rem;
  color: var(--mg-ink);
  font-size: clamp(2.35rem, 1.8rem + 2.5vw, 4.6rem);
  line-height: 1;
  letter-spacing: -0.055em;
}

body.mgt-legacy-components :where(.mg-hero-lead, .mg-compact-hero p) {
  max-width: 44rem;
  margin: 0;
  color: #43534b;
  font-size: clamp(1rem, .95rem + .28vw, 1.18rem);
  line-height: 1.58;
}

body.mgt-legacy-components .mg-eyebrow,
body.mgt-legacy-components .mg-kicker {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  margin: 0 0 .8rem;
  color: var(--mg-teal-dark);
  font-size: .73rem;
  font-weight: 820;
  letter-spacing: .1em;
  line-height: 1.4;
  text-transform: uppercase;
}

body.mgt-legacy-components .mg-eyebrow::before {
  width: .5rem;
  height: .5rem;
  flex: 0 0 auto;
  border-radius: 50%;
  content: "";
  background: var(--mg-sun);
  box-shadow: 0 0 0 .28rem rgba(243, 198, 81, .18);
}

body.mgt-legacy-components :where(.mg-hero-media, .mg-compact-hero figure, .mg-showcase-media) {
  margin: 0;
}

body.mgt-legacy-components :where(.mg-hero-media img, .mg-compact-hero img, .mg-showcase-media img, .mg-article-cover img, .mg-article-photo img) {
  display: block;
  width: 100%;
  border-radius: var(--mg-radius);
  object-fit: cover;
}

body.mgt-legacy-components :where(.mg-hero-media img, .mg-compact-hero img) {
  aspect-ratio: 4 / 3;
  box-shadow: var(--mg-shadow-soft);
}

body.mgt-legacy-components :where(.mg-article-cover img, .mg-article-photo img, .mg-showcase-media img) {
  aspect-ratio: 16 / 9;
  box-shadow: none;
}

body.mgt-legacy-components .mg-photo-credit {
  margin: .6rem .25rem 0;
  color: var(--mgt-muted, #66716b);
  font-size: .72rem;
  line-height: 1.4;
}

body.mgt-legacy-components .mg-section {
  padding: clamp(3rem, 5vw, 4rem) 0;
  background: var(--mgt-paper, #fff);
}

body.mgt-legacy-components .mg-section--tint,
body.mgt-legacy-components .mg-section--sand {
  background: var(--mgt-paper, #fff);
}

body.mgt-legacy-components .mg-section-head {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(18rem, .85fr);
  gap: clamp(1.5rem, 4vw, 3.5rem);
  align-items: end;
  margin-bottom: clamp(1.5rem, 3vw, 2rem);
}
body.mgt-legacy-components .mg-section-head .mg-eyebrow { grid-column: 1 / -1; margin-bottom: -.4rem; }
body.mgt-legacy-components .mg-section-head h2 {
  max-width: 18ch;
  margin: 0;
  font-size: clamp(1.75rem, 1.42rem + 1.3vw, 2.65rem);
}
body.mgt-legacy-components .mg-section-head > p:not(.mg-eyebrow) { margin: 0; color: var(--mgt-muted, #66716b); }

body.mgt-legacy-components :where(.mg-actions, .mg-chip-row, .mg-route-card-meta) {
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
}
body.mgt-legacy-components .mg-actions { margin-top: 1.4rem; }
body.mgt-legacy-components .mg-chip-row { margin-top: 1rem; }

body.mgt-legacy-components .mg-chip,
body.mgt-legacy-components .mg-route-card-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 2.15rem;
  padding: .42rem .76rem;
  border: 1px solid var(--mg-line);
  border-radius: 999px;
  background: rgba(255,255,255,.78);
  color: var(--mg-teal-dark);
  font-size: .8rem;
  font-weight: 720;
}

body.mgt-legacy-components .mg-button,
body.mgt-legacy-components .wp-block-button__link {
  display: inline-flex;
  min-height: 3rem;
  align-items: center;
  justify-content: center;
  padding: .78rem 1.3rem !important;
  border-radius: .75rem !important;
  font-weight: 760;
  line-height: 1.2;
  text-decoration: none;
}
body.mgt-legacy-components .mg-button--primary { background: var(--mg-teal); color: #fff; }
body.mgt-legacy-components .mg-button--primary:hover { background: var(--mg-teal-dark); color: #fff; }
body.mgt-legacy-components .mg-button--ghost { border: 1px solid var(--mg-line); background: #fff; color: var(--mg-ink); }
body.mgt-legacy-components .mg-button--light { background: #fff; color: var(--mg-ink); }

body.mgt-legacy-components :where(.mg-feature-grid, .mg-step-grid, .mg-planned-grid, .mg-directory-grid, .mg-compare) {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}
body.mgt-legacy-components .mg-route-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }

body.mgt-legacy-components :where(.mg-feature-card, .mg-step-card, .mg-planned-card, .mg-route-card, .mg-compare > article, .mg-directory-grid > article) {
  min-width: 0;
  border: 1px solid var(--mg-line);
  border-radius: var(--mgt-radius, 1.1rem);
  background: #fff;
  box-shadow: none;
  transition: box-shadow 160ms ease, border-color 160ms ease;
}
body.mgt-legacy-components :where(.mg-feature-card, .mg-step-card, .mg-planned-card, .mg-route-card, .mg-compare > article, .mg-directory-grid > article):hover {
  border-color: #cbd6d0;
  box-shadow: var(--mg-shadow-soft);
}
body.mgt-legacy-components :where(.mg-feature-card, .mg-step-card, .mg-planned-card, .mg-compare > article, .mg-directory-grid > article) { padding: 1.25rem; }
body.mgt-legacy-components .mg-route-card { overflow: hidden; }
body.mgt-legacy-components .mg-route-card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
body.mgt-legacy-components .mg-route-card-body { padding: 1.35rem; }
body.mgt-legacy-components :where(.mg-route-card h2, .mg-route-card h3, .mg-compare h3) { margin: 0 0 .65rem; }

body.mgt-legacy-components .mg-notice {
  margin: 1.25rem 0;
  padding: 1rem 1.15rem;
  border-left: 4px solid var(--mg-teal);
  border-radius: var(--mgt-radius-sm, .75rem);
  background: var(--mg-mint);
  color: #34433c;
}

body.mgt-legacy-components .mg-check-list {
  margin: 1rem 0 0;
  padding-left: 1.25rem;
}
body.mgt-legacy-components .mg-check-list li + li { margin-top: .45rem; }

body.mgt-legacy-components .mg-toc,
body.mgt-legacy-components .mg-day-navigation,
body.mgt-legacy-components .mg-transit-times,
body.mgt-legacy-components .mg-budget-calculator {
  margin: 1.5rem 0 2rem;
  padding: 1.25rem;
  border: 1px solid var(--mg-line);
  border-radius: var(--mgt-radius, 1.1rem);
  background: #f7faf8;
}
body.mgt-legacy-components .mg-toc-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .5rem 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
body.mgt-legacy-components .mg-toc a { font-weight: 650; text-decoration: none; }

body.mgt-legacy-components :where(.mg-table-wrap, .wp-block-table) {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--mg-line);
  border-radius: var(--mgt-radius-sm, .75rem);
  background: #fff;
}
body.mgt-legacy-components :where(.mg-table, .wp-block-table table) { width: 100%; border-collapse: collapse; }
body.mgt-legacy-components :where(.mg-table th, .mg-table td, .wp-block-table th, .wp-block-table td) {
  padding: .8rem .9rem;
  border-bottom: 1px solid var(--mg-line);
  text-align: left;
  vertical-align: top;
}
body.mgt-legacy-components :where(.mg-table th, .wp-block-table th) { background: var(--mg-mint); color: var(--mg-ink); }

body.mgt-legacy-components .mg-cta {
  overflow: hidden;
  padding: clamp(2.2rem, 6vw, 4.5rem);
  border-radius: var(--mgt-radius-lg, 1.65rem);
  background: var(--mgt-dark, #111a16);
  color: #dbe6e0;
}
body.mgt-legacy-components .mg-cta :where(h2,h3) { color: #fff; }
body.mgt-legacy-components .mg-cta h2 { max-width: 18ch; margin-bottom: .8rem; font-size: clamp(1.9rem, 1.55rem + 1.5vw, 3rem); }

body.mgt-legacy-components .mg-article-cover,
body.mgt-legacy-components .mg-article-photo { margin: 2rem 0; }

@media (max-width: 1024px) {
  body.mgt-legacy-components :where(.mg-hero-grid, .mg-compact-hero-grid, .mg-showcase) { grid-template-columns: 1fr; }
  body.mgt-legacy-components .mg-section-head { grid-template-columns: 1fr; }
  body.mgt-legacy-components .mg-section-head .mg-eyebrow { grid-column: auto; }
  body.mgt-legacy-components :where(.mg-feature-grid, .mg-step-grid, .mg-planned-grid, .mg-directory-grid, .mg-compare) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 767px) {
  body.mgt-legacy-components .mg-shell { width: min(100% - 2rem, var(--mgt-wide, 1280px)); }
  body.mgt-legacy-components :where(.mg-feature-grid, .mg-step-grid, .mg-planned-grid, .mg-directory-grid, .mg-compare, .mg-route-grid, .mg-toc-list) { grid-template-columns: 1fr; }
  body.mgt-legacy-components .mg-actions { align-items: stretch; }
  body.mgt-legacy-components .mg-actions .mg-button { width: 100%; }
  body.mgt-legacy-components :where(.mg-hero, .mg-compact-hero) { padding-block: 3rem; }
  body.mgt-legacy-components .mg-section { padding-block: 2.625rem; }
  body.mgt-legacy-components :where(.mg-hero h1, .mg-compact-hero h1) { font-size: clamp(2.15rem, 11vw, 3.4rem); }
}

@media (prefers-reduced-motion: reduce) {
  body.mgt-legacy-components .mg-button,
  body.mgt-legacy-components :where(.mg-feature-card, .mg-step-card, .mg-planned-card, .mg-route-card, .mg-compare > article, .mg-directory-grid > article) {
    transition: none;
  }
}
