/* Floating action cluster geometry */
:root {
  /* The three FABs share the same bottom end corner of the viewport, in one
     row: the calendar button nearest the corner, then Go back, then the report
     button. These five values are the whole geometry; below 1024px the phone
     block at the end of this file sets them again. */
  --fab-size: 60px;
  --fab-gap: 12px;
  --fab-edge: 30px;
  --fab-bottom: 30px;
  --fab-calendar-bottom: 30px;
  --fab-cluster-clearance: 0px;
  /* How far the desktop rail pushes the button cluster in from its end edge,
     and the tour pill from its start edge. Set from 1024px, below. */
  --fab-rail-end: 0px;
  --fab-rail-start: 0px;
}

body:has(.calendar-widget-btn, #go-back-btn, #bug-report-btn) {
  --fab-cluster-clearance: calc(
    max(var(--fab-bottom), var(--fab-calendar-bottom)) + var(--fab-size)
  );
}

/* From 1024px the rail (#sidebar-root, the DesktopSidebar island) is docked on
   the physical left or right. The cluster sits at the end edge of the page
   and the tour pill at the start edge: in a left-to-right page the end edge
   is the right, in a right-to-left page the left. A rail on the cluster's
   edge moves the cluster in by its width; a rail on the pill's edge moves
   the pill. The width is the rail's own: --sidebar-width, or --sidebar-collapsed
   while the rail is minimized, so a collapsed rail leaves no gap behind it.
   Under 1024px there is no rail, so nothing moves the cluster in: both
   offsets stay 0. */
@media (min-width: 1024px) {
  body {
    --fab-rail-width: var(--sidebar-width);
  }

  body:has(#sidebar-root.minimized) {
    --fab-rail-width: var(--sidebar-collapsed);
  }

  body:has(#sidebar-root.app-sidebar-right) {
    --fab-rail-end: var(--fab-rail-width);
  }

  body:has(#sidebar-root.app-sidebar-left) {
    --fab-rail-start: var(--fab-rail-width);
  }

  [dir="rtl"] body:has(#sidebar-root.app-sidebar-right) {
    --fab-rail-end: 0px;
    --fab-rail-start: var(--fab-rail-width);
  }

  [dir="rtl"] body:has(#sidebar-root.app-sidebar-left) {
    --fab-rail-start: 0px;
    --fab-rail-end: var(--fab-rail-width);
  }
}

/* Calendar Widget Button */
.calendar-widget-btn {
  position: fixed;
  bottom: var(--fab-calendar-bottom);
  inset-inline-end: calc(var(--fab-edge) + var(--fab-rail-end));
  z-index: calc(var(--z-dock) + 1);
  width: var(--fab-size);
  height: var(--fab-size);
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s, box-shadow 0.2s;
}

/* The FAB also carries the generic .btn class, so page stylesheets loaded
   after this one (e.g. messaging.css's .btn { border-radius:8px; padding }) can
   clobber its circular shape and squash the logo. Win with higher specificity. */
.btn.calendar-widget-btn {
  border-radius: 50%;
  padding: 0;
}

/* The face of the calendar button is the TehGuys mark, drawn inline by
   calendar-widget.js (an SVG with its own fixed colours, the same in light and
   dark). The mark is the whole disc, its off-white ring is the button's edge,
   so the primary variant's gradient behind it is switched off: left on, a
   hairline of it shows round the anti-aliased rim. The focus ring, the hover
   and the pressed feedback are the button's own and sit outside the disc. */
.btn.calendar-widget-btn,
.btn.calendar-widget-btn:hover {
  background: none;
}

.calendar-widget-btn-logo {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.calendar-widget-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.calendar-widget-btn:active {
  transform: scale(0.95);
}

/* Go Back floating button — to the left of the calendar FAB */
#go-back-btn {
  position: fixed;
  bottom: var(--fab-bottom);
  inset-inline-end: calc(
    var(--fab-edge) + var(--fab-size) + var(--fab-gap) + var(--fab-rail-end)
  );
  z-index: calc(var(--z-dock) + 1);
  width: var(--fab-size);
  height: var(--fab-size);
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card, #fff);
  color: var(--text-primary, #1a1a2e);
  border: 1.5px solid var(--border-light, #e2e8f0);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, background 0.15s;
}

#go-back-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
  background: var(--surface-light, #f1f5f9);
}

#go-back-btn:active {
  transform: scale(0.95);
}

/* Report-a-bug floating button — to the left of the Go Back FAB */
#bug-report-btn {
  position: fixed;
  bottom: var(--fab-bottom);
  inset-inline-end: calc(
    var(--fab-edge) + 2 * (var(--fab-size) + var(--fab-gap)) + var(--fab-rail-end)
  );
  z-index: calc(var(--z-dock) + 1);
  width: var(--fab-size);
  height: var(--fab-size);
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card, #fff);
  color: var(--text-primary, #1a1a2e);
  border: 1.5px solid var(--border-light, #e2e8f0);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, background 0.15s;
}

#bug-report-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
  background: var(--surface-light, #f1f5f9);
}

#bug-report-btn:active {
  transform: scale(0.95);
}

/* The "Take a tour" pill: the bottom corner on the start edge, opposite the
   cluster, clear of a rail docked on that edge (see the top of this file).
   The phone shell moves it above the tab bar (shell-phone.css). */
.tour-launch-btn {
  position: fixed;
  inset-inline-start: calc(16px + var(--fab-rail-start));
  inset-block-end: 16px;
  z-index: calc(var(--z-dock) + 2); /* above the sidebar and the FABs */
}

/* Below 1024px the three buttons are still here: one row in the bottom end
   corner, directly above the tab bar of the phone shell (shell-phone.css), in
   the same order as on the desktop. Wave C1 hid them and wave C2 (owner
   decision, 2026-11-19) brought them back; the calendar is still a tab and
   Report a problem is still a row of the You sheet (YouSheet.tsx opens the same
   dialog), these are the quick way to them and the way back.
   - Size: 44px, the touch tier of the pointer contract (DESIGN.md s5), on every
     pointer, with a gap that keeps neighbours apart. The row clears the bar
     plus the safe-area inset plus --space-md, and sits at the end edge, so it
     mirrors in a right-to-left language (the offsets above are logical).
   - Layers stay those of the desktop: the row is one above the bar (--z-dock)
     and below the You sheet, the dialogs, the consent panel and the toasts, so
     none of them can be pressed through. The calendar panel's scrim is raised
     above the row too (calendar-widget.css).
   - Clearance: --fab-cluster-clearance is what the consent panel clears, and
     the page frame reserves the same band plus --space-md at its end, so the
     last line of any page scrolls clear of the row. A guest has no buttons and
     clears the bar alone. A reduced page (onboarding) has no bar and no
     buttons; shell.css hides them there.
   Under 1024px there is no rail, so --fab-rail-end is 0 and the calendar
   route's rail (below) is a transparent boundary here too. */
@media (max-width: 1023.98px) {
  :root {
    --fab-size: 44px;
    --fab-gap: var(--space-md);
    --fab-edge: var(--space-md);
    --fab-bottom: calc(
      var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px) + var(--space-md)
    );
    --fab-calendar-bottom: var(--fab-bottom);
  }

  body:has(#shell-tabbar-root) {
    --fab-cluster-clearance: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
  }

  body:not([data-shell="reduced"]):has(#shell-tabbar-root):has(
      .calendar-widget-btn,
      #go-back-btn,
      #bug-report-btn
    ) {
    --fab-cluster-clearance: calc(
      max(var(--fab-bottom), var(--fab-calendar-bottom)) + var(--fab-size)
    );
  }

  body:not([data-shell="reduced"]):has(#shell-tabbar-root):has(
      .calendar-widget-btn,
      #go-back-btn,
      #bug-report-btn
    )
    .shell-frame {
    padding-bottom: calc(var(--fab-cluster-clearance) + var(--space-md));
  }

  /* The forum's Post button ends its form at the inline end, which is where
     the row floats: at 320px wide it sat under the calendar button and Go back
     on arrival. On the phone shell it starts the form's action row instead,
     the side the row is not on, in either direction. */
  .forum-page .forum-actions {
    justify-content: flex-start;
  }
}

/* The calendar route's rail is a transparent DOM boundary at every width. The
   buttons stay position:fixed where base.html put them, so the rail never
   becomes their containing block (W18.F4), and the fixed row above the bar is
   the one placement the route has too. */
.calendar-route-fab-rail,
.calendar-route-fab-rail > #bug-report-root {
  display: contents;
}
