/*
 * Site tweaks that aren't part of the theme or of dark mode.
 * Loaded after beautifuljekyll.css and dark-mode.css (see `site-css` in
 * _config.yml), so anything here wins over both.
 */

/* --- Navbar avatar --- */

/*
 * Applied by the script in _includes/navbar-avatar-fit.html when the nav links
 * have come too close to the avatar. See that file for the reasoning.
 *
 * Hidden with visibility rather than display on purpose: the script measures
 * the avatar's position to decide when it can come back, and display:none
 * would collapse its box to nothing, so it could never reappear. Fading these
 * two properties also matches how the theme already hides the avatar when you
 * scroll down, so it uses the transition already defined for that.
 */
.navbar-custom .avatar-container.avatar-crowded {
  opacity: 0;
  visibility: hidden;
}

/*
 * Tightens the gaps between the nav links so the avatar has room to show on
 * ordinary laptop screens. The theme's own value is 0.9375rem a side; at that
 * spacing, with eight links, the avatar only appeared above ~1712px.
 *
 * This is the dial to turn if you want the avatar at narrower or wider windows:
 * lower for narrower, raise for roomier links. Roughly every 0.0625rem here
 * moves the width at which the avatar appears by about 28px.
 *
 *   0.9375rem (theme default) -> avatar from ~1712px
 *   0.625rem                  -> ~1575px
 *   0.5rem                    -> ~1524px
 *   0.4375rem (set below)     -> ~1496px
 *   0.375rem                  -> ~1468px
 *
 * Letter-spacing on the labels is deliberately left alone: removing it would
 * buy another ~75px but visibly changes how the uppercase nav type reads.
 */
@media (min-width: 1200px) {
  .navbar-expand-xl .navbar-nav .nav-link {
    padding-left: 0.4375rem;
    padding-right: 0.4375rem;
  }
}

/* --- Whiteboard / chalkboard --- */

/*
 * The drawing surface, driven by assets/js/whiteboard.js.
 *
 * It spans the whole document rather than the viewport, so strokes stay put
 * when the page scrolls. pointer-events: none is what keeps it from breaking
 * the site -- every click passes straight through to the page beneath, and the
 * script reads pointer events from the document instead. The z-index sits above
 * the content so you can draw over it like a real board, but below Bootstrap's
 * fixed navbar (1030) so the navigation always stays legible.
 */
.board-canvas {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  pointer-events: none;
}

/* Shared shape for the two corner controls. */
.board-toggle,
.board-clear {
  position: fixed;
  bottom: 1.25rem;
  z-index: 1031;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--bj-navbar-border-col);
  border-radius: 50%;
  background-color: var(--bj-navbar-col);
  color: var(--bj-navbar-text-col);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  /* Centres the glyph regardless of whether it's an icon font or an SVG. */
  display: flex;
  align-items: center;
  justify-content: center;
}

.board-toggle:focus-visible,
.board-clear:focus-visible {
  outline: 2px solid var(--bj-hover-col);
  outline-offset: 2px;
}

/*
 * Drawing switch, bottom left. Sits quietly at partial opacity until hovered,
 * and fills in with the link colour while drawing is on so the mode is
 * visible at a glance rather than only discoverable by trying to draw.
 */
.board-toggle {
  left: 1.25rem;
  /*
   * Off state. This used to be a pale circle at half opacity, which on a white
   * page was very nearly invisible. It now reads as a proper control: full
   * opacity, the link colour on the icon and rim so it registers as something
   * clickable, and a soft shadow to lift it off the background in both themes.
   */
  background-color: var(--bj-page-col);
  border: 2px solid var(--bj-link-col);
  color: var(--bj-link-col);
  box-shadow: 0 1px 4px var(--bj-button-shadow-col);
  transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out,
              color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.board-toggle:hover,
.board-toggle:focus {
  border-color: var(--bj-hover-col);
  color: var(--bj-hover-col);
  box-shadow: 0 2px 7px var(--bj-button-shadow-col);
}

/* On: filled rather than outlined, so the two states differ in more than
   just hue for anyone who doesn't distinguish colours easily. */
.board-toggle[aria-pressed="true"] {
  background-color: var(--bj-link-col);
  border-color: var(--bj-link-col);
  color: var(--bj-page-col);
}

.board-toggle[aria-pressed="true"]:hover,
.board-toggle[aria-pressed="true"]:focus {
  background-color: var(--bj-hover-col);
  border-color: var(--bj-hover-col);
  color: var(--bj-page-col);
}

/* The marker/chalk pair. Only one is shown, picked by the theme. */
.board-toggle .board-icon {
  width: 1.35rem;
  height: 1.35rem;
  margin: 0 auto;
}

.board-toggle .board-icon-marker {
  display: var(--bj-icon-marker, block);
}

.board-toggle .board-icon-chalk {
  display: var(--bj-icon-chalk, none);
}

/* Crosshair everywhere while armed, so it's obvious the page will draw. */
body.board-armed {
  cursor: crosshair;
}

/* Wipe control, bottom right. Hidden until there is something to wipe. */
.board-clear {
  right: 1.25rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease-in-out, visibility 0.25s, color 0.2s ease-in-out;
}

.board-clear.is-visible {
  opacity: 0.85;
  visibility: visible;
}

.board-clear.is-visible:hover,
.board-clear.is-visible:focus {
  opacity: 1;
  color: var(--bj-hover-col);
}

@media (prefers-reduced-motion: reduce) {
  .board-toggle,
  .board-clear {
    transition: none;
  }
}
