/* ---------------------------------------------------------------------------
   Shortcut bar — one component, two placements.

     narrow (< 62rem)   fixed to the BOTTOM of the viewport, full width,
                        thumb-reachable, padded past the home indicator with
                        env(safe-area-inset-bottom).
     >= 62rem           a compact rail DOCKED to the left or right edge and
                        vertically centred, unless the administrator chose
                        `bottom`, in which case it stays where it is.

   This file is only ever linked when the bar actually renders (see
   includes/shortcut-bar.php), so every rule in it — including the ones on
   :root and body — is scoped by its own presence. Master switch off means the
   stylesheet is not requested at all.

   COORDINATION WITH THE BACK-TO-TOP BUTTON
   towing-disclosure.css positions .tw-backtotop at
       bottom: calc(max(1rem, safe-area) + var(--tw-bottom-stack, 0px))
   so publishing --tw-bottom-stack from here lifts that button above the bar
   without either component knowing the other's height. When the bar is docked
   to a side on a wide screen the corner is free again and the offset goes back
   to zero.

   The CSP is `style-src 'self'` — nothing here may be inlined.
   No CSS nesting; nothing else in this codebase uses it.
   --------------------------------------------------------------------------- */

:root {
  --tw-shortcutbar-h: 3.5rem;          /* the bar itself, excluding safe area */
  --tw-shortcutbar-gap: 0.5rem;        /* breathing room above the back-to-top */
}

/* Published for .tw-backtotop. Every bar is a bottom bar on a narrow screen. */
:root:has(.tw-shortcutbar) {
  --tw-bottom-stack: calc(var(--tw-shortcutbar-h) + var(--tw-shortcutbar-gap) + env(safe-area-inset-bottom, 0px));
}

/* The page must be able to scroll clear of a bar that floats over it. */
body:has(.tw-shortcutbar) {
  padding-bottom: calc(var(--tw-shortcutbar-h) + env(safe-area-inset-bottom, 0px));
}

/* ---- the bar ------------------------------------------------------------- */

.tw-shortcutbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-bottomnav, 50);
  box-sizing: border-box;
  min-height: var(--tw-shortcutbar-h);
  padding: 0 var(--stack-sm, 0.5rem);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--surface-container-highest, #263040);
  border-top: 1px solid var(--outline-variant, #333E4D);
  border-top-left-radius: var(--radius-xl, 0.75rem);
  border-top-right-radius: var(--radius-xl, 0.75rem);
  box-shadow: var(--shadow-lg, 0 10px 24px rgba(0, 0, 0, .45));
  /* A long item list scrolls INSIDE the bar. The page never scrolls sideways,
     which is the whole point at 320px. */
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

.tw-shortcutbar__list {
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  gap: var(--stack-xs, 0.25rem);
  list-style: none;
  margin: 0;
  padding: 0;
  min-width: min-content;   /* items keep their size; the bar scrolls, not them */
}

.tw-shortcutbar__item {
  display: flex;
  flex: 0 0 auto;
}

.tw-shortcutbar__link {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  /* Hard floor for a touch target, and wide enough that two labels never touch. */
  min-width: 3.25rem;
  min-height: 44px;
  padding: 0.375rem 0.5rem;
  border-radius: var(--radius-lg, 0.5rem);
  color: var(--on-surface-variant, #A7B2C2);
  text-decoration: none;
  font: 600 0.625rem/1.2 var(--font-body, system-ui, sans-serif);
  letter-spacing: 0.02em;
  transition: background-color var(--dur-menu, 200ms) ease,
              color var(--dur-menu, 200ms) ease,
              transform var(--dur-press, 140ms) var(--ease-out, ease-out);
}

.tw-shortcutbar__icon {
  display: block;
  line-height: 0;
}

.tw-shortcutbar__icon .tw-icon {
  width: 20px;
  height: 20px;
}

.tw-shortcutbar__label {
  display: block;
  max-width: 5.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (hover: hover) {
  .tw-shortcutbar__link:hover {
    background: var(--hairline-faint, rgba(255, 255, 255, .05));
    color: var(--on-surface, #EEF2F7);
  }
}

.tw-shortcutbar__link:active { transform: scale(0.97); }

.tw-shortcutbar__link:focus-visible {
  outline: var(--focus-ring-width, 2px) solid var(--focus-ring-color, #FF6B1F);
  outline-offset: -2px;
}

.tw-shortcutbar__link.is-active {
  background: var(--secondary, #FF6B1F);
  color: var(--on-secondary, #160800);
}

/* Real count, drawn over the icon. Hidden from assistive tech — the link
   carries an .tw-sr-only "N unread" instead, which actually reads. */
.tw-shortcutbar__badge {
  position: absolute;
  top: 0.125rem;
  left: 50%;
  transform: translateX(0.25rem);
  min-width: 1rem;
  padding: 0 0.25rem;
  border-radius: var(--radius-full, 9999px);
  background: var(--secondary, #FF6B1F);
  color: var(--on-secondary, #160800);
  font: 700 0.625rem/1rem var(--font-body, system-ui, sans-serif);
  text-align: center;
}

.tw-shortcutbar__link.is-active .tw-shortcutbar__badge {
  background: var(--on-secondary, #160800);
  color: var(--secondary, #FF6B1F);
}

@media (prefers-reduced-motion: reduce) {
  .tw-shortcutbar__link { transition: none; }
  .tw-shortcutbar__link:active { transform: none; }
}

/* ---- >= 62rem: the side dock -------------------------------------------- */
/* Same markup, re-laid out as a narrow vertical rail floating against one edge.
   It is deliberately NOT full height and does not push the page: the public
   shell already owns the top of the screen, and reserving a whole column would
   reflow every marketing page. */

@media (min-width: 62rem) {

  /* The corner is free again, so the back-to-top button drops back down and the
     page no longer needs bottom clearance. */
  :root:has(.tw-shortcutbar--side) { --tw-bottom-stack: 0px; }
  body:has(.tw-shortcutbar--side) { padding-bottom: 0; }

  .tw-shortcutbar--side {
    top: 50%;
    bottom: auto;
    left: auto;
    right: auto;
    transform: translateY(-50%);
    width: max-content;
    min-height: 0;
    max-height: calc(100dvh - 8rem);
    padding: var(--stack-sm, 0.5rem);
    padding-bottom: var(--stack-sm, 0.5rem);
    border: 1px solid var(--outline-variant, #333E4D);
    border-radius: var(--radius-xl, 0.75rem);
    background: var(--surface-card, #131820);
    box-shadow: var(--elev-2, 0 4px 12px -2px rgba(0, 0, 0, .5));
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
  }

  .tw-shortcutbar--left  { left:  max(0.75rem, env(safe-area-inset-left, 0px)); }
  .tw-shortcutbar--right { right: max(0.75rem, env(safe-area-inset-right, 0px)); }

  .tw-shortcutbar--side .tw-shortcutbar__list {
    flex-direction: column;
    justify-content: flex-start;
    gap: 2px;
    min-width: 0;
  }

  .tw-shortcutbar--side .tw-shortcutbar__link {
    min-width: 4rem;
    width: 100%;
  }

  /* An administrator who chose `bottom` keeps a bottom bar on desktop too; the
     touch-density rules above already cover it. */
  .tw-shortcutbar--dock-bottom .tw-shortcutbar__list { justify-content: center; }
  .tw-shortcutbar--dock-bottom .tw-shortcutbar__link { min-width: 4.5rem; }
}
