/* =========================================================
   MOBILE UI / UX
   ========================================================= */

@media (max-width: 800px) {

  /* ---------- Mobile Navigation ---------- */

  :root {
    --nav-h: 64px;
  }

  .nav {
    height: var(--nav-h);
    padding-top: env(safe-area-inset-top);
  }

  .nav-inner {
    min-height: var(--nav-h);
    padding-inline: 14px;
  }

  .nav-logo {
    display: flex;
    align-items: center;
    min-width: 0;
  }

  .nav-logo img {
    height: 38px;
    width: auto;
    max-width: 150px;
    object-fit: contain;
  }

  /* Hamburger */
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 44px;
    height: 44px;
    min-width: 44px;

    padding: 0;
    border: 1px solid rgba(196, 154, 90, 0.22);
    border-radius: 12px;

    background: rgba(255, 255, 255, 0.04);
    color: inherit;

    cursor: pointer;

    transition:
      background 0.2s ease,
      border-color 0.2s ease,
      transform 0.2s ease;
  }

  .nav-toggle:hover,
  .nav-toggle:focus-visible {
    background: rgba(196, 154, 90, 0.10);
    border-color: rgba(196, 154, 90, 0.42);
  }

  .nav-toggle:active {
    transform: scale(0.94);
  }


  /* ---------- Mobile Menu ---------- */

  .nav-links {
    position: fixed;

    top: var(--nav-h);
    left: 0;
    right: 0;

    z-index: 99;

    display: flex;
    flex-direction: column;
    align-items: stretch;

    max-height: calc(
      100dvh - var(--nav-h)
    );

    overflow-y: auto;
    overscroll-behavior: contain;

    padding:
      0.65rem
      1rem
      calc(1.25rem + env(safe-area-inset-bottom));

    background: rgba(23, 21, 19, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);

    border-bottom: 1px solid rgba(196, 154, 90, 0.18);

    box-shadow:
      0 16px 35px rgba(0, 0, 0, 0.28);

    /* Closed state */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transform: translateY(-8px);

    transition:
      opacity 0.22s ease,
      transform 0.22s ease,
      visibility 0.22s ease;
  }

  .nav-links.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;

    transform: translateY(0);
  }


  /* Menu links */

  .nav-links a {
    display: flex;
    align-items: center;

    min-height: 48px;

    padding: 0.75rem 0.85rem;

    border-radius: 10px;

    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.04em;

    transition:
      background 0.2s ease,
      color 0.2s ease,
      padding-left 0.2s ease;
  }

  .nav-links a:hover,
  .nav-links a:focus-visible {
    padding-left: 1.05rem;
    background: rgba(196, 154, 90, 0.08);
  }

  .nav-links a:active {
    background: rgba(196, 154, 90, 0.14);
  }

  /* Active indicator */

  .nav-links a::after {
    left: 0.25rem;
    width: 3px;
    height: 22px;

    transform: scaleY(0);
    transform-origin: center;

    border-radius: 999px;
  }

  .nav-links a:hover::after,
  .nav-links a[aria-current="true"]::after {
    transform: scaleY(1);
  }


  /* Hide desktop actions */

  .nav-actions {
    display: none;
  }


  /* ---------- Hero ---------- */

  .hero {
    min-height: 76dvh;

    padding:
      calc(var(--nav-h) + 1rem)
      1rem
      4rem;
  }

  .hero-content {
    width: min(100%, 680px);

    padding:
      1.5rem
      0
      3rem;
  }

  .hero h1 {
    font-size: clamp(2rem, 9vw, 3.2rem);
    line-height: 1.05;
  }

  .hero p {
    max-width: 34rem;

    font-size: 0.94rem;
    line-height: 1.65;
  }


  /* ---------- Product Grid ---------- */

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

    gap: 0.75rem;
  }

  .product-card {
    min-width: 0;
    border-radius: 14px;
    overflow: hidden;
  }

  .card-image,
  .product-card img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
  }

  .card-body {
    padding: 0.75rem 0.75rem 0.85rem;
  }

  .card-title {
    font-size: 0.86rem;
    line-height: 1.3;

    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .card-price {
    margin-top: 0.4rem;
    font-size: 0.95rem;
  }


  /* ---------- Product Actions ---------- */

  .card-foot {
    flex-direction: column;
    align-items: stretch;

    gap: 0.5rem;

    margin-top: 0.65rem;
  }

  .add-btn {
    width: 100%;

    min-height: 44px;

    padding-inline: 0.75rem;

    border-radius: 10px;

    font-size: 0.78rem;
    font-weight: 700;
  }

  .add-btn:active {
    transform: scale(0.97);
  }


  /* ---------- General Touch Targets ---------- */

  button,
  a,
  input[type="button"],
  input[type="submit"] {
    -webkit-tap-highlight-color: transparent;
  }

  button {
    min-height: 44px;
  }

  input,
  select,
  textarea {
    min-height: 44px;

    font-size: 16px; /* Prevents iOS zoom */
  }


  /* ---------- Sections ---------- */

  section {
    scroll-margin-top: calc(var(--nav-h) + 12px);
  }

  .container {
    width: 100%;
    padding-inline: 1rem;
  }


  /* ---------- Sticky Cart ---------- */

  body {
    padding-bottom: 0;
  }

  body[data-cart-active="true"] {
    padding-bottom:
      calc(76px + env(safe-area-inset-bottom));
  }

  .sticky-bar {
    position: fixed;

    left: 0;
    right: 0;
    bottom: 0;

    z-index: 90;

    min-height: 68px;

    padding:
      0.55rem
      0.75rem
      calc(0.55rem + env(safe-area-inset-bottom));

    background: rgba(23, 21, 19, 0.96);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);

    border-top:
      1px solid rgba(196, 154, 90, 0.18);

    box-shadow:
      0 -10px 30px rgba(0, 0, 0, 0.22);
  }

  .sticky-bar button,
  .sticky-bar .cart-pill {
    min-height: 50px;
  }

  .cart-pill {
    border-radius: 12px;
  }


  /* ---------- Better Modal Behaviour ---------- */

  .modal {
    align-items: flex-end;
    padding: 0;
  }

  .modal-content {
    width: 100%;
    max-width: none;

    max-height: 92dvh;

    overflow-y: auto;

    border-radius:
      20px
      20px
      0
      0;

    padding-bottom:
      calc(1.25rem + env(safe-area-inset-bottom));
  }


  /* ---------- Form UX ---------- */

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

  .form-group {
    width: 100%;
  }

  .form-group input,
  .form-group select,
  .form-group textarea {
    width: 100%;
    min-height: 46px;

    border-radius: 10px;
  }


  /* ---------- Tables ---------- */

  .table-wrapper {
    width: 100%;
    overflow-x: auto;

    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 620px;
  }


  /* ---------- Reduced Visual Density ---------- */

  .section {
    padding-block: 3rem;
  }
}


/* =========================================================
   SMALL PHONES
   ========================================================= */

@media (max-width: 480px) {

  .nav-inner {
    padding-inline: 12px;
  }

  .nav-logo img {
    height: 35px;
    max-width: 135px;
  }

  .hero {
    min-height: 72dvh;
  }

  .hero-content {
    padding-bottom: 2.5rem;
  }

  .product-grid {
    gap: 0.65rem;
  }

  .card-body {
    padding: 0.65rem;
  }

  .card-title {
    font-size: 0.82rem;
  }

  .card-price {
    font-size: 0.9rem;
  }

  .add-btn {
    min-height: 42px;
    font-size: 0.74rem;
  }

  .section {
    padding-block: 2.5rem;
  }
}


/* =========================================================
   VERY SMALL PHONES
   ========================================================= */

@media (max-width: 380px) {

  .nav-logo img {
    height: 32px;
    max-width: 120px;
  }

  .nav-toggle {
    width: 42px;
    height: 42px;
    min-width: 42px;
  }

  .product-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .product-card {
    display: grid;
    grid-template-columns: 105px 1fr;
  }

  .product-card .card-image,
  .product-card > img {
    height: 100%;
    aspect-ratio: auto;
  }

  .card-body {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .cart-pill .cart-pill-text {
    display: none;
  }
}


/* =========================================================
   DESKTOP ONLY
   ========================================================= */

@media (min-width: 801px) {

  .nav-toggle {
    display: none;
  }

  .sticky-bar {
    display: none !important;
  }
}


/* =========================================================
   ACCESSIBILITY / REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }

  .nav-links {
    transition: none;
  }
}
