/**
 * @file
 * Wares Point Mobile Jewel Navigation Styles.
 *
 * Implements slim, faceted gold jewel tabs, synchronized edge drawer transitions,
 * drill-down navigation panels, accessibility focus outlines, and responsive fallbacks.
 */

:root {
  /* Official Wares Point Brand Palette */
  --wp-m-cream: #FFF2E0;
  --wp-m-beige: #EED6B5;
  --wp-m-sand: #C8A97E;
  --wp-m-tan: #A88554;
  --wp-m-brown: #896432;
  --wp-m-text: #24211E;
  --wp-m-muted: #6B6259;
  --wp-m-border: #DECDB5;
  --wp-m-white: #FFFFFF;

  /* Flat, Polished Gold Jewel Palette & Restrained Elevation */
  --wp-jewel-bg: linear-gradient(135deg, #E6D2B8 0%, #D4B68B 50%, #C8A97E 100%);
  --wp-jewel-bg-hover: linear-gradient(135deg, #F0E0CB 0%, #DEBF96 50%, #D2B285 100%);
  --wp-jewel-bg-active: linear-gradient(135deg, #CCA77A 0%, #BF9869 100%);
  --wp-jewel-border: #A88554;
  --wp-jewel-shadow: 0 3px 10px rgba(36, 33, 30, 0.16), 0 1px 2px rgba(36, 33, 30, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  --wp-jewel-shadow-hover: 0 5px 16px rgba(168, 133, 84, 0.32), 0 2px 4px rgba(36, 33, 30, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.65);
  --wp-jewel-shadow-active: 0 1px 4px rgba(36, 33, 30, 0.2), inset 0 1px 2px rgba(36, 33, 30, 0.15);

  /* Drawer Sizing & Timing Defaults */
  --wp-drawer-width: min(85vw, 360px);
  --wp-drawer-height-h: min(75dvh, 480px);
  --wp-drawer-duration: 240ms;
  --wp-drilldown-duration: 180ms;
  --wp-drawer-easing: cubic-bezier(0.25, 1, 0.5, 1);
}

/* ==========================================================================
   Base Drawer Container & Backdrop
   ========================================================================== */

.wp-mobile-drawer {
  position: relative;
  z-index: 1000;
}

/* Backdrop Overlay */
.wp-mobile-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(36, 33, 30, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--wp-drawer-duration) ease, visibility var(--wp-drawer-duration) ease;
  z-index: 1001;
  pointer-events: none;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.wp-mobile-drawer.is-open .wp-mobile-backdrop {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* ==========================================================================
   Drawer Panel (Modal Dialog)
   ========================================================================== */

.wp-mobile-panel {
  position: fixed;
  z-index: 1002;
  background-color: var(--wp-m-cream);
  color: var(--wp-m-text);
  box-shadow: 0 10px 30px rgba(36, 33, 30, 0.25);
  display: flex;
  flex-direction: column;
  transition: transform var(--wp-drawer-duration) var(--wp-drawer-easing),
              visibility var(--wp-drawer-duration) var(--wp-drawer-easing);
  visibility: hidden;
  outline: none;
  box-sizing: border-box;
}

/* Edge-specific panel positioning and transforms */
.wp-mobile-drawer--left .wp-mobile-panel {
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--wp-drawer-width);
  height: 100dvh;
  border-right: 1px solid var(--wp-m-border);
  transform: translateX(-100%);
}

.wp-mobile-drawer--right .wp-mobile-panel {
  top: 0;
  bottom: 0;
  right: 0;
  width: var(--wp-drawer-width);
  height: 100dvh;
  border-left: 1px solid var(--wp-m-border);
  transform: translateX(100%);
}

.wp-mobile-drawer--top .wp-mobile-panel {
  top: 0;
  left: 0;
  right: 0;
  height: var(--wp-drawer-height-h);
  border-bottom: 1px solid var(--wp-m-border);
  transform: translateY(-100%);
}

.wp-mobile-drawer--bottom .wp-mobile-panel {
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--wp-drawer-height-h);
  border-top: 1px solid var(--wp-m-border);
  transform: translateY(100%);
}

/* Open states */
.wp-mobile-drawer--left.is-open .wp-mobile-panel,
.wp-mobile-drawer--right.is-open .wp-mobile-panel {
  transform: translateX(0);
  visibility: visible;
}

.wp-mobile-drawer--top.is-open .wp-mobile-panel,
.wp-mobile-drawer--bottom.is-open .wp-mobile-panel {
  transform: translateY(0);
  visibility: visible;
}

/* ==========================================================================
   Jewel Handle: Anchored to Edge, Slides in Lockstep with Drawer
   ========================================================================== */

.wp-jewel-handle {
  position: fixed;
  z-index: 1005;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Minimum 44x44px touch target */
  min-width: 44px;
  min-height: 48px;
  visibility: visible !important;
  pointer-events: auto !important;
  transition: transform var(--wp-drawer-duration) var(--wp-drawer-easing);
}

.wp-jewel-handle:focus-visible {
  outline: 2px solid var(--wp-m-brown);
  outline-offset: 2px;
}

/* Jewel Tab Geometry: Flatter, polished satin gold tab */
.wp-jewel-handle__tab {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--wp-jewel-bg);
  box-shadow: var(--wp-jewel-shadow);
  color: var(--wp-m-text);
  border: 1px solid var(--wp-jewel-border);
  box-sizing: border-box;
  transition: background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.wp-jewel-handle:hover .wp-jewel-handle__tab {
  background: var(--wp-jewel-bg-hover);
  box-shadow: var(--wp-jewel-shadow-hover);
}

.wp-jewel-handle:active .wp-jewel-handle__tab {
  background: var(--wp-jewel-bg-active);
  box-shadow: var(--wp-jewel-shadow-active);
  transform: scale(0.96);
}

/* Edge-specific initial handle positions & open synchronized translations */
.wp-mobile-drawer--left .wp-jewel-handle {
  left: 0;
  top: var(--wp-jewel-offset, 50%);
  transform: translateY(-50%);
}

.wp-mobile-drawer--left.is-open .wp-jewel-handle {
  transform: translate(var(--wp-drawer-width), -50%);
}

.wp-mobile-drawer--left .wp-jewel-handle__tab {
  width: 34px;
  height: 52px;
  border-top-right-radius: 10px;
  border-bottom-right-radius: 10px;
  border-left: none;
  padding-left: 2px;
  padding-right: 4px;
}

.wp-mobile-drawer--right .wp-jewel-handle {
  right: 0;
  top: var(--wp-jewel-offset, 50%);
  transform: translateY(-50%);
}

.wp-mobile-drawer--right.is-open .wp-jewel-handle {
  transform: translate(calc(-1 * var(--wp-drawer-width)), -50%);
}

.wp-mobile-drawer--right .wp-jewel-handle__tab {
  width: 34px;
  height: 52px;
  border-top-left-radius: 10px;
  border-bottom-left-radius: 10px;
  border-right: none;
  padding-right: 2px;
  padding-left: 4px;
}

.wp-mobile-drawer--top .wp-jewel-handle {
  top: 0;
  left: var(--wp-jewel-offset, 50%);
  transform: translateX(-50%);
}

.wp-mobile-drawer--top.is-open .wp-jewel-handle {
  transform: translate(-50%, var(--wp-drawer-height-h));
}

.wp-mobile-drawer--top .wp-jewel-handle__tab {
  width: 52px;
  height: 34px;
  border-bottom-left-radius: 10px;
  border-bottom-right-radius: 10px;
  border-top: none;
  padding-top: 2px;
  padding-bottom: 4px;
}

.wp-mobile-drawer--bottom .wp-jewel-handle {
  bottom: 0;
  left: var(--wp-jewel-offset, 50%);
  transform: translateX(-50%);
}

.wp-mobile-drawer--bottom.is-open .wp-jewel-handle {
  transform: translate(-50%, calc(-1 * var(--wp-drawer-height-h)));
}

.wp-mobile-drawer--bottom .wp-jewel-handle__tab {
  width: 52px;
  height: 34px;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  border-bottom: none;
  padding-bottom: 2px;
  padding-top: 4px;
}

/* Jewel SVG icon inside tab: crisp, polished, proportional */
.wp-jewel-icon {
  width: 18px;
  height: 18px;
  display: block;
  stroke: var(--wp-m-text);
}

/* ==========================================================================
   Panel Header & Close Button
   ========================================================================== */

.wp-mobile-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 14px 18px;
  border-bottom: 1px solid var(--wp-m-border);
  background: var(--wp-m-cream);
  flex-shrink: 0;
}

.wp-mobile-panel__title {
  margin: 0;
  font-family: var(--wp-font-heading, 'Merriweather', Georgia, serif);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--wp-m-brown);
  line-height: 1.3;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wp-mobile-panel__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: -6px -8px -6px 0;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--wp-m-muted);
  cursor: pointer;
  border-radius: 6px;
  transition: color 150ms ease, background 150ms ease;
}

.wp-mobile-panel__close:hover {
  color: var(--wp-m-text);
  background: var(--wp-m-beige);
}

.wp-mobile-panel__close:focus-visible {
  outline: 2px solid var(--wp-m-brown);
  outline-offset: 2px;
}

/* ==========================================================================
   Drilldown Viewport & Panels
   ========================================================================== */

.wp-mobile-panel__viewport {
  position: relative;
  flex: 1 1 auto;
  overflow: hidden;
  width: 100%;
  height: 100%;
}

.wp-mobile-drilldown-panel {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 14px calc(env(safe-area-inset-bottom, 0px) + 20px) 14px;
  background: var(--wp-m-cream);
  transform: translateX(100%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: transform var(--wp-drilldown-duration) ease,
              opacity var(--wp-drilldown-duration) ease,
              visibility var(--wp-drilldown-duration) ease;
}

.wp-mobile-drilldown-panel.is-active {
  transform: translateX(0);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 2;
}

.wp-mobile-drilldown-panel.is-parent {
  transform: translateX(-25%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 1;
}

/* Drilldown Submenu Header (Back button + Submenu title) */
.wp-mobile-drilldown-panel__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--wp-m-border);
}

.wp-mobile-drilldown-panel__back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 10px 0 6px;
  background: var(--wp-m-beige);
  border: 1px solid var(--wp-m-border);
  border-radius: 6px;
  color: var(--wp-m-text);
  font-family: var(--wp-font-body, system-ui, sans-serif);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
}

.wp-mobile-drilldown-panel__back:hover {
  background: var(--wp-m-sand);
  color: #FFFFFF;
}

.wp-mobile-drilldown-panel__back:focus-visible {
  outline: 2px solid var(--wp-m-brown);
  outline-offset: 2px;
}

.wp-mobile-drilldown-panel__title {
  font-family: var(--wp-font-heading, Georgia, serif);
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--wp-m-brown);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   Menu Rows & Item Controls
   ========================================================================== */

.wp-mobile-menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wp-mobile-menu__item {
  border-radius: 6px;
  transition: background 150ms ease;
}

.wp-mobile-menu__item:hover {
  background: rgba(238, 214, 181, 0.4);
}

.wp-mobile-menu__item.is-active,
.wp-mobile-menu__item.in-active-trail {
  background: var(--wp-m-beige);
}

.wp-mobile-menu__row {
  display: flex;
  align-items: stretch;
  min-height: 44px;
}

.wp-mobile-menu__link {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  color: var(--wp-m-text);
  font-family: var(--wp-font-body, 'Inter', system-ui, sans-serif);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  line-height: 1.4;
  word-break: break-word;
}

.wp-mobile-menu__item.is-active .wp-mobile-menu__link,
.wp-mobile-menu__item.in-active-trail .wp-mobile-menu__link {
  color: var(--wp-m-brown);
  font-weight: 700;
}

.wp-mobile-menu__link:focus-visible {
  outline: 2px solid var(--wp-m-brown);
  outline-offset: -2px;
  border-radius: 4px;
}

/* Disclosure Button for Drilldown Children */
.wp-mobile-menu__disclosure {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-height: 44px;
  padding: 0;
  margin: 0;
  background: transparent;
  border: none;
  border-left: 1px solid rgba(222, 205, 181, 0.6);
  color: var(--wp-m-muted);
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
  border-top-right-radius: 6px;
  border-bottom-right-radius: 6px;
}

.wp-mobile-menu__disclosure:hover {
  background: var(--wp-m-sand);
  color: #FFFFFF;
}

.wp-mobile-menu__disclosure:focus-visible {
  outline: 2px solid var(--wp-m-brown);
  outline-offset: -2px;
}

/* Optional link description */
.wp-mobile-menu__desc {
  padding: 0 12px 6px 12px;
  font-size: 0.75rem;
  color: var(--wp-m-muted);
  line-height: 1.35;
}

/* ==========================================================================
   Block Integration Styles
   ========================================================================== */

/* On mobile (< 768px), suppress duplicate static menu links when enhanced drawer is active,
   while ensuring the drawer host, edge jewel handle, and sliding drawer remain visible */
@media (max-width: 767.98px) {
  .wp-mobile-block-enhanced .block__content > *:not(.wp-mobile-drawer):not(.wp-mobile-drawer-host),
  .wp-mobile-block-enhanced .wp-mobile-drawer-host > *:not(.wp-mobile-drawer) {
    display: none !important;
  }

  .wp-mobile-block-enhanced .wp-mobile-drawer-host {
    display: block !important;
    visibility: visible !important;
    width: auto !important;
    height: auto !important;
    overflow: visible !important;
  }

  .wp-mobile-drawer {
    display: block !important;
    visibility: visible !important;
  }
}

/* Suppress block header when hide_block_title is set */
.wp-mobile-block--hide-title > .block__title {
  display: none !important;
}

/* ==========================================================================
   No-JS Accessible Fallback
   ========================================================================== */

.wp-mobile-noscript-menu {
  display: none;
  padding: 16px;
  background: var(--wp-m-cream);
  border: 1px solid var(--wp-m-border);
  margin-top: 12px;
}

html:not(.js) .wp-mobile-noscript-menu {
  display: block;
}

html:not(.js) .wp-jewel-handle,
html:not(.js) .wp-mobile-panel,
html:not(.js) .wp-mobile-backdrop {
  display: none !important;
}

/* ==========================================================================
   Desktop Viewport Media Queries & Responsive Visibility
   ========================================================================== */

@media (min-width: 768px) {
  /* Unless explicitly configured as always-visible, hide mobile drawer on desktop */
  .wp-mobile-drawer:not(.wp-mobile-drawer--always-visible) {
    display: none !important;
  }

  /* When block is explicitly configured to hide on desktop, suppress it */
  .wp-mobile-hide-desktop {
    display: none !important;
  }

  /*
   * Crucial: On desktop, always restore and display the original menu block content.
   * Ensures that switching/resizing between mobile and desktop never leaves the original
   * header navigation collapsed or hidden, even if always_visible was set on the drawer.
   */
  .wp-mobile-block-enhanced:not(.wp-mobile-hide-desktop) {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  .wp-mobile-block-enhanced:not(.wp-mobile-hide-desktop) .block__content {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  .wp-mobile-block-enhanced:not(.wp-mobile-hide-desktop) .wp-mobile-drawer-host {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: auto !important;
    height: auto !important;
    overflow: visible !important;
  }

  .wp-mobile-block-enhanced:not(.wp-mobile-hide-desktop) .menu--main {
    display: block !important;
    visibility: visible !important;
  }

  .wp-mobile-block-enhanced:not(.wp-mobile-hide-desktop) ul.menu:not(.menu--sub) {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  .wp-mobile-block-enhanced:not(.wp-mobile-hide-desktop) ul.menu:not(.menu--sub) > .menu-item {
    display: inline-flex !important;
    align-items: center !important;
    visibility: visible !important;
  }

  .wp-mobile-block-enhanced:not(.wp-mobile-hide-desktop) ul.menu:not(.menu--sub) > .menu-item a {
    display: inline-flex !important;
    visibility: visible !important;
  }
}

/* Lock document scrolling safely when drawer is open */
body.wp-mobile-scroll-locked {
  overflow: hidden !important;
  touch-action: none;
}

/* ==========================================================================
   Accessibility: Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .wp-mobile-panel,
  .wp-mobile-backdrop,
  .wp-mobile-drilldown-panel,
  .wp-jewel-handle {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
