/* Mobile / tablet layer shared by every page. Loaded after each page's own <style>.
   Everything is inside a max-width query, so desktop (>1100px) is untouched. */

/* mobile menu sub-pages exist in the DOM on every width, but only show inside the burger menu */
.m-sub-tg,
.m-sub {
  display: none;
}

/* burger menu — the burger is shown from 1100px down, so the menu is too.
   Spec: Figma 'Header — Mobile 390 · Menu open' (1115:6560, 1115:6612). */
@media (max-width: 1100px) {
  .top.menu-open {
    background: var(--plaster);
    color: var(--graphite);
    box-shadow: 0 1px 0 var(--hair);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .top.menu-open .logo {
    color: var(--red);
  }
  .top .links {
    display: flex;
    flex-direction: column;
    gap: 0;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    height: var(--menu-h, calc(100dvh - 120px));
    padding: 8px var(--menu-pad, var(--pad))
      calc(40px + env(safe-area-inset-bottom, 0px));
    background: var(--plaster);
    color: var(--graphite);
    overflow-y: auto;
    overscroll-behavior: contain;
    font-size: 18px;
    line-height: 1.6;
    font-weight: 400;
    clip-path: inset(0 0 100% 0);
    visibility: hidden;
    transition:
      clip-path 0.55s var(--ease),
      visibility 0s 0.55s;
  }
  .top.menu-open .links {
    clip-path: inset(0 0 0 0);
    visibility: visible;
    transition:
      clip-path 0.55s var(--ease),
      visibility 0s;
  }
  .top .links li {
    border-bottom: 1px solid var(--hair);
  }
  .top .links a {
    display: block;
    padding: 14px 0;
  }
  .top .links a::after,
  .top .links .chev {
    display: none;
  }
  .top .links a[aria-current] {
    color: var(--red);
  }
  .top .mega {
    display: none;
  }
  /* Documentation / Contact are accordions: the row toggles its sub-pages, label turns red, chevron flips */
  .top .links li.has-mega {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
  }
  .m-sub-tg {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin-right: -17px;
    background: none;
    border: 0;
    color: inherit;
    cursor: pointer;
  }
  .m-sub-tg svg {
    transition: transform 0.4s var(--ease);
  }
  .top .links .sub-open > a {
    color: var(--red);
  }
  .sub-open > .m-sub-tg svg {
    transform: rotate(180deg);
  }
  .sub-open > .m-sub {
    display: flex;
    flex-direction: column;
    gap: 14px;
    grid-column: 1 / -1;
    list-style: none;
    margin: 0;
    padding: 0 0 16px 16px;
    font-size: 14px;
    line-height: 1.5;
  }
  .top .links .m-sub li {
    border: 0;
  }
  .top .links .m-sub a {
    padding: 0;
    color: var(--stone);
  }
  /* burger: two 24x1.5 lines 7px apart in a 24px box (44px tap area); open, it becomes the 20px Close icon */
  .burger {
    position: relative;
    box-sizing: content-box;
    width: 24px;
    height: 24px;
    padding: 10px;
    margin: -10px;
  }
  .burger span {
    position: absolute;
    left: 10px;
    width: 24px;
    height: 1.5px;
    margin: 0;
  }
  .burger span:first-child {
    top: 18px;
  }
  .burger span:last-child {
    top: 25px;
  }
  .top.menu-open .burger span {
    display: none;
  }
  .top.menu-open .burger::after {
    content: "";
    position: absolute;
    left: 12px;
    top: 12px;
    width: 20px;
    height: 20px;
    background: url(/assets/icons/close.svg) center / contain no-repeat;
  }
  html.menu-lock,
  html.menu-lock body {
    overflow: hidden;
  }
}

@media (max-width: 760px) {
  /* exactly two buttons together: share one row, half width each */
  :is(.btns, .op-actions, .f-foot, .k-acts):has(
    > .btn:nth-child(2):last-child
  ) {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 10px;
  }
  :is(.btns, .op-actions, .f-foot, .k-acts):has(> .btn:nth-child(2):last-child)
    > .btn {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    justify-content: center;
    text-align: center;
    gap: 8px;
    padding: 12px 10px;
    font-size: 14px;
    line-height: 1.2;
  }

  /* mobile header — sizes from Figma 'Header — Mobile 390 · Menu closed' (1115:6544): 96px logo, 16/24 padding,
     "Preorder now" on its own line. Like desktop it starts transparent with a white logo over the hero and
     turns solid (plaster, red logo, hairline) once scrolled or while the menu is open. */
  .top {
    --menu-pad: 24px;
  }
  .top .nav,
  .top.scrolled .nav {
    padding: 16px 24px;
  }
  .top .logo {
    width: 96px;
  }
  .announce {
    padding: 8px 24px;
    font-size: 12px;
    line-height: 1.5;
  }
  .announce a {
    display: block;
    width: max-content;
    margin: 2px auto 0;
    font-weight: 400;
  }

  /* footer legal: one item per line instead of orphaned "|" separators */
  .foot .legal {
    flex-direction: column;
    align-items: flex-start;
  }
  .foot .legal > span:not(:first-child) {
    display: none;
  }

  /* legal pages: the side index is hidden on mobile, so site-mobile.js adds an "On this page" block */
  .m-index {
    margin: 0 0 40px;
    border-top: 1px solid var(--hair);
    border-bottom: 1px solid var(--hair);
  }
  .m-index summary {
    cursor: pointer;
    padding: 16px 0;
    font-weight: 500;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .m-index summary::-webkit-details-marker {
    display: none;
  }
  .m-index summary::after {
    content: "+";
    font-size: 24px;
    font-weight: 300;
    line-height: 1;
  }
  .m-index[open] summary::after {
    content: "\2212";
  }
  .m-index ul {
    list-style: none;
    margin: 0;
    padding: 0 0 16px;
  }
  .m-index ul ul {
    padding: 0 0 4px 14px;
  }
  .m-index a {
    display: block;
    padding: 9px 0;
    color: var(--stone);
    text-decoration: none;
    font-size: 15px;
    line-height: 1.4;
  }
  .m-index li.g > a {
    color: var(--graphite);
    font-weight: 500;
  }
  .to-top {
    position: fixed;
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    z-index: 40;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 1px solid var(--hair);
    border-radius: 50%;
    background: var(--paper);
    color: var(--graphite);
    font-size: 18px;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition:
      opacity 0.3s,
      visibility 0s 0.3s;
  }
  .to-top.on {
    opacity: 1;
    visibility: visible;
    transition:
      opacity 0.3s,
      visibility 0s;
  }

  /* legal tables: stacked rows with the column name above each value */
  .tbl table {
    min-width: 0;
  }
  .tbl thead {
    display: none;
  }
  .tbl tr,
  .tbl td {
    display: block;
  }
  .tbl tr {
    border-bottom: 1px solid var(--hair);
    padding: 14px 0;
  }
  .tbl td {
    border-bottom: 0;
    padding: 4px 0;
    width: auto;
  }
  .tbl td:first-child {
    width: auto;
    font-size: 17px;
    padding-bottom: 6px;
  }
  .tbl td[data-label]:not(:first-child)::before {
    content: attr(data-label);
    display: block;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--graphite);
    margin: 8px 0 2px;
  }

  /* exploded view (Model P / V): tap opens it full size */
  .inside .wrapi {
    cursor: zoom-in;
  }
  .inside .wrapi::after {
    content: "Tap to enlarge";
    display: block;
    margin-top: 12px;
    text-align: center;
    font-size: 13px;
    color: var(--stone);
  }
  .zoomer {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: #f3f3f3;
    overflow: auto;
    overscroll-behavior: contain;
  }
  .zoomer img {
    display: block;
    width: 260%;
    max-width: none;
  }
  .zoomer button {
    position: fixed;
    top: calc(12px + env(safe-area-inset-top, 0px));
    right: 12px;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: var(--graphite);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
  }
}
