/* Mobile player search
   The dock exposes one stable action. Activating it opens a dedicated,
   top-anchored search surface so the keyboard never crowds the control. */

#mobile-search-back {
  display: none;
}

@media screen and (max-width: 900px) {
  body.mobile-search-open {
    overflow: hidden;
    overscroll-behavior: none;
  }

  #top-part #search-container {
    position: fixed;
    left: 50%;
    right: auto;
    top: auto;
    bottom: calc(10px + env(safe-area-inset-bottom));
    width: 56px;
    height: 56px;
    min-width: 56px;
    max-width: none;
    transform: translateX(-50%);
    z-index: 2402;
    transition: none;
  }

  #search-container #search-form.search-form {
    position: relative;
    display: grid;
    grid-template-columns: 0 0 56px;
    gap: 0;
    width: 56px;
    height: 56px;
    min-height: 56px;
    margin: 0 !important;
    border: 0;
    border-radius: 50%;
    background: transparent;
    box-shadow: none;
    overflow: visible;
    transition: none;
  }

  #search-container #search-form .search-bar,
  #mobile-search-back {
    width: 0;
    min-width: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
  }

  #search-container #search-form #search-button {
    position: relative;
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    min-width: 56px;
    min-height: 56px;
    padding: 0;
    border: 0 !important;
    border-radius: 50%;
    background: var(--accent);
    color: var(--on-accent);
    box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 30%, transparent);
    transform: none;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  #search-container #search-form #search-button::before {
    display: none !important;
  }

  #search-container #search-form #search-button svg {
    display: block;
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    fill: currentColor;
    transform: none;
  }

  #search-container #search-form #search-button:hover,
  #search-container #search-form #search-button:active,
  #search-container #search-form #search-button:focus-visible {
    background: var(--accent-strong);
    color: var(--on-accent);
    transform: none;
  }

  #search-button .t-icon-swap {
    display: grid;
    width: 24px;
    height: 24px;
    place-items: center;
  }

  #search-button .t-icon {
    grid-area: 1 / 1;
    width: 24px;
    height: 24px;
  }

  /* Keep the dock affordance visually identical before and after a search.
     The desktop success-check swap is too busy at this scale and can overlap
     the magnifier when reduced-motion preferences are active. */
  #search-button .t-icon[data-icon="a"] {
    opacity: 1 !important;
    filter: none !important;
    transform: none !important;
  }

  #search-button .t-icon[data-icon="b"] {
    display: none !important;
    animation: none !important;
  }

  body:not(.mobile-search-open) #search-container #suggestions,
  body:not(.mobile-search-open) #search-container .bottom-search-panel,
  body:not(.mobile-search-open) #search-container .t-error-msg {
    display: none !important;
  }

  body.mobile-search-open #top-part #search-container {
    inset: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-width: 0;
    padding:
      calc(12px + env(safe-area-inset-top))
      14px
      calc(18px + env(safe-area-inset-bottom));
    box-sizing: border-box;
    background:
      radial-gradient(circle at 82% 0%, rgba(101, 215, 97, 0.11), transparent 34%),
      var(--bg);
    transform: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    z-index: 5000;
  }

  body.mobile-search-open #search-container #search-form.search-form {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 52px;
    gap: 10px;
    width: 100%;
    height: auto;
    min-height: 52px;
    max-width: 720px;
    margin: 0 auto !important;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
  }

  body.mobile-search-open #mobile-search-back {
    position: relative;
    display: grid;
    place-items: center;
    width: 44px;
    height: 52px;
    min-width: 44px;
    padding: 0;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: var(--text);
    opacity: 1;
    overflow: visible;
    pointer-events: auto;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  body.mobile-search-open #mobile-search-back:active {
    background: var(--surface-2);
  }

  body.mobile-search-open #mobile-search-back:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  body.mobile-search-open #search-container #search-form .search-bar {
    position: relative;
    width: auto;
    min-width: 0;
    height: 52px;
    border: 1px solid var(--border-strong);
    border-radius: 16px;
    background: var(--surface-2);
    opacity: 1;
    overflow: visible;
    pointer-events: auto;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  }

  body.mobile-search-open #search-container #search-form .search-bar:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
  }

  body.mobile-search-open #search-container #search-form #player-name {
    width: 100%;
    height: 50px;
    min-height: 50px;
    padding: 0 16px;
    border: 0;
    border-radius: 15px;
    background: transparent;
    color: var(--text);
    box-shadow: none;
    font-size: 16px !important;
    font-weight: 650;
    line-height: 1;
  }

  body.mobile-search-open #search-container #search-form #player-name:focus {
    outline: 0;
    box-shadow: none;
  }

  body.mobile-search-open #search-container #search-form #search-button {
    width: 52px;
    height: 52px;
    min-width: 52px;
    min-height: 52px;
    border-radius: 16px;
    box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 25%, transparent);
  }

  body.mobile-search-open #search-container #search-form #suggestions {
    position: absolute;
    top: calc(100% + 10px);
    bottom: auto;
    left: 0;
    right: 0;
    z-index: 4;
    max-height: min(360px, calc(100dvh - 110px - env(safe-area-inset-top)));
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow-2);
    overflow-y: auto;
  }

  body.mobile-search-open #search-container #search-form #suggestions .suggestion {
    min-height: 50px;
    padding: 14px 16px;
    box-sizing: border-box;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text);
    font-size: 15px;
  }

  body.mobile-search-open #search-container .bottom-search-panel {
    position: absolute;
    top: calc(100% + 12px);
    left: 54px;
    right: 0;
    bottom: auto;
    width: auto;
    max-height: calc(100dvh - 96px - env(safe-area-inset-top));
    border-radius: 18px;
    transform-origin: top center;
  }

  body.mobile-search-open #search-container .bottom-search-panel-grid {
    max-height: calc(100dvh - 154px - env(safe-area-inset-top));
  }

  body.mobile-search-open #search-form .t-error-msg {
    top: calc(100% + 8px);
    left: 54px;
  }

  body.mobile-search-open #bottom-menu {
    visibility: hidden;
    pointer-events: none;
  }

  #bottom-menu .menu-button,
  #bottom-menu .menu-button:hover,
  #bottom-menu .menu-button:active,
  #bottom-menu .menu-button.active {
    font-weight: 800;
    transform: none;
  }

  #bottom-menu .menu-button svg,
  #bottom-menu .menu-button:hover svg,
  #bottom-menu .menu-button:active svg,
  #bottom-menu .menu-button.active svg {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  #top-part #search-container,
  #search-container #search-form.search-form,
  #search-container #search-form #search-button {
    transition: none !important;
    animation: none !important;
  }
}
