/* Mobile side drawer - Ultra Responsive */
.Drawer {
  position: fixed;
  inset: 0;
  z-index: 999;
  pointer-events: none;
  isolation: isolate;
}

.Drawer .Drawer__panel {
  position: absolute;
  right: 0;
  left: auto;
  top: 0;
  bottom: 0;
  width: min(90vw, 380px);
  background: linear-gradient(to bottom, #ffffff 0%, #fafbfc 100%);
  box-shadow: -8px 0 32px rgba(14, 42, 71, 0.12);
  transform: translateX(102%);
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  border-left: 1px solid rgba(14, 42, 71, 0.08);
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* Dynamic viewport для mobile browsers */
  max-height: -webkit-fill-available; /* Safari iOS fix */
  overscroll-behavior: contain; /* Запобігає overscroll */
}

/* Brand row */
.Drawer .Drawer__brand {
  display: flex;
  align-items: center;
  gap: clamp(0.5rem, 2vw, 0.75rem);
  padding: clamp(0.75rem, 2.5vw, 1rem);
  padding-bottom: clamp(0.6rem, 2vw, 0.85rem);
  border-bottom: 1px solid rgba(14, 42, 71, 0.08);
  background: #fff;
  flex-shrink: 0;
}

.Drawer .Drawer__brand img {
  width: clamp(26px, 7vw, 32px);
  height: clamp(26px, 7vw, 32px);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(14, 42, 71, 0.08);
  flex-shrink: 0;
}

.Drawer .Drawer__brand strong {
  font-weight: 700;
  font-size: clamp(0.85rem, 2.5vw, 0.95rem);
  color: var(--brand-800);
  letter-spacing: -0.01em;
  line-height: 1.3;
  word-break: break-word;
}

.Drawer .Drawer__brand .Drawer__close {
  margin-left: auto;
  flex-shrink: 0;
}

/* Quick actions */
.Drawer .Drawer__quick {
  display: flex;
  gap: clamp(0.35rem, 1.5vw, 0.5rem);
  flex-wrap: wrap;
  padding: clamp(0.65rem, 2vw, 0.85rem) clamp(0.75rem, 2.5vw, 1rem);
  border-bottom: 1px solid rgba(14, 42, 71, 0.08);
  background: #fff;
  flex-shrink: 0;
}

.Drawer .Drawer__quick .btn {
  flex: 1 1 auto;
  justify-content: center;
  min-height: 44px; /* Accessibility: мінімум для touch targets */
  min-width: 44px;
  font-size: clamp(0.8rem, 2.2vw, 0.9rem);
  font-weight: 600;
  border-radius: 10px;
  transition: all 0.2s ease;
  touch-action: manipulation; /* Покращує тач */
}

.Drawer .Drawer__quick .btn:active {
  transform: scale(0.97);
}

/* Sections - Scrollable content */
.Drawer .Drawer__sections {
  padding: clamp(0.4rem, 1.5vw, 0.5rem) clamp(0.4rem, 1.5vw, 0.5rem) 0.5rem;
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  min-height: 0; /* Critical для flex scroll */
}

.Drawer .Drawer__sections h4 {
  font-size: clamp(0.7rem, 2vw, 0.75rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: clamp(0.6rem, 2vw, 0.75rem) clamp(0.75rem, 2.5vw, 1rem) clamp(0.4rem, 1.5vw, 0.5rem);
  color: var(--muted);
}

/* Menu items */
.Drawer .Drawer__menu {
  padding: 0.25rem clamp(0.35rem, 1.5vw, 0.5rem) 1rem;
}

.Drawer .Drawer__menu li {
  margin: clamp(0.1rem, 0.5vw, 0.15rem) 0;
}

.Drawer .Drawer__menu a {
  display: flex;
  align-items: center;
  padding: clamp(0.7rem, 2.2vw, 0.85rem) clamp(0.8rem, 2.5vw, 1rem);
  min-height: 48px; /* Accessibility: touch target */
  border-radius: 12px;
  font-weight: 600;
  font-size: clamp(0.85rem, 2.3vw, 0.95rem);
  color: var(--brand-800);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.Drawer .Drawer__menu a::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  background: var(--brand-600);
  border-radius: 0 3px 3px 0;
  transition: height 0.2s ease;
}

/* Hover тільки для desktop/tablet з hover */
@media (hover: hover) and (pointer: fine) {
  .Drawer .Drawer__menu a:hover {
    background: rgba(14, 42, 71, 0.08);
    padding-left: 1.25rem;
  }
  
  .Drawer .Drawer__menu a:hover::before {
    height: 60%;
  }
}

.Drawer .Drawer__menu a:active {
  background: rgba(14, 42, 71, 0.12);
  transform: scale(0.98);
}

/* Utils - Sticky footer */
.Drawer .Drawer__utils {
  margin-top: 0;
  padding: clamp(0.65rem, 2vw, 0.85rem) clamp(0.75rem, 2.5vw, 1rem);
  border-top: 1px solid rgba(14, 42, 71, 0.08);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px); /* Safari */
  flex-shrink: 0;
}

.Drawer .Drawer__socials {
  display: inline-flex;
  gap: clamp(0.4rem, 1.5vw, 0.5rem);
  flex-wrap: wrap;
}

/* Social icons - Accessibility compliant */
.Drawer .Drawer__icon {
  display: grid;
  place-items: center;
  width: clamp(40px, 10vw, 44px); /* Мінімум 40px для touch */
  height: clamp(40px, 10vw, 44px);
  border-radius: 12px;
  background: rgba(14, 42, 71, 0.06);
  color: var(--brand-800);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.Drawer .Drawer__icon::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: var(--brand-600);
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: -1;
}

@media (hover: hover) and (pointer: fine) {
  .Drawer .Drawer__icon:hover {
    color: #fff;
    transform: translateY(-2px);
  }
  
  .Drawer .Drawer__icon:hover::after {
    opacity: 1;
  }
}

.Drawer .Drawer__icon:active {
  transform: translateY(0) scale(0.95);
}

.Drawer .Drawer__icon:active::after {
  opacity: 1;
}

/* Note */
.Drawer .Drawer__note {
  padding: clamp(0.4rem, 1.5vw, 0.5rem) clamp(0.75rem, 2.5vw, 1rem) clamp(0.6rem, 2vw, 0.75rem);
  color: var(--muted);
  font-size: clamp(0.75rem, 2vw, 0.8rem);
  text-align: center;
  flex-shrink: 0;
}

/* Close button */
.Drawer .Drawer__close {
  align-self: flex-end;
  background: transparent;
  border: 0;
  font-size: clamp(1.5rem, 4vw, 1.75rem);
  line-height: 1;
  padding: clamp(0.25rem, 1vw, 0.3rem) clamp(0.5rem, 2vw, 0.6rem);
  min-width: 44px; /* Touch target */
  min-height: 44px;
  border-radius: 10px;
  color: var(--brand-800);
  transition: all 0.2s ease;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) and (pointer: fine) {
  .Drawer .Drawer__close:hover {
    background: rgba(14, 42, 71, 0.08);
    transform: rotate(90deg);
  }
}

.Drawer .Drawer__close:active {
  background: rgba(14, 42, 71, 0.12);
  transform: rotate(90deg) scale(0.95);
}

/* Backdrop */
.Drawer .Drawer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(14, 22, 33, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.32s ease, backdrop-filter 0.32s ease;
  z-index: 0;
  touch-action: none; /* Блокує тачі на backdrop */
}

.Drawer .Drawer__panel {
  z-index: 1;
}

/* Open state */
.Drawer.is-open {
  pointer-events: auto;
}

.Drawer.is-open .Drawer__panel {
  transform: none;
}

.Drawer.is-open .Drawer__backdrop {
  opacity: 1;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Scrollbar styling */
.Drawer .Drawer__sections::-webkit-scrollbar {
  width: 6px;
}

.Drawer .Drawer__sections::-webkit-scrollbar-track {
  background: transparent;
}

.Drawer .Drawer__sections::-webkit-scrollbar-thumb {
  background: rgba(14, 42, 71, 0.15);
  border-radius: 3px;
}

.Drawer .Drawer__sections::-webkit-scrollbar-thumb:hover {
  background: rgba(14, 42, 71, 0.25);
}

/* ========================================
   RESPONSIVE BREAKPOINTS
   ======================================== */

/* Ultra-small phones: 280-320px (Galaxy Fold, старі Android) */
@media (max-width: 320px) {
  .Drawer .Drawer__panel {
    width: 95vw;
  }
  
  .Drawer .Drawer__brand {
    gap: 0.4rem;
    padding: 0.6rem 0.65rem 0.5rem;
  }
  
  .Drawer .Drawer__brand img {
    width: 24px;
    height: 24px;
  }
  
  .Drawer .Drawer__brand strong {
    font-size: 0.8rem;
  }
  
  .Drawer .Drawer__quick {
    padding: 0.55rem 0.65rem;
    gap: 0.3rem;
  }
  
  .Drawer .Drawer__quick .btn {
    min-height: 40px;
    font-size: 0.75rem;
    padding: 0.5rem 0.6rem;
  }
  
  .Drawer .Drawer__menu a {
    padding: 0.65rem 0.7rem;
    min-height: 44px;
    font-size: 0.8rem;
  }
  
  .Drawer .Drawer__utils {
    padding: 0.6rem 0.65rem;
  }
  
  .Drawer .Drawer__icon {
    width: 38px;
    height: 38px;
  }
  
  .Drawer .Drawer__icon svg {
    width: 16px;
    height: 16px;
  }
}

/* Small phones: 321-375px (iPhone SE, малі Android) */
@media (min-width: 321px) and (max-width: 375px) {
  .Drawer .Drawer__panel {
    width: 92vw;
  }
  
  .Drawer .Drawer__brand {
    padding: 0.7rem 0.75rem 0.6rem;
  }
  
  .Drawer .Drawer__quick {
    padding: 0.6rem 0.75rem;
  }
  
  .Drawer .Drawer__quick .btn {
    min-height: 42px;
    font-size: 0.82rem;
  }
  
  .Drawer .Drawer__menu a {
    padding: 0.7rem 0.8rem;
    font-size: 0.87rem;
  }
}

/* Standard phones: 376-414px (iPhone 12/13/14, більшість Android) */
@media (min-width: 376px) and (max-width: 414px) {
  .Drawer .Drawer__panel {
    width: 88vw;
  }
}

/* Large phones: 415-480px (iPhone Pro Max, великі Android) */
@media (min-width: 415px) and (max-width: 480px) {
  .Drawer .Drawer__panel {
    width: 85vw;
    max-width: 360px;
  }
}

/* Small tablets portrait: 481-600px */
@media (min-width: 481px) and (max-width: 600px) {
  .Drawer .Drawer__panel {
    width: 75vw;
    max-width: 380px;
  }
}

/* Tablets portrait: 601-768px (iPad Mini, Android tablets) */
@media (min-width: 601px) and (max-width: 768px) {
  .Drawer .Drawer__panel {
    width: 65vw;
    max-width: 400px;
  }
  
  .Drawer .Drawer__brand img {
    width: 34px;
    height: 34px;
  }
  
  .Drawer .Drawer__brand strong {
    font-size: 1rem;
  }
  
  .Drawer .Drawer__quick .btn {
    min-height: 46px;
    font-size: 0.95rem;
  }
  
  .Drawer .Drawer__menu a {
    padding: 0.9rem 1.1rem;
    font-size: 1rem;
  }
  
  .Drawer .Drawer__icon {
    width: 46px;
    height: 46px;
  }
}

/* Tablets landscape: 769-900px */
@media (min-width: 769px) and (max-width: 900px) {
  .Drawer .Drawer__panel {
    width: 50vw;
    max-width: 420px;
  }
}

/* Landscape orientation adjustments */
@media (orientation: landscape) and (max-height: 500px) {
  .Drawer .Drawer__brand {
    padding: 0.6rem 0.8rem 0.5rem;
  }
  
  .Drawer .Drawer__brand img {
    width: 26px;
    height: 26px;
  }
  
  .Drawer .Drawer__quick {
    padding: 0.55rem 0.75rem;
  }
  
  .Drawer .Drawer__quick .btn {
    min-height: 38px;
    font-size: 0.85rem;
  }
  
  .Drawer .Drawer__menu a {
    padding: 0.65rem 0.85rem;
    min-height: 42px;
  }
  
  .Drawer .Drawer__utils {
    padding: 0.6rem 0.8rem;
  }
  
  .Drawer .Drawer__sections h4 {
    margin-top: 0.4rem;
    margin-bottom: 0.3rem;
  }
}

/* Foldable phones (unfolded): Galaxy Z Fold */
@media (min-width: 653px) and (max-width: 717px) {
  .Drawer .Drawer__panel {
    width: 70vw;
    max-width: 420px;
  }
}

/* High DPI screens - smaller touch targets можуть бути більш точними */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .Drawer .Drawer__menu a,
  .Drawer .Drawer__icon,
  .Drawer .Drawer__close {
    -webkit-tap-highlight-color: rgba(14, 42, 71, 0.1);
  }
}

/* Prefers reduced motion - accessibility */
@media (prefers-reduced-motion: reduce) {
  .Drawer .Drawer__panel,
  .Drawer .Drawer__backdrop,
  .Drawer .Drawer__menu a,
  .Drawer .Drawer__icon,
  .Drawer .Drawer__close,
  .Drawer .Drawer__quick .btn {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* High contrast mode - accessibility */
@media (prefers-contrast: high) {
  .Drawer .Drawer__panel {
    border-left: 2px solid rgba(14, 42, 71, 0.3);
  }
  
  .Drawer .Drawer__brand,
  .Drawer .Drawer__quick,
  .Drawer .Drawer__utils {
    border-color: rgba(14, 42, 71, 0.2);
  }
  
  .Drawer .Drawer__menu a:hover,
  .Drawer .Drawer__menu a:active {
    background: rgba(14, 42, 71, 0.15);
  }
}

/* Desktop and up - hide drawer */
@media (min-width: 901px) {
  .Drawer {
    display: none;
  }
}

/* Safe area insets для iPhone з notch */
@supports (padding: max(0px)) {
  .Drawer .Drawer__panel {
    padding-top: max(0px, env(safe-area-inset-top));
    padding-bottom: max(0px, env(safe-area-inset-bottom));
  }
  
  .Drawer .Drawer__utils {
    padding-bottom: max(0.85rem, calc(0.85rem + env(safe-area-inset-bottom)));
  }
}
