/*
 * Silverstone Parts - mobile app layer (additive, mobile-only).
 * Everything below is scoped to <=760px so desktop rendering is untouched.
 * No theme stylesheet is edited; this file loads after parts.css.
 */

/* Elements this layer injects must stay hidden outside the mobile media query. */
.sp-app-tabs,
.sp-app-search,
.sp-app-az,
.sp-app-gate,
.sp-app-sheet,
.sp-app-scrim {
  display: none;
}

@media (max-width: 760px) {
  :root {
    --sp-tab-h: 62px;
    --sp-hd-h: 68px;
    --sp-app-top: calc(var(--sp-gb-h, 34px) + var(--sp-hd-h, 68px));
  }

  /* ---------- 1. group bar: one slim row ---------- */
  .sp-group-bar__inner {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
  }
  .sp-group-bar__endorsement {
    width: auto;
    padding: 0;
    font-size: 10.5px;
    letter-spacing: .1em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .sp-group-bar__links {
    margin-left: auto;
    width: auto;
    min-width: 0;
    padding: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex: 0 1 auto;
  }
  .sp-group-bar__links::-webkit-scrollbar {
    display: none;
  }
  .sp-group-bar__links > a,
  .sp-group-bar__links > span {
    padding: 4px 7px;
    gap: 4px;
    font-size: 11.5px;
  }

  /* ---------- 2. header: logo + search pill + menu ---------- */
  .sp-hd__inner {
    gap: 10px;
    padding-block: 5px;
  }
  .sp-logo {
    min-height: 44px;
  }
  .sp-logo__img {
    height: 26px;
  }
  .sp-hd__actions {
    gap: 2px;
    flex: 1 1 auto;
    min-width: 0;
  }
  .sp-burger {
    width: 44px;
    height: 44px;
    border-color: transparent;
    border-radius: 999px;
  }
  .sp-app-search {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
  }
  .sp-app-search form {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    min-width: 0;
    min-height: 48px;
    padding: 0 6px 0 14px;
    background: var(--sp-bg);
    border: 1px solid var(--sp-line);
    border-radius: 999px;
  }
  .sp-app-search label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .sp-app-search input[type="search"] {
    flex: 1 1 0;
    min-width: 0;
    min-height: 44px;
    padding: 6px 0;
    border: 0;
    background: transparent;
    color: var(--sp-ink);
    font: inherit;
    font-size: 16px;
    appearance: none;
  }
  .sp-app-search input[type="search"]::placeholder {
    color: #8b95a1;
  }
  .sp-app-search button {
    flex: none;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--sp-ink);
    cursor: pointer;
  }
  .sp-app-search svg {
    width: 18px;
    height: 18px;
  }

  /* ---------- 3. bottom tab bar ---------- */
  .sp-app-tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: calc(var(--sp-tab-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(255, 255, 255, .97);
    border-top: 1px solid var(--sp-line);
    backdrop-filter: blur(8px);
  }
  .sp-app-tab {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: #8b95a1;
    font-size: 10.5px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
  }
  .sp-app-tab__icon {
    position: relative;
    display: block;
    width: 22px;
    height: 22px;
  }
  .sp-app-tab__icon svg {
    width: 22px;
    height: 22px;
    display: block;
  }
  .sp-app-tab.is-active {
    color: #101418;
  }
  .sp-app-badge {
    position: absolute;
    top: -5px;
    right: -12px;
    min-width: 16px;
    height: 16px;
    display: grid;
    place-items: center;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--sp-blue);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
  }
  .sp-app-badge[hidden] {
    display: none;
  }
  html body {
    padding-bottom: calc(var(--sp-tab-h) + env(safe-area-inset-bottom));
  }
  html body.sp-app-hasbulk {
    padding-bottom: calc(var(--sp-tab-h) + 68px + env(safe-area-inset-bottom));
  }

  /* ---------- 4. listing: sticky filter row + A-Z index ---------- */
  .sp-part-tools {
    position: sticky;
    top: var(--sp-app-top);
    z-index: 6;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0 0 10px;
    padding: 8px 0 10px;
    background: var(--sp-white);
  }
  .sp-part-tools > label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .sp-part-tools input {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 48px;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 16px;
  }
  .sp-part-tools > span {
    flex: 1 1 100%;
    font-size: 12.5px;
  }
  .sp-app-az {
    order: 5;
    flex: 1 1 100%;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 2px 0 4px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .sp-app-az::-webkit-scrollbar {
    display: none;
  }
  .sp-app-az[hidden] {
    display: none;
  }
  .sp-app-az button {
    flex: none;
    min-width: 44px;
    height: 44px;
    padding: 0 8px;
    border: 1px solid var(--sp-line);
    border-radius: 10px;
    background: #fff;
    color: var(--sp-ink);
    font: inherit;
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
  }
  .sp-app-az button[disabled] {
    color: #b6c0cb;
    background: var(--sp-bg);
  }
  .sp-app-az button.is-on {
    background: #101418;
    border-color: #101418;
    color: #fff;
  }

  /* ---------- 5. rows: full-width tap targets ---------- */
  .sp-part-table {
    font-size: 1rem;
  }
  .sp-part-table th,
  .sp-part-table td {
    padding: 14px 10px;
  }
  .sp-part-table thead {
    display: none;
  }
  .sp-part-table code {
    font-size: 1rem;
  }
  .sp-part-table tbody tr {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .sp-part-table tbody tr:active {
    background: #d8ecf8;
  }
  .sp-part-table input[type="checkbox"] {
    width: 24px;
    height: 24px;
  }
  .sp-part-check-col {
    width: 44px;
  }

  /* ---------- 6. quote bar: pinned above the tabs ---------- */
  .sp-part-bulk {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: calc(var(--sp-tab-h) + env(safe-area-inset-bottom));
    z-index: 55;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 12px 16px;
    background: #101418;
    border-bottom: 0;
    border-radius: 0;
    box-shadow: 0 -10px 26px rgba(15, 23, 42, .22);
    transform: translateY(130%);
    transition: transform .22s ease;
  }
  .sp-part-bulk.sp-app-bulk--on {
    transform: none;
  }
  .sp-part-bulk > span {
    flex: 1 1 auto;
    color: #fff;
    font-size: 15px;
  }
  .sp-part-bulk .sp-btn {
    flex: none;
    min-height: 44px;
    padding: 12px 18px;
    border-radius: 999px;
  }
  .sp-part-bulk .sp-btn--primary {
    background: #fff;
    border-color: #fff;
    color: #101418;
    font-weight: 700;
  }
  .sp-part-bulk .sp-btn--ghost {
    background: transparent;
    border: 1px solid #3b4859;
    color: #aebccb;
  }
  .sp-part-bulk .sp-btn:disabled {
    opacity: 1;
    background: #fff;
    border-color: #fff;
    color: #101418;
  }

  /* ---------- 7. quote sheet ---------- */
  .sp-app-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(15, 23, 42, .45);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }
  .sp-app-scrim.is-on {
    opacity: 1;
    pointer-events: auto;
  }
  .sp-app-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 71;
    display: flex;
    flex-direction: column;
    max-height: 72vh;
    padding-bottom: env(safe-area-inset-bottom);
    background: #fff;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -22px 50px rgba(15, 23, 42, .28);
    transform: translateY(101%);
    transition: transform .26s ease;
  }
  .sp-app-sheet.is-on {
    transform: none;
  }
  .sp-app-sheet__grip {
    width: 42px;
    height: 5px;
    margin: 10px auto 2px;
    border-radius: 999px;
    background: #dbe2ea;
    flex: none;
  }
  .sp-app-sheet__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 20px 10px;
    flex: none;
  }
  .sp-app-sheet__head h2 {
    margin: 0;
    font-size: 20px;
    letter-spacing: -.01em;
  }
  .sp-app-sheet__head span {
    font-size: 13px;
    color: #8b95a1;
    text-align: right;
  }
  .sp-app-sheet__body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 20px 12px;
  }
  .sp-app-line {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    border-top: 1px solid var(--sp-line);
  }
  .sp-app-line__main {
    flex: 1 1 auto;
    min-width: 0;
  }
  .sp-app-line__pn {
    display: block;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 15px;
    font-weight: 700;
    color: var(--sp-ink);
    overflow-wrap: anywhere;
  }
  .sp-app-line__sub {
    display: block;
    font-size: 12.5px;
    color: var(--sp-muted);
  }
  .sp-app-step {
    flex: none;
    display: flex;
    align-items: center;
    border: 1px solid var(--sp-line);
    border-radius: 12px;
    overflow: hidden;
  }
  .sp-app-step button {
    width: 34px;
    height: 38px;
    padding: 0;
    border: 0;
    background: #fff;
    color: var(--sp-ink);
    font: inherit;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
  }
  .sp-app-step output {
    min-width: 26px;
    text-align: center;
    font-size: 15px;
    font-weight: 700;
  }
  .sp-app-del {
    flex: none;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #8b95a1;
    cursor: pointer;
  }
  .sp-app-del svg {
    width: 18px;
    height: 18px;
  }
  .sp-app-sheet__note {
    margin: 10px 0 0;
    color: var(--sp-muted);
    font-size: 13px;
    line-height: 1.45;
  }
  .sp-app-sheet__add {
    width: 100%;
    min-height: 46px;
    margin-top: 12px;
    border: 1px solid var(--sp-line);
    border-radius: 999px;
    background: #fff;
    color: var(--sp-ink);
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
  }
  .sp-app-sheet__foot {
    flex: none;
    padding: 12px 20px 16px;
    border-top: 1px solid var(--sp-line);
    background: #fff;
  }
  .sp-app-sheet__foot p {
    margin: 0 0 10px;
    color: var(--sp-muted);
    font-size: 12.5px;
    text-align: center;
  }
  .sp-app-sheet__go {
    width: 100%;
    min-height: 50px;
    border: 0;
    border-radius: 999px;
    background: var(--sp-blue);
    color: #fff;
    font: inherit;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
  }

  /* ---------- 8. forms: no iOS focus zoom, 44px controls ---------- */
  .sp-form input,
  .sp-form select,
  .sp-form textarea,
  .sp-login-field input,
  .sp-rfq-paste {
    font-size: 16px;
  }
  .sp-form label {
    font-size: .9rem;
  }
  .sp-form input,
  .sp-form select,
  .sp-form textarea,
  .sp-login-field input {
    min-height: 46px;
  }
  .sp-form__field input,
  .sp-form__field select,
  .sp-form__field textarea {
    width: 100%;
  }
  .sp-rfq-lines th,
  .sp-rfq-lines td {
    padding: 8px 6px;
  }

  /* ---------- 9. guest quick order ---------- */
  .sp-app-gate {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0 0 14px;
    padding: 14px 16px;
    border: 1px solid var(--sp-line);
    border-radius: 16px;
    background: var(--sp-bg);
  }
  .sp-app-gate strong {
    font-size: 16px;
  }
  .sp-app-gate span {
    font-size: 13px;
    color: var(--sp-muted);
  }
  .sp-app-gate button {
    margin-top: 6px;
    min-height: 48px;
    border: 0;
    border-radius: 999px;
    background: #101418;
    color: #fff;
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
  }

  /* ---------- 10. footer + group bar tap targets ---------- */
  .sp-ft__grid a,
  .sp-ft__legal a,
  .sp-ft__cookie {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }
  .sp-group-bar__links > a,
  .sp-group-bar__links > span {
    min-height: 26px;
    display: inline-flex;
    align-items: center;
  }
  .sp-related a,
  .sp-dd__kids a,
  .sp-dd__parent,
  .sp-dd__more {
    display: flex;
    align-items: center;
    min-height: 44px;
  }
}
