/* ============================================================
   BOOKSBYAMA — HEADER COMPONENT
   header.css
   ============================================================
   Standalone — no dependency on style.css.
   Paste this <link> before closing </head>:
     <link rel="stylesheet" href="assets/css/header.css" />
   ============================================================ */

/* ── TOKENS (scoped to header) ──────────────────────────── */
:root {
  --hdr-purple:       #635DA9;
  --hdr-purple-dark:  #4E4890;
  --hdr-purple-soft:  #F2F1FA;
  --hdr-gold:         #FFC93B;
  --hdr-bg:           #F7F5FF;
  --hdr-surface:      #FFFFFF;
  --hdr-border:       #E6E4F2;
  --hdr-text:         #2D2A4A;
  --hdr-muted:        #6E6B8E;
  --hdr-height:       72px;
  --hdr-z:            1000;
  --hdr-radius:       12px;
  --hdr-transition:   0.25s ease;
  --hdr-drawer-w:     320px;
  --font-head:        'Poppins', system-ui, sans-serif;
  --font-body:        'Inter',   system-ui, sans-serif;
}

/* ── RESET (header-scoped) ──────────────────────────────── */
.header *,
.header *::before,
.header *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── BASE HEADER ────────────────────────────────────────── */
.header {
  position: fixed;
  inset-inline: 0;
  top: 0;
  z-index: var(--hdr-z);
  height: var(--hdr-height);
  display: flex;
  align-items: center;

  /* Default: solid white */
  background: var(--hdr-surface);
  border-bottom: 1px solid var(--hdr-border);
  box-shadow: none;
  transition:
    background var(--hdr-transition),
    border-color var(--hdr-transition),
    box-shadow var(--hdr-transition);
  will-change: background, box-shadow;
}

/* ── TRANSPARENT MODE (hero pages) ─────────────────────── */
/*
   Add data-transparent="true" to <header> on pages that have
   a full-bleed hero section behind the nav.
   JS adds .header--scrolled once user scrolls > 60 px.
*/
.header[data-transparent="true"] {
  background: transparent;
  border-bottom-color: transparent;
}

.header[data-transparent="true"] .header__link {
  color: rgba(255, 255, 255, 0.9);
}
.header[data-transparent="true"] .header__link::after {
  background: var(--hdr-gold);
}
.header[data-transparent="true"] .header__logo-text {
  color: #fff;
}
.header[data-transparent="true"] .header__logo-text span {
  color: var(--hdr-gold);
}
.header[data-transparent="true"] .header__hamburger-line {
  background: #fff;
}

/* ── SCROLLED STATE ─────────────────────────────────────── */
.header--scrolled,
.header.header--scrolled[data-transparent="true"] {
  background: var(--hdr-surface) !important;
  border-bottom-color: var(--hdr-border) !important;
  box-shadow: 0 2px 20px rgba(99, 93, 169, 0.10);
}
.header--scrolled .header__link,
.header.header--scrolled[data-transparent="true"] .header__link {
  color: var(--hdr-muted) !important;
}
.header--scrolled .header__logo-text,
.header.header--scrolled[data-transparent="true"] .header__logo-text {
  color: var(--hdr-text) !important;
}
.header--scrolled .header__logo-text span,
.header.header--scrolled[data-transparent="true"] .header__logo-text span {
  color: var(--hdr-purple) !important;
}
.header--scrolled .header__hamburger-line,
.header.header--scrolled[data-transparent="true"] .header__hamburger-line {
  background: var(--hdr-text) !important;
}

/* ── CONTAINER ──────────────────────────────────────────── */
.header__container {
  width: 100%;
  max-width: 1280px;
  margin-inline: auto;
  padding-inline: 24px;
  display: flex;
  align-items: center;
  gap: 32px;
}

/* ── LOGO ───────────────────────────────────────────────── */
.header__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
  outline-offset: 4px;
}

.header__logo-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--hdr-transition);
}
.header__logo:hover .header__logo-icon {
  transform: rotate(-4deg) scale(1.05);
}

.header__logo-text {
  font-family: var(--font-head);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--hdr-text);
  letter-spacing: -.01em;
  transition: color var(--hdr-transition);
}
.header__logo-text span {
  color: var(--hdr-purple);
}

/* ── DESKTOP NAV ────────────────────────────────────────── */
.header__nav {
  flex: 1;
  display: flex;
  justify-content: center;
}

.header__nav-list {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.header__link {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--hdr-muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 8px;
  position: relative;
  display: inline-flex;
  align-items: center;
  transition: color var(--hdr-transition), background var(--hdr-transition);
  outline-offset: 3px;
  white-space: nowrap;
}

/* Underline slide-in animation */
.header__link::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 12px;
  right: 12px;
  height: 2px;
  border-radius: 2px;
  background: var(--hdr-purple);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.22s ease;
}

.header__link:hover {
  color: var(--hdr-purple);
  background: var(--hdr-purple-soft);
}
.header__link:hover::after {
  transform: scaleX(1);
}

/* Active state */
.header__link--active {
  color: var(--hdr-purple);
  font-weight: 600;
}
.header__link--active::after {
  transform: scaleX(1);
}

/* ── CTA BUTTON ─────────────────────────────────────────── */
.header__actions {
  flex-shrink: 0;
}

.header__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--hdr-purple), var(--hdr-purple-dark));
  border: none;
  border-radius: var(--hdr-radius);
  padding: 10px 22px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition:
    transform var(--hdr-transition),
    box-shadow var(--hdr-transition),
    background var(--hdr-transition);
  outline-offset: 3px;
}
.header__cta:hover {
  background: linear-gradient(135deg, var(--hdr-purple-dark), #3c3778);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 93, 169, 0.35);
}
.header__cta:active {
  transform: translateY(0);
  box-shadow: none;
}
.header__cta--full {
  width: 100%;
  padding: 14px 22px;
  font-size: 0.95rem;
  border-radius: 14px;
}

/* ── HAMBURGER ──────────────────────────────────────────── */
.header__hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 48px;
  height: 48px;
  background: none;
  border: 1.5px solid var(--hdr-border);
  border-radius: 12px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: border-color var(--hdr-transition), background var(--hdr-transition);
  outline-offset: 3px;
}
.header__hamburger:hover {
  background: var(--hdr-purple-soft);
  border-color: var(--hdr-purple);
}

.header__hamburger-line {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: var(--hdr-text);
  transition: transform 0.3s ease, opacity 0.3s ease, width 0.3s ease;
  transform-origin: center;
}

/* Hamburger → X animation */
.header__hamburger[aria-expanded="true"] .header__hamburger-line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.header__hamburger[aria-expanded="true"] .header__hamburger-line:nth-child(2) {
  opacity: 0;
  width: 0;
}
.header__hamburger[aria-expanded="true"] .header__hamburger-line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ── MOBILE DRAWER ──────────────────────────────────────── */
.header__drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--hdr-drawer-w);
  max-width: 100vw;
  height: 100dvh;
  background: var(--hdr-surface);
  z-index: calc(var(--hdr-z) + 1);
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 40px rgba(45, 42, 74, 0.14);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.header__drawer[aria-hidden="false"] {
  transform: translateX(0);
}

.header__drawer-inner {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 20px 24px 32px;
  gap: 0;
}

/* Drawer top row — logo + close */
.header__drawer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--hdr-border);
  margin-bottom: 8px;
}

.header__drawer-close {
  width: 38px;
  height: 38px;
  border: 1.5px solid var(--hdr-border);
  border-radius: 10px;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--hdr-muted);
  flex-shrink: 0;
  transition: background var(--hdr-transition), border-color var(--hdr-transition), color var(--hdr-transition);
  outline-offset: 3px;
}
.header__drawer-close:hover {
  background: var(--hdr-purple-soft);
  border-color: var(--hdr-purple);
  color: var(--hdr-purple);
}

/* Drawer nav list */
.header__drawer-nav {
  flex: 1;
  padding: 8px 0;
}

.header__drawer-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.header__drawer-link {
  display: flex;
  align-items: center;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 500;
  color: var(--hdr-text);
  text-decoration: none;
  padding: 13px 14px;
  border-radius: 12px;
  transition: background var(--hdr-transition), color var(--hdr-transition), transform 0.15s ease;
  outline-offset: 3px;
}
.header__drawer-link:hover {
  background: var(--hdr-purple-soft);
  color: var(--hdr-purple);
  transform: translateX(4px);
}
.header__drawer-link--active {
  background: var(--hdr-purple-soft);
  color: var(--hdr-purple);
  font-weight: 600;
}

/* Drawer footer — CTA + socials */
.header__drawer-footer {
  margin-top: auto;
  padding-top: 24px;
  border-top: 1px solid var(--hdr-border);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.header__drawer-social {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.header__drawer-social a {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1.5px solid var(--hdr-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--hdr-muted);
  text-decoration: none;
  transition: background var(--hdr-transition), border-color var(--hdr-transition), color var(--hdr-transition);
  outline-offset: 3px;
}
.header__drawer-social a:hover {
  background: var(--hdr-purple-soft);
  border-color: var(--hdr-purple);
  color: var(--hdr-purple);
}

/* ── OVERLAY ────────────────────────────────────────────── */
.header__overlay {
  position: fixed;
  inset: 0;
  background: rgba(45, 42, 74, 0.45);
  backdrop-filter: blur(3px);
  z-index: var(--hdr-z);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}
.header__overlay--visible {
  opacity: 1;
  pointer-events: all;
}

/* ── BODY LOCK (applied by JS) ──────────────────────────── */
body.nav-open {
  overflow: hidden;
}

/* ── FOCUS STYLES ───────────────────────────────────────── */
.header__link:focus-visible,
.header__cta:focus-visible,
.header__logo:focus-visible,
.header__hamburger:focus-visible,
.header__drawer-close:focus-visible,
.header__drawer-link:focus-visible,
.header__drawer-social a:focus-visible {
  outline: 2px solid var(--hdr-purple);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 960px) {
  /* Hide desktop nav + actions, show hamburger */
  .header__nav,
  .header__actions {
    display: none;
  }
  .header__hamburger {
    display: flex;
    margin-left: auto;
  }
}

@media (max-width: 480px) {
  .header__container {
    padding-inline: 16px;
  }
  .header__logo-text {
    font-size: 1rem;
  }
  .header__drawer {
    width: 100vw;
  }
}

/* ── PAGE OFFSET (prevent content hiding under fixed header) */
/*
   Add this to your page's <body> or first section:
     padding-top: var(--hdr-height);
   Or use this utility class on the first content element:
     .header-offset { padding-top: var(--hdr-height); }
*/
.header-offset {
  padding-top: var(--hdr-height);
}

/* ── DROPDOWN MENUS ─────────────────────────────────────── */
.header__nav-item--dropdown,
.header__drawer-item--dropdown {
  position: relative;
}

/* Toggle button inherits .header__link/.header__drawer-link */
.header__link--toggle,
.header__drawer-link--toggle {
  background: none;
  border: none;
  font-family: inherit;
  cursor: pointer;
  gap: 4px;
}
.header__link--toggle svg,
.header__drawer-link--toggle svg {
  transition: transform var(--hdr-transition);
}

.header__nav-item--dropdown.is-open .header__link--toggle svg,
.header__nav-item--dropdown:hover .header__link--toggle svg,
.header__nav-item--dropdown:focus-within .header__link--toggle svg {
  transform: rotate(180deg);
}

/* Desktop dropdown */
.header__dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 220px;
  background: var(--hdr-surface);
  border: 1px solid var(--hdr-border);
  border-radius: var(--hdr-radius);
  box-shadow: 0 8px 24px rgba(45, 42, 74, 0.12);
  list-style: none;
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
  z-index: 1001;
}

.header__nav-item--dropdown:hover .header__dropdown,
.header__nav-item--dropdown:focus-within .header__dropdown,
.header__nav-item--dropdown.is-open .header__dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.header__dropdown-link {
  display: block;
  padding: 8px 16px;
  color: var(--hdr-muted);
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--hdr-transition), background var(--hdr-transition);
}

.header__dropdown-link:hover,
.header__dropdown-link:focus {
  color: var(--hdr-purple);
  background: var(--hdr-purple-soft);
  outline: none;
}

/* Mobile drawer dropdown */
.header__drawer-dropdown {
  list-style: none;
  display: none;
  flex-direction: column;
  padding: 4px 0 8px 14px;
  gap: 2px;
}

.header__drawer-item--dropdown.is-open .header__drawer-dropdown {
  display: flex;
}

.header__drawer-item--dropdown.is-open .header__drawer-link--toggle svg {
  transform: rotate(180deg);
}

.header__drawer-dropdown-link {
  display: flex;
  align-items: center;
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--hdr-muted);
  text-decoration: none;
  padding: 10px 14px;
  border-radius: 10px;
  transition: background var(--hdr-transition), color var(--hdr-transition);
}

.header__drawer-dropdown-link:hover,
.header__drawer-dropdown-link:focus {
  background: var(--hdr-purple-soft);
  color: var(--hdr-purple);
  outline: none;
}
