/*
 * Traina & Partners - base styles: reset, typography, layout grid.
 * Requires tokens.css. Flexbox only (mirrors Divi 5 sections, rows and columns).
 */

/* ---------------------------------------------------------------------------
 * Reset
 * ------------------------------------------------------------------------ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + var(--space-2));
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-body);
  font-family: var(--font-body);
  font-size: var(--text-body);
  font-weight: var(--weight-body);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img,
svg,
video {
  display: block;
  max-width: 100%;
  height: auto;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

hr {
  border: 0;
  border-top: 1px solid var(--color-border);
  margin: var(--space-4) 0;
}

/* ---------------------------------------------------------------------------
 * Typography
 * ------------------------------------------------------------------------ */
h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0 0 var(--space-2);
  font-family: var(--font-heading);
  font-weight: var(--weight-heading);
  line-height: var(--leading-heading);
  letter-spacing: var(--tracking-heading);
  color: var(--color-heading);
  overflow-wrap: break-word;
}

h1 {
  font-size: var(--text-h1);
}

h2 {
  font-size: var(--text-h2);
}

h3 {
  font-size: var(--text-h3);
  line-height: var(--leading-subheading);
}

h4,
h5,
h6 {
  font-size: var(--text-h4);
  font-weight: var(--weight-heading-light);
  line-height: var(--leading-subheading);
}

.display {
  font-size: var(--text-display);
  line-height: var(--leading-display);
}

/* Visual heading classes: use when the document outline needs a lower level than the look. */
.h1,
.h2,
.h3,
.h4 {
  display: block;
  margin: 0 0 var(--space-2);
  font-family: var(--font-heading);
  font-weight: var(--weight-heading);
  line-height: var(--leading-heading);
  letter-spacing: var(--tracking-heading);
  color: var(--color-heading);
}

.h1 {
  font-size: var(--text-h1);
}

.h2 {
  font-size: var(--text-h2);
}

.h3 {
  font-size: var(--text-h3);
  line-height: var(--leading-subheading);
}

.h4 {
  font-size: var(--text-h4);
  font-weight: var(--weight-heading-light);
  line-height: var(--leading-subheading);
}

p,
ul,
ol {
  margin: 0 0 var(--space-2);
}

ul,
ol {
  padding-left: 1.25rem;
}

li + li {
  margin-top: var(--space-1);
}

.lead {
  font-size: var(--text-lead);
  line-height: 1.5;
}

small,
.small {
  font-size: var(--text-small);
}

strong,
b {
  font-weight: var(--weight-body-strong);
  color: var(--color-heading);
}

.eyebrow {
  margin: 0 0 var(--space-1);
  font-size: var(--text-small);
  font-weight: var(--weight-body-strong);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--color-primary);
}

a {
  color: var(--color-primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition: color var(--transition), text-decoration-color var(--transition);
}

a:hover {
  color: var(--color-accent);
  text-decoration-thickness: 2px;
}

.text-center {
  text-align: center;
}

/* Sections on dark backgrounds override heading and body colours. */
.section--dark,
.section--dark h1,
.section--dark h2,
.section--dark h3,
.section--dark h4,
.section--dark .h1,
.section--dark .h2,
.section--dark .h3,
.section--dark .h4,
.section--dark strong {
  color: var(--color-white);
}

.section--dark {
  color: var(--color-on-dark);
}

.section--dark a {
  color: var(--color-white);
}

.section--dark a:hover {
  color: var(--color-bg-alt);
}

.section--dark .eyebrow {
  color: var(--color-bg-alt);
}

/* ---------------------------------------------------------------------------
 * Focus and accessibility helpers
 * ------------------------------------------------------------------------ */
:focus {
  outline: none;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: var(--radius);
}

.section--dark :focus-visible {
  box-shadow: var(--focus-on-dark);
}

.skip-link {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 200;
  padding: var(--space-1) var(--space-2);
  background: var(--color-primary-dark);
  color: var(--color-white);
  font-weight: var(--weight-body-strong);
  text-decoration: none;
  border-radius: 0 0 var(--radius) 0;
  transform: translateY(-120%);
}

.skip-link:focus,
.skip-link:focus-visible {
  transform: translateY(0);
  color: var(--color-white);
}

.visually-hidden {
  position: absolute !important; /* Beats any positioning on the element: this is the standard sr-only pattern. */
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important; /* Honour the OS setting: overrides every component transition. */
    animation-duration: 0.01ms !important; /* Same reason as above. */
    animation-iteration-count: 1 !important; /* Same reason as above. */
  }
}

/* ---------------------------------------------------------------------------
 * Layout: section, row, columns (Divi 5: Section > Row > Column)
 * ------------------------------------------------------------------------ */
.section {
  padding: var(--section-y) 0;
}

.section--tight {
  padding: var(--space-6) 0;
}

.section--alt {
  background: var(--color-bg-alt);
}

.section--dark {
  background: var(--color-primary-dark);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--row-gap);
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.row + .row {
  margin-top: var(--row-gap);
}

/* A row nested in a column inherits the outer gutter: no second padding. */
.row .row {
  padding: 0;
}

.row--center {
  align-items: center;
}

.row--middle {
  justify-content: center;
}

.row--narrow {
  max-width: 48rem;
}

[class^="col-"],
[class*=" col-"] {
  flex: 1 1 100%;
  min-width: 0;
}

.col-1 {
  flex-basis: 100%;
}

/* Desktop column widths: 100% minus the gaps taken by the other columns. */
@media (min-width: 981px) {
  .col-1-2 {
    flex-basis: calc((100% - var(--row-gap)) / 2);
  }

  .col-1-3 {
    flex-basis: calc((100% - 2 * var(--row-gap)) / 3);
  }

  .col-2-3 {
    flex-basis: calc((100% - var(--row-gap)) * 2 / 3);
  }

  .col-1-4 {
    flex-basis: calc((100% - 3 * var(--row-gap)) / 4);
  }

  .col-3-4 {
    flex-basis: calc((100% - var(--row-gap)) * 3 / 4);
  }

  .col-1-2,
  .col-1-3,
  .col-2-3,
  .col-1-4,
  .col-3-4 {
    flex-grow: 0;
  }
}

/* Tablet: halves stay halves, thirds and quarters fold to halves, 2/3 + 1/3 stack. */
@media (min-width: 768px) and (max-width: 980px) {
  .col-1-2,
  .col-1-3,
  .col-1-4 {
    flex: 0 1 calc((100% - var(--row-gap)) / 2);
  }

  .col-2-3,
  .col-3-4 {
    flex-basis: 100%;
  }

  /* An orphan third card spans the whole second line instead of leaving a hole.
   * Divi 5: Row column layout on tablet = 1/2 + 1/2 + full. */
  .row > .col-1-3:nth-child(3):last-child {
    flex-basis: 100%;
  }
}

/* Utility: equal-height cards inside a column. */
.col-stretch {
  display: flex;
  flex-direction: column;
}

.col-stretch > * {
  flex: 1 1 auto;
}
