/* Card-market dock. Visual baseline: the root pack simulator dock. */
@media (min-width: 0px) {
  body.cg-mobile-navigation-enabled {
    padding-bottom: calc(55px + env(safe-area-inset-bottom, 0px));
  }

  body.cg-mobile-navigation-enabled #header,
  body.cg-mobile-navigation-enabled .l-header {
    transition: transform 180ms ease, opacity 180ms ease;
    will-change: transform;
  }

  body.cg-mobile-navigation-enabled.cg-mobile-header-hidden #header,
  body.cg-mobile-navigation-enabled.cg-mobile-header-hidden .l-header {
    opacity: 0;
    pointer-events: none;
    transform: translate3d(0, -110%, 0);
  }

  .cg-mobile-navigation {
    --cg-mobile-yellow: #ffd84d;
    --cg-mobile-bg: #0e0f12;
    --cg-mobile-border: #2a2d34;
    --cg-mobile-muted: #9aa0aa;
    --cg-mobile-text: #f2f3f5;
    position: relative;
    z-index: 1003;
  }

  .cg-mobile-dock {
    align-items: stretch;
    background: var(--cg-mobile-bg);
    border-top: 1px solid var(--cg-mobile-border);
    bottom: 0;
    box-sizing: border-box;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, .18);
    display: grid;
    grid-template-columns: repeat(var(--cg-mobile-dock-columns, 4), minmax(0, 1fr));
    height: calc(55px + env(safe-area-inset-bottom, 0px));
    left: 0;
    max-width: none;
    padding: 0 6px env(safe-area-inset-bottom, 0px);
    position: fixed;
    right: auto;
    transform: translate3d(0, 110%, 0);
    transition: transform 180ms ease;
    visibility: hidden;
    width: 100vw;
    width: 100dvw;
    z-index: 1005;
  }

  body.cg-mobile-dock-visible .cg-mobile-dock,
  body.cg-mobile-sheet-open .cg-mobile-dock {
    transform: translate3d(0, 0, 0);
    visibility: visible;
  }

  .cg-mobile-dock-item,
  button.cg-mobile-dock-item {
    align-items: center;
    appearance: none;
    background: transparent;
    border: 0;
    border-radius: 7px;
    box-sizing: border-box;
    color: var(--cg-mobile-muted);
    display: flex;
    flex-direction: column;
    font-family: inherit;
    font-size: 10px;
    font-weight: 700;
    gap: 2px;
    justify-content: center;
    line-height: 1.1;
    height: 54px;
    margin: 0;
    min-width: 0;
    padding: 3px 2px 2px;
    text-decoration: none;
    width: 100%;
    -webkit-tap-highlight-color: transparent;
  }

  .cg-mobile-dock-item > span {
    color: inherit;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
  }

  .cg-mobile-dock-item:active,
  .cg-mobile-dock-item[aria-expanded="true"] {
    background: rgba(255, 216, 77, .08);
    color: var(--cg-mobile-yellow);
  }

  .cg-mobile-dock-item:focus-visible,
  .cg-mobile-sheet button:focus-visible,
  .cg-mobile-sheet a:focus-visible,
  .cg-mobile-sheet input:focus-visible,
  .cg-mobile-sheet select:focus-visible {
    outline: 2px solid var(--cg-mobile-yellow);
    outline-offset: 2px;
  }

  .cg-mobile-dock-icon {
    display: block;
    flex: 0 0 auto;
    fill: none;
    height: 17px;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
    width: 17px;
  }

  .cg-mobile-sheet-backdrop {
    appearance: none;
    background: rgba(0, 0, 0, .58);
    border: 0;
    bottom: 0;
    left: 0;
    margin: 0;
    padding: 0;
    position: fixed;
    right: 0;
    top: 0;
    width: 100%;
    z-index: 1002;
  }

  .cg-mobile-sheet-backdrop[hidden],
  .cg-mobile-sheet[hidden] {
    display: none !important;
  }

  .cg-mobile-sheet {
    background: #fff;
    border: 1px solid #dedfe3;
    border-bottom: 0;
    border-radius: 18px 18px 0 0;
    bottom: calc(55px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -18px 42px rgba(0, 0, 0, .24);
    color: #15171b;
    left: 0;
    margin: 0;
    max-height: min(72vh, 610px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 8px 18px 22px;
    position: fixed;
    right: 0;
    transform: translate3d(0, 105%, 0);
    transition: transform 200ms ease;
    z-index: 1004;
  }

  .cg-mobile-sheet[aria-hidden="false"] {
    transform: translate3d(0, 0, 0);
  }

  .cg-mobile-sheet-handle {
    background: #d7d9de;
    border-radius: 99px;
    height: 4px;
    margin: 0 auto 7px;
    width: 42px;
  }

  .cg-mobile-sheet-head {
    align-items: center;
    border-bottom: 1px solid #ececef;
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    padding-bottom: 10px;
  }

  .cg-mobile-sheet-title {
    color: #15171b;
    font-size: 18px;
    font-weight: 800;
    line-height: 1.35;
    margin: 0;
  }

  .cg-mobile-sheet-close {
    align-items: center;
    appearance: none;
    background: #f0f1f3;
    border: 0;
    border-radius: 50%;
    color: #2a2d34;
    display: inline-flex;
    font: 700 24px/1 sans-serif;
    height: 36px;
    justify-content: center;
    padding: 0 0 3px;
    width: 36px;
  }

  .cg-mobile-search,
  .cg-mobile-search label {
    display: grid;
    gap: 6px;
  }

  .cg-mobile-search {
    gap: 13px;
  }

  .cg-mobile-search-row {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cg-mobile-search label > span {
    color: #4a4e57;
    font-size: 12px;
    font-weight: 800;
  }

  .cg-mobile-search input,
  .cg-mobile-search select {
    appearance: none;
    background: #f6f7f9;
    border: 1px solid #c9cbd1;
    border-radius: 9px;
    color: #15171b;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
    height: 46px;
    margin: 0;
    max-width: none;
    padding: 0 12px;
    width: 100%;
  }

  .cg-mobile-search select {
    background-image: linear-gradient(45deg, transparent 50%, #525762 50%), linear-gradient(135deg, #525762 50%, transparent 50%);
    background-position: calc(100% - 17px) 20px, calc(100% - 12px) 20px;
    background-repeat: no-repeat;
    background-size: 5px 5px, 5px 5px;
    padding-right: 30px;
  }

  .cg-mobile-search-submit {
    appearance: none;
    background: #15171b;
    border: 1px solid #15171b;
    border-radius: 10px;
    color: #fff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 800;
    line-height: 1;
    min-height: 48px;
    padding: 12px 16px;
  }

  .cg-mobile-tool-list {
    display: grid;
    gap: 8px;
  }

  .cg-mobile-tool-list a {
    align-items: center;
    background: #f6f7f9;
    border: 1px solid #e1e2e6;
    border-radius: 10px;
    color: #1d2026;
    display: flex;
    font-size: 14px;
    font-weight: 800;
    justify-content: space-between;
    min-height: 50px;
    padding: 10px 14px;
    text-decoration: none;
  }

  body.cg-mobile-sheet-open {
    overflow: hidden;
  }
}

@media (min-width: 960px) {
  .cg-mobile-dock {
    padding-left: max(6px, calc((100vw - 720px) / 2));
    padding-right: max(6px, calc((100vw - 720px) / 2));
  }

  .cg-mobile-sheet {
    border-bottom: 1px solid #dedfe3;
    border-radius: 18px;
    bottom: auto;
    left: 50%;
    right: auto;
    top: 50%;
    transform: translate3d(-50%, -45%, 0);
    width: min(620px, calc(100dvw - 32px));
  }

  .cg-mobile-sheet[aria-hidden="false"] {
    transform: translate3d(-50%, -50%, 0);
  }
}

/*
 * Shared bottom-fixed UI contract.
 *
 * Every plugin-owned control anchored to the viewport bottom must opt in with
 * .cg-bottom-fixed-ui. This keeps dock clearance centralized instead of
 * maintaining a selector list that silently misses newly added controls.
 */
body.cg-mobile-dock-visible,
body.cg-mobile-sheet-open {
  --cg-mobile-dock-clearance: var(--cg-mobile-dock-height, calc(55px + env(safe-area-inset-bottom, 0px)));
}

body.cg-mobile-dock-visible .cg-bottom-fixed-ui,
body.cg-mobile-sheet-open .cg-bottom-fixed-ui {
  bottom: calc(var(--cg-mobile-dock-clearance) + var(--cg-bottom-fixed-gap, 12px)) !important;
}

body.cg-mobile-dock-visible .cg-bottom-fixed-ui--panel,
body.cg-mobile-sheet-open .cg-bottom-fixed-ui--panel {
  --cg-bottom-fixed-gap: 66px;
  max-height: min(72vh, calc(100dvh - var(--cg-mobile-dock-clearance) - 92px));
}

.cg-bottom-fixed-ui--flush {
  --cg-bottom-fixed-gap: 0px;
}

@media (max-width: 768px) {
  /* This tab rail is bottom-fixed on desktop but intentionally top-fixed on phones. */
  body.cg-mobile-dock-visible .cg-bottom-fixed-ui--desktop-only,
  body.cg-mobile-sheet-open .cg-bottom-fixed-ui--desktop-only {
    bottom: auto !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.cg-mobile-navigation-enabled #header,
  body.cg-mobile-navigation-enabled .l-header,
  .cg-mobile-dock,
  .cg-mobile-sheet {
    transition-duration: 0.01ms !important;
  }
}
