/* Phone and tablet layout. Loaded last so it can override the earlier sheets. */
.menu-close,
.nav-scrim {
  display: none;
}
.table-wrap,
.overview-table-scroll,
.overview-menu-content,
.terminal-market-strip {
  scrollbar-width: thin;
  scrollbar-color: #353535 transparent;
}
.overview-tabs {
  scrollbar-width: none;
}

/* Navigation becomes a drawer: phones, landscape phones and tablets. */
@media (max-width: 1024px) {
  .workspace,
  .terminal-expanded .workspace {
    margin-left: 0;
  }
  .sidebar,
  .terminal-expanded .sidebar {
    display: flex;
  }
  .sidebar {
    width: min(288px, 86vw);
    z-index: 40;
    padding: 20px 14px 14px;
    background: #0b0b0b;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    transform: translateX(-100%);
    visibility: hidden;
    transition:
      transform 0.22s ease,
      visibility 0s linear 0.22s;
  }
  .sidebar.open {
    transform: translateX(0);
    visibility: visible;
    box-shadow: 10px 0 50px #000a;
    transition: transform 0.22s ease;
  }
  .sidebar > .brand {
    padding-right: 48px;
  }
  .sidebar nav {
    min-height: 0;
    overscroll-behavior: contain;
  }
  .sidebar nav a {
    min-height: 44px;
    font-size: 14px;
  }
  .menu-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 14px;
    right: 8px;
    width: 44px;
    height: 44px;
    font-size: 26px;
  }
  .nav-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: #000a;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }
  body.menu-open .nav-scrim {
    opacity: 1;
    pointer-events: auto;
  }
  body.menu-open {
    overflow: hidden;
  }

  /* The menu button stays reachable however far the page is scrolled. */
  .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    padding: 0 14px 0 6px;
    background: #080808;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  #menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 44px;
    height: 44px;
    font-size: 22px;
  }
  .breadcrumb {
    flex: 1;
    min-width: 0;
    margin-right: auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar-right {
    flex: none;
  }

  /* iOS Safari zooms the whole page when a focused field is under 16px. */
  input:not([type='checkbox'], [type='radio']),
  select,
  textarea {
    font-size: 16px !important;
  }

  dialog {
    max-height: calc(100dvh - 24px);
    overflow: auto;
  }
  .heading-actions .button {
    min-width: 40px;
    min-height: 40px;
  }
  .overview-star {
    flex: none;
    width: 28px;
    line-height: 32px;
  }
}

/* Short screens: phones held sideways. */
@media (max-width: 1024px) and (max-height: 500px) {
  .sidebar {
    padding-top: 8px;
    padding-bottom: 6px;
  }
  .sidebar > .brand {
    padding-bottom: 8px;
  }
  .menu-close {
    top: 4px;
  }
  .sidebar-bottom {
    display: none;
  }
}

@media (max-width: 600px) {
  /* Page name only: the "Workspace /" prefix costs too much width here. */
  .breadcrumb {
    font-size: 0;
  }
  .breadcrumb span {
    display: none;
  }
  .breadcrumb strong {
    font-size: 13px;
  }
  .topbar-right {
    font-size: 11px;
  }

  /* Wide tables become one card per row, so nothing hides off the right edge. */
  .data-table.stack-on-phone,
  .data-table.stack-on-phone tbody,
  .data-table.stack-on-phone tr {
    display: block;
    width: 100%;
  }
  .data-table.stack-on-phone thead {
    display: none;
  }
  .data-table.stack-on-phone tr {
    padding: 12px 16px;
    border-bottom: 1px solid #ffffff12;
  }
  .data-table.stack-on-phone tr:last-child {
    border-bottom: 0;
  }
  .data-table.stack-on-phone td {
    display: block;
    position: relative;
    min-height: 24px;
    padding: 4px 0 4px 38%;
    border: 0;
    font-size: 12px;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .data-table.stack-on-phone td * {
    min-width: 0;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .data-table.stack-on-phone td::before {
    content: attr(data-label);
    position: absolute;
    left: 0;
    top: 5px;
    width: 34%;
    color: #7d7d7d;
    font-size: 11px;
  }
  .data-table.stack-on-phone td:first-child,
  .data-table.stack-on-phone td[data-label=''] {
    padding-left: 0;
  }
  .data-table.stack-on-phone td:first-child {
    padding-bottom: 8px;
    color: #f0f0f0;
    font-size: 13px;
    font-weight: 600;
  }
  .data-table.stack-on-phone td:first-child::before,
  .data-table.stack-on-phone td[data-label='']::before {
    display: none;
  }

  /* Market screener: price and change first, market name pinned while swiping. */
  .overview-market-table .overview-col-name,
  .overview-menu-content .overview-col-name {
    display: none;
  }
  .overview-table-scroll {
    max-height: none;
    overscroll-behavior-x: contain;
  }
  .overview-market-table th,
  .overview-market-table td {
    padding-left: 9px;
    padding-right: 9px;
  }
  .overview-market-table th:first-child,
  .overview-market-table td:first-child {
    position: sticky;
    left: 0;
    min-width: 136px;
    background: #090b0d;
  }
  .overview-market-table td:first-child {
    z-index: 1;
  }
  .overview-market-table th:first-child {
    z-index: 3;
  }
  .overview-market-cell {
    gap: 6px;
  }
}
