/* r15b — dedicated-servers filter, mobile + tablet only (max-width: 900px).
   iOS-style segmented controls. Desktop sidebar and filter JS are unchanged. */

@media (max-width: 900px) {
  body.hm-r1 .hm-r4-ded__layout {
    gap: 1.25rem;
  }

  body.hm-r1 .hm-r4-ded__filters {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1.25rem;
    padding: 1.25rem;
    position: static;
    grid-template-columns: none;
  }

  body.hm-r1 .hm-r4-ded__filters fieldset {
    display: grid;
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    position: relative;
    gap: 0;
  }

  body.hm-r1 .hm-r4-ded__filters legend {
    display: block;
    width: auto;
    margin: 0 0 8px;
    padding: 0;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.2;
    color: #64748b;
  }

  /* Radio groups: legend sits just above a 12px grey track. */
  body.hm-r1 .hm-r4-ded__filters fieldset:has(input[type="radio"]) {
    margin-top: calc(1.2 * 13px + 8px);
    padding: 3px;
    border-radius: 12px;
    background: #f1f5f9;
    gap: 2px;
  }

  body.hm-r1 .hm-r4-ded__filters fieldset:has(input[type="radio"]) legend {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    margin: 0 0 8px;
  }

  body.hm-r1 .hm-r4-ded__filters fieldset:has([name="ded-cc"]) {
    grid-template-columns: 1fr 1fr;
  }
  body.hm-r1 .hm-r4-ded__filters fieldset:has([name="ded-cpu"]) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  body.hm-r1 .hm-r4-ded__filters fieldset:has([name="ded-disk"]) {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  body.hm-r1 .hm-r4-ded__filters fieldset:has(input[type="radio"]) > label {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    box-sizing: border-box;
    width: auto;
    max-width: none;
    height: 40px;
    min-height: 40px;
    margin: 0;
    padding: 0 0.4rem;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: #475569;
    font-size: 14px;
    font-weight: 550;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  }

  body.hm-r1 .hm-r4-ded__filters input[type="radio"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
    appearance: none;
    -webkit-appearance: none;
  }

  body.hm-r1 .hm-r4-ded__filters label:has(input[type="radio"]:checked) {
    background: #fff;
    color: var(--r-ink, #0f1b2a);
    font-weight: 650;
    box-shadow: 0 1px 2px rgba(15, 27, 42, 0.08), 0 1px 1px rgba(15, 27, 42, 0.04);
  }

  body.hm-r1 .hm-r4-ded__filters label:has(:focus-visible) {
    outline: 2px solid var(--r-ink, #0f1b2a);
    outline-offset: 2px;
  }

  /* Narrow phones: shorten long labels so equal cells stay one line.
     JS filters by input value, not the visible text. */
  body.hm-r1 .hm-r4-ded__filters label:has([name="ded-cc"][value="eu"]),
  body.hm-r1 .hm-r4-ded__filters label:has([name="ded-cpu"][value="amd"]) {
    font-size: 0;
  }
  body.hm-r1 .hm-r4-ded__filters label:has([name="ded-cc"][value="eu"])::after,
  body.hm-r1 .hm-r4-ded__filters label:has([name="ded-cpu"][value="amd"])::after {
    font-size: 14px;
    font-weight: inherit;
    letter-spacing: normal;
    line-height: 1.2;
    color: inherit;
    text-transform: none;
  }
  body.hm-r1 .hm-r4-ded__filters label:has([name="ded-cc"][value="eu"])::after {
    content: "Европа";
  }
  body.hm-r1 .hm-r4-ded__filters label:has([name="ded-cpu"][value="amd"])::after {
    content: "AMD";
  }

  /* RAM select: same 40×12 as the segment track. */
  body.hm-r1 .hm-r4-ded__filters select {
    display: block;
    width: 100%;
    max-width: 100%;
    height: 40px;
    min-height: 40px;
    max-height: 40px;
    box-sizing: border-box;
    margin: 0;
    padding: 0 2.5rem 0 0.85rem;
    border: 0;
    border-radius: 12px;
    background-color: #f1f5f9;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
    background-size: 16px 16px;
    color: var(--r-ink);
    font: inherit;
    font-size: 14px;
    font-weight: 550;
    line-height: 40px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
  }

  body.hm-r1 .hm-r4-ded__filters select:focus-visible {
    outline: 2px solid var(--r-ink, #0f1b2a);
    outline-offset: 2px;
  }

  /* Port toggle: no heavy box, 40px row, switch on the right. */
  body.hm-r1 .hm-r4-ded__filters fieldset:has([name="ded-port"]) {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    margin: 0;
    padding: 0;
    background: none;
  }

  body.hm-r1 .hm-r4-ded__filters .hm-r4-switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 100%;
    height: 40px;
    min-height: 40px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--r-ink, #0f1b2a);
    font-size: 14px;
    font-weight: 550;
    white-space: nowrap;
    text-align: left;
    box-shadow: none;
  }

  body.hm-r1 .hm-r4-ded__filters .hm-r4-switch:has(:checked) {
    background: transparent;
    border: 0;
    color: var(--r-ink, #0f1b2a);
    box-shadow: none;
  }

  body.hm-r1 .hm-r4-ded__filters .hm-r4-switch input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    flex: 0 0 auto;
    order: 2;
    width: 44px;
    height: 26px;
    margin: 0 0 0 0.75rem;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: #d0d5dd;
    cursor: pointer;
    transition: background-color 0.15s ease;
    clip: auto;
    clip-path: none;
    overflow: visible;
    white-space: normal;
  }

  body.hm-r1 .hm-r4-ded__filters .hm-r4-switch input[type="checkbox"]::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 27, 42, 0.18);
    transition: transform 0.15s ease;
  }

  body.hm-r1 .hm-r4-ded__filters .hm-r4-switch input[type="checkbox"]:checked {
    background: var(--r-accent, #0d9488);
  }

  body.hm-r1 .hm-r4-ded__filters .hm-r4-switch input[type="checkbox"]:checked::after {
    transform: translateX(18px);
  }

  body.hm-r1 .hm-r4-ded__filters .hm-r4-switch input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--r-ink, #0f1b2a);
    outline-offset: 2px;
  }

  /* Reset: quiet text button, not a big boxed control. */
  body.hm-r1 .hm-r4-ded__reset {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    width: auto;
    min-height: 32px;
    margin: -0.25rem auto 0;
    padding: 0.25rem 0.6rem;
    border: 0;
    border-radius: 8px;
    background: transparent;
    box-shadow: none;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    transition: background-color 0.15s ease, color 0.15s ease;
  }

  body.hm-r1 .hm-r4-ded__count {
    margin: 0 0 0.5rem;
  }

  body.hm-r1 .hm-r4-srv {
    transition: border-color 0.15s ease, background-color 0.15s ease;
  }
  body.hm-r1 .hm-r4-srv:hover {
    box-shadow: none;
    background: #f6fffe;
    border-color: rgba(13, 148, 136, 0.45);
  }
}

/* Tablet: location fits in one even row; restore full labels. */
@media (min-width: 641px) and (max-width: 900px) {
  body.hm-r1 .hm-r4-ded__filters fieldset:has([name="ded-cc"]) {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  body.hm-r1 .hm-r4-ded__filters label:has([name="ded-cc"][value="eu"]),
  body.hm-r1 .hm-r4-ded__filters label:has([name="ded-cpu"][value="amd"]) {
    font-size: 14px;
  }
  body.hm-r1 .hm-r4-ded__filters label:has([name="ded-cc"][value="eu"])::after,
  body.hm-r1 .hm-r4-ded__filters label:has([name="ded-cpu"][value="amd"])::after {
    content: none;
  }
}

@media (max-width: 900px) and (hover: hover) and (pointer: fine) {
  body.hm-r1 .hm-r4-ded__filters fieldset:has(input[type="radio"]) > label:hover {
    background-color: rgba(255, 255, 255, 0.55);
  }
  body.hm-r1 .hm-r4-ded__filters label:has(input[type="radio"]:checked):hover {
    background-color: #fff;
  }
  body.hm-r1 .hm-r4-ded__filters select:hover {
    background-color: #e8eef5;
    box-shadow: none;
    transform: none;
  }
  body.hm-r1 .hm-r4-ded__reset:hover {
    background-color: #f1f5f9;
    color: var(--r-ink, #0f1b2a);
    border: 0;
    box-shadow: none;
    transform: none;
  }
}

@media (max-width: 900px) and (prefers-reduced-motion: reduce) {
  body.hm-r1 .hm-r4-ded__filters label,
  body.hm-r1 .hm-r4-ded__filters .hm-r4-switch input[type="checkbox"],
  body.hm-r1 .hm-r4-ded__filters .hm-r4-switch input[type="checkbox"]::after,
  body.hm-r1 .hm-r4-ded__reset,
  body.hm-r1 .hm-r4-srv {
    transition: none;
  }
}
