/* Mobile storefront. Loaded last so these rules are the single source of truth
   for phone layouts after the earlier desktop design experiments. */

.mobile-tabbar,
.mobile-menu-topbar,
.mobile-catalog-top,
.mobile-store-link {
  display: none;
}

.product-card-open {
  display: block;
}

@media (max-width: 760px) {
  :root {
    --mobile-gutter: 14px;
  }

  html {
    scroll-padding-top: 12px;
  }

  body {
    min-width: 320px;
    padding-bottom: calc(68px + env(safe-area-inset-bottom));
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
  }

  button,
  a,
  input,
  select,
  textarea {
    -webkit-tap-highlight-color: transparent;
  }

  .shell {
    width: calc(100% - (var(--mobile-gutter) * 2));
    max-width: none;
  }

  .prototype-note {
    display: none;
  }

  /* Header */
  .header {
    position: sticky;
    top: 0;
    box-shadow: 0 3px 14px rgba(20, 42, 58, .07);
  }

  .header-top {
    display: none;
  }

  .header-main {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: 104px;
    gap: 10px;
    min-height: 104px;
    padding-block: 0;
  }

  .logo {
    grid-column: 1;
    grid-row: 1;
  }

  .brand-logo-image {
    width: 112px;
    height: 102px;
    object-fit: contain;
    border-radius: 0;
  }

  .mobile-store-link {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-self: end;
    gap: 7px;
    padding: 6px 9px 6px 6px;
    color: var(--navy);
    background: #f3f7f6;
    border: 1px solid #e0e9e7;
    border-radius: 12px;
  }

  .mobile-store-icon {
    display: grid;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    place-items: center;
    color: var(--teal);
    background: #fff;
    border-radius: 9px;
  }

  .mobile-store-icon svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
  }

  .mobile-store-link > span:last-child {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 0;
  }

  .mobile-store-link small {
    display: none;
  }

  .mobile-store-link strong {
    overflow: hidden;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .header-actions {
    display: none;
  }

  .header-actions .action-link {
    display: none;
  }

  .search {
    position: fixed;
    z-index: 115;
    right: var(--mobile-gutter);
    bottom: calc(76px + env(safe-area-inset-bottom));
    left: var(--mobile-gutter);
    display: none;
    width: auto;
    height: 50px;
    margin: 0;
    padding-left: 13px;
    border-radius: 12px;
    background: #fff;
    border-color: #cddbd8;
    box-shadow: 0 12px 36px rgba(23, 42, 58, .18);
  }

  body.mobile-search-open .search {
    display: grid;
  }

  body.mobile-search-open .mobile-catalog-top {
    display: none;
  }

  .search input {
    min-width: 0;
    padding: 0 9px;
    font-size: 16px;
  }

  .search button {
    min-width: 68px;
    padding: 0 14px;
    font-size: 11px;
  }

  .category-nav { display: none; }

  .category-nav .category-nav-inner::-webkit-scrollbar,
  .catalog-subcategory-chips::-webkit-scrollbar,
  #catalogBreadcrumbs::-webkit-scrollbar,
  #categoryTree::-webkit-scrollbar,
  .benefits::-webkit-scrollbar {
    display: none;
  }

  /* Persistent one-thumb navigation */
  .mobile-tabbar {
    position: fixed;
    z-index: 110;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    min-height: calc(64px + env(safe-area-inset-bottom));
    padding: 5px 8px env(safe-area-inset-bottom);
    background: rgba(255, 255, 255, .96);
    border-top: 1px solid #dfe7e5;
    box-shadow: 0 -8px 26px rgba(23, 42, 58, .09);
    backdrop-filter: blur(14px);
  }

  .mobile-tabbar-item {
    position: relative;
    display: flex;
    min-width: 0;
    min-height: 54px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    padding: 4px;
    color: #66767d;
    background: transparent;
    border: 0;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 750;
  }

  .mobile-tabbar-item svg {
    width: 23px;
    height: 23px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .mobile-tabbar-item.active,
  .mobile-tabbar-item:active {
    color: var(--teal);
    background: #edf6f4;
  }

  .mobile-tabbar-cart b {
    position: absolute;
    top: 3px;
    left: calc(50% + 8px);
    display: grid;
    min-width: 18px;
    height: 18px;
    place-items: center;
    padding: 0 4px;
    color: #fff;
    background: var(--orange);
    border: 2px solid #fff;
    border-radius: 999px;
    font-size: 8px;
  }

  .mobile-catalog-top {
    position: fixed;
    z-index: 105;
    right: var(--mobile-gutter);
    bottom: calc(76px + env(safe-area-inset-bottom));
    display: grid;
    width: 46px;
    height: 46px;
    padding: 0;
    place-items: center;
    color: #fff;
    background: var(--teal);
    border: 0;
    border-radius: 10px;
    box-shadow: 0 8px 22px rgba(8, 127, 121, .25);
    cursor: pointer;
  }

  .mobile-catalog-top[hidden] {
    display: none;
  }

  .mobile-catalog-top svg {
    width: 23px;
    height: 23px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  /* Full-screen catalog menu */
  #catalogMegaMenu {
    position: fixed;
    z-index: 120;
    inset: 0;
    width: 100%;
    max-height: none;
    height: 100dvh;
    padding: 0 0 calc(24px + env(safe-area-inset-bottom));
    overflow-y: auto;
    background: #fff;
    border: 0;
    box-shadow: none;
  }

  body.mega-menu-open {
    overflow: hidden;
  }

  #catalogMegaMenu .catalog-mega-inner {
    display: flex;
    width: 100%;
    min-height: 100%;
    flex-direction: column;
    gap: 0;
    padding: 0 var(--mobile-gutter) 28px;
    background: #f6f8f7;
  }

  .mobile-menu-topbar {
    position: sticky;
    z-index: 5;
    top: 0;
    display: flex;
    width: calc(100% + (var(--mobile-gutter) * 2));
    min-height: calc(70px + env(safe-area-inset-top));
    align-items: center;
    justify-content: space-between;
    margin: 0 calc(var(--mobile-gutter) * -1);
    padding: env(safe-area-inset-top) var(--mobile-gutter) 0;
    background: rgba(255, 255, 255, .97);
    border-bottom: 1px solid #e3e9e7;
    backdrop-filter: blur(14px);
  }

  .mobile-menu-topbar div {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .mobile-menu-topbar small {
    color: var(--teal);
    font-size: 9px;
    font-weight: 850;
    letter-spacing: .08em;
    text-transform: uppercase;
  }

  .mobile-menu-topbar strong {
    color: var(--navy);
    font-size: 21px;
    letter-spacing: -.025em;
  }

  #mobileCloseCatalogMenu {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    padding: 0;
    color: var(--navy);
    background: #f1f5f4;
    border: 0;
    border-radius: 50%;
    font-size: 28px;
    line-height: 1;
  }

  #categoryTree {
    position: static;
    display: grid;
    width: 100%;
    max-height: none;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 0;
    padding: 16px 0 18px;
    overflow: visible;
    background: transparent;
    border: 0;
    border-bottom: 1px solid #e6ebe8;
  }

  #categoryTree .catalog-root-button {
    display: flex;
    width: 100%;
    min-width: 0;
    min-height: 82px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    padding: 9px 5px;
    color: #52636b;
    background: #fff !important;
    border: 1px solid transparent;
    border-radius: 14px;
    box-shadow: 0 3px 12px rgba(23, 42, 58, .045);
    font-size: 10px;
    text-align: center;
  }

  #categoryTree .catalog-root-icon {
    width: 32px;
    height: 32px;
    background: #eaf3f1;
    border-radius: 10px;
    font-size: 17px;
  }

  #categoryTree .catalog-root-button > span:nth-child(2) {
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #categoryTree .catalog-root-button b {
    display: block;
    color: #93a09f;
    font-size: 8px;
  }

  #categoryTree .catalog-root-button i {
    display: none;
  }

  #categoryTree .catalog-root-button.menu-active,
  #categoryTree .catalog-root-button.active {
    color: var(--teal) !important;
    background: #e8f4f1 !important;
    border-color: #bcded8;
  }

  #closeCatalogMenu {
    display: none;
  }

  #catalogMegaMenu .mega-subcategories {
    position: static;
    width: 100%;
    padding: 20px 0 0;
  }

  #catalogMegaMenu .mega-menu-heading {
    min-height: 0;
    margin: 0 0 14px;
    padding: 0 52px 0 0;
  }

  #catalogMegaMenu .mega-menu-heading h2 {
    font-size: 25px;
  }

  #catalogMegaMenu .mega-all-link {
    display: flex;
    width: 100%;
    min-height: 46px;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 20px;
    padding: 0 14px;
    color: var(--teal);
    background: #edf7f5;
    border: 1px solid #d4e8e5;
    border-radius: 11px;
    text-decoration: none;
  }

  #catalogMegaMenu .mega-all-link strong {
    font-size: 12px;
  }

  #catalogMegaMenu .mega-all-link i {
    font-size: 18px;
  }

  #catalogMegaMenu .mega-group-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  #catalogMegaMenu .mega-group {
    min-width: 0;
    padding: 13px 14px 10px;
    background: #fff;
    border: 1px solid #e1e8e6;
    border-radius: 13px;
  }

  #catalogMegaMenu .mega-group-title {
    min-height: 40px;
  }

  #catalogMegaMenu .mega-group-title strong {
    font-size: 14px;
    line-height: 1.3;
  }

  #catalogMegaMenu .mega-leaf-links button {
    min-height: 38px;
    padding: 7px 0;
    font-size: 11.5px;
    line-height: 1.35;
  }

  /* Hero and service highlights */
  .hero,
  .hero-tv-pets {
    display: flex;
    height: auto;
    min-height: 0;
    flex-direction: column;
    margin-top: 12px;
    overflow: hidden;
    border-radius: 16px;
  }

  .hero-tv-pets::before,
  .hero-tv-pets::after {
    display: none;
  }

  .hero-tv-pets .hero-content {
    position: relative;
    z-index: 1;
    order: 0;
    width: 100%;
    padding: 25px 21px 22px;
  }

  .hero-label {
    font-size: 10px;
  }

  .hero h1,
  .hero-tv-pets h1 {
    margin: 10px 0 12px;
    font-size: clamp(29px, 9vw, 36px);
    line-height: 1.02;
  }

  .hero-content p {
    margin-bottom: 18px;
    font-size: 12px;
    line-height: 1.55;
  }

  .hero-content .primary-button {
    min-height: 44px;
  }

  .hero-tv-pets > img {
    position: relative;
    inset: auto;
    order: 1;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    object-position: 64% center;
  }

  .hero-tv-pets .hero-delivery {
    position: relative;
    inset: auto;
    order: 2;
    min-height: 60px;
    margin: 0;
    padding: 13px 18px;
    background: #fff;
    border-top: 1px solid #e4e8e4;
    border-radius: 0;
    box-shadow: none;
  }

  .benefits {
    display: grid;
    width: calc(100% - var(--mobile-gutter));
    grid-auto-columns: minmax(230px, 76vw);
    grid-auto-flow: column;
    grid-template-columns: none;
    gap: 9px;
    margin: 12px 0 0 var(--mobile-gutter);
    padding: 0 var(--mobile-gutter) 4px 0;
    overflow-x: auto;
    border: 0;
    border-radius: 0;
    scroll-snap-type: x proximity;
  }

  .benefits article,
  .benefits article + article,
  .benefits article:nth-child(3),
  .benefits article:nth-child(4) {
    min-height: 76px;
    padding: 13px 15px;
    background: #f7f9f9;
    border: 1px solid var(--line);
    border-radius: 13px;
    scroll-snap-align: start;
  }

  .benefit-icon {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
  }

  /* Catalog */
  #catalog {
    padding-top: 36px;
    padding-bottom: 62px;
    scroll-margin-top: 8px;
  }

  #catalogBreadcrumbs {
    display: flex;
    width: 100%;
    flex-wrap: nowrap;
    gap: 6px;
    margin: 0 0 16px;
    overflow-x: auto;
  }

  #catalogBreadcrumbs button {
    flex: 0 0 auto;
    min-height: 36px;
    font-size: 11px;
  }

  #catalog .catalog-navigation-header,
  #catalog .catalog-navigation-header.compact {
    display: block;
    margin-bottom: 17px;
  }

  #catalog .catalog-navigation-header h2,
  #catalog .catalog-navigation-header.compact h2 {
    margin-bottom: 5px;
    font-size: 28px;
  }

  #catalog .catalog-navigation-header p,
  #catalog .catalog-navigation-header.compact p {
    margin: 0;
    padding: 0;
    font-size: 12px;
  }

  .pet-departments {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .pet-department {
    display: flex;
    min-height: 0;
    flex-direction: column;
    padding: 9px 9px 13px;
    border-radius: 14px;
  }

  .pet-portrait {
    width: 100%;
    margin-bottom: 10px;
  }

  .pet-department strong {
    min-height: 34px;
    font-size: 14px;
  }

  .pet-department small {
    font-size: 10px;
  }

  .shared-departments {
    grid-template-columns: 1fr;
    gap: 7px;
    margin-top: 10px;
  }

  .shared-departments button {
    min-height: 58px;
    padding: 13px 15px;
    border-radius: 12px;
  }

  .shared-departments strong {
    font-size: 14px;
  }

  #catalog .catalog-subcategory-chips {
    display: flex;
    width: calc(100% + var(--mobile-gutter));
    flex-wrap: nowrap;
    gap: 7px;
    margin: 0 0 15px;
    padding: 1px var(--mobile-gutter) 4px 0;
    overflow-x: auto;
    scroll-snap-type: x proximity;
  }

  #catalog .catalog-subcategory-chips button {
    flex: 0 0 auto;
    min-height: 42px;
    padding: 8px 13px;
    font-size: 11px;
    scroll-snap-align: start;
  }

  #catalogTools {
    display: flex;
    margin: 0 0 13px;
  }

  #catalogTools select {
    width: 100%;
    height: 44px;
    padding-inline: 13px 34px;
    border-radius: 11px;
    background-color: #fff;
    font-size: 13px;
  }

  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    align-items: stretch;
  }

  .product-card {
    height: 300px;
    min-height: 0;
    min-width: 0;
    border-radius: 13px;
    cursor: pointer;
  }

  .product-card:hover {
    transform: none;
    box-shadow: none;
  }

  .product-image {
    height: 138px;
    min-height: 138px;
    padding: 9px;
    background: #fff;
  }

  .product-image > img {
    max-width: 100%;
    max-height: 100%;
  }

  .photo-coming-soon strong {
    font-size: 9px;
    line-height: 1.35;
    text-align: center;
  }

  .product-info {
    min-width: 0;
    padding: 10px;
  }

  .product-category {
    overflow: hidden;
    font-size: 8px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .product-info h3 {
    height: auto;
    min-height: 0;
    margin: 0 0 4px;
    font-size: 11px;
    line-height: 1.4;
    -webkit-line-clamp: 4;
  }

  .product-volume {
    height: auto;
    min-height: 0;
    margin: 2px 0 5px;
    overflow: hidden;
    font-size: 8px;
  }

  .product-card .details-button,
  .product-card .stock {
    display: none;
  }

  .product-card-open {
    position: absolute;
    z-index: 2;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: inherit;
    cursor: pointer;
  }

  .product-card-open:focus-visible {
    outline: 3px solid #f0a356;
    outline-offset: -3px;
  }

  .product-footer {
    min-height: 39px;
    margin-top: auto;
    gap: 5px;
    padding-top: 7px;
  }

  .product-price strong {
    font-size: 15px;
    white-space: nowrap;
  }

  .add-button {
    position: relative;
    z-index: 3;
    min-width: 68px;
    height: 34px;
    padding: 0 8px;
    border-radius: 8px;
    font-size: 9px;
  }

  .catalog-pagination {
    grid-template-columns: 1fr auto;
    gap: 10px;
    margin-top: 18px;
    padding-top: 14px;
  }

  .pagination-back {
    grid-column: 1 / -1;
    width: 100%;
    min-height: 44px;
  }

  .pagination-pages button {
    min-width: 40px;
    min-height: 40px;
  }

  .pagination-pages button:not(:first-child):not(:last-child):not(.active) {
    display: none;
  }

  /* Lower page */
  .delivery-section {
    padding: 50px 0;
  }

  .delivery-inner {
    grid-template-columns: 1fr;
    gap: 25px;
  }

  .delivery-inner h2,
  .about h2 {
    font-size: 30px;
  }

  .delivery-cards {
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .delivery-cards article {
    min-height: 142px;
    padding: 20px;
  }

  .delivery-cards strong {
    margin-top: 32px;
  }

  .about {
    grid-template-columns: 1fr;
    gap: 15px;
    padding-block: 50px;
  }

  .about > p {
    margin: 0;
    font-size: 13px;
  }

  .footer {
    padding: 42px 0 calc(20px + env(safe-area-inset-bottom));
  }

  .footer-main {
    grid-template-columns: 1fr 1fr;
    gap: 32px 18px;
  }

  .footer-main > div:first-child {
    grid-column: 1 / -1;
  }

  .footer-logo .brand-logo-image {
    width: 104px;
    height: 82px;
  }

  .footer-logo {
    width: 132px;
    height: 104px;
    padding: 8px 12px;
  }

  .footer-bottom {
    gap: 12px;
    flex-direction: column;
    margin-top: 30px;
  }

  /* Cart and dialogs */
  .cart-drawer {
    width: 100%;
    height: 100dvh;
    padding: calc(18px + env(safe-area-inset-top)) var(--mobile-gutter) calc(14px + env(safe-area-inset-bottom));
    box-shadow: none;
  }

  .drawer-header {
    padding-bottom: 14px;
  }

  .drawer-header h2 {
    font-size: 26px;
  }

  .icon-button {
    width: 42px;
    height: 42px;
  }

  .icon-button:focus-visible,
  #catalogMegaMenu button:focus-visible,
  #catalog button:focus-visible {
    outline: 3px solid rgba(8, 127, 121, .28);
    outline-offset: 2px;
  }

  .cart-item {
    grid-template-columns: 58px minmax(0, 1fr) auto;
    gap: 10px;
    padding: 12px 0;
  }

  .cart-item-visual {
    width: 58px;
    height: 58px;
  }

  .quantity-control button {
    width: 30px;
    height: 30px;
  }

  .cart-summary {
    padding-top: 14px;
  }

  .checkout-dialog,
  .product-dialog {
    width: 100%;
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    padding: calc(62px + env(safe-area-inset-top)) var(--mobile-gutter) calc(20px + env(safe-area-inset-bottom));
    border-radius: 0;
  }

  .checkout-dialog .dialog-close,
  .product-dialog .dialog-close {
    position: fixed;
    z-index: 3;
    top: calc(12px + env(safe-area-inset-top));
    right: var(--mobile-gutter);
  }

  .checkout-dialog h2 {
    margin-bottom: 20px;
    font-size: 27px;
  }

  .receive-toggle span,
  .form-field input,
  .form-field textarea,
  .checkout-dialog .primary-button {
    min-height: 44px;
    font-size: 16px;
  }

  .form-field {
    font-size: 11px;
  }

  .form-field textarea {
    min-height: 88px;
  }

  .product-dialog-layout {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .product-dialog-image {
    height: min(290px, 36dvh);
    padding: 16px;
  }

  .product-dialog-copy h2 {
    font-size: 20px;
  }

  .product-dialog-section {
    margin-top: 22px;
    padding-top: 18px;
  }

  .product-attributes > div {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .toast {
    right: var(--mobile-gutter);
    bottom: calc(14px + env(safe-area-inset-bottom));
    left: var(--mobile-gutter);
    text-align: center;
  }
}

@media (max-width: 430px) {
  #catalogMegaMenu .mega-group-list {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .product-card {
    height: 300px;
  }

  .product-image {
    height: 130px;
    min-height: 130px;
  }

  .product-info {
    padding: 9px;
  }

  .product-info h3 {
    font-size: 10.5px;
  }

  .product-price strong {
    font-size: 14px;
  }

  .add-button {
    min-width: 62px;
    padding-inline: 6px;
    font-size: 8.5px;
  }
}

@media (max-width: 350px) {
  .product-grid {
    grid-template-columns: 1fr;
  }

  .product-card {
    height: 350px;
  }

  .product-image {
    height: 180px;
    min-height: 180px;
  }

  .footer-main {
    grid-template-columns: 1fr;
  }

  .footer-main > div:first-child {
    grid-column: auto;
  }
}

@media (hover: none) and (pointer: coarse) {
  .product-card:hover,
  .pet-department:hover {
    transform: none;
    box-shadow: none;
  }
}
