/* ============================================================
   KODIF — LAYOUT
   Tokens (--primary, --bg-reverse, --line, …) are declared in css/style.css.
   Page layout blocks (header, footer, …) — built from existing components
   (.container, .button). Order: layout → @media (breakpoints at the end).
   ============================================================ */

/* ============ HEADER ============ */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-reverse);
}

/* While the mobile nav is open, lift the whole header above page content so the
   dropdown isn't covered by stacked sections below it. */
.header.is-open {
  z-index: 60;
}

.header__inner {
  display: flex;
  align-items: center;
  gap: 40px;
  height: 72px;
}

/* ----- Logo ----- */
.header__logo {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.header__logo-img {
  display: block;
  width: auto;
  height: 24px;
}

/* ----- Nav ----- */
.header__nav {
  display: flex;
  align-items: center;
  gap: 32px;
}

.header__link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: "TWK Lausanne", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  font-weight: 500;
  color: #e8e8e8;
  white-space: nowrap;
  transition: color 0.18s ease;
}

.header__link:hover {
  color: var(--white);
}

/* Dropdown caret (SVG) for items with a submenu */
.header__caret {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: transform 0.18s ease;
}

/* ----- Dropdown items (The Agent / Customers / Resources / Company) ----- */
/* Wrapper stretches full header height so the panel docks flush to the bottom
   edge with no hover gap between trigger and menu. */
.header__item {
  position: relative;
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  /* Taller hover target: vertical padding fills the header height so the panel
     docks flush at the bottom edge. Negative side margin keeps the gap between
     nav items unchanged. */
  padding: 16px;
  margin: 0 -16px;
}

.header__item > .header__link {
  height: 100%;
}

/* Caret flips up while the menu is open */
.header__item:hover .header__caret,
.header__item:focus-within .header__caret {
  transform: rotate(180deg);
}

/* Submenu panel: hidden until the item is hovered/focused */
.header__menu {
  position: absolute;
  top: 100%;
  left: 16px; /* matches .header__item padding so the panel lines up under the label */
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 300px;
  padding: 24px;
  font-family: "TWK Lausanne", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0a0a0a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
}

.header__item:hover .header__menu,
.header__item:focus-within .header__menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.header__menu-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.header__menu-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  font-weight: 500;
  color: #e8e8e8;
  white-space: nowrap;
  transition: color 0.18s ease;
}

.header__menu-link:hover .header__menu-title {
  color: var(--white);
}

.header__menu-sub {
  font-size: 14px;
  color: var(--text-dim);
}

/* External-link glyph (Trust Center) */
.header__menu-ext {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  opacity: 0.7;
}

/* ----- Actions (pushed to the right edge) ----- */
.header__actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  flex-shrink: 0;
}

/* ----- Toggle (hamburger) for mobile ----- */
button.header__toggle,
.header__toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  margin-left: auto;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
}

button.header__toggle:hover {
  background: transparent !important;
}

.header__toggle span {
  display: block;
  width: 20px;
  height: 2px;
  margin-left: auto;
  background: var(--white);
  transition: transform 0.25s ease, opacity 0.2s ease;
}

/* Open: collapse the 3 bars into an X — outer bars meet at center + rotate,
   middle bar fades out. (7px = bar gap 5px + bar height 2px.) */
.header.is-open .header__toggle span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.header.is-open .header__toggle span:nth-child(2) {
  opacity: 0;
}
.header.is-open .header__toggle span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Respect reduced motion: snap between hamburger and X. */
@media (prefers-reduced-motion: reduce) {
  .header__toggle span {
    transition: none;
  }
}

/* ============ FOOTER ============ */
.footer {
  background: var(--bg-reverse);
  color: var(--white);
}

/* ----- Link columns ----- */
.footer__cols {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  padding-top: 40px;
  padding-bottom: 48px;
  border-top: 1px solid var(--line);
}

.footer__col {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.footer__col-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--white);
  margin-bottom: 6px;
}

.footer__col-link {
  font-size: 15px;
  color: var(--text-dim);
  transition: color 0.18s ease;
}

.footer__col-link:hover {
  color: var(--white);
}

/* ----- Oversized brand wordmark ----- */
.footer__brand {
  padding-top: 16px;
  padding-bottom: 28px;
  border-top: 1px solid var(--line);
}

.footer__wordmark {
  display: block;
  width: 100%;
  height: auto;
}

/* ----- Bottom bar: copyright + legal links ----- */
.footer__bottom {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 32px;
}

.footer__copy {
  max-width: 280px;
  font-size: 14px;
  color: var(--text-dim);
}

.footer__legal {
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  flex-shrink: 0;
}

.footer__legal-link {
  font-size: 14px;
  color: var(--text-dim);
  white-space: nowrap;
  transition: color 0.18s ease;
}

.footer__legal-link:hover {
  color: var(--white);
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1199px) {
  .header__inner {
    gap: 28px;
  }
  /* Nav collapses into a dropdown, opened via .header__toggle */
  button.header__toggle,
  .header__toggle {
    display: flex;
  }
  /* Hide Sign in / Book A Demo — dropdown takes over from here down */
  .header__actions {
    display: none;
  }
  .header__nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 40;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 8px 0;
    background: var(--bg-reverse);
    border-top: 1px solid var(--line);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
    /* Fill the viewport below the 72px header; a taller menu scrolls inside. */
    height: calc(100vh - 72px);
    overflow-y: auto;
    overflow-x: hidden;
    /* Hidden via opacity/visibility (not display) so it can fade + slide in. */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
  }
  .header.is-open .header__nav {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
  /* Respect reduced motion: appear instantly, no slide. */
  @media (prefers-reduced-motion: reduce) {
    .header__nav {
      transform: none;
      transition: none;
    }
  }
  .header__link {
    padding: 12px 24px;
  }
  .header__link.header__link--caret {
    justify-content: space-between;
    padding-right: 0;
    padding-top: 0;
    padding-bottom: 0;
    flex: 1;
  }
  /* Bigger tap target for the caret on touch — padding gives the 14px glyph a
     46×46 hit area (box-sizing: border-box). */
  .header__caret {
    width: 46px;
    height: 46px;
    padding: 16px;
  }
  /* Dropdowns can't hover on touch — stack each item and show its menu inline */
  .header__item {
    align-self: stretch;
    flex-direction: column;
    align-items: stretch;
    padding-top: 0;
    padding-bottom: 0;
  }
  /* Accordion: collapsed by default, slides open when its item gets .is-open
     (toggled by tapping the caret — see js/layout.js). max-height + padding
     animate the slide; overflow clips the panel while closed. */
  .header__menu {
    position: static;
    min-width: 0;
    padding: 0 24px 0 36px;
    gap: 16px;
    background: transparent;
    border: 0;
    box-shadow: none;
    opacity: 1;
    visibility: visible;
    transform: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.28s ease, padding 0.28s ease;
  }
  .header__item.is-open > .header__menu {
    max-height: 600px;
    padding-top: 4px;
    padding-bottom: 16px;
  }
  /* Hover/focus no longer drives the panel on touch — only the .is-open toggle
     flips the caret. */
  .header__item:hover .header__caret,
  .header__item:focus-within .header__caret {
    transform: none;
  }
  .header__item.is-open .header__caret {
    transform: rotate(180deg);
  }
}

@media (max-width: 991px) {
  /* Columns wrap to a flexible grid on tablets */
  .footer__cols {
    flex-wrap: wrap;
  }
  .footer__col {
    flex: 0 0 calc(33.333% - 22px);
    gap: 8px;
  }
  .footer__col-link {
    font-size: 14px;
  }
  .footer__copy {
    font-size: 13px;
  }
}

@media (max-width: 767px) {
  .header__link {
    padding-left: 20px;
    padding-right: 20px;
  }
  /* Columns become two-up */
  .footer__cols {
    padding-top: 20px;
    padding-bottom: 24px;
    gap: 16px 12px;
  }
  .footer__col {
    flex-basis: calc(50% - 16px);
  }
  /* Bottom bar stacks */
  .footer__bottom {
    flex-direction: column;
    gap: 12px;
  }
}

@media (max-width: 539px) {
  /* Single column footer */
  .footer__legal {
    row-gap: 8px;
    column-gap: 16px;
  }
}
