/* ============================================================
   Umbraco Block Grid Layout — base from Umbraco CMS static assets
   + WMCA Design System grid utilities & themes
   ============================================================ */

/* --- Block Grid → Design System Grid mapping -------------------------
   Maps Umbraco block grid to ds-grid-container / ds-css-grid-span-* (12-col).
   The design system grid uses ds-grid-container as the wrapper and
   ds-css-grid-span-{n} on children. Here we rewrite the block grid layout
   to use a 12-column grid matching the DS grid so both systems align.
   --------------------------------------------------------------- */

.umb-block-grid__layout-container {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--umb-block-grid--grid-columns, 12), minmax(0, 1fr));
  grid-auto-flow: row;
  grid-auto-rows: auto;
  column-gap: var(--umb-block-grid--column-gap, 1rem);
  row-gap: var(--umb-block-grid--row-gap, 1rem);
}

.umb-block-grid__layout-item {
  position: relative;
  display: flex;
  flex-direction: column;
  grid-column-end: span var(--umb-block-grid--item-column-span, 12);
  grid-row: span var(--umb-block-grid--item-row-span, 1);
}

.umb-block-grid__area-container,
.umb-block-grid__block--view::part(area-container) {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--umb-block-grid--area-grid-columns, var(--umb-block-grid--grid-columns, 12)), minmax(0, 1fr));
  grid-auto-flow: row;
  grid-auto-rows: auto;
  column-gap: var(--umb-block-grid--areas-column-gap, 1rem);
  row-gap: var(--umb-block-grid--areas-row-gap, 1rem);
}

.umb-block-grid__area {
  position: relative;
  display: flex;
  flex-direction: column;
  grid-column-end: span var(--umb-block-grid--area-column-span, 12);
  grid-row: span var(--umb-block-grid--area-row-span, 1);
  height: 100%;
}

.umb-block-grid__layout-item > *,
.umb-block-grid__area > * {
  flex: 1;
}

.umb-block-grid__layout-item > wmcaui-content-card,
.umb-block-grid__area > wmcaui-content-card {
  height: 100%;
  min-height: 0;
}

/* Custom layout partials (e.g. "Homepage - Top Section") wrap their areas in
   ds-css-grid-span-* divs instead of Umbraco's .umb-block-grid__area, so the
   flex sizing above never reaches the block component. The content card web
   component is inline by default and would collapse to its content width.
   Make it fill the grid cell. */
[class*='ds-css-grid-span-'] > wmcaui-content-card {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
}

/* --- Design System — Typography ------------------------------------- */

[class*=ds-] div,
[class*=ds-] span,
[class*=ds-] p,
[class*=ds-] a {
  font-size: 1rem;
  line-height: 1.5rem;
}

[class*=ds-] p,
[class*=ds-] pre,
[class*=ds-] table,
[class*=ds-] blockquote {
  margin-top: 0;
  margin-bottom: 1.5rem;
}

/* Tiptap wraps plain list item text in a paragraph. Remove the paragraph
   spacing so existing list content matches the editor's presentation. */
[class*=ds-] li > p {
  margin-top: 0;
  margin-bottom: 0;
}

[class*=ds-] li > p + p {
  margin-top: 0.5rem;
}

[class*=ds-] sub,
[class*=ds-] sup {
  position: relative;
  line-height: 0;
  vertical-align: baseline;
}

[class*=ds-] sup { top: -0.5em; }
[class*=ds-] sub { bottom: -0.25em; }

[class*=ds-] h1,
[class*=ds-] h1[class*=ds-col],
[class*=ds-] h2,
[class*=ds-] h2[class*=ds-col],
[class*=ds-] h3,
[class*=ds-] h3[class*=ds-col],
[class*=ds-] h4,
[class*=ds-] h4[class*=ds-col] {
  font-family: "DM Sans", sans-serif;
}

[class*=ds-] h1, [class*=ds-].ds-h1 {
  color: var(--color-primary);
  margin-top: 1.275rem;
  margin-bottom: 1.7rem;
  font-size: 2.44375rem;
  line-height: 2.55rem;
}
@media all and (min-width: 768px) {
  [class*=ds-] h1, [class*=ds-].ds-h1 {
    margin-top: 1.5rem;
    margin-bottom: 2rem;
    font-size: 2.875rem;
    line-height: 3rem;
  }
}

[class*=ds-] h2, [class*=ds-].ds-h2 {
  color: var(--color-primary);
  margin-top: 1.275rem;
  margin-bottom: 1.275rem;
  font-size: 1.7rem;
  line-height: 1.955rem;
  font-weight: bold;
}
@media all and (min-width: 768px) {
  [class*=ds-] h2, [class*=ds-].ds-h2 {
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
    font-size: 2rem;
    line-height: 2.3rem;
  }
}

[class*=ds-] a h2,
[class*=ds-] a .ds-h2 { color: var(--color-cta); }
[class*=ds-] a h2:visited,
[class*=ds-] a .ds-h2:visited { color: var(--color-ctaActive, #003f54); }
[class*=ds-] a h2:hover,
[class*=ds-] a .ds-h2:hover { color: var(--color-ctaActive, rgb(0, 37.8, 50.4)); }

[class*=ds-] h3, [class*=ds-].ds-h3 {
  color: inherit;
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
  font-size: 1.4375rem !important;
  line-height: 1.5rem;
  font-weight: bold;
}

[class*=ds-] h4, [class*=ds-].ds-h4 {
  color: inherit;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  font-size: 1.125rem !important;
  line-height: 1.5rem;
  font-weight: bold;
}

[class*=ds-] h4.ds-weight-400, [class*=ds-].ds-h4.ds-weight-400 { font-weight: normal; }

[class*=ds-] h5, [class*=ds-].ds-h5 {
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  font-size: 1rem;
  line-height: 1.5rem;
  font-weight: bold;
}

[class*=ds-] h6, [class*=ds-].ds-h6 {
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  font-size: 1rem;
  line-height: 1.5rem;
  font-weight: normal;
}

[class*=ds-].ds-h2 > *, [class*=ds-].ds-h3 > *, [class*=ds-].ds-h4 > *, [class*=ds-].ds-h5 > * {
  color: initial;
  font-weight: initial;
}

.ds-h1[class*=ds-],
.ds-h2[class*=ds-],
.ds-h3[class*=ds-],
.ds-h4[class*=ds-] {
  font-family: "DM Sans", sans-serif;
}

* div.ds-grid-container + p,
* div.ds-grid-container + p[class*=ds-] { margin-top: 1rem; }
* p:first-child,
* p:first-child[class*=ds-] { margin-top: 1rem; }
* h1:first-child, * h2:first-child, * h3:first-child, * h4:first-child,
* h1:first-child[class*=ds-], * h2:first-child[class*=ds-],
* h3:first-child[class*=ds-], * h4:first-child[class*=ds-] { margin-top: 0; }

/* --- Design System — CSS Custom Properties / Themes ----------------- */

:root {
  --color-primary: #f0f0f0;
  --color-secondary: #f0f0f0;
  --color-text: #f0f0f0;
  --color-background: #f0f0f0;
  --color-darkGrey: #54565b;
  --color-cta: #f0f0f0;
  --color-globalCta: #f0f0f0;
  --color-white: #ffffff;
  --color-inset: #f0f0f0;
  --color-warning: #cc6900;
  --color-error: #d03118;
}

[data-theme=wmca] {
  --color-primary: #bd4b07;
  --color-white: #ffffff;
  --color-secondary: #231f20;
  --color-secondaryActive: #fcf0e9;
  --color-secondaryBgText: #ffffff;
  --color-text: #231f20;
  --color-background: #f3f2f1;
  --color-cta: #00789d;
  --color-susTravel: #679500;
  --color-warning: #cc6900;
  --color-error: #d03118;
}

[data-theme=tfwm] {
  --color-primary: #3c1053;
  --color-white: #ffffff;
  --color-primaryHover: #5c236e;
  --color-primaryActive: #42194f;
  --color-secondary: #9d5baf;
  --color-secondaryActive: #ceadd8;
  --color-secondaryActiveDark: #775887;
  --color-secondaryHover: #e2cee7;
  --color-secondaryBgText: #ffffff;
  --color-primary-50-dark: #1e082a;
  --color-text: #231f20;
  --color-background: #f3f2f1;
  --color-cta: #1b73b1;
  --color-ctaHover: #145889;
  --color-ctaActive: #0f3f62;
  --color-ctaHoverDark: #ece7ee;
  --color-ctaActiveDark: #d8cfdd;
  --color-globalCta: #1b73b1;
  --color-inset: #ceadd8;
  --color-information: #84329b;
  --color-error: #d03118;
  --color-destructive: #d4351c;
  --color-destructiveHover: #942514;
  --color-destructiveActive: #6a1b0e;
  --color-bus: #ea0029;
  --color-railway: #e07709;
  --color-metro: #0075c9;
  --color-roads: #df1683;
  --color-susTravel: #679500;
}

[data-theme=st] {
  --color-primary: #1d7bbf;
  --color-white: #ffffff;
  --color-primaryHover: #145786;
  --color-primaryActive: #0f3e60;
  --color-secondary: #9d5baf;
  --color-secondaryHover: #e2cee7;
  --color-secondaryActive: #809da6;
  --color-secondaryActiveDark: #775887;
  --color-secondaryBgText: #ffffff;
  --color-text: #231f20;
  --color-background: #f3f2f1;
  --color-cta: #007497;
  --color-globalCta: #1b73b1;
  --color-ctaHover: #00546e;
  --color-ctaHoverDark: #ece7ee;
  --color-ctaActive: #0f3f62;
  --color-ctaActiveDark: #d8cfdd;
  --color-inset: #ceadd8;
}

[data-theme=mc] {
  --color-primary: #008080;
  --color-white: #ffffff;
  --color-primaryHover: #005959;
  --color-primaryActive: #004040;
  --color-secondary: #000000;
  --color-secondaryHover: #1a1a1a;
  --color-secondaryActive: #808080;
  --color-secondaryBgText: #ffffff;
  --color-text: #231f20;
  --color-background: #f3f2f1;
  --color-cta: #1b73b1;
  --color-globalCta: #1b73b1;
  --color-ctaActive: #0e3a59;
  --color-inset: #ceadd8;
}

[data-theme=cia] {
  --color-primary: #007399;
  --color-white: #ffffff;
  --color-primaryHover: #005959;
  --color-primaryActive: #003a4d;
  --color-secondary: #f8c77c;
  --color-secondaryHover: #fcedd9;
  --color-secondaryActive: #fce3be;
  --color-secondaryBgText: #000000;
  --color-text: #231f20;
  --color-background: #f3f2f1;
  --color-cta: #1b73b1;
  --color-globalCta: #1b73b1;
  --color-ctaHover: #145889;
  --color-ctaActive: #003e53;
  --color-inset: #009fd4;
}

[data-theme=wmre] {
  --color-primary: #076a5b;
  --color-white: #ffffff;
  --color-primaryHover: #044d3e;
  --color-primaryActive: #04352e;
  --color-secondary: #128664;
  --color-secondaryHover: #0e644f;
  --color-secondaryActive: #89c3b2;
  --color-secondaryBgText: #ffffff;
  --color-text: #231f20;
  --color-background: #f3f2f1;
  --color-cta: #1b73b1;
  --color-globalCta: #1b73b1;
  --color-ctaHover: #145889;
  --color-ctaActive: #003e53;
  --color-inset: #009fd4;
}

/* --- Design System — Grid Utilities --------------------------------- */

.ds-grid > * { box-sizing: border-box; }
.ds-grid.ds-grid--justify-between { justify-content: space-between; }
.ds-grid.ds-grid--justify-around  { justify-content: space-around; }
.ds-grid.ds-grid--justify-end    { justify-content: flex-end; }
.ds-grid.ds-grid--justify-center { justify-content: center; }
.ds-grid.ds-grid--justify-even   { justify-content: space-evenly; }
.ds-grid.ds-grid--align-center   { align-items: center; }

/* --- Design System — Layout ----------------------------------------- */

.ds-body {
  display: flex;
  min-height: 100vh;
  margin: 0;
  flex-direction: column;
  align-items: stretch;
}

.ds-container {
  width: 100%;
  max-width: 992px;
  margin: auto;
}
@media screen and (max-width: 992px) {
  .ds-container { padding: 0 1rem; }
}
.ds-container--main { flex-grow: 1; }
.ds-container.wmnds-sticky {
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
}
@media screen and (max-width: 768px) {
  .ds-container.wmnds-sticky {
    position: initial;
    max-height: fit-content;
  }
}

.ds-full-width { width: 100%; }

/* --- Design System — Text Alignment / Float ------------------------- */

.ds-text-align-left   { text-align: left; }
.ds-text-align-center { text-align: center; }
.ds-text-align-right  { text-align: right; }

.ds-float-left  { float: left; }
.ds-float-right { float: right; }

/* --- Design System — Margin Utilities ------------------------------- */

body { margin: 0; }

.ds-m-xs  { margin: 0.25rem; }
.ds-m-xsm { margin: 0.5rem; }
.ds-m-sm  { margin: 0.75rem; }
.ds-m-sm-sm-none { margin: 0; }
.ds-m-md  { margin: 1rem; }
.ds-m-lg  { margin: 2rem; }
.ds-m-xl  { margin: 3rem; }
.ds-m-none { margin: 0 !important; }

.ds-m-t-xs  { margin-top: 0.25rem; }
.ds-m-t-xsm { margin-top: 0.5rem; }
.ds-m-t-sm  { margin-top: 0.75rem; }
.ds-m-t-sm-sm-none { margin-top: 0; }
.ds-m-t-md  { margin-top: 1rem; }
.ds-m-t-lg  { margin-top: 2rem; }
.ds-m-t-xl  { margin-top: 3rem; }
.ds-m-t-none { margin-top: 0 !important; }

.ds-m-r-xs  { margin-right: 0.25rem; }
.ds-m-r-xsm { margin-right: 0.5rem; }
.ds-m-r-sm  { margin-right: 0.75rem; }
.ds-m-r-sm-sm-none { margin-right: 0; }
.ds-m-r-md  { margin-right: 1rem; }
.ds-m-r-lg  { margin-right: 2rem; }
.ds-m-r-xl  { margin-right: 3rem; }
.ds-m-r-none { margin-right: 0 !important; }

.ds-m-b-xs  { margin-bottom: 0.25rem; }
.ds-m-b-xsm { margin-bottom: 0.5rem; }
.ds-m-b-sm  { margin-bottom: 0.75rem; }
.ds-m-b-sm-sm-none { margin-bottom: 0; }
.ds-m-b-md  { margin-bottom: 1rem; }
.ds-m-b-lg  { margin-bottom: 2rem; }
.ds-m-b-xl  { margin-bottom: 3rem; }
.ds-m-b-none { margin-bottom: 0 !important; }

.ds-m-l-xs  { margin-left: 0.25rem; }
.ds-m-l-xsm { margin-left: 0.5rem; }
.ds-m-l-sm  { margin-left: 0.75rem; }
.ds-m-l-sm-sm-none { margin-left: 0; }
.ds-m-l-md  { margin-left: 1rem; }
.ds-m-l-lg  { margin-left: 2rem; }
.ds-m-l-xl  { margin-left: 3rem; }
.ds-m-l-none { margin-left: 0 !important; }

/* --- Design System — Padding Utilities ------------------------------ */

.ds-p-xs  { padding: 0.25rem; }
.ds-p-xsm { padding: 0.5rem; }
.ds-p-sm  { padding: 0.75rem; }
.ds-p-sm-sm-none { padding: 0; }
.ds-p-md  { padding: 1rem; }
.ds-p-lg  { padding: 2rem; }
.ds-p-xl  { padding: 3rem; }
.ds-p-none { padding: 0 !important; }

.ds-p-t-xs  { padding-top: 0.25rem; }
.ds-p-t-xsm { padding-top: 0.5rem; }
.ds-p-t-sm  { padding-top: 0.75rem; }
.ds-p-t-sm-sm-none { padding-top: 0; }
.ds-p-t-md  { padding-top: 1rem; }
.ds-p-t-lg  { padding-top: 2rem; }
.ds-p-t-xl  { padding-top: 3rem; }
.ds-p-t-none { padding-top: 0 !important; }

.ds-p-r-xs  { padding-right: 0.25rem; }
.ds-p-r-xsm { padding-right: 0.5rem; }
.ds-p-r-sm  { padding-right: 0.75rem; }
.ds-p-r-sm-sm-none { padding-right: 0; }
.ds-p-r-md  { padding-right: 1rem; }
.ds-p-r-lg  { padding-right: 2rem; }
.ds-p-r-xl  { padding-right: 3rem; }
.ds-p-r-none { padding-right: 0 !important; }

.ds-p-b-xs  { padding-bottom: 0.25rem; }
.ds-p-b-xsm { padding-bottom: 0.5rem; }
.ds-p-b-sm  { padding-bottom: 0.75rem; }
.ds-p-b-sm-sm-none { padding-bottom: 0; }
.ds-p-b-md  { padding-bottom: 1rem; }
.ds-p-b-lg  { padding-bottom: 2rem; }
.ds-p-b-xl  { padding-bottom: 3rem; }
.ds-p-b-none { padding-bottom: 0 !important; }

.ds-p-l-xs  { padding-left: 0.25rem; }
.ds-p-l-xsm { padding-left: 0.5rem; }
.ds-p-l-sm  { padding-left: 0.75rem; }
.ds-p-l-sm-sm-none { padding-left: 0; }
.ds-p-l-md  { padding-left: 1rem; }
.ds-p-l-lg  { padding-left: 2rem; }
.ds-p-l-xl  { padding-left: 3rem; }
.ds-p-l-none { padding-left: 0 !important; }

/* --- Design System — Visibility ------------------------------------- */

@media screen and (max-width: 768px) {
  .ds-hide-mobile { display: none !important; }
}
@media screen and (min-width: 768px) {
  .ds-hide-desktop { display: none !important; }
}
.ds-hide { display: none !important; }

.visible-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}
.visible-hidden:focus {
  position: absolute;
  width: auto;
  height: auto;
  overflow: auto;
  clip: auto;
}

/* --- Design System — Borders ---------------------------------------- */

.bdr-primary       { border: 2px solid var(--color-primary); }
.bdr-primary-left  { border-left: 2px solid var(--color-primary); }
.bdr-primary-right { border-right: 2px solid var(--color-primary); }
.bdr-primary-bottom { border-bottom: 2px solid var(--color-primary); }

.bdr-white         { border: 2px solid #ffffff; }
.bdr-white-left    { border-left: 2px solid #ffffff; }
.bdr-white-right   { border-right: 2px solid #ffffff; }
.bdr-white-bottom  { border-bottom: 2px solid #ffffff; }

.bdr-gray          { border: 2px solid var(--color-secondary); }
.bdr-gray-left     { border-left: 2px solid var(--color-secondary); }
.bdr-gray-right    { border-right: 2px solid var(--color-secondary); }
.bdr-gray-bottom   { border-bottom: 2px solid var(--color-secondary); }

.bdr-transparent         { border: 2px solid transparent; }
.bdr-transparent-left    { border-left: 2px solid transparent; }
.bdr-transparent-right   { border-right: 2px solid transparent; }
.bdr-transparent-bottom  { border-bottom: 2px solid transparent; }

/* --- Design System — Backgrounds ------------------------------------ */

.bg-default              { background-color: var(--color-background); }
.bg-white                { background-color: #ffffff; }
.bg-secondary            { background-color: var(--color-secondary); }
.bg-planned-disruption   { background-color: var(--color-plannedDisruption); }
.bg-disabled-elements    { background-color: var(--color-disable); }
.bg-transparent          { background-color: transparent; }


.ds-grid [class*=ds-col-] {
    display: inline-block;
    zoom: 1;
    letter-spacing: normal;
    word-spacing: normal;
    text-rendering: auto;
    vertical-align: top;
}

.ds-html
 {
    min-width: 320px;
    overflow-y: auto;
    background: var(--color-background);
    scroll-behavior: smooth;
}

/* --- Block Component Wrappers --------------------------------------- */

.layout-item {
  position: relative;
  width: 100%;
}

.py-3 {
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.hero,
.homepage-grid-hero {
  position: relative;
  width: 100%;
}

.what-we-do {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1.5rem;
}

/* Icons inside the what-we-do links; inline in main.cshtml previously,
   moved here so the back-office block preview gets the same styles. */
.what-we-do svg {
    display: block;
    width: 50px;
    height: 50px;
    fill: var(--color-primary, #bd4b07);
}

/* The accordion component sets its internal .ds-accordion margin-bottom to 0,
   so add the block spacing on the host instead. */
wmcaui-accordion {
    display: block;
    margin-bottom: 1rem;
}
