/* NodeBook — tablet and phone layouts, reduced motion. */

/* ---------- responsive: tablet ---------- */

@media (max-width: 1180px) {
  :root {
    --list-w: 340px;
    --sidebar-w: 76px;
  }

  .sidebar {
    align-items: center;
    padding: var(--space-4) var(--space-2);
  }

  .nav-item .label,
  .nav-count,
  .server-state .label {
    display: none;
  }

  .nav-item {
    width: 52px;
    height: 46px;
    justify-content: center;
    padding: 0;
    position: relative;
  }

  .sidebar-foot {
    align-items: center;
  }

  /* No room for the credit line in the icon rail; About has it. */
  .app-credit {
    display: none;
  }
}

/* ---------- responsive: phone ---------- */

@media (max-width: 820px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .sidebar {
    display: none;
  }

  .topbar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    height: var(--topbar-h);
    padding: 0 var(--space-2) 0 var(--space-4);
    padding-top: env(safe-area-inset-top);
    box-sizing: content-box;
    background: var(--bar-bg);
    border-bottom: 1px solid var(--bar-line);
  }

  .topbar .switcher,
  .topbar .spacer,
  .topbar .wordmark-tool,
  .topbar-back:not([hidden]) + .wordmark {
    display: none;
  }

  /* "#BEmesh" as on the other tools; the page's name follows it. */
  .topbar .wordmark {
    min-width: 0;
  }

  .topbar h1 {
    flex: 1;
    font-size: var(--text-lg);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar .icon-btn,
  .topbar .bar-btn,
  .topbar .tools-menu > .menu-btn {
    width: var(--tap);
    height: var(--tap);
    border-color: transparent;
  }

  .topbar img {
    width: 26px;
    height: 26px;
  }

  .tabbar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: var(--tabbar-h);
    padding-bottom: env(safe-area-inset-bottom);
    box-sizing: content-box;
    background: var(--bar-bg);
    border-top: 1px solid var(--bar-line);
  }

  /* Ink in both themes, like the top bar; the page you are on has a yellow pill behind its icon. */
  .tabbar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--bar-mut);
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
  }

  .tabbar a svg {
    box-sizing: content-box;
    padding: 3px 18px;
    border-radius: 999px;
  }

  .tabbar a[aria-current="page"] {
    color: var(--bar-text);
    font-weight: 700;
  }

  .tabbar a[aria-current="page"] svg {
    background: var(--bar-accent);
    color: var(--ink);
  }

  .split {
    grid-template-columns: minmax(0, 1fr);
  }

  .split.has-detail .pane--list,
  .split:not(.has-detail) .pane--detail {
    display: none;
  }

  .pane--list {
    border-right: 0;
  }

  .page-head {
    padding: var(--space-4) var(--space-4) var(--space-3);
  }

  .page-head h1 {
    display: none;
  }

  .page-body,
  .detail-body {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }

  .detail-head {
    padding: var(--space-4) var(--space-4) 0;
  }

  .detail-head .detail-actions {
    display: none;
  }

  .tabs {
    padding: var(--space-3) var(--space-2) 0;
  }

  .card {
    padding: var(--space-4);
    border-radius: var(--radius-md);
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-3);
  }

  .card-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  input[type="text"],
  input[type="search"],
  input[type="number"],
  input[type="password"],
  input[type="datetime-local"],
  input[type="date"],
  input:not([type]),
  select,
  textarea {
    font-size: 16px; /* prevents iOS zoom on focus */
    min-height: var(--tap);
  }

  .link-btn {
    min-height: 24px; /* WCAG 2.2 minimum touch target */
    padding: 4px 0;
  }

  .btn {
    min-height: 40px;
  }

  .row {
    min-height: 60px;
  }

  .coords-row {
    grid-template-columns: 1fr 1fr;
  }

  .coords-row .btn-row {
    grid-column: 1 / -1;
  }

  .mini-map {
    height: 220px;
  }

  .savebar {
    bottom: var(--space-3);
    width: calc(100% - 24px);
    border-radius: var(--radius-lg);
    justify-content: space-between;
  }

  .savebar .btn {
    border-radius: var(--radius-md);
  }

  .savebar-text {
    white-space: normal;
  }

  .toasts {
    left: var(--space-4);
    right: var(--space-4);
    max-width: none;
  }

  .dialog {
    width: 100vw;
    max-width: 100vw;
    max-height: 92dvh;
    margin: auto 0 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: 0;
  }

  .dialog-foot {
    border-radius: 0;
    padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom));
  }

  .dialog-foot .btn {
    flex: 1;
  }

  .channel {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .channel-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
    border-top: 1px solid var(--border);
    padding-top: var(--space-2);
  }

  .region-row {
    flex-wrap: wrap;
    padding-left: calc(var(--space-3) + var(--depth, 0) * 14px);
  }

  .region-code {
    flex-basis: 100%;
  }

  .region-row select {
    flex: 1;
    max-width: none;
    min-width: 0;
  }

  .map-toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 4px;
  }

  .map-toolbar::-webkit-scrollbar {
    display: none;
  }

  .map-toolbar > * {
    flex: none;
  }

  /* Clear of the zoom buttons in the bottom-right corner. */
  .legend {
    bottom: var(--space-3);
    right: calc(var(--tap) + var(--space-3) * 2);
  }

  .hide-phone {
    display: none !important;
  }

  /* The overview above an empty list already says what to do. */
  .list-overview[open] + .rows > .empty-list--none {
    display: none;
  }
}

@media (min-width: 821px) {
  .show-phone {
    display: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0ms !important;
    animation-duration: 0ms !important;
  }
}
