/*!
 * Schematic Parts – sp-mobile-cards.css
 * Path: assets/css/sp-mobile-cards.css
 * Layout: mockup "schematic-mobile-OK.html" – v3.4.8
 */

@layer sp {
  @media (max-width: 1024px) {
    :root {
      --spm-gap: 12px;
      --spm-heart-size: 34px;
      --spm-fab-bottom: 24px;
      --spm-panel-maxw: 560px;
    }

    /* ── Block wrapper ── */
    .spm-block {
      padding: 0;
      min-width: 0;
      width: 100%;
    }

    .spm-block * {
      min-width: 0;
      box-sizing: border-box;
    }

    .spm-block-hero {
      margin: 0 12px 0;
      border-radius: 12px;
      overflow: hidden;
      border: 1px solid var(--sp-border-color);
    }

    .spm-block-hero img {
      display: block;
      width: 100%;
      height: auto;
      max-height: none;
      background: transparent;
      border-radius: 0;
      object-fit: contain;
    }

    .sp-view .spm-block-hero img {
      background: transparent !important;
      border: 0 !important;
      width: 100% !important;
      height: auto !important;
    }

    /* ── Sticky mini-diagram (appears when hero scrolls out) ── */
    .spm-mini-diagram {
      position: fixed;
      top: 12px;
      right: 12px;
      z-index: 9990;
      width: 28vw;
      max-width: 130px;
      border-radius: 8px;
      overflow: hidden;
      background: #fff;
      border: 1px solid var(--sp-border-color);
      box-shadow: 0 4px 16px rgba(0, 0, 0, .15);
      cursor: pointer;
      opacity: 0;
      transform: translateY(-12px) scale(.9);
      pointer-events: none;
      transition: opacity .25s ease, transform .25s ease;
    }

    .spm-mini-diagram.is-visible {
      opacity: 1;
      transform: translateY(0) scale(1);
      pointer-events: auto;
    }

    .spm-mini-diagram img {
      display: block;
      width: 100%;
      height: auto;
      padding: 4px;
    }

    .spm-block-title {
      font-size: 18px;
      font-weight: 700;
      line-height: 1.2;
      margin: 12px 0 14px;
      white-space: normal;
      overflow-wrap: anywhere;
      word-break: break-word;
      hyphens: auto;
    }

    /* ── Cards grid ── */
    .spm-cards {
      display: grid;
      gap: 8px;
      padding: 0 12px 16px;
      width: 100%;
      min-width: 0;
    }

    /* ── Card shell ── */
    .sp-card {
      position: relative;
      width: 100%;
      border-radius: 12px;
      border: 1px solid var(--sp-border-color);
      background: #fff;
      box-sizing: border-box;
      overflow: hidden;
      transition: box-shadow .2s ease;
    }

    .sp-card:active {
      box-shadow: 0 4px 20px rgba(0, 0, 0, .1);
    }

    /* ── Top row: badge + info + thumb ── */
    .sp-card__top {
      display: grid;
      grid-template-columns: 32px 1fr 64px;
      gap: 10px;
      align-items: center;
      padding: 12px 10px 12px 12px;
    }

    /* When no thumbnail image – collapse to 2-column */
    .sp-card__top--no-thumb {
      grid-template-columns: 32px 1fr;
    }

    .sp-card__badge {
      width: 28px;
      height: 28px;
      border-radius: 50%;
      background: #111;
      color: #fff;
      font-weight: 700;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-size: 11px;
      line-height: 1;
      text-align: center;
      flex: 0 0 auto;
    }

    .sp-card__info {
      min-width: 0;
    }

    .sp-card__sku {
      font-family: 'DM Mono', ui-monospace, monospace;
      font-size: 10px;
      color: #737373;
      letter-spacing: 0.06em;
      margin-bottom: 3px;
      white-space: normal;
      overflow-wrap: anywhere;
      word-break: break-word;
    }

    .sp-card__sku-link {
      color: inherit;
      text-decoration: none;
    }

    .sp-card__sku-link:hover {
      text-decoration: none;
    }

    .sp-card__name {
      font-weight: 700;
      font-size: 13px;
      color: var(--tm-red, #D42B2B);
      line-height: 1.2;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .sp-card__name-link {
      color: inherit;
      text-decoration: none;
    }

    .sp-card__name-link:hover {
      text-decoration: none;
    }

    /* Thumb in card-top (right column) */
    .sp-card__thumb {
      width: 64px;
      height: 52px;
      border-radius: 8px;
      background: #f5f5f5;
      border: 1px solid var(--sp-border-color);
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      overflow: hidden;
    }

    .sp-card__thumb img {
      width: 100%;
      height: 100%;
      object-fit: contain;
      display: block;
      cursor: zoom-in;
    }

    /* ── Meta tag chips ── */
    .sp-card__meta {
      padding: 0 12px 10px;
      display: flex;
      flex-wrap: wrap;
      gap: 5px;
    }

    .sp-card__tag {
      font-size: 10px;
      font-family: 'DM Mono', ui-monospace, monospace;
      background: #f5f5f5;
      color: #3d3d3d;
      border-radius: 4px;
      padding: 3px 7px;
      border: 1px solid var(--sp-border-color);
      display: inline-flex;
      align-items: center;
      gap: 4px;
    }

    .sp-card__tag-label {
      color: #737373;
      font-weight: 400;
    }

    .sp-card__tag-val {
      color: #111;
      font-weight: 500;
    }

    /* ── Details accordion ── */
    .sp-card__details-toggle {
      width: 100%;
      border: none !important;
      background: #f5f5f5 !important;
      border-top: 1px solid var(--sp-border-color) !important;
      padding: 10px 16px !important;
      margin: 0 !important;
      display: flex;
      align-items: center;
      justify-content: space-between;
      font-family: inherit;
      font-size: 13px;
      font-weight: 600;
      color: #3d3d3d !important;
      letter-spacing: 0.02em;
      text-transform: none;
      cursor: pointer;
      -webkit-appearance: none;
      appearance: none;
      border-radius: 0 !important;
      box-shadow: none !important;
      line-height: 1.4;
    }

    .sp-card__details-toggle:hover,
    .sp-card__details-toggle:focus,
    .sp-card__details-toggle:active,
    .sp-card__details-toggle.is-open {
      background: #f5f5f5 !important;
      color: #3d3d3d !important;
      box-shadow: none !important;
      outline: none;
    }

    .sp-card__details-toggle svg {
      transition: transform .2s ease;
      flex-shrink: 0;
      color: #737373;
    }

    .sp-card__details-toggle.is-open svg {
      transform: rotate(180deg);
    }

    .sp-card__details-body {
      display: none;
      padding: 10px 16px;
      background: #f5f5f5;
      border-top: 1px solid var(--sp-border-color);
    }

    .sp-card__details-body.is-open {
      display: block;
    }

    .sp-card__detail-row {
      display: flex;
      gap: 6px;
      padding: 4px 0;
      font-size: 12px;
      border-bottom: 1px solid var(--sp-border-color);
    }

    .sp-card__detail-row:last-child {
      border-bottom: none;
    }

    .sp-card__dl {
      color: #737373;
      min-width: 100px;
      flex-shrink: 0;
    }

    .sp-card__dv {
      color: #111;
      font-weight: 500;
      word-break: break-word;
      overflow-wrap: anywhere;
    }

    /* ── Bottom bar: price + controls ── */
    .sp-card__bottom {
      border-top: 1px solid var(--sp-border-color);
      padding: 10px 12px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      background: #fff;
    }

    .sp-card__price {
      font-family: 'DM Mono', ui-monospace, monospace;
      font-size: 20px;
      font-weight: 500;
      color: #111;
      letter-spacing: -0.02em;
      white-space: nowrap;
    }

    .sp-card__controls {
      display: flex;
      align-items: center;
      gap: 6px;
    }

    /* ── QTY stepper buttons ── */
    .spm-btn {
      width: 34px !important;
      height: 34px !important;
      min-width: 34px !important;
      border-radius: 8px !important;
      border: 1.5px solid var(--sp-border-color) !important;
      background: #fff !important;
      font-size: 18px !important;
      font-weight: 300 !important;
      line-height: 1 !important;
      color: #111 !important;
      -webkit-appearance: none;
      appearance: none;
      display: inline-flex !important;
      align-items: center;
      justify-content: center;
      flex: 0 0 auto;
      padding: 0 !important;
      margin: 0 !important;
      cursor: pointer;
      transition: border-color .15s ease, background-color .15s ease;
      box-shadow: none !important;
    }

    .spm-btn:hover,
    .spm-btn:focus {
      background: #fff !important;
      border-color: #d2d8df !important;
      color: #111 !important;
      box-shadow: none !important;
    }

    .spm-btn:active {
      background: #f5f5f5 !important;
      border-color: #111 !important;
    }

    /* ── QTY input ── */
    .spm-qty {
      width: 48px !important;
      min-width: 48px !important;
      max-width: 48px !important;
      text-align: center;
      font-weight: 500 !important;
      font-size: 14px !important;
      font-family: 'DM Mono', ui-monospace, monospace;
      border: 1.5px solid var(--sp-border-color) !important;
      border-radius: 8px !important;
      height: 34px !important;
      color: #111 !important;
      background: #fff !important;
      padding: 0 2px !important;
      box-shadow: none !important;
      appearance: textfield;
      -moz-appearance: textfield;
      outline: none;
    }

    .spm-qty:focus {
      border-color: #111;
    }

    input.spm-qty::-webkit-outer-spin-button,
    input.spm-qty::-webkit-inner-spin-button {
      -webkit-appearance: none;
      margin: 0;
    }

    /* ── Cart button ── */
    .spm-add.btn-primary.is-icon {
      width: 40px;
      height: 34px;
      min-width: 40px;
      padding: 0;
      border: 0;
      border-radius: 8px !important;
      background: var(--tm-red) !important;
      color: #fff !important;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      position: relative;
      flex: 0 0 auto;
      cursor: pointer;
      transition: background-color .15s ease, transform .06s ease, opacity .15s ease;
      box-shadow: none;
    }

    .spm-add.btn-primary.is-icon:hover {
      background: var(--tm-red-dark) !important;
    }

    .spm-add.btn-primary.is-icon:active {
      background: var(--tm-red-dark) !important;
    }

    .spm-add.btn-primary.is-icon.added {
      background: var(--tm-red-dark) !important;
    }

    .spm-add.btn-primary.is-icon.is-busy {
      opacity: .7;
      pointer-events: none;
    }

    .spm-add.btn-primary.is-icon svg,
    .spm-add.btn-primary.is-icon .spm-add__icon {
      width: 16px;
      height: 16px;
      display: block;
      pointer-events: none;
      color: currentColor;
      flex: 0 0 auto;
    }

    /* ── Wishlist (heart) button ── */
    .spm-heart-btn {
      width: var(--spm-heart-size) !important;
      height: var(--spm-heart-size) !important;
      min-width: var(--spm-heart-size) !important;
      border: 1.5px solid var(--sp-border-color) !important;
      border-radius: 8px !important;
      padding: 0 !important;
      display: inline-flex !important;
      align-items: center;
      justify-content: center;
      background: #fff !important;
      transition: border-color .15s ease, background .15s ease, color .15s ease;
      color: var(--sp-text-muted, #737373) !important;
      flex: 0 0 auto;
      cursor: pointer;
      box-shadow: none !important;
    }

    .spm-heart-btn svg {
      width: 16px;
      height: 16px;
      display: block;
      pointer-events: none;
      color: currentColor;
      transition: fill .15s ease, stroke .15s ease;
    }

    .spm-heart-btn:hover {
      border-color: var(--sp-border-color) !important;
      background: #fef2f2 !important;
      color: var(--tm-red) !important;
    }

    .spm-heart-btn:active {
      background: #fef2f2 !important;
    }

    .spm-heart-btn.is-active,
    .spm-heart-btn[aria-pressed="true"] {
      border-color: var(--tm-red) !important;
      background: #fef2f2 !important;
    }

    .spm-heart-btn.is-active svg,
    .spm-heart-btn[aria-pressed="true"] svg {
      fill: var(--tm-red);
      stroke: var(--tm-red);
    }

    .spm-heart-btn.is-active:hover,
    .spm-heart-btn[aria-pressed="true"]:hover {
      background: #fde8e8 !important;
    }

    .sp-card[data-canbuy="1"] .spm-heart-btn {
      display: none;
    }

    /* ── Focus states ── */
    .spm-btn:focus-visible,
    .spm-add:focus-visible,
    .spm-heart-btn:focus-visible,
    .sp-card__details-toggle:focus-visible,
    .spm-panel__close:focus-visible,
    .spm-panel__item-remove:focus-visible,
    .spm-send-btn:focus-visible,
    .spm-inquiry-open-btn:focus-visible,
    .spm-fab:focus-visible,
    .spm-inquiry-form input:focus-visible,
    .spm-inquiry-form textarea:focus-visible {
      outline: none;
      box-shadow: var(--sp-shadow-focus);
    }

    /* ── FAB – full-width bar ── */
    .spm-fab {
      position: fixed;
      bottom: calc(var(--spm-fab-bottom) + env(safe-area-inset-bottom, 0px));
      right: 16px;
      left: 16px;
      max-width: 430px;
      margin: 0 auto;
      height: 52px;
      z-index: 9998;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 10px;
      padding: 0 14px;
      border: 0;
      border-radius: 14px;
      background: #111;
      color: #fff;
      font-family: inherit;
      font-size: 14px;
      font-weight: 700;
      letter-spacing: 0.04em;
      box-shadow: 0 4px 24px rgba(0, 0, 0, .25);
      opacity: 0;
      visibility: hidden;
      transform: translateY(16px);
      pointer-events: none;
      cursor: pointer;
      transition: opacity .3s cubic-bezier(.34, 1.56, .64, 1),
                  transform .3s cubic-bezier(.34, 1.56, .64, 1),
                  visibility .3s ease,
                  background-color .15s ease;
    }

    .spm-fab.is-visible {
      opacity: 1;
      visibility: visible;
      transform: translateY(0);
      pointer-events: auto;
    }

    .spm-fab:active {
      transform: scale(0.97);
    }

    .spm-fab svg {
      display: block;
      flex: 0 0 auto;
    }

    .spm-fab__count {
      min-width: 22px;
      height: 22px;
      border-radius: 50%;
      background: var(--tm-red);
      color: #fff;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 0 6px;
      font-size: 11px;
      line-height: 1;
      font-weight: 800;
    }

    /* ── Wishlist panel overlay ── */
    .spm-panel-overlay {
      position: fixed;
      inset: 0;
      z-index: 9999;
      display: none;
      background: rgba(0, 0, 0, .45);
      backdrop-filter: blur(2px);
      box-sizing: border-box;
    }

    .spm-panel-overlay.is-open {
      display: block;
    }

    .spm-panel {
      position: fixed;
      bottom: 0;
      left: 0;
      right: 0;
      max-width: var(--spm-panel-maxw);
      margin: 0 auto;
      background: #fff;
      border-radius: 20px 20px 0 0;
      max-height: 82vh;
      display: flex;
      flex-direction: column;
      transform: translateY(100%);
      transition: transform .35s cubic-bezier(.32, .72, 0, 1);
      z-index: 10000;
      overflow: hidden;
      overscroll-behavior: contain;
    }

    .spm-panel-overlay.is-open .spm-panel {
      transform: none;
    }

    .spm-panel__handle {
      width: 36px;
      height: 4px;
      border-radius: 2px;
      background: var(--sp-border-color);
      margin: 12px auto 0;
      flex: 0 0 auto;
    }

    .spm-panel__header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 14px 16px 12px;
      border-bottom: 1px solid var(--sp-border-color);
    }

    .spm-panel__title {
      font-size: 16px;
      font-weight: 800;
      line-height: 1.2;
      color: #111;
      letter-spacing: -0.01em;
    }

    .spm-panel__close {
      width: 32px;
      height: 32px;
      min-width: 32px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      border: none;
      border-radius: 50%;
      background: #f5f5f5;
      color: #3d3d3d;
      padding: 0;
      cursor: pointer;
      transition: background-color .15s ease;
    }

    .spm-panel__close:hover {
      background: #e5e5e5;
    }

    .spm-panel__items {
      padding: 12px 16px;
      overflow: auto;
      flex: 1 1 auto;
      min-height: 80px;
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    .spm-panel__empty {
      padding: 32px 0;
      color: #737373;
      font-size: 13px;
      text-align: center;
    }

    .spm-panel__item {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 10px;
      background: #f5f5f5;
      border-radius: 10px;
      border: 1px solid var(--sp-border-color);
    }

    .spm-panel__item-num {
      width: 24px;
      height: 24px;
      border-radius: 50%;
      background: #111;
      color: #fff;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-size: 10px;
      font-weight: 700;
      line-height: 1;
      flex-shrink: 0;
    }

    .spm-panel__item-info {
      flex: 1;
      min-width: 0;
    }

    .spm-panel__item-sku {
      font-family: 'DM Mono', ui-monospace, monospace;
      font-size: 10px;
      color: #737373;
    }

    .spm-panel__item-name {
      font-weight: 700;
      font-size: 13px;
      color: #111;
    }

    .spm-panel__item-qty {
      font-weight: 400;
      color: #737373;
    }

    .spm-panel__item-remove {
      width: 28px;
      height: 28px;
      min-width: 28px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      border: none;
      background: transparent;
      color: #737373;
      padding: 0;
      cursor: pointer;
      flex-shrink: 0;
    }

    .spm-panel__footer {
      border-top: 1px solid var(--sp-border-color);
      padding: 12px 16px 28px;
      background: #fff;
      flex: 0 0 auto;
    }

    .spm-success-msg {
      display: none;
      align-items: center;
      justify-content: center;
      gap: 8px;
      padding: 16px;
      color: #16a34a;
      font-weight: 700;
      font-size: 14px;
    }

    .spm-success-msg.is-show {
      display: flex;
    }

    .spm-inquiry-form {
      display: none;
      flex-direction: column;
      gap: 8px;
      margin-bottom: 10px;
    }

    .spm-inquiry-form.is-open {
      display: flex;
    }

    .spm-form-field {
      display: flex;
      flex-direction: column;
      gap: 4px;
    }

    .spm-form-field label {
      font-size: 11px;
      font-weight: 600;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      color: #737373;
    }

    .spm-inquiry-form input,
    .spm-inquiry-form textarea {
      width: 100%;
      border: 1.5px solid var(--sp-border-color);
      border-radius: 8px;
      background: #fff;
      color: #111;
      padding: 9px 12px;
      font-family: inherit;
      font-size: 14px;
      line-height: 1.4;
      box-sizing: border-box;
      transition: border-color .15s ease;
      outline: none;
      resize: none;
    }

    .spm-inquiry-form input:focus,
    .spm-inquiry-form textarea:focus {
      border-color: #111;
    }

    .spm-send-btn,
    .spm-inquiry-open-btn {
      width: 100%;
      height: 48px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      border: 0;
      border-radius: 12px;
      padding: 0 14px;
      font: inherit;
      font-size: 15px;
      font-weight: 700;
      letter-spacing: 0.03em;
      cursor: pointer;
      transition: background-color .15s ease;
    }

    .spm-send-btn {
      background: var(--tm-red);
      color: #fff;
    }

    .spm-send-btn:active {
      background: var(--tm-red-dark);
    }

    .spm-send-btn:disabled {
      opacity: .7;
      pointer-events: none;
    }

    .spm-inquiry-open-btn {
      background: #111;
      color: #fff;
    }

    .spm-inquiry-open-btn:active {
      background: #000;
    }
  }

  /* ── Small screen adjustments ── */
  @media (max-width: 360px) {
    :root {
      --spm-heart-size: 30px;
    }

    .spm-block-title {
      font-size: 17px;
    }

    .sp-card__top {
      grid-template-columns: 28px 1fr 52px;
      gap: 8px;
      padding: 10px 8px 10px 10px;
    }

    .sp-card__top--no-thumb {
      grid-template-columns: 28px 1fr;
    }

    .sp-card__badge {
      width: 24px;
      height: 24px;
      font-size: 10px;
    }

    .sp-card__thumb {
      width: 52px;
      height: 44px;
    }

    .sp-card__bottom {
      padding: 8px 10px;
      flex-wrap: wrap;
    }

    .sp-card__price {
      font-size: 18px;
    }

    .spm-btn {
      width: 30px !important;
      height: 30px !important;
      min-width: 30px !important;
      font-size: 16px !important;
    }

    .spm-qty {
      width: 42px !important;
      min-width: 42px !important;
      max-width: 42px !important;
      height: 30px !important;
      font-size: 12px !important;
    }

    .spm-add.btn-primary.is-icon {
      width: 36px;
      height: 30px;
      min-width: 36px;
    }

    .spm-panel-overlay .spm-panel__header,
    .spm-panel-overlay .spm-panel__items,
    .spm-panel-overlay .spm-panel__footer {
      padding-left: 12px;
      padding-right: 12px;
    }
  }
}

/* ── Outside @layer – Astra-hardening for sticky mini-diagram ── */
@media (max-width: 1024px) {
  .spm-mini-diagram {
    position: fixed !important;
    display: block !important;
  }

  .spm-mini-diagram img {
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
  }
}

/* Hide mini-diagram on desktop – only mobile feature */
@media (min-width: 1025px) {
  .spm-mini-diagram {
    display: none !important;
  }
}
