/* Qaz.pet mobile and tablet shell layer.
   This file owns the app-like navigation shell: bottom nav, mobile sheet and
   tablet rail. Content grids stay in legacy/product layers for now. */

.bottom-nav {
  display: none;
}

.mobile-menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-direction: column;
  border-radius: var(--radius-sm);
  color: var(--text);
}

.mobile-menu-btn span {
  display: block;
  width: 20px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform var(--transition), opacity var(--transition);
}

.mobile-menu-btn.is-open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.mobile-menu-btn.is-open span:nth-child(2) {
  opacity: 0;
}

.mobile-menu-btn.is-open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.mobile-nav {
  display: none;
  flex-direction: column;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.mobile-nav.is-open {
  display: flex;
}

.mobile-nav-link {
  padding: 12px 20px;
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}

.mobile-nav-link:hover {
  background: var(--border-light);
  color: var(--text);
}

.mobile-nav-link.active {
  background: var(--accent-light);
  color: var(--accent-dark);
}

.mobile-nav-link--urgent {
  color: var(--danger);
}

.bottom-nav-item svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

body[data-display-mode="standalone"] {
  overscroll-behavior-y: none;
}

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

@media (max-width: 768px) {
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--z-navigation);
    background: var(--surface);
    border-top: 1px solid var(--border-light);
    height: var(--bottom-nav-h);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
  }

  .bottom-nav-inner {
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    height: 100%;
  }

  .bottom-nav-item {
    display: flex;
    position: relative;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 4px 0 2px;
    color: var(--text-muted);
    font-size: 0.58rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    text-decoration: none;
    transition: color var(--transition);
    -webkit-tap-highlight-color: transparent;
  }

  .bottom-nav-item svg {
    width: 20px;
    height: 20px;
  }

  .bottom-nav-item.active {
    color: var(--accent);
    font-weight: 600;
  }

  .bottom-nav-item.active::after {
    position: absolute;
    top: 0;
    left: 50%;
    width: 16px;
    height: 2px;
    transform: translateX(-50%);
    border-radius: 0 0 2px 2px;
    background: var(--accent);
    content: "";
  }

  .bottom-nav-item--urgent {
    color: var(--danger);
  }

  .bottom-nav-item--urgent.active {
    color: var(--danger);
  }

  .bottom-nav-item--urgent.active::after {
    background: var(--danger);
  }

  body {
    padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  }

  .animal-action-card {
    scroll-margin-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 20px);
  }

  .request-status-page {
    padding: 32px 0;
  }

  .request-status-card {
    padding: 24px 20px;
  }

  .mobile-nav {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 10px);
    z-index: var(--z-mobile-sheet);
    display: none !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    max-height: min(62vh, 360px);
    padding: 8px;
    overflow-y: auto;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
  }

  .mobile-nav.is-open {
    display: grid !important;
  }

  .mobile-nav-link {
    min-width: 0;
    padding: 12px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--surface) 92%, var(--accent-light));
  }

.mobile-nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-mobile-backdrop);
  border: 0;
  background: color-mix(in srgb, var(--text) 18%, transparent);
  backdrop-filter: blur(2px);
}

  .mobile-nav-backdrop[hidden] {
    display: none;
  }

  .mobile-menu-btn {
    display: none !important;
  }

  .site-header {
    height: 52px;
    overflow-x: hidden;
  }

  .main-nav {
    display: none;
  }

  .header-inner {
    gap: 8px;
    overflow: visible;
  }

  .logo svg {
    width: 28px;
    height: 28px;
  }

  .logo-text {
    font-size: 1.05rem;
  }

  .header-actions {
    gap: 6px;
    flex-shrink: 0;
  }

  .header-utility-cluster {
    gap: 4px;
    min-height: 32px;
    padding: 2px 0 2px 4px;
    border-left: 0;
  }

  .lang-switch {
    gap: 2px;
  }

  .lang-btn {
    min-width: 26px;
    min-height: 26px;
    padding: 2px 5px;
    font-size: 10px;
  }

  .theme-toggle {
    width: 30px;
    height: 30px;
  }

  .theme-toggle svg {
    width: 15px;
    height: 15px;
  }

  .nav-login-btn {
    min-height: 30px;
    padding: 4px 10px;
    font-size: 0.75rem;
  }

  .pwa-banner {
    bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 719px), (min-width: 720px) and (max-width: 1100px) {
  .mobile-nav.is-open {
    display: flex !important;
    flex-direction: column;
    gap: 10px;
  }

  .bottom-nav-item.active::after {
    display: none;
  }

  .mobile-nav {
    display: none !important;
    background: var(--surface);
  }

  .mobile-nav-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2px 2px 6px;
  }

  .mobile-nav-close {
    display: inline-flex;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    color: var(--text-secondary);
  }

  .mobile-nav-links {
    display: grid;
    gap: 6px;
  }

  .mobile-nav-link {
    min-height: 48px;
    padding: 12px 14px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--surface) 84%, var(--accent-light));
    color: var(--text);
  }

  .mobile-nav-link .ui-icon {
    width: 20px;
    height: 20px;
    color: var(--accent);
  }

  .pwa-banner {
    border: 1px solid color-mix(in srgb, var(--border-light) 78%, var(--accent-light));
    border-radius: 16px;
    box-shadow: 0 16px 36px hsl(24 16% 16% / 0.16);
  }
}

@media (max-width: 719px) {
  html {
    scroll-padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 16px);
  }

  main {
    min-width: 0;
  }

  .bottom-nav {
    isolation: isolate;
    height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
    padding:
      0 env(safe-area-inset-right, 0px)
      env(safe-area-inset-bottom, 0px)
      env(safe-area-inset-left, 0px);
    border-top-color: color-mix(in srgb, var(--border-light) 72%, var(--accent-light));
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    box-shadow: 0 -8px 24px hsl(24 16% 16% / 0.08);
    backdrop-filter: blur(16px);
  }

  .bottom-nav-inner {
    max-width: 560px;
    height: var(--bottom-nav-h);
    padding: 4px 4px 3px;
  }

  .bottom-nav-item {
    min-width: 0;
    min-height: 56px;
    gap: 2px;
    padding: 5px 2px 3px;
    font-size: 0.64rem;
    line-height: 1.1;
  }

  .bottom-nav-item > * {
    position: relative;
    z-index: var(--z-raised);
  }

  .bottom-nav-item svg {
    width: 21px;
    height: 21px;
  }

  .bottom-nav-item.active::before {
    position: absolute;
    inset: 4px 8px 23px;
    z-index: var(--z-sunken);
    border-radius: 10px;
    background: color-mix(in srgb, var(--accent-light) 64%, transparent);
    content: "";
  }

  .mobile-nav {
    right: 8px;
    left: 8px;
    bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 8px);
    max-height: min(74svh, 520px);
    padding: 12px;
    border: 1px solid color-mix(in srgb, var(--border-light) 78%, var(--accent-light));
    border-radius: 18px;
    box-shadow: 0 18px 42px hsl(24 16% 16% / 0.18);
  }

  .mobile-nav-sheet-header {
    min-height: 36px;
  }

  .mobile-nav-title {
    font-size: 0.9rem;
    line-height: 1.25;
  }

  .mobile-nav-link {
    font-size: 0.92rem;
    line-height: 1.25;
  }

  .mobile-nav-backdrop {
    background: hsl(24 16% 16% / 0.32);
  }

  .pwa-banner {
    right: 8px;
    left: 8px;
    bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 10px);
  }

  .bottom-nav-label {
    display: block;
    max-width: 100%;
    overflow: hidden;
    line-height: 1.1;
    text-align: center;
    text-overflow: clip;
    white-space: normal;
  }

  .bottom-nav-icon-wrap {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
  }

  .bottom-nav-count {
    position: absolute;
    top: -7px;
    right: -11px;
    display: inline-grid;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    place-items: center;
    border: 2px solid var(--surface);
    border-radius: 999px;
    background: var(--accent);
    color: hsl(var(--primary-foreground));
    font-size: 0.625rem;
    font-weight: 800;
    line-height: 1;
  }

  .mobile-nav {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 359px) {
  .bottom-nav-item {
    font-size: 0.625rem;
  }

  .bottom-nav-count {
    right: -8px;
  }
}

@media (min-width: 720px) and (max-width: 1100px) {
  body {
    padding-left: var(--tablet-rail-w);
  }

  .main-nav {
    display: none;
  }

  .site-header {
    height: 64px;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
  }

  .header-inner {
    gap: 16px;
  }

  .header-utility-cluster {
    min-height: 36px;
    padding: 3px 0 3px 6px;
  }

  .bottom-nav {
    position: fixed;
    top: 0;
    right: auto;
    bottom: 0;
    left: 0;
    z-index: var(--z-navigation);
    display: block;
    width: var(--tablet-rail-w);
    height: 100dvh;
    padding: env(safe-area-inset-top, 0px) 8px env(safe-area-inset-bottom, 0px);
    border-top: 0;
    border-right: 1px solid color-mix(in srgb, var(--border-light) 72%, var(--accent-light));
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    box-shadow: 8px 0 24px hsl(24 16% 16% / 0.05);
    backdrop-filter: blur(16px);
  }

  .bottom-nav-inner {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 6px;
    width: 100%;
    max-width: none;
    height: auto;
    padding-top: 72px;
  }

  .bottom-nav-item {
    display: flex;
    flex: 0 0 auto;
    min-height: 64px;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 4px;
    border-radius: 12px;
    color: var(--text-muted);
    font-size: 0.66rem;
    font-weight: 600;
    line-height: 1.15;
    text-align: center;
  }

  .bottom-nav-item:hover,
  .bottom-nav-item.active {
    background: color-mix(in srgb, var(--accent-light) 64%, transparent);
    color: var(--accent);
  }

  .mobile-nav {
    top: 78px;
    right: auto;
    bottom: auto;
    left: calc(var(--tablet-rail-w) + 10px);
    width: min(330px, calc(100vw - var(--tablet-rail-w) - 20px));
    max-height: calc(100dvh - 96px);
    padding: 12px;
    border: 1px solid color-mix(in srgb, var(--border-light) 78%, var(--accent-light));
    border-radius: 16px;
    box-shadow: 0 18px 42px hsl(24 16% 16% / 0.18);
  }

  .mobile-nav-sheet-header {
    min-height: 38px;
  }

  .mobile-nav-title {
    font-size: 0.92rem;
  }

  .mobile-nav-backdrop {
    left: var(--tablet-rail-w);
    background: hsl(24 16% 16% / 0.18);
  }

  .pwa-banner {
    right: 20px;
    bottom: 20px;
    left: calc(var(--tablet-rail-w) + 20px);
  }
}
