/**
 * Jarayan 8.1 — header/menu resilience and psychology library overhaul.
 * Loaded after all other public styles.
 */

/* --------------------------------------------------------------------------
   Global defensive layout
   -------------------------------------------------------------------------- */
html,
body.jarayan-v81,
body.jarayan-v81 .site-shell {
  width: 100%;
  max-width: none;
}

body.jarayan-v81 .site-shell {
  display: block;
  margin: 0;
  overflow-x: clip;
}

body.jarayan-v81 .site-header,
body.jarayan-v81 .premium-topbar,
body.jarayan-v81 .site-main,
body.jarayan-v81 .premium-footer {
  width: 100%;
  max-width: none;
}

body.jarayan-v81 img,
body.jarayan-v81 svg,
body.jarayan-v81 video,
body.jarayan-v81 iframe {
  max-width: 100%;
}

/* --------------------------------------------------------------------------
   Header architecture
   -------------------------------------------------------------------------- */
body.jarayan-v81 .premium-header {
  container-type: inline-size;
  isolation: isolate;
}

body.jarayan-v81 .premium-header__inner {
  display: grid !important;
  grid-template-columns: minmax(190px, auto) minmax(0, 1fr) auto;
  align-items: center;
  column-gap: clamp(10px, 1.5vw, 24px) !important;
  min-width: 0;
}

body.jarayan-v81 .premium-header__brand,
body.jarayan-v81 .premium-navigation,
body.jarayan-v81 .premium-header__actions {
  min-width: 0;
  margin: 0;
}

body.jarayan-v81 .premium-navigation {
  width: 100%;
}

body.jarayan-v81 .premium-navigation .primary-menu {
  width: 100%;
  justify-content: center;
  flex-wrap: nowrap;
  min-width: 0;
}

body.jarayan-v81 .premium-navigation .primary-menu > li {
  min-width: 0;
  flex: 0 1 auto;
}

body.jarayan-v81 .premium-navigation .primary-menu > li > a {
  min-width: 0;
  white-space: nowrap;
  text-overflow: ellipsis;
}

body.jarayan-v81 .premium-header__actions {
  justify-content: flex-end;
  flex-wrap: nowrap;
}

body.jarayan-v81 .jarayan-header-width-standard .premium-header__inner {
  width: min(calc(100% - 40px), 1240px) !important;
}

body.jarayan-v81 .jarayan-header-width-wide .premium-header__inner {
  width: min(calc(100% - 44px), 1440px) !important;
  max-width: 1440px !important;
}

body.jarayan-v81 .jarayan-header-width-fluid .premium-header__inner {
  width: min(calc(100% - 48px), 1680px) !important;
  max-width: 1680px !important;
}

body.jarayan-v81 .jarayan-header-layout-compact .premium-header__inner {
  min-height: 74px !important;
  column-gap: 10px !important;
}

body.jarayan-v81 .jarayan-header-layout-compact .site-logo {
  width: 58px;
  height: 52px;
}

body.jarayan-v81 .jarayan-header-layout-compact .site-brand__text strong {
  font-size: .9rem;
}

body.jarayan-v81 .jarayan-header-layout-compact .site-brand__text small {
  display: none;
}

body.jarayan-v81 .jarayan-header-layout-compact .premium-navigation .primary-menu > li > a {
  padding: 10px 8px;
  font-size: .78rem;
}

body.jarayan-v81 .jarayan-header-layout-airy .premium-header__inner {
  min-height: 98px !important;
  column-gap: clamp(20px, 2.3vw, 38px) !important;
}

body.jarayan-v81 .jarayan-header-hide-brand-text .site-brand__text {
  display: none !important;
}

body.jarayan-v81 .premium-header.is-menu-compact .premium-header__inner {
  min-height: 72px !important;
  column-gap: 8px !important;
}

body.jarayan-v81 .premium-header.is-menu-compact .site-logo {
  width: 56px;
  height: 50px;
}

body.jarayan-v81 .premium-header.is-menu-compact .site-brand__text small,
body.jarayan-v81 .premium-header.is-menu-compact .header-team-link span {
  display: none !important;
}

body.jarayan-v81 .premium-header.is-menu-compact .primary-menu > li > a {
  padding-inline: 7px !important;
  font-size: .75rem !important;
}

body.jarayan-v81 .premium-header.is-menu-compact .premium-header__actions {
  gap: 5px;
}

body.jarayan-v81 .premium-header.is-menu-compact .header-appointment {
  padding-inline: 12px;
}

body.jarayan-v81 .jarayan-header-static,
body.jarayan-v81 .jarayan-header-static.is-sticky {
  position: relative !important;
  inset: auto !important;
  transform: none !important;
  animation: none !important;
}

/* Parent-width fallback: prevents the exact “desktop menu inside a narrow shell” bug. */
@media (min-width: 981px) {
  body.jarayan-v81 .premium-header.is-container-mobile .premium-header__inner {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    width: min(calc(100% - 32px), 1440px) !important;
    min-height: 72px !important;
  }

  body.jarayan-v81 .premium-header.is-container-mobile .premium-header__brand {
    margin-inline-end: auto;
  }

  body.jarayan-v81 .premium-header.is-container-mobile .premium-navigation {
    position: fixed !important;
    inset: 0 0 0 auto !important;
    z-index: 220 !important;
    display: flex !important;
    width: min(430px, 92vw) !important;
    max-width: none !important;
    height: 100vh !important;
    height: 100dvh !important;
    padding: max(8px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom)) !important;
    flex-direction: column;
    overflow: hidden !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: #fff !important;
    box-shadow: -24px 0 70px rgba(7, 28, 43, .2) !important;
    transform: translateX(110%) !important;
    transition: transform .3s cubic-bezier(.2,.75,.25,1) !important;
  }

  body.jarayan-v81 .premium-header.is-container-mobile .premium-navigation.is-open {
    transform: none !important;
  }

  body.jarayan-v81 .premium-header.is-container-mobile .mobile-nav-head {
    display: flex !important;
    flex: 0 0 auto;
    min-height: 76px;
  }

  body.jarayan-v81 .premium-header.is-container-mobile .primary-menu {
    display: grid !important;
    flex: 1 1 auto;
    align-content: start;
    justify-content: stretch;
    gap: 7px !important;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 2px 18px !important;
  }

  body.jarayan-v81 .premium-header.is-container-mobile .primary-menu > li {
    width: 100%;
    border: 1px solid #e3edf2;
    border-radius: 15px;
    background: #fff;
    overflow: hidden;
  }

  body.jarayan-v81 .premium-header.is-container-mobile .primary-menu > li > a {
    width: 100%;
    min-height: 48px;
    padding: 10px 13px !important;
    border-radius: 0 !important;
    font-size: .88rem !important;
    white-space: normal;
  }

  body.jarayan-v81 .premium-header.is-container-mobile .primary-menu .sub-menu {
    position: static !important;
    display: none !important;
    width: auto !important;
    margin: 0 !important;
    padding: 6px 12px 12px !important;
    border: 0 !important;
    border-top: 1px solid #edf2f4 !important;
    border-radius: 0 !important;
    background: #f6fafc !important;
    box-shadow: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
  }

  body.jarayan-v81 .premium-header.is-container-mobile .menu-item-has-children.is-open > .sub-menu {
    display: grid !important;
  }

  body.jarayan-v81 .premium-header.is-container-mobile .submenu-toggle {
    position: absolute;
    top: 7px;
    left: 7px;
    z-index: 3;
    display: grid !important;
    width: 36px;
    height: 36px;
    place-items: center;
    border: 0;
    border-radius: 11px;
    background: #edf7fb;
    color: var(--accent);
  }

  body.jarayan-v81 .premium-header.is-container-mobile .submenu-toggle::before {
    content: "";
    width: 8px;
    height: 8px;
    border-left: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
  }

  body.jarayan-v81 .premium-header.is-container-mobile .menu-item-has-children.is-open > .submenu-toggle::before {
    transform: rotate(135deg);
  }

  body.jarayan-v81 .premium-header.is-container-mobile .mobile-nav-shortcuts,
  body.jarayan-v81 .premium-header.is-container-mobile .mobile-nav-contact {
    display: grid !important;
    flex: 0 0 auto;
  }

  body.jarayan-v81 .premium-header.is-container-mobile .menu-toggle {
    display: grid !important;
  }

  body.jarayan-v81 .premium-header.is-container-mobile .search-toggle,
  body.jarayan-v81 .premium-header.is-container-mobile .header-team-link {
    display: none !important;
  }

  body.jarayan-v81 .premium-header.is-container-mobile .header-appointment {
    display: inline-flex !important;
  }
}

/* --------------------------------------------------------------------------
   Single book page — full-width and no JS-dependent blank hero
   -------------------------------------------------------------------------- */
body.single-psych_book,
body.single-psych_book .site-shell,
body.single-psych_book #main,
body.single-psych_book .jarayan-book-single {
  width: 100% !important;
  max-width: none !important;
  margin-inline: 0 !important;
}

body.single-psych_book .jarayan-book-single {
  min-height: 60vh;
  overflow: visible;
}

body.single-psych_book .jarayan-book-single .reveal-up,
body.single-psych_book .jarayan-book-single .reveal-scale {
  opacity: 1 !important;
  transform: none !important;
  transition: none !important;
}

body.single-psych_book .jarayan-book-hero {
  min-height: 0 !important;
  padding: clamp(26px, 4vw, 58px) 0 clamp(44px, 6vw, 82px) !important;
  background:
    radial-gradient(circle at 12% 20%, rgba(53,180,232,.16), transparent 34%),
    linear-gradient(135deg, #edf8fd 0%, #fff 52%, #f4f9fb 100%) !important;
}

body.single-psych_book .jarayan-book-hero__grid {
  position: relative;
  width: min(calc(100% - 48px), 1380px) !important;
  max-width: 1380px !important;
  padding: clamp(26px, 4vw, 56px);
  border: 1px solid rgba(198,220,230,.82);
  border-radius: clamp(26px, 3.2vw, 42px);
  background: rgba(255,255,255,.82);
  box-shadow: 0 30px 90px rgba(15,48,65,.1);
  overflow: hidden;
}

body.single-psych_book .jarayan-book-hero__grid::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(15,134,197,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15,134,197,.025) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: linear-gradient(90deg, #000, transparent 78%);
}

body.single-psych_book .jarayan-book-hero__cover,
body.single-psych_book .jarayan-book-hero__content {
  position: relative;
  z-index: 1;
}

body.single-psych_book .jarayan-book-hero__cover {
  min-height: clamp(360px, 40vw, 500px);
}

body.single-psych_book .jarayan-book-hero__book {
  width: min(320px, 82%);
  border-radius: 12px 26px 26px 12px;
  box-shadow: -26px 34px 65px rgba(12,31,43,.27), inset 12px 0 14px rgba(255,255,255,.1), inset -4px 0 10px rgba(0,0,0,.22);
}

body.single-psych_book .jarayan-book-hero__content h1 {
  max-width: 820px;
  margin-block: .85rem .65rem;
  font-size: clamp(2.15rem, 4.6vw, 4.7rem);
  line-height: 1.22;
}

body.single-psych_book .jarayan-book-lead {
  max-width: 800px;
  font-size: clamp(.95rem, 1.35vw, 1.1rem);
}

body.single-psych_book .jarayan-book-facts {
  grid-template-columns: repeat(3, minmax(150px, 1fr));
}

body.single-psych_book .jarayan-book-facts > div {
  min-width: 0;
  box-shadow: 0 10px 30px rgba(16,33,47,.045);
}

body.single-psych_book .jarayan-book-body {
  padding: clamp(40px, 5vw, 76px) 0 !important;
}

body.single-psych_book .jarayan-book-body__grid {
  width: min(calc(100% - 48px), 1280px) !important;
  max-width: 1280px !important;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, .55fr);
  gap: clamp(24px, 4vw, 58px);
}

body.single-psych_book .jarayan-book-article > section,
body.single-psych_book .jarayan-book-article .entry-content {
  padding: clamp(20px, 2.8vw, 34px);
  border: 1px solid #e1ebef;
  border-radius: 26px;
  background: #fff;
  box-shadow: 0 16px 44px rgba(16,33,47,.055);
}

body.single-psych_book .jarayan-book-article > section + section,
body.single-psych_book .jarayan-book-article > section + .entry-content {
  margin-top: 18px;
}

body.single-psych_book .jarayan-book-highlight {
  background: linear-gradient(135deg, #eef9fd, #fff);
}

body.single-psych_book .jarayan-book-info-card,
body.single-psych_book .jarayan-book-disclaimer {
  box-shadow: 0 14px 36px rgba(16,33,47,.055);
}

body.single-psych_book .jarayan-related-books > .container {
  width: min(calc(100% - 48px), 1280px) !important;
  max-width: 1280px !important;
}

/* Fail-safe for older browsers without overflow:clip and color-mix support. */
@supports not (overflow: clip) {
  body.jarayan-v81 .site-shell,
  .jarayan-library-page,
  .jarayan-book-single {
    overflow-x: hidden;
  }
}

@supports not (color: color-mix(in srgb, #000, #fff)) {
  body.single-psych_book .jarayan-book-topics a {
    background: #edf7fb;
    color: #0b709f;
  }
}

@media (max-width: 1100px) {
  body.jarayan-v81 .premium-header__inner {
    grid-template-columns: minmax(165px, auto) minmax(0, 1fr) auto;
  }

  body.single-psych_book .jarayan-book-hero__grid,
  body.single-psych_book .jarayan-book-body__grid {
    grid-template-columns: 1fr;
  }

  body.single-psych_book .jarayan-book-hero__cover {
    order: 2;
    min-height: 390px;
  }

  body.single-psych_book .jarayan-book-hero__content {
    order: 1;
  }

  body.single-psych_book .jarayan-book-sidebar {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  body.jarayan-v81 .premium-header__inner,
  body.jarayan-v81 .jarayan-header-width-standard .premium-header__inner,
  body.jarayan-v81 .jarayan-header-width-wide .premium-header__inner,
  body.jarayan-v81 .jarayan-header-width-fluid .premium-header__inner {
    display: flex !important;
    width: calc(100% - 24px) !important;
    min-height: 70px !important;
  }
}

@media (max-width: 720px) {
  body.single-psych_book .jarayan-book-hero__grid,
  body.single-psych_book .jarayan-book-body__grid,
  body.single-psych_book .jarayan-related-books > .container {
    width: calc(100% - 24px) !important;
  }

  body.single-psych_book .jarayan-book-hero__grid {
    padding: 22px 18px 28px;
    border-radius: 26px;
  }

  body.single-psych_book .jarayan-book-hero__cover {
    min-height: 320px;
  }

  body.single-psych_book .jarayan-book-hero__book {
    width: min(220px, 72%);
  }

  body.single-psych_book .jarayan-book-facts,
  body.single-psych_book .jarayan-book-sidebar {
    grid-template-columns: 1fr;
  }

  body.single-psych_book .jarayan-book-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  body.single-psych_book .jarayan-book-actions .button {
    width: 100%;
  }

  body.single-psych_book .jarayan-related-books__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 380px) {
  body.single-psych_book .jarayan-book-hero__grid,
  body.single-psych_book .jarayan-book-body__grid,
  body.single-psych_book .jarayan-related-books > .container {
    width: calc(100% - 16px) !important;
  }

  body.single-psych_book .jarayan-book-hero__grid {
    padding-inline: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.jarayan-v81 .premium-navigation,
  body.jarayan-v81 .premium-header,
  body.single-psych_book * {
    scroll-behavior: auto !important;
  }
}

/* Logged-in administrators: keep sticky surfaces below the WordPress toolbar. */
body.admin-bar.jarayan-v81 .site-header.is-sticky:not(.jarayan-header-static){top:32px!important}
@media(max-width:782px){body.admin-bar.jarayan-v81 .site-header.is-sticky:not(.jarayan-header-static){top:46px!important}}
