/* ==========================================================================
   LAYOUT / HEADER
   Shared site header — appears on every page.
   ========================================================================== */

/* ==========================================================================
   2. HEADER STYLES
   ========================================================================== */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: 100px;
  z-index: 1000;
  background: var(--bg-header);
  backdrop-filter: blur(8px); /* Enhances glassmorphism look */
  max-width: var(--container-max); /* "full" */
  margin: 0 auto;
}

/* --- Inner container ("container/inner") — nested inside the full-width
   header bar; holds the actual nav/actions row and centers it once the
   viewport exceeds --container-inner-max. --- */
.header-inner {
  width: 100%;
  max-width: var(--container-inner-max);
  height: 100%;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0;
  direction: rtl;
}

/* --- Right Side: Logo & Navigation Wrapper --- */
.header .logo-nav-wrapper {
  display: flex;
  align-items: center;
  gap: 70px;
}

.header .logo-container img {
  height: 85px;
  width: auto;
  display: block;
}

.header .nav-menu {
  display: flex;
  align-items: center;
  gap: 75px;
  list-style: none;
}

.header .nav-item,
.offcanvas-panel .nav-item {
  font-family: var(--font-main);
  font-style: normal;
  font-weight: 500;
  font-size: 20px;
  line-height: 24px;
  color: var(--color-primary-navy);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: right;
  flex: none;
}

.header .nav-stories,
.offcanvas-panel .nav-stories {
  width: 141px;
  height: 24px;
}

.header .chevron,
.offcanvas-panel .chevron {
  color: var(--color-primary-navy);
  transition: transform 0.2s ease;
}

.header .nav-item:hover .chevron,
.offcanvas-panel .nav-item:hover .chevron {
  transform: translateY(2px);
}

/* --- Left Side: Actions Container --- */
.header .actions-container,
.offcanvas-panel .actions-container {
  display: flex;
  align-items: center;
  gap: 15px;
}

.header .icon-button,
.offcanvas-panel .icon-button {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 1px solid var(--color-border-icon);
  background: transparent;
  color: var(--color-primary-navy);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s ease;
  padding: 5px;
}

.header .icon-button:hover,
.offcanvas-panel .icon-button:hover {
  background-color: #EFEFEF;
}

.header .user-profile,
.offcanvas-panel .user-profile {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-main);
  font-weight: 500;
  font-size: 16px;
  color: var(--color-profile-text);
  cursor: pointer;
  margin-left: 8px;
}

.header .btn-primary,
.offcanvas-panel .btn-primary {
  background: linear-gradient(135deg, var(--color-pink-btn) 0%, var(--color-pink-gradient-end) 100%);
  color: #FFFFFF;
  border: none;
  border-radius: 999px;
  padding: 11px 24px;
  font-family: var(--font-main);
  font-size: 21px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0px 4px 12px rgba(213, 90, 158, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.header .btn-primary:hover,
.offcanvas-panel .btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0px 6px 16px rgba(213, 90, 158, 0.45);
}

.header .btn-outline,
.offcanvas-panel .btn-outline {
  background: transparent;
  color: #183B51;
  border: 1px solid #00008040;
  border-radius: 999px;
  padding: 11px 23px;
  font-family: var(--font-main);
  font-size: 21px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.header .btn-outline:hover,
.offcanvas-panel .btn-outline:hover {
  background-color: rgba(0, 0, 128, 0.05);
}

/* --- Mobile nav toggle (hamburger) ---
   Hidden on wide viewports; the desktop nav-menu is always visible
   there. Markup: a single <button data-nav-toggle> per header, right
   before <nav class="nav-menu">. Behavior lives in
   assets/js/core/header.js (initMobileNav), which toggles
   aria-expanded on this button and .is-open on .nav-menu. */
.nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--color-primary-navy);
  flex: none;
}

.nav-toggle:hover {
  background-color: #EFEFEF;
}

.nav-toggle-icon,
.nav-toggle-icon::before,
.nav-toggle-icon::after {
  display: block;
  width: 22px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-toggle-icon {
  position: relative;
}

.nav-toggle-icon::before,
.nav-toggle-icon::after {
  content: '';
  position: absolute;
  right: 0;
}

.nav-toggle-icon::before {
  top: -7px;
}

.nav-toggle-icon::after {
  top: 7px;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-icon {
  background: transparent;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-icon::before {
  top: 0;
  transform: rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle-icon::after {
  top: 0;
  transform: rotate(-45deg);
}

/* --- Header search toggle (expand-in-place search field) ---
   Markup: <button data-header-search-toggle> immediately followed by
   a hidden <div data-header-search-panel><form>...<input></form></div>.
   Behavior lives in assets/js/core/header.js (initHeaderSearch). */
.header-search {
  position: relative;
}

.header-search-panel {
  position: absolute;
  top: calc(100% + 12px);
  left: 0;
  z-index: var(--z-header);
  width: 280px;
  max-width: calc(100vw - 32px);
  background: var(--color-white);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
  padding: var(--space-3);
}

.header-search-panel[hidden] {
  display: none;
}

.header-search-panel form {
  display: flex;
  gap: var(--space-2);
}

.header-search-panel input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--color-border-icon);
  border-radius: var(--radius-input);
  padding: 8px 12px;
  font-family: var(--font-main);
}

/* The offcanvas shell (built by assets/js/core/header.js) only ever
   matters below 900px — on desktop its contents have been moved back
   into .header-inner, leaving it empty, so keep it out of the render
   tree entirely until the mobile media query below re-enables it. */
.offcanvas-overlay,
.offcanvas-panel {
  display: none;
}

/* ==========================================================================
   3. RESPONSIVE / MOBILE NAV — OFFCANVAS
   Below 900px, header-inner is left holding ONLY the logo + hamburger.
   The hamburger (assets/js/core/header.js -> initMobileNav) physically
   moves .nav-menu AND .actions-container (search, cart, login/join, or
   user-profile — every header button) into a fixed offcanvas panel that
   slides in from the side. Selectors are nested under ".header" so every
   existing ".header X" rule (icon-button, btn-primary, btn-outline,
   user-profile, nav-item, chevron, …) keeps styling the moved-in content
   with nothing duplicated.
   ========================================================================== */
@media (max-width: 899px) {
  .header {
    height: 76px;
  }

  .header .logo-container img {
    height: 60px;
  }

  .header-inner {
    padding: 0 var(--space-4);
  }

  /* header-inner now only ever contains .logo-container + .nav-toggle at
     this breakpoint (logo-nav-wrapper's .nav-menu has been moved out by
     JS), so it can behave like a plain two-item row. */
  .header .logo-nav-wrapper {
    gap: 16px;
    width: 100%;
    justify-content: space-between;
  }

  .nav-toggle {
    display: inline-flex;
  }

  /* --- Offcanvas overlay (backdrop) --- */
  .offcanvas-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(24, 59, 81, 0.45);
    z-index: calc(var(--z-header) + 400);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, visibility 0.25s ease;
  }

  .offcanvas-overlay.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  /* --- Offcanvas panel --- */
  .offcanvas-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(320px, 86vw);
    max-width: 360px;
    background: var(--color-white);
    z-index: calc(var(--z-header) + 500);
    display: flex;
    flex-direction: column;
    box-shadow: -12px 0 32px rgba(0, 0, 0, 0.18);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-y: auto;
    direction: rtl;
  }

  .offcanvas-panel.is-open {
    transform: translateX(0);
  }

  .offcanvas-panel-header {
    display: flex;
    justify-content: flex-start;
    padding: var(--space-4);
    border-bottom: 1px solid rgba(0, 0, 128, 0.08);
    flex: none;
  }

  .offcanvas-close {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary-navy);
    cursor: pointer;
  }

  .offcanvas-close:hover {
    background-color: #EFEFEF;
  }

  .offcanvas-panel-body {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
    padding: var(--space-4);
  }

  /* --- Nav links, once moved inside the panel --- */
  .offcanvas-panel .nav-menu {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    width: 100%;
  }

  .offcanvas-panel .nav-item {
    width: 100%;
    padding: var(--space-3) 0;
    border-bottom: 1px solid rgba(0, 0, 128, 0.08);
    height: auto;
  }

  .offcanvas-panel .nav-item-has-mega {
    width: 100%;
  }

  .offcanvas-panel .nav-item-has-mega > .nav-item {
    width: 100%;
    background: none;
    border: none;
    justify-content: space-between;
  }

  /* Mega menu becomes a simple inline expandable sub-list on mobile
     instead of a hover dropdown. It sits inside the (already white)
     offcanvas panel, so it doesn't need its own background or the
     decorative texture pattern used for the desktop dropdown. */
  .offcanvas-panel .mega-menu {
    position: static;
    width: 100%;
    height: auto;
    background: none;
    box-shadow: none;
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: none;
    padding: 0 0 0 var(--space-4);
    display: none;
  }

  .offcanvas-panel .mega-menu::before {
    display: none;
  }

  .offcanvas-panel .mega-menu {
    max-height: none;
    overflow: visible;
  }

  .offcanvas-panel .mega-col-list a {
    padding-block: 2px;
    font-size: 17px;
  }

  .offcanvas-panel .mega-col-list a::before {
    top: 15px;
  }

  .offcanvas-panel .mega-menu.is-open {
    display: block;
  }

  .offcanvas-panel .mega-menu-inner {
    flex-direction: column;
    height: auto;
    padding-block: var(--space-4);
    gap: var(--space-6);
  }

  .offcanvas-panel .mega-promo-card {
    display: none;
  }

  /* --- Action buttons (search, cart, login/join, or user-profile),
     once moved inside the panel. Icon buttons (search, cart) stay
     compact and sit in a row; only the auth buttons stretch full
     width, stacked below them. --- */
  .offcanvas-panel .actions-container {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    padding-top: var(--space-2);
    justify-content: center;
  }

  .offcanvas-panel .header-search {
    flex: 0 0 auto;
  }

  .offcanvas-panel .header-search-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: auto;
    width: 260px;
    max-width: calc(100vw - 64px);
  }

  .offcanvas-panel .icon-button {
    flex: 0 0 auto;
  }

  .offcanvas-panel .user-profile {
    flex: 1 1 auto;
    justify-content: flex-start;
    margin-left: 0;
  }

  .offcanvas-panel .btn-outline,
  .offcanvas-panel .btn-primary {
    width: 100%;
    text-align: center;
    padding: 12px 14px;
    font-size: 17px;
  }

  body.nav-open {
    overflow: hidden;
  }
}



/* ==========================================================================
   MEGA MENU - FULL WIDTH (100vw) PIXEL PERFECT
   ========================================================================== */

/* ביטול מיקום יחסי באלמנט האב כדי לאפשר פריסה על כל רוחב המסך */
.nav-item-has-mega {
  position: static;
}

/* --- Container Mega Menu (Figma "Menu" 1920x681, incl. the 100px header) ---
   Positioned against .header (position: fixed + backdrop-filter make it
   the containing block), so left/right: 0 spans exactly the header's
   width. Not 100vw: that includes the scrollbar and overflows sideways. */
.mega-menu {
  position: absolute;
  top: 100px; /* גובה ה-Header בדיוק */
  right: 0;
  left: 0;
  height: auto;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  background-color: #FFF9F5;
  border-radius: 0 0 15px 15px;
  padding: 16px 35px;
  box-shadow: 0px 20px 40px rgba(0, 0, 0, 0.08);
  box-sizing: border-box;
  z-index: 1100;
  direction: rtl;

  /* הנפשת פתיחה מלמעלה למטה (Slide Down) */
  opacity: 0;
  visibility: hidden;
  transform: translateY(-20px);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.25s ease,
              visibility 0.25s;
}

/* פס ה-Ribbon הרקום בחלק העליון/רקע התפריט */
.mega-menu::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%; /* גובה ה-Ribbon לפי ה-Footer */
  
  /* הוספת ה-Pattern הרקום */
  background-image: url('../../images/backgrounds/pattern-texture-menu.jpg');
  background-repeat: repeat-x; /* חזרה אופקית בלבד */
  background-position: top center;
  background-size: auto 100%;
  pointer-events: none;
  z-index: -1;
  opacity: 0.3;
}

/* מצב פעיל — נשלט רק ע"י JS (initMegaMenu ב-header.js).
   אין כאן :hover / :focus-within בכוונה: הם נלחמו בכפתור ה-toggle
   (הכפתור נשאר בפוקוס, ולכן אי אפשר היה לסגור את התפריט בלחיצה). */
.mega-menu.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* --- Inner Wrapper (1850x506) --- */
.mega-menu-inner {
  width: 100%;
  max-width: 1850px;
  min-height: 506px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 50px;
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  padding-block: 32px 40px;
}

/* --- Columns --- */
.mega-col {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* כותרת עמודה: רווחה ומצוקה */
.mega-col-title {
  font-family: 'Fredoka', sans-serif;
  font-weight: 500;
  font-size: 21px;
  line-height: 24px;
  color: var(--color-primary-navy, #183B51);
  text-align: right;
  margin: 0 0 14px 0;
}

/* רשימת הקישורים */
.mega-col-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* פריט קישור: מבוא לרווחה ומצוקה
   Figma: 18px, שורה בודדת בגובה 42px; פריט שנשבר לשתי שורות — 30px
   לשורה. line-height 30 + padding 6+6 נותן בדיוק את שניהם. */
.mega-col-list a {
  font-family: 'Fredoka', sans-serif;
  font-weight: 400;
  font-size: 18px;
  line-height: 30px;
  color: var(--color-primary-navy, #183B51);
  text-decoration: none;
  text-align: right;
  transition: color 0.15s ease;
  display: block;
  position: relative;
  padding: 6px 16px 6px 0;
}

.mega-col-list a::before {
  content: "";
  position: absolute;
  right: 2px;
  top: 19px; /* 6px padding + חצי שורה ראשונה, פחות חצי נקודה */
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
}

.mega-col-list a:hover,
.mega-col-list a:focus-visible {
  color: var(--color-pink-accent);
}

.mega-col-list a:focus-visible,
.promo-btn:focus-visible {
  outline: 2px solid var(--color-pink-accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --- "מרכז הידע" trigger — chevron flips while the menu is open --- */
.nav-item-has-mega > .nav-item {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.nav-item-has-mega.is-open > .nav-item .chevron,
.nav-item-has-mega.is-open > .nav-item:hover .chevron {
  transform: rotate(180deg);
}

@media (prefers-reduced-motion: reduce) {
  .mega-menu,
  .chevron {
    transition: none;
  }
}

/* --- Promo Frame Card (248x484) --- */
.mega-promo-card {
  width: 248px;
  height: 484px;
  border-radius: 20px;
  padding: 61px 8px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-sizing: border-box;
  overflow: hidden;
  flex-shrink: 0;
}

.mega-promo-card .promo-bg-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  z-index: 0;
}

.promo-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  height: 100%;
}

/* תמונת סמל קורס (116x73) */
.promo-icon {
  width: 116px;
  height: 73px;
  object-fit: contain;
}

/* מבוא לשפה הסמלית */
.promo-subtitle {
  font-family: 'Fredoka', sans-serif;
  font-weight: 400;
  font-size: 19px;
  line-height: 29px;
  color: var(--color-primary-navy, #183B51);
  text-align: center;
  margin: 0;
}

/* קורס PIVOT המלא */
.promo-title {
  font-family: 'Fredoka', sans-serif;
  font-weight: 500;
  font-size: 22px;
  line-height: 29px;
  color: var(--color-primary-navy, #183B51);
  text-align: center;
  margin: 0;
}

/* כל הידע הנדרש לפענוח... */
.promo-description {
  font-family: 'Fredoka', sans-serif;
  font-weight: 400;
  font-size: 19px;
  line-height: 26px;
  color: var(--color-primary-navy, #183B51);
  text-align: center;
  margin: 0;
}

/* כפתור: התחילו עכשיו (168x52) */
.promo-btn {
  width: 168px;
  height: 52px;
  background: var(--color-pink-accent);
  border-radius: 9999px;
  padding: 12px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 21px;
  line-height: 28px;
  color: #FFFFFF;
  text-decoration: none;
  box-sizing: border-box;
  margin-top: auto;
  transition: background-color 0.2s ease, transform 0.15s ease;
  margin-top: 15px;
}

.promo-btn:hover {
  background-color: #b55b93;
  transform: translateY(-2px);
}

/* ==========================================================================
   RESPONSIVE (Screen smaller than 1200px)
   ========================================================================== */
@media (max-width: 1200px) {
  .mega-menu {
    height: auto;
  }
  .mega-menu-inner {
    height: auto;
    flex-wrap: wrap;
  }
  .mega-promo-card {
    display: none;
  }
}