/* ══════════════════════════════════════════════════════════════
   SCRUB IN — FRIENDS RAIL
   The people you follow, beside the board.

   Same two-shape idea as the Ward's active-students rail
   (styles/pages/ward-active-users.css): a thin edge tab that opens a
   drawer on phones, an always-open panel in the gutter on desktop.
   Two things differ on purpose:

   - It is `position:fixed`, not absolute. The Ward rail is an ambient
     "who is around" readout, so it scrolls away with the timer. This
     one is a NAVIGATION control — you tap a friend to jump to their
     post — so it has to stay reachable while you scroll the feed.
   - Desktop docks it into a real second column (see the grid below)
     rather than floating it in the page gutter. Scrub In's .si-wrap is
     1080px wide and centred, so there is no gutter wide enough to hold
     a 250px panel without it overlapping the feed.

   Colours come from the page's own tokens (--si-amber / --si-cream /
   --si-line, declared on #page-scrubin) so the rail belongs to Scrub In
   rather than importing the Ward's steel blue.
   ══════════════════════════════════════════════════════════════ */

/* `.page` (styles/base.css) fades every page in with a shared keyframe that
   animates `transform: translateY()`. A transformed ancestor becomes the
   containing block for its position:fixed descendants — so for the 400ms that
   animation runs, the rail would resolve "50% from the top" against the whole
   page instead of the viewport and sit far below the fold before snapping
   into place. Scrub In fades on opacity alone: same entrance, no transform,
   rail stable from the first frame. */
#page-scrubin { animation: siPageFade 0.4s ease; }
@keyframes siPageFade { from { opacity: 0; } to { opacity: 1; } }

/* ⚠ Every rule that touches .si-wrap is written as `.page#page-scrubin` on
   purpose. SCRUB_STYLE (in sections/scrub-in.section.js) is injected into
   <head> at DOMContentLoaded, so it lands AFTER this stylesheet's <link> and
   wins any tie on specificity — a plain `#page-scrubin .si-wrap` rule here is
   dead config that silently does nothing. #page-scrubin is a .page, so the
   extra class is true as well as louder. Verified: without it the padding
   below stayed at 16px and the desktop grid never applied at all. */

/* Nothing may sit under the edge tab. The tab is only 32px wide, but the
   things it would cover on a phone are a post's tick box and delete button,
   and a control you cannot reliably tap is worse than a slightly narrower
   page. Desktop overlays the rail on the left, so this is undone there. */
@media (max-width: 1179px) {
  .page#page-scrubin .si-wrap { padding-left: 2.9rem; }
}

#page-scrubin .si-friends {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 45;
  display: flex;
  align-items: center;
  flex-direction: row;
  pointer-events: none;
}
#page-scrubin .si-friends > * { pointer-events: auto; }

/* ── Edge tab (phones / tablets) ────────────────────────────── */
#page-scrubin .sif-tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  /* ≥44px on the long axis; the short axis is an edge grab handle, kept
     slim so it never covers the feed underneath. */
  width: 32px;
  min-height: 108px;
  padding: 0.6rem 0.1rem;
  border: 1px solid var(--si-line);
  border-left: none;
  border-radius: 0 12px 12px 0;
  background: rgba(26, 19, 13, 0.95);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: rgba(244, 234, 217, 0.72);
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.18s ease, color 0.18s ease;
}
#page-scrubin .sif-tab:hover { background: rgba(48, 34, 22, 0.97); color: var(--si-cream); }
#page-scrubin .sif-tab:focus-visible { outline: 2px solid rgba(255, 196, 132, 0.9); outline-offset: 2px; }

#page-scrubin .sif-tab-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--si-amber);
  line-height: 1;
}
#page-scrubin .sif-tab-label {
  writing-mode: vertical-rl;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}
/* Unread count. Carries a number, not just a colour — the tab is also
   labelled "n new" for screen readers by its aria-label. */
#page-scrubin .sif-badge {
  position: absolute;
  top: -6px;
  left: -6px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 99px;
  background: #ff6a5e;
  box-shadow: 0 0 8px rgba(255, 106, 94, 0.7);
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 19px;
  text-align: center;
  display: none;
}
#page-scrubin .si-friends.has-new .sif-badge { display: block; }

/* ── Panel ─────────────────────────────────────────────────── */
#page-scrubin .sif-panel {
  position: absolute;
  left: 0;
  top: 50%;
  width: min(80vw, 292px);
  max-height: min(74vh, 560px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--si-line);
  border-left: none;
  border-radius: 0 16px 16px 0;
  background: rgba(20, 15, 10, 0.98);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
  transform: translate(-101%, -50%);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.26s cubic-bezier(0.34, 1.1, 0.64, 1), opacity 0.2s ease, visibility 0.26s;
}
#page-scrubin .si-friends.is-open .sif-panel {
  transform: translate(0, -50%);
  opacity: 1;
  visibility: visible;
}
#page-scrubin .sif-panel:focus { outline: none; }

#page-scrubin .sif-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.75rem 0.8rem 0.55rem;
  border-bottom: 1px solid rgba(255, 177, 94, 0.14);
}
#page-scrubin .sif-title {
  flex: 1;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--si-cream);
}
#page-scrubin .sif-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--si-amber);
  background: rgba(255, 177, 94, 0.12);
  border: 1px solid rgba(255, 177, 94, 0.3);
  border-radius: 99px;
  padding: 0.1rem 0.5rem;
}
#page-scrubin .sif-close {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: rgba(244, 234, 217, 0.55);
  font-size: 1.2rem;
  line-height: 1;
  font-family: inherit;
  cursor: pointer;
}
#page-scrubin .sif-close:hover { background: rgba(255, 177, 94, 0.14); color: var(--si-cream); }
#page-scrubin .sif-close:focus-visible { outline: 2px solid rgba(255, 196, 132, 0.9); outline-offset: 1px; }

/* ── Tool strip (notifications / mark seen / manage) ────────── */
#page-scrubin .sif-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid rgba(255, 177, 94, 0.1);
}
#page-scrubin .sif-tool {
  flex: 1 1 auto;
  min-height: 34px;
  padding: 0.25rem 0.5rem;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(244, 234, 217, 0.7);
  font-family: inherit;
  font-size: 0.66rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
#page-scrubin .sif-tool:hover { background: rgba(255, 177, 94, 0.1); color: var(--si-cream); }
#page-scrubin .sif-tool:focus-visible { outline: 2px solid rgba(255, 196, 132, 0.9); outline-offset: 1px; }
#page-scrubin .sif-tool[aria-pressed="true"] {
  background: rgba(255, 177, 94, 0.16);
  border-color: rgba(255, 177, 94, 0.42);
  color: var(--si-cream);
}
#page-scrubin .sif-tool:disabled { opacity: 0.45; cursor: not-allowed; }

#page-scrubin .sif-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.5rem 0.55rem 0.7rem;
}

#page-scrubin .sif-group {
  margin: 0.6rem 0 0.35rem 0.25rem;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(244, 234, 217, 0.42);
}
#page-scrubin .sif-group:first-child { margin-top: 0.1rem; }

#page-scrubin .sif-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.25rem; }

#page-scrubin .sif-row {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid transparent;
  /* Grid items default to min-width:auto, which lets a long display name
     push the row past the panel edge and clip the action button. */
  min-width: 0;
}
#page-scrubin .sif-row.is-new { border-color: rgba(255, 106, 94, 0.4); background: rgba(255, 106, 94, 0.07); }
#page-scrubin .sif-row.is-partner { border-color: rgba(110, 195, 255, 0.34); background: rgba(110, 195, 255, 0.07); }

/* The whole row is the jump-to-post control. Actions sit beside it as
   siblings rather than nested buttons (which is invalid HTML). */
#page-scrubin .sif-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.2rem 0.4rem 0.42rem;
  min-height: 44px;
  border: none;
  border-radius: 11px;
  background: none;
  color: inherit;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
#page-scrubin .sif-row-main:hover { background: rgba(255, 177, 94, 0.08); }
#page-scrubin .sif-row-main:focus-visible { outline: 2px solid rgba(255, 196, 132, 0.9); outline-offset: -2px; }

#page-scrubin .sif-av {
  position: relative;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 177, 94, 0.22);
  font-size: 0.78rem;
  font-weight: 800;
  color: rgba(244, 234, 217, 0.75);
}
#page-scrubin .sif-av .si-av-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#page-scrubin .sif-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.1rem; }
#page-scrubin .sif-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--si-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#page-scrubin .sif-sub {
  font-size: 0.62rem;
  color: rgba(244, 234, 217, 0.46);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#page-scrubin .sif-sub.cleared { color: #8df0b8; }

/* "New" marker on a row. The word is the signal, not the colour. */
#page-scrubin .sif-new {
  flex-shrink: 0;
  padding: 0.1rem 0.36rem;
  border-radius: 99px;
  background: rgba(255, 106, 94, 0.16);
  border: 1px solid rgba(255, 106, 94, 0.45);
  color: #ffb3ac;
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

/* Both a <button> (cheer / encourage / unfollow) and a <span> (the inert
   "you already cheered" heart) wear this, so centring is explicit rather
   than relying on a button's default text alignment. */
#page-scrubin .sif-act {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  min-height: 44px;
  border: none;
  border-radius: 10px;
  background: none;
  color: rgba(244, 234, 217, 0.7);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
}
#page-scrubin span.sif-act { cursor: default; }
#page-scrubin .sif-act:hover { background: rgba(255, 177, 94, 0.12); }
/* The un-cheered heart is the page's outline SVG, not an emoji — centre it
   in the button and let it warm on hover like the one on a post card. */
#page-scrubin .sif-act .si-heart-o { margin: 0 auto; }
#page-scrubin .sif-act:hover .si-heart-o { stroke: var(--si-cream); }
#page-scrubin .sif-act:focus-visible { outline: 2px solid rgba(255, 196, 132, 0.9); outline-offset: -2px; }
#page-scrubin .sif-act.drop { color: rgba(255, 140, 130, 0.8); font-size: 1.05rem; }
#page-scrubin .sif-act.drop:hover { background: rgba(255, 106, 94, 0.14); }

#page-scrubin .sif-empty {
  margin: 0;
  padding: 1rem 0.7rem;
  text-align: center;
  font-size: 0.72rem;
  line-height: 1.6;
  color: rgba(244, 234, 217, 0.5);
}
#page-scrubin .sif-empty b { color: var(--si-cream); }

#page-scrubin .sif-foot {
  padding: 0.5rem 0.7rem 0.6rem;
  border-top: 1px solid rgba(255, 177, 94, 0.1);
  font-size: 0.63rem;
  line-height: 1.5;
  color: rgba(244, 234, 217, 0.45);
}
#page-scrubin .sif-foot b { color: rgba(244, 234, 217, 0.72); }

/* ── Follow button on a board card ──────────────────────────── */
/* Stacked under the partner-request button, per the action bar's layout. */
/* Both secondary actions on ONE line where they fit — stacked, they put two
   right-aligned lines of text on every row of the communal board and pulled
   the eye away from the cheer, which is the action that matters here. They
   still wrap to two lines on a narrow screen rather than squeezing. */
#page-scrubin .si-post-rel {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.1rem 0.3rem;
  margin-left: auto;
}
/* A quiet text action, matching .si-post-pact above it. It used to be a
   filled amber pill, which put two competing pills on the right of every row
   in the communal board and out-shouted the cheer. */
#page-scrubin .si-post-follow {
  min-height: 32px;
  padding: 0.3rem 0.4rem;
  border-radius: 8px;
  border: none;
  background: none;
  color: rgba(255, 206, 138, 0.78);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  text-align: right;
}
#page-scrubin .si-post-follow:hover { background: rgba(255, 177, 94, 0.1); color: #ffce8a; }
#page-scrubin .si-post-follow:focus-visible { outline: 2px solid rgba(255, 196, 132, 0.9); outline-offset: 1px; }
#page-scrubin .si-post-follow.on { color: rgba(244, 234, 217, 0.45); }
#page-scrubin .si-post-follow.on:hover {
  background: rgba(255, 106, 94, 0.12);
  color: #ffb3ac;
}

/* Landing flash when the rail jumps you to someone's post. */
#page-scrubin .si-post.si-post-focus {
  animation: siPostFocus 2s ease-out;
}
@keyframes siPostFocus {
  0%, 62% { box-shadow: 0 0 0 2px rgba(255, 177, 94, 0.85), 0 10px 34px rgba(255, 140, 60, 0.28); }
  100% { box-shadow: 0 0 0 0 rgba(255, 177, 94, 0); }
}

/* ── Desktop: the rail sits in its own column on the left ─────── */
/* The rail is position:fixed, so it reserves no space of its own. It used to
   simply overlay the left of a 1080px centred .si-wrap, which covered the
   first ~170px of every card at 1280px — survivable when that was a feed of
   loose cards, not survivable now that YOUR BOARD starts there.
   The wrap is therefore held clear of the rail: centred in what is left of
   the viewport, but never starting left of the rail's 268px + a gutter.
   `max()` is the whole mechanism — a browser without it drops the
   declaration and falls back to today's centred wrap rather than breaking. */
@media (min-width: 1180px) {
  .page#page-scrubin .si-wrap {
    max-width: 792px;
    margin-left: max(292px, calc(50% - 396px));
    margin-right: auto;
  }
}
@media (min-width: 1180px) {
  .page#page-scrubin .si-friends {
    left: 0;
    width: 268px;
    display: block;
    z-index: 3;
  }
  #page-scrubin .sif-tab { display: none; }
  #page-scrubin .sif-close { display: none; }
  #page-scrubin .sif-panel {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    opacity: 1;
    visibility: visible;
    width: 268px;
    max-height: min(72vh, 620px);
    border: 1px solid var(--si-line);
    border-radius: 16px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  }
}

@media (prefers-reduced-motion: reduce) {
  #page-scrubin .sif-panel { transition: none; }
  #page-scrubin .si-post.si-post-focus { animation: none; box-shadow: 0 0 0 2px rgba(255, 177, 94, 0.85); }
}
