/* responsive-desktop.css - ensures Panda Chess teaching app looks great on laptops and desktops */

/* General layout tweaks for wide screens */
@media (min-width: 1280px) {
  /* Expand board when there is ample horizontal space */
  /* NO max-width transition here. fitBoard() writes an inline px max-width;
     animating it re-lays-out the board every frame for 300ms, which retriggers
     both board ResizeObservers and reads as a flicker/shake. style.css says the
     same thing — this file loads later, so a transition added back here would
     silently win. Snap instantly. */
  .board-wrapper {
    max-width: min(100%, calc(100vh - 200px));
  }
  /* Wider side panels for extra controls */
  #right-panel,
  #left-panel {
    width: 420px;
  }
  /* Increase toolbar icon size for better click targets */
  #app-toolbar button {
    padding: 0.75rem;
    font-size: 1.125rem;
  }
  /* Slightly larger base font for readability. The variable, not html's
     font-size: css/style.css multiplies it by Settings → Text size. */
  :root { --root-size: 18px; }
}

/* Extra breathing room on very wide screens (MacBook Neo / 4K) */
@media (min-width: 1536px) {
  #main-area {
    padding-left: 3rem !important;
    padding-right: 3rem !important;
    gap: 4rem !important;
  }
  #right-panel {
    width: 460px;
  }
}

/* Adjust teaching mode layout on desktop */
@media (min-width: 1280px) {
  .teaching-mode .board-wrapper {
    max-width: min(100%, calc(100vh - 150px));
  }
  /* No width here, on purpose. style.css's `.teaching-mode #right-panel` sets
     `width: auto !important`, which beats any width in this file whatever the
     source order — so the `width: 380px` that sat here was dead, and read like
     live configuration. It misled a reviewer into pinning 380px in a test and
     describing the cascade wrongly in a commit message, which is the real cost.
     `auto` is correct: teaching mode IS maximize-board (js/features/teaching.js
     `toggleMaximizeBoard`), and style.css hides this panel's contents and makes
     it transparent and borderless, so it should hug the playback controls —
     380px would be a 380px-wide invisible box. Measured in teaching mode: 67.5px.
     `right` DOES apply from here (equal specificity, later file, overriding
     style.css's 1.5rem), so it stays. */
  .teaching-mode #right-panel, .teaching-mode #left-panel {
    right: 2.5rem;
  }
  .teaching-mode #main-area {
    padding: 1rem 3rem;
  }
}

/* WSB ("Who Stands Better?") checklist — widen the sidebar while it is open.
   It is a checklist a class reads off a TV and the coach clicks with a mouse,
   so it gets room rather than being squeezed into the analysis-width column.
   These must live in THIS file: it is loaded after style.css and owns every
   other #right-panel width, including the 420px/460px desktop rules above.
   Capped against the viewport so a smaller laptop never crushes the board. */
#right-panel.wsb-wide { width: min(42rem, 46vw) !important; }
@media (min-width: 1536px) {
  #right-panel.wsb-wide { width: min(46rem, 44vw) !important; }
}

/* ==========================================================================
   NO GEOMETRY TRANSITIONS ON THE BOARD CHAIN  (anti-flicker)
   ==========================================================================
   #main-area, #right-panel and #board-surface all carry Tailwind's
   `transition-all duration-300`, i.e. transition-property: all. That animates
   WIDTH / HEIGHT / PADDING / GAP as well as colors, so any layout change —
   a panel toggle, a window resize, a Zoom share handing the window a new size
   or devicePixelRatio — spends 300ms continuously re-laying-out the board.
   Every one of those frames fires both board ResizeObservers, which re-run
   fitBoard() and reallocate + repaint the two canvases. The measurements taken
   mid-animation are transient values, so the next pass computes a slightly
   different target and animates again. That is the flicker: it is invisible
   at fullscreen (one dimension is comfortably slack, so the size converges on
   the first pass) and obvious in a smaller window, where the board is pinned
   against both axes at once.

   Colors, shadows and transforms may still animate — they never change layout.
   Keep this list free of any layout-affecting property. */
#main-area,
#right-panel,
#left-panel,
#board-surface,
.board-wrapper {
  transition-property: background-color, border-color, color, fill, stroke,
                       opacity, box-shadow, transform, filter, backdrop-filter !important;
}
