/**
 * Mobile / tablet layout overrides — Precious Surgicals
 * Loaded after style.css so these rules win.
 */

html {
  overflow-x: clip;
}

body {
  overflow-x: clip;
}

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

/* Mobile floating dock — hidden on desktop */
.ps-mobile-dock {
  display: none;
}

/* ─── Tablet + phone: hamburger from 1024px ─── */
@media (max-width: 1024px) {
  body {
    padding-bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px));
  }

  .top-bar__inner {
    flex-wrap: wrap;
    gap: 0.35rem 1rem;
    justify-content: center;
    text-align: center;
  }

  .header--mega {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: #fff;
  }

  .header--mega .header__inner {
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 64px;
    flex-wrap: wrap;
    row-gap: 0.55rem;
  }

  .header--mega .header__inner > .logo {
    order: 1;
    margin: 0 auto;
    max-width: min(70vw, 280px);
    justify-content: center;
  }

  .header--mega .header__end {
    order: 2;
    width: 100%;
    margin-left: 0;
    justify-content: center;
    flex: 0 0 100%;
    gap: 0.55rem;
  }

  .header__actions,
  .menu-toggle {
    display: none !important;
  }

  .header__search {
    display: none;
  }

  .logo__text small {
    display: none;
  }

  .logo__text strong {
    font-size: 1rem;
    text-align: center;
  }

  .nav {
    display: none;
    position: fixed;
    top: auto;
    bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px));
    left: 0.75rem;
    right: 0.75rem;
    z-index: 10040;
    max-height: min(62dvh, 520px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #fff;
    flex-direction: column;
    align-items: stretch;
    padding: 0.85rem 1.1rem 1.15rem;
    border: 1px solid #e8ecf0;
    border-radius: 18px;
    box-shadow: 0 18px 48px rgba(11, 35, 65, 0.18);
  }

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

  .nav .menu,
  .nav ul {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    gap: 0.15rem;
  }

  .nav .menu > li,
  .nav ul > li {
    width: 100%;
    border-bottom: 1px solid #f0f0f0;
  }

  .nav .menu > li > a,
  .nav ul > li > a:not(.btn) {
    display: block;
    width: 100%;
    padding: 0.85rem 0;
  }

  .nav .menu-item--cta {
    margin-left: 0;
    border-bottom: none;
    padding-top: 0.75rem;
  }

  .nav .menu-item--cta > a,
  .nav .menu-item--cta a.btn--nav-cta {
    width: 100%;
    text-align: center;
    justify-content: center;
  }

  .menu-item--mega {
    width: 100%;
  }

  .ps-mega-trigger {
    width: 100%;
    justify-content: space-between;
    padding: 0.85rem 0;
  }

  .menu-item--mega > .ps-mega-panel {
    position: static !important;
    width: 100%;
    box-shadow: none;
    border: none;
    border-top: 1px solid #f0f0f0;
    background: #f7f9fb;
  }

  .menu-item--mega > .ps-mega-panel .ps-mega-panel__inner {
    padding: 0.75rem 0.35rem 1rem;
  }

  .menu-item--mega > .ps-mega-panel .ps-mega-panel__grid--instruments,
  .menu-item--mega > .ps-mega-panel .ps-mega-panel__grid--sets {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .ps-mega-dropdowns:empty {
    display: none;
  }

  .ps-header-search {
    min-width: 0;
  }

  .container {
    width: min(1200px, 94vw);
  }

  /* Floating dock */
  .ps-mobile-dock {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10045;
    padding: 0 0.85rem calc(0.65rem + env(safe-area-inset-bottom, 0px));
    pointer-events: none;
  }

  .ps-mobile-dock__inner {
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.1rem;
    max-width: 460px;
    margin: 0 auto;
    padding: 0.35rem 0.35rem;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 999px;
    box-shadow: 0 10px 30px rgba(11, 35, 65, 0.16);
    backdrop-filter: blur(10px);
  }

  .ps-mobile-search {
    pointer-events: auto;
    max-width: 460px;
    margin: 0 auto 0.55rem;
    padding: 0.55rem 0.65rem;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(15, 23, 42, 0.1);
    border-radius: 16px;
    box-shadow: 0 10px 28px rgba(11, 35, 65, 0.14);
  }

  .ps-mobile-search[hidden] {
    display: none !important;
  }

  .ps-mobile-search__form {
    display: flex;
    align-items: center;
    gap: 0.35rem;
  }

  .ps-mobile-search__input {
    flex: 1;
    min-width: 0;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    padding: 0.65rem 0.9rem;
    font-family: inherit;
    font-size: 0.92rem;
    background: #f8fafc;
  }

  .ps-mobile-search__input:focus {
    outline: none;
    border-color: var(--color-teal, #0d7c8c);
    box-shadow: 0 0 0 3px rgba(13, 124, 140, 0.12);
  }

  .ps-mobile-search__submit,
  .ps-mobile-search__close {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 999px;
    background: var(--color-navy, #0b2341);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
  }

  .ps-mobile-search__close {
    background: #eef2f6;
    color: #445;
    font-size: 1.35rem;
    line-height: 1;
  }

  .ps-mobile-dock__item {
    position: relative;
    flex: 1 1 0;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.12rem;
    min-width: 0;
    min-height: 48px;
    padding: 0.3rem 0.15rem;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: #9aa3af;
    text-decoration: none;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
  }

  .ps-mobile-dock__item.is-active,
  .ps-mobile-dock__item[aria-expanded="true"] {
    background: #eef2ff;
    color: var(--color-navy, #0b2341);
  }

  .ps-mobile-dock__item.is-active .ps-mobile-dock__label,
  .ps-mobile-dock__item[aria-expanded="true"] .ps-mobile-dock__label {
    display: block;
  }

  .ps-mobile-dock__icon {
    position: relative;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
  }

  .ps-mobile-dock__label {
    display: none;
    font-size: 0.58rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
  }

  .ps-mobile-dock__item.is-active .ps-mobile-dock__label {
    display: block;
  }

  .ps-mobile-dock__count {
    top: -4px;
    right: -8px;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    font-size: 0.62rem;
  }

  body.ps-nav-open .ps-mobile-dock__item--menu,
  body.ps-search-open .ps-mobile-dock__item--search {
    background: #eef2ff;
    color: var(--color-navy, #0b2341);
  }

  body.ps-nav-open .ps-mobile-dock__item--menu .ps-mobile-dock__label,
  body.ps-search-open .ps-mobile-dock__item--search .ps-mobile-dock__label {
    display: block;
  }
}

@media (max-width: 768px) {
  .top-bar {
    font-size: 0.72rem;
    padding: 0.45rem 0;
  }

  .top-bar__links {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.35rem 0.85rem;
  }

  .header__search {
    display: flex;
    width: 100%;
    max-width: 360px;
    margin: 0 auto;
  }

  .ps-header-search {
    width: 100%;
    max-width: none;
  }

  .header--mega .header__end {
    justify-content: center;
  }

  .header--mega .header__inner > .logo {
    max-width: min(78vw, 300px);
  }

  .logo__text {
    min-width: 0;
  }

  .logo__text strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
  }

  .hero__title {
    font-size: clamp(1.45rem, 6vw, 1.85rem) !important;
    line-height: 1.2;
  }

  .hero__subtitle {
    font-size: 0.95rem;
  }

  .hero__cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
  }

  .hero__card-value {
    font-size: 1.2rem;
  }

  .hero__card-label,
  .hero__card-eyebrow {
    font-size: 0.72rem;
  }

  /* Homepage grids — readable, not micro type */
  .features-grid {
    grid-template-columns: 1fr !important;
    gap: 0.85rem !important;
  }

  .feature-card {
    padding: 1.1rem 1rem !important;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.75rem 1rem;
    align-items: start;
    text-align: left;
  }

  .feature-card__icon {
    width: 40px !important;
    height: 40px !important;
    font-size: 0.95rem !important;
    margin: 0 !important;
  }

  .feature-card h3 {
    font-size: 0.95rem !important;
    margin-bottom: 0.25rem !important;
  }

  .feature-card p {
    font-size: 0.85rem !important;
    line-height: 1.5 !important;
  }

  .certs-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.75rem !important;
  }

  .cert-card {
    padding: 1rem 0.85rem !important;
  }

  .cert-card__icon {
    width: 42px !important;
    height: 42px !important;
    font-size: 0.8rem !important;
    margin-bottom: 0.55rem !important;
  }

  .cert-card h3 {
    font-size: 0.88rem !important;
    margin-bottom: 0.3rem !important;
  }

  .cert-card p {
    font-size: 0.78rem !important;
    line-height: 1.45 !important;
  }

  .specialty-grid,
  .product-grid,
  .sets-grid,
  .bestseller-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
  }

  .specialty-card__body h3,
  .set-card__body h3,
  .bestseller-card h3 {
    font-size: 0.88rem !important;
  }

  .ps-about-contact__grid,
  .ps-value-prop__after-grid {
    grid-template-columns: 1fr !important;
  }

  .contact-form {
    padding: 1.25rem !important;
  }

  .video-carousel {
    padding: 0 2.25rem;
  }

  .section {
    padding: 3rem 0;
  }

  .section__title {
    font-size: clamp(1.35rem, 5vw, 1.75rem);
  }

  .footer {
    padding-top: 3rem;
  }

  .footer__brand p {
    max-width: none;
  }
}

@media (max-width: 480px) {
  .container {
    width: min(1200px, 92vw);
  }

  .top-bar__links a:last-child {
    display: none;
  }

  .hero__cards {
    grid-template-columns: 1fr;
  }

  .specialty-grid,
  .product-grid,
  .sets-grid,
  .bestseller-grid,
  .clients-grid {
    grid-template-columns: 1fr !important;
  }

  .certs-grid {
    grid-template-columns: 1fr !important;
  }

  .video-carousel {
    padding: 0 1.75rem;
  }

  .testimonial-carousel__track .testimonial-card {
    flex-basis: 92%;
  }
}
