/* SeLAVIA interaction layer
 * Motion, sticky navigation, hover feedback and the Training accordion.
 * Colours come from the site's own global style tokens (navy / amber).
 * Applies on top of the Extendable theme; no theme files are modified.
 */

:root {
  --sl-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --sl-rise: 18px;
  --sl-dur: 0.6s;
  --sl-accent: var(--wp--preset--color--primary, #E5A62E);
  --sl-ink: var(--wp--preset--color--foreground, #F5F7FA);
  --sl-ground: var(--wp--preset--color--background, #0B1F3A);
  --sl-surface: var(--wp--preset--color--tertiary, #122B4F);
}

html {
  scroll-behavior: smooth;
}

/* Anchor targets clear the sticky header */
main [id] {
  scroll-margin-top: 104px;
}

/* ------------------------------------------------------------------
   1. Scroll reveal
   Elements are pre-hidden only when the loader script has set .sl-js,
   so with JS off, or if the script never runs, everything stays visible.
   ------------------------------------------------------------------ */
/* The structural half of each selector sits inside :where() so it carries no
   specificity of its own. The .sl-in rule below is then free to win. */
html.sl-js :where(main .wp-block-columns > .wp-block-column),
html.sl-js :where(main .is-layout-grid > .wp-block-group),
html.sl-js :where(main .wp-block-group.alignfull > .wp-block-group > *:not(.wp-block-columns):not(.is-layout-grid):not(.sl-accordion)),
html.sl-js :where(main .sl-accordion > .wp-block-details) {
  opacity: 0;
  transform: translate3d(0, var(--sl-rise), 0);
  transition:
    opacity var(--sl-dur) var(--sl-ease),
    transform var(--sl-dur) var(--sl-ease);
  transition-delay: var(--sl-delay, 0ms);
}

html.sl-js main .sl-in {
  opacity: 1;
  transform: none;
}

/* ------------------------------------------------------------------
   2. Sticky, condensing header
   ------------------------------------------------------------------ */
.wp-site-blocks > header.wp-block-template-part {
  position: sticky;
  top: 0;
  z-index: 100;
  transition:
    background-color 0.3s var(--sl-ease),
    box-shadow 0.3s var(--sl-ease);
}

html.sl-scrolled .wp-site-blocks > header.wp-block-template-part {
  background-color: color-mix(in srgb, var(--sl-ground) 92%, transparent);
  -webkit-backdrop-filter: saturate(150%) blur(10px);
  backdrop-filter: saturate(150%) blur(10px);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--sl-ink) 14%, transparent);
}

@supports not (background-color: color-mix(in srgb, red 50%, transparent)) {
  html.sl-scrolled .wp-site-blocks > header.wp-block-template-part {
    background-color: rgba(11, 31, 58, 0.94);
    box-shadow: 0 1px 0 rgba(245, 247, 250, 0.14);
  }
}

/* Top level navigation links get an amber underline on hover and focus */
.wp-block-navigation__container > .wp-block-navigation-item > .wp-block-navigation-item__content {
  position: relative;
}

.wp-block-navigation__container > .wp-block-navigation-item > .wp-block-navigation-item__content::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -6px;
  height: 2px;
  background: var(--sl-accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.28s var(--sl-ease);
}

.wp-block-navigation__container > .wp-block-navigation-item:hover > .wp-block-navigation-item__content::after,
.wp-block-navigation__container > .wp-block-navigation-item > .wp-block-navigation-item__content:focus-visible::after,
.wp-block-navigation__container > .current-menu-item > .wp-block-navigation-item__content::after {
  transform: scaleX(1);
}

/* The underline is noise inside the mobile overlay menu */
.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content::after {
  display: none;
}

/* ------------------------------------------------------------------
   3. Card and button feedback
   Depth stays in the two navy steps: lift plus an amber hairline,
   never a drop shadow.
   ------------------------------------------------------------------ */
.sl-card {
  transition:
    transform 0.35s var(--sl-ease),
    outline-color 0.35s var(--sl-ease);
  outline: 1px solid transparent;
  outline-offset: 0;
}

.sl-card:hover,
.sl-card:focus-within {
  transform: translateY(-4px);
  outline-color: color-mix(in srgb, var(--sl-accent) 55%, transparent);
}

@supports not (outline-color: color-mix(in srgb, red 50%, transparent)) {
  .sl-card:hover,
  .sl-card:focus-within {
    outline-color: rgba(229, 166, 46, 0.55);
  }
}

.sl-card .wp-block-image {
  overflow: hidden;
  border-radius: var(--wp--preset--spacing--20, 16px);
}

.sl-card .wp-block-image img {
  transition: transform 0.6s var(--sl-ease);
}

.sl-card:hover .wp-block-image img {
  transform: scale(1.04);
}

.wp-block-button__link {
  transition:
    transform 0.18s var(--sl-ease),
    background-color 0.25s var(--sl-ease),
    border-color 0.25s var(--sl-ease),
    color 0.25s var(--sl-ease);
}

.wp-block-button__link:hover {
  transform: translateY(-2px);
}

.wp-block-button__link:active {
  transform: translateY(0);
}

/* ------------------------------------------------------------------
   4. Training page: logo plate and course accordion
   ------------------------------------------------------------------ */
.sl-logo-plate {
  display: inline-block;
  background: #FFFFFF;
  border-radius: 16px;
  padding: 18px 22px;
  margin: 0;
}

.sl-logo-plate img {
  display: block;
  height: auto;
}

/* The courses band sits on the lighter navy, so the panels step back down to
   the ground navy: the two tints stay one step apart either way round. */
.sl-accordion .wp-block-details {
  background: var(--sl-ground);
  border-radius: 24px;
  padding: clamp(20px, 3vw, 32px);
  border: 1px solid rgba(245, 247, 250, 0.1);
  transition: border-color 0.3s var(--sl-ease);
}

.sl-accordion .wp-block-details:hover,
.sl-accordion .wp-block-details[open] {
  border-color: color-mix(in srgb, var(--sl-accent) 45%, transparent);
}

@supports not (border-color: color-mix(in srgb, red 50%, transparent)) {
  .sl-accordion .wp-block-details:hover,
  .sl-accordion .wp-block-details[open] {
    border-color: rgba(229, 166, 46, 0.45);
  }
}

.sl-accordion .wp-block-details > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  font-weight: 600;
  line-height: 1.2;
  font-size: clamp(1.05rem, 1.4vw, 1.3rem);
}

.sl-accordion .wp-block-details > summary::-webkit-details-marker,
.sl-accordion .wp-block-details > summary::marker {
  display: none;
  content: "";
}

.sl-accordion .wp-block-details > summary::after {
  content: "";
  flex: none;
  width: 11px;
  height: 11px;
  margin-right: 4px;
  border-right: 2px solid var(--sl-accent);
  border-bottom: 2px solid var(--sl-accent);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform 0.3s var(--sl-ease);
}

.sl-accordion .wp-block-details[open] > summary::after {
  transform: rotate(-135deg) translate(-2px, -2px);
}

.sl-accordion .wp-block-details > summary:focus-visible {
  outline: 2px solid var(--sl-accent);
  outline-offset: 4px;
  border-radius: 4px;
}

.sl-accordion .wp-block-details[open] > *:not(summary) {
  animation: sl-open 0.45s var(--sl-ease) both;
}

.sl-accordion .wp-block-details > *:not(summary):first-of-type {
  margin-top: 20px;
}

@keyframes sl-open {
  from {
    opacity: 0;
    transform: translate3d(0, -6px, 0);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.sl-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--sl-accent);
  margin-bottom: 8px;
}

/* ------------------------------------------------------------------
   5. Grid sections collapse on small screens
   The core grid layout holds its column count at every width, which
   squeezes the programme cards into unreadable strips on a phone.
   ------------------------------------------------------------------ */
@media (max-width: 781px) {
  main .wp-block-group.is-layout-grid {
    grid-template-columns: repeat(1, minmax(0, 1fr));
  }
}

@media (min-width: 782px) and (max-width: 1023px) {
  main .wp-block-group.is-layout-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ------------------------------------------------------------------
   6. Reduced motion: everything settles, nothing moves
   ------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  html.sl-js main .wp-block-columns > .wp-block-column,
  html.sl-js main .is-layout-grid > .wp-block-group,
  html.sl-js main .wp-block-group.alignfull > .wp-block-group > *,
  html.sl-js main .sl-accordion > .wp-block-details {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  .sl-card,
  .sl-card:hover,
  .sl-card:focus-within,
  .wp-block-button__link,
  .wp-block-button__link:hover,
  .sl-card .wp-block-image img,
  .sl-card:hover .wp-block-image img {
    transform: none !important;
    transition: none !important;
  }

  .sl-accordion .wp-block-details[open] > *:not(summary) {
    animation: none;
  }

  .sl-accordion .wp-block-details > summary::after {
    transition: none;
  }
}
