/* v2.7.2 — Bullet: allt borðið rúmast á mjóum skjám. */
/* Keep board rules scoped to Bullet; other workspaces retain their layout. */
[data-pro-chess="openings"],
[data-pro-chess="openings"] .pro-opening-layout,
[data-pro-chess="openings"] .pro-opening-layout > *,
[data-pro-chess="openings"] .pro-opening-head > div,
[data-pro-chess="openings"] .pro-opening-tree-card,
[data-pro-chess="openings"] .pro-opening-tree,
[data-pro-chess="openings"] .pro-tree-level > div {
  min-width: 0;
}

[data-pro-chess="openings"] .pro-opening-board {
  min-width: 0;
  max-width: 100%;
}

[data-pro-chess="openings"] .pro-study-controls {
  flex-wrap: wrap;
}

[data-pro-chess="openings"] .pro-study-controls button {
  max-width: 100%;
  white-space: normal;
}

[data-pro-chess="openings"] .pro-opening-head {
  flex-wrap: wrap;
}

[data-pro-chess="openings"] .pro-opening-head > div {
  flex: 1 1 180px;
}

[data-pro-chess="openings"] .pro-page-heading,
[data-pro-chess="openings"] .pro-opening-head,
[data-pro-chess="openings"] .pro-training-feedback,
[data-pro-chess="openings"] .pro-opening-notes,
[data-pro-chess="openings"] .pro-tree-heading {
  overflow-wrap: anywhere;
}

[data-pro-chess="openings"] .pro-opening-stats {
  flex-wrap: wrap;
  max-width: 100%;
  gap: 8px 16px;
}

[data-pro-chess="openings"] .pro-opening-stats > span {
  white-space: nowrap;
}

[data-pro-chess="openings"] .pro-tree-level {
  grid-template-columns: 34px minmax(0, 1fr);
}

[data-pro-chess="openings"] .pro-tree-root,
[data-pro-chess="openings"] .pro-tree-level button {
  max-width: 100%;
  overflow-wrap: anywhere;
}

/* A tablet also needs room for the navigation sidebar when it is visible. */
@media (max-width: 1150px) {
  [data-pro-chess="openings"] .pro-opening-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  [data-pro-chess="openings"] .pro-opening-stage { order: 1; }
  [data-pro-chess="openings"] .pro-opening-library { order: 2; }
  [data-pro-chess="openings"] .pro-opening-notes {
    order: 3;
    grid-column: auto;
    display: block;
    padding: 0;
  }

  [data-pro-chess="openings"] .pro-opening-notes > section {
    margin: 12px;
  }

  [data-pro-chess="openings"] .pro-opening-notes > .primary-button {
    width: calc(100% - 24px);
    margin: 0 12px 12px;
  }

  [data-pro-chess="openings"] .pro-speed-panel {
    margin: 0 12px 12px;
    flex-wrap: wrap;
  }

  [data-pro-chess="openings"] .pro-card-title {
    flex-wrap: wrap;
    gap: 6px 12px;
    padding-block: 10px;
  }
}

@media (max-width: 620px) {
  [data-pro-chess="openings"] .pro-opening-stage {
    padding: 8px;
  }

  [data-pro-chess="openings"] .pro-opening-board {
    width: 100%;
  }

  /* Five navigation buttons on row one; flip and lesson actions on row two. */
  [data-pro-chess="openings"] .pro-study-controls {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px;
  }

  [data-pro-chess="openings"] .pro-study-controls button {
    min-width: 0;
    width: 100%;
    min-height: 44px;
    padding: 6px 4px;
  }

  [data-pro-chess="openings"] .pro-study-controls [data-step="play"] {
    grid-column: span 2;
  }

  [data-pro-chess="openings"] .pro-study-controls [data-opening-lesson] {
    grid-column: span 5;
  }

  [data-pro-chess="openings"] .pro-tree-level {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  [data-pro-chess="openings"] .pro-tree-level button {
    min-width: 0;
    min-height: 44px;
  }

  [data-pro-chess="openings"] .pro-review-status > div {
    flex-wrap: wrap;
  }
}

/* Later large-type rules restored desktop minimums on the shared mobile bar. */
@media (max-width: 900px) {
  .topbar .brand,
  .topbar .profile-chip {
    min-width: 0;
  }
}

/* Keep the full site name and every header action available on small phones. */
@media (max-width: 620px) {
  .topbar {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    grid-template-rows: 44px 36px;
    align-content: center;
    gap: 6px;
    height: 112px;
    padding: 10px 12px;
  }

  .topbar .mobile-menu {
    grid-column: 1;
    grid-row: 1;
    width: 44px;
    height: 44px;
  }

  .topbar .brand {
    grid-column: 2;
    grid-row: 1;
    gap: 6px;
  }

  .topbar .brand > div { min-width: 0; }
  .topbar .brand-mark {
    flex: 0 0 32px;
    width: 32px;
    height: 36px;
    font-size: 26px;
  }

  .topbar .brand strong {
    font-size: clamp(10px, 3vw, 15px);
    letter-spacing: .04em;
    overflow-wrap: anywhere;
  }

  .topbar .profile-chip {
    grid-column: 3;
    grid-row: 1;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
  }

  .topbar > .academy-tools-dock {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: center;
    margin: 0;
  }

  .sidebar {
    top: 112px;
    max-height: calc(100dvh - 112px);
  }

  .menu-scrim { top: 112px; }
  .academy-sheet { top: 114px; }
}
