/* ==========================================================================
   Matinno Living — Main navigation
   Mega-menu header with breadcrumbs,
   styled to the Matinno Brandbook v1 (June 2021):
     · Text: Figtree Regular · Buttons & subtitles: Figtree Bold, uppercase, +75 tracking
     · Titles: Figtree Bold
     · Ink #2C2E35 · Palette #D5A286 / #5C88DA / #9EA2A2
   ========================================================================== */

.mt-header {
  /* Brand tokens */
  --mt-ink: #2c2e35;
  --mt-grey: #9ea2a2;
  --mt-terracotta: #d5a286;
  --mt-blue: #5c88da;
  --mt-white: #ffffff;

  /* Theme (white header — default) */
  --mt-bg: var(--mt-white);
  --mt-line: rgba(44, 46, 53, 0.1);
  --mt-hover: var(--mt-grey);
  --mt-accent: var(--mt-terracotta);

  /* Type */
  --mt-font: "Figtree", Helvetica, Arial, sans-serif; /* one family for text and titles */
  --mt-font-display: var(--mt-font);

  /* Metrics */
  --mt-bar-h: 74px;
  --mt-crumbs-h: 34px;
  --mt-gutter: 18px;

  position: fixed;
  inset: 0 0 auto 0;
  z-index: 100;
  font-family: var(--mt-font);
  color: var(--mt-ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip; /* contains the full-bleed dropdown band */
}

/* Brand-grey header, per Brandbook §6 “Website guidelines” (header colour #9EA2A2) */
.mt-header--brand {
  --mt-bg: var(--mt-grey);
  --mt-line: rgba(44, 46, 53, 0.16);
  --mt-hover: var(--mt-white);
  --mt-accent: var(--mt-ink);
}

.mt-header *,
.mt-header *::before,
.mt-header *::after {
  box-sizing: border-box;
}

/* Resets use :where() so they carry no specificity and never beat component rules */
.mt-header :where(ul, ol) {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mt-header :where(a) {
  color: inherit;
  text-decoration: none;
}

.mt-header :where(button) {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.mt-header :focus-visible {
  outline: 2px solid var(--mt-blue);
  outline-offset: -2px;
}

.mt-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Top bar: logo · centred menu
   -------------------------------------------------------------------------- */

.mt-header__bar {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(max-content, 1fr) auto minmax(max-content, 1fr);
  height: var(--mt-bar-h);
  padding: 0 10px;
  background: var(--mt-bg);
  border-bottom: 1px solid var(--mt-line);
  transition: background-color 0.2s ease;
}

.mt-header__logo {
  justify-self: start;
  display: flex;
  align-items: center;
  padding: 0 20px;
  color: var(--mt-ink);
  transition: opacity 0.15s linear;
}

.mt-header__logo svg {
  display: block;
  width: 100px; /* Brandbook minimum digital size: 70px */
  height: auto;
}

@media (hover: hover) {
  .mt-header__logo:hover {
    opacity: 0.65;
  }
}

/* Main menu ---------------------------------------------------------------- */

.mt-header__nav {
  display: flex;
  height: 100%;
}

.mt-nav {
  display: flex;
  height: 100%;
}

.mt-nav__item {
  position: relative;
  display: flex;
}

.mt-nav__trigger,
.mt-nav__link {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 var(--mt-gutter);
  font-size: 15px;
  line-height: 1;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: color 0.15s linear;
}

.mt-nav__chevron {
  display: none;
}

/* Active / hover indicator sits on the bar's bottom rule */
.mt-nav__item::after {
  content: "";
  position: absolute;
  left: var(--mt-gutter);
  right: var(--mt-gutter);
  bottom: -1px;
  height: 2px;
  background: var(--mt-accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.2s ease;
  pointer-events: none;
}

.mt-nav__item.is-active::after,
.mt-nav__item.is-open::after {
  transform: scaleX(1);
}

@media (hover: hover) {
  .mt-nav__item:hover::after {
    transform: scaleX(1);
  }

  .mt-nav__trigger:hover,
  .mt-nav__link:hover,
  .mt-nav__item.is-open > .mt-nav__trigger {
    color: var(--mt-hover);
  }
}

/* Dropdown: links align with the menu label, background band spans the viewport */
.mt-nav__panel {
  position: absolute;
  z-index: 1;
  top: calc(100% + 1px);
  left: 0;
  min-width: 100%;
  padding: 16px 0 26px;
  background: var(--mt-bg);
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.15s linear, visibility 0s linear 0.15s;
}

.mt-nav__panel::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 0;
  bottom: 0;
  left: -100vw;
  width: 200vw;
  background: inherit;
  border-bottom: 1px solid var(--mt-line);
}

.mt-nav__item.is-open > .mt-nav__panel {
  visibility: visible;
  opacity: 1;
  transition: opacity 0.15s linear;
}

.mt-nav__panel a {
  display: block;
  padding: 0 var(--mt-gutter);
  font-size: 15px;
  line-height: 36px;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: color 0.15s linear;
}

.mt-nav__panel a[aria-current="page"] {
  text-decoration: underline;
  text-decoration-color: var(--mt-accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 7px;
}

@media (hover: hover) {
  .mt-nav__panel a:hover {
    color: var(--mt-hover);
  }
}

/* Sign in ------------------------------------------------------------------ */

.mt-header__actions {
  justify-self: end;
  display: flex;
  align-items: center;
  padding: 0 20px 0 12px;
}

.mt-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 20px;
  border: 1px solid var(--mt-ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.075em; /* Brandbook: buttons are bold, uppercase, +75 */
  text-transform: uppercase;
  white-space: nowrap;
  transition: background-color 0.15s linear, color 0.15s linear;
}

.mt-btn__arrow {
  display: none;
  width: 14px;
  height: 10px;
  flex: none;
}

@media (hover: hover) {
  .mt-btn:hover {
    background: var(--mt-ink);
    color: var(--mt-bg);
  }
}

/* Mobile menu toggle — the Matinno icon (Brandbook §6.02: icon = menu) ------ */

.mt-header__toggle {
  display: none;
}

/* --------------------------------------------------------------------------
   Breadcrumbs
   -------------------------------------------------------------------------- */

.mt-breadcrumbs {
  position: relative;
  z-index: 1;
  background: var(--mt-bg);
  border-bottom: 1px solid var(--mt-line);
  transition: background-color 0.2s ease;
}

.mt-breadcrumbs ol {
  display: flex;
  align-items: center;
  height: var(--mt-crumbs-h);
  padding: 0 15px;
  overflow-x: auto;
  scrollbar-width: none;
  white-space: nowrap;
}

.mt-breadcrumbs ol::-webkit-scrollbar {
  display: none;
}

.mt-breadcrumbs li {
  display: flex;
  align-items: center;
}

.mt-breadcrumbs li + li::before {
  content: "";
  flex: none;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--mt-accent);
}

.mt-breadcrumbs a,
.mt-breadcrumbs [aria-current] {
  display: block;
  padding: 0 15px;
  font-size: 13px;
  line-height: var(--mt-crumbs-h);
  letter-spacing: 0.01em;
  transition: color 0.15s linear;
}

@media (hover: hover) {
  .mt-breadcrumbs a:hover {
    color: var(--mt-hover);
  }
}

/* --------------------------------------------------------------------------
   Tablet & mobile  (< 960px)
   Logo + icon toggle · full-height accordion drawer
   -------------------------------------------------------------------------- */

@media (max-width: 959.98px) {
  .mt-header {
    --mt-cta-h: 52px;
    --mt-bar-h: 64px;
  }

  .mt-header__bar {
    grid-template-columns: 1fr auto;
    grid-template-rows: var(--mt-cta-h) var(--mt-bar-h);
    height: auto;
    padding: 0;
  }

  .mt-header__logo {
    grid-row: 2;
    grid-column: 1;
  }

  .mt-header__logo svg {
    width: 92px;
  }

  /* Sign-in row, spanning the full width above the logo bar */
  .mt-header__actions {
    grid-row: 1;
    grid-column: 1 / -1;
    justify-self: stretch;
    padding: 0;
    border-bottom: 1px solid var(--mt-line);
  }

  .mt-btn {
    flex: 1 1 100%;
    justify-content: space-between;
    height: 100%;
    padding: 0 20px;
    border: 0;
  }

  .mt-btn__arrow {
    display: block;
  }

  @media (hover: hover) {
    .mt-btn:hover {
      background: transparent;
      color: var(--mt-hover);
    }
  }

  /* Icon toggle */
  .mt-header__toggle {
    grid-row: 2;
    grid-column: 2;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 100%;
  }

  .mt-toggle__icon {
    width: 30px;
    height: auto;
    transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.2s linear;
  }

  .mt-toggle__close {
    position: absolute;
    width: 22px;
    height: 22px;
    opacity: 0;
    transform: rotate(-45deg) scale(0.6);
    transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.2s linear;
  }

  .mt-toggle__close::before,
  .mt-toggle__close::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 1.5px;
    margin-top: -0.75px;
    background: currentColor;
    transform: rotate(45deg);
  }

  .mt-toggle__close::after {
    transform: rotate(-45deg);
  }

  .mt-header.is-menu-open .mt-toggle__icon {
    opacity: 0;
    transform: rotate(90deg) scale(0.4);
  }

  .mt-header.is-menu-open .mt-toggle__close {
    opacity: 1;
    transform: none;
  }

  @media (hover: hover) {
    .mt-header__toggle:hover .mt-toggle__icon {
      transform: rotate(30deg);
    }
  }

  /* Drawer */
  .mt-header__nav {
    display: none;
    position: fixed;
    top: calc(var(--mt-cta-h) + var(--mt-bar-h) + 1px);
    right: 0;
    bottom: 0;
    left: 0;
    height: auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--mt-bg);
  }

  .mt-header.is-menu-open .mt-header__nav {
    display: block;
    animation: mt-drawer-in 0.25s ease both;
  }

  .mt-nav {
    flex-direction: column;
    height: auto;
  }

  .mt-nav__item {
    flex-direction: column;
    border-bottom: 1px solid var(--mt-line);
  }

  .mt-nav__item::after {
    display: none;
  }

  .mt-nav__trigger,
  .mt-nav__link {
    justify-content: space-between;
    width: 100%;
    height: 60px;
    padding: 0 20px;
    font-size: 16px;
  }

  .mt-nav__item.is-active > .mt-nav__trigger,
  .mt-nav__item.is-active > .mt-nav__link {
    font-weight: 700;
  }

  .mt-nav__chevron {
    display: block;
    width: 14px;
    height: 10px;
    flex: none;
    transition: transform 0.2s ease;
  }

  .mt-nav__item.is-open .mt-nav__chevron {
    transform: rotate(90deg);
  }

  .mt-nav__panel {
    position: static;
    display: none;
    min-width: 0;
    padding: 0 0 16px;
    visibility: visible;
    opacity: 1;
    transition: none;
  }

  .mt-nav__panel::before {
    display: none;
  }

  .mt-nav__item.is-open > .mt-nav__panel {
    display: block;
  }

  .mt-nav__panel a {
    padding: 0 20px;
    line-height: 40px;
  }

  .mt-breadcrumbs ol {
    padding: 0 5px;
  }

  .mt-breadcrumbs a,
  .mt-breadcrumbs [aria-current] {
    padding: 0 12px;
  }
}

@keyframes mt-drawer-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* Locks page scroll while the mobile drawer is open */
html.mt-scroll-lock,
html.mt-scroll-lock body {
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .mt-header *,
  .mt-header *::before,
  .mt-header *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
