/* ==========================================================================
   Tabs: the app's one tab pattern, in two variants (kit review C1, 28 Oct). Both are plain markup, so a screen keeps
   its own ids, data attributes and click handlers; tabs.js adds the keyboard (roving tabindex, arrows mirrored under
   RTL, Home/End) to every row marked role="tablist", and slides the segmented thumb.

     .tabs-line > .tab-line        underline: a screen's sections (Hub, Studio, Drive places, Meetings, Inbox).
                                   .scrolls scrolls sideways with its own edge fade; .sticks sticks under the title.
                                   .scrolls.snug: on a phone each tab's side padding is tighter, so a short row
                                   (five tabs, English or Arabic) fits a 360px phone whole; a longer one still
                                   scrolls with the fade.
     .seg > .seg-tab               segmented: a compact switch (My tasks / Team tasks, Documents / Templates).
                                   role="tablist" with buttons (aria-selected), or role="radiogroup" with
                                   <label class="seg-tab"><input type="radio" class="sr-only">…</label> for a choice
                                   inside a form (the arrows then come from the radios themselves).
   ========================================================================== */

/* ---- Underline ---- */
/* ---- Tabs with an underline. The row is full width; each tab is as wide as its label and the tabs pack at the start
   (the start edge: the right in Arabic), one rule on every screen (the lead, B4, 2 Nov); the active tab's label is white and
   carries a 3px bar that slides along the hairline under the row (the bar is the tab's own ::after, so it moves with
   the tab without JS). Icons sit before the label at 18px. On a pointer, idle tabs brighten on hover. ---- */
.tabs-line{position:relative;display:flex;flex-wrap:nowrap;gap:0;margin-top:var(--verser-tabs-line-margin-top,12px);border-bottom:1px solid var(--verser-tabs-line-border)}
.tabs-line::-webkit-scrollbar{display:none}
.tabs-line .tab-line{position:relative;flex:0 0 auto;min-width:0;min-height:var(--verser-tabs-line-height);padding:0 var(--verser-tabs-line-padding-inline,var(--space-3));border:0;border-radius:var(--verser-tabs-line-radius) var(--verser-tabs-line-radius) 0 0;background:none;color:var(--verser-tabs-line-text);font:inherit;font-size:var(--verser-tabs-line-font-size);font-weight:var(--verser-tabs-line-font-weight);line-height:1.2;white-space:nowrap;display:inline-flex;align-items:center;justify-content:center;gap:7px;transition:color 140ms ease,background-color 140ms ease}
.tabs-line .tab-line .icon{width:18px;height:18px;flex:none}
.tabs-line .tab-line::after{content:"";position:absolute;left:50%;bottom:-1px;width:min(100%,var(--verser-tabs-line-indicator-max));height:var(--verser-tabs-line-indicator-size);border-radius:var(--radius-5xs) var(--radius-5xs) 0 0;background:var(--verser-tabs-line-indicator);transform:translateX(-50%) scaleX(0);transition:transform var(--duration-base) var(--ease-out),opacity var(--duration-base) var(--ease-out);opacity:0}
.tabs-line .tab-line[aria-selected="true"]{color:var(--verser-tabs-line-active-text)}
.tabs-line .tab-line[aria-selected="true"]::after{transform:translateX(-50%) scaleX(1);opacity:1}
/* The bar grows by transform only (2 Nov, the live review C13), never by width; under reduced motion it only fades. */
@media (prefers-reduced-motion:reduce){.tabs-line .tab-line::after{transition:opacity var(--duration-base) var(--ease-out)}}
.tabs-line .tab-line:active{transform:scale(.97)}
@media (hover:hover) and (pointer:fine){.tabs-line .tab-line:not([aria-selected="true"]):hover{color:var(--verser-tabs-line-active-text);background:var(--verser-tabs-line-hover)}}
.tabs-line .tab-line:focus-visible{outline:var(--ring-width) solid var(--ring);outline-offset:-2px}
/* A count after a label (unread, pending). */
.tabs-line .tab-badge{min-width:18px;height:18px;padding:0 5px;border-radius:var(--r-pill);background:var(--pink);color:var(--night);font-family:var(--mono);font-size:var(--font-size-caption);font-weight:600;line-height:18px;text-align:center}
/* Many tabs on a phone: the row scrolls sideways, each tab its own width, and never up and down (overflow-x alone
   makes overflow-y auto, and the labels then slide half out of the row under a finger). */
.tabs-line.scrolls{overflow-x:auto;overflow-y:hidden;overscroll-behavior-x:contain;scrollbar-width:none;-webkit-overflow-scrolling:touch;scroll-snap-type:x proximity}
.tabs-line.scrolls .tab-line{flex:0 0 auto;padding:0 var(--vx-sp-3h);scroll-snap-align:start}
/* Snug (a project's five tabs): on a phone the tabs keep less room at their sides, so every tab shows at 360px rather
   than the last one sitting wholly past the edge, where the fade has nothing to cut and the row reads as complete. */
body:not(.desk) .tabs-line.scrolls.snug .tab-line{padding-inline:var(--verser-tabs-line-snug-padding-inline)}
/* The row can stick under the title while the list scrolls. */
.tabs-line.sticks{position:sticky;top:calc(var(--safe-top) + 6px);z-index:5;background:var(--glass-nav);-webkit-backdrop-filter:var(--blur);backdrop-filter:var(--blur);border-radius:var(--r-small) var(--r-small) 0 0}
body.desk .tabs-line .tab-line{min-height:44px}

/* ---- Sticky tabs: the same night glass on every tabbed screen, edge to edge on a phone, so the rows passing under it
   stay out of its way. ---- */
.tabs-line.sticks{background:var(--verser-tabs-sticky-fill);-webkit-backdrop-filter:var(--verser-tabs-sticky-blur);backdrop-filter:var(--verser-tabs-sticky-blur)}
/* A phone's stuck row runs edge to edge over the page's side gutter (--vx-tabs-sticky-bleed, index.html), and its first
   label stays on the gutter, where the page's words start: the row's side room is the gutter less the first tab's own
   start padding (--_tabs-start, the row's tab padding), and a row that scrolls snaps to that room, not to the screen's
   edge. */
body:not(.desk) .tabs-line.sticks{--_tabs-start:var(--verser-tabs-line-padding-inline,var(--space-3));
  margin-inline:calc(-1 * var(--vx-tabs-sticky-bleed));padding-inline:max(0px,calc(var(--vx-tabs-sticky-bleed) - var(--_tabs-start)));
  scroll-padding-inline:max(0px,calc(var(--vx-tabs-sticky-bleed) - var(--_tabs-start)));border-radius:0}
body:not(.desk) .tabs-line.sticks>.tab-line:first-child{padding-inline-start:var(--_tabs-start)}
body.desk .tabs-line.sticks{top:0;border-radius:0}
/* On a phone a stuck row sits just under the ☰ (or a sub-page's ‹ Parent) at the top start corner, never under it.
   With a scroll timeline the rule below puts it at the very top with its glass reaching up instead; this is the
   placement without one. */
body:not(.desk) .tabs-line.sticks{top:var(--verser-tabs-sticky-reach)}
/* At rest the row is clear on the backdrop like every other header; its glass comes in as the page scrolls toward the
   point where it sticks (a scroll timeline). Without one, it keeps the glass. */
@supports (animation-timeline:scroll()){
  .tabs-line.sticks{background-color:transparent;-webkit-backdrop-filter:none;backdrop-filter:none;animation:sticks-fill linear both;animation-timeline:scroll(root);animation-range:40px 120px}
  @keyframes sticks-fill{to{background-color:var(--verser-tabs-sticky-fill);-webkit-backdrop-filter:var(--verser-tabs-sticky-blur);backdrop-filter:var(--verser-tabs-sticky-blur)}}
  /* On a phone the stuck row sits at the very top and its glass reaches up over the status bar and the ☰ row
     (--verser-tabs-sticky-reach), so the tabs stop just under the ☰ or ‹ Parent and the page no longer shows through
     above them; those float on that glass. The reach
     is padding, with the same amount taken off the top margin, so at rest the tabs sit where they did, over a band
     that is still clear. Only the tabs take taps; the band lets them through to the title row under it. Without a
     scroll timeline the glass is always on, and the band would cover the title, so the row sticks under the ☰ row
     instead (above). */
  body:not(.desk) .tabs-line.sticks{top:0;margin-top:calc(var(--verser-tabs-line-margin-top,12px) - var(--verser-tabs-sticky-reach));padding-top:var(--verser-tabs-sticky-reach);pointer-events:none}
  body:not(.desk) .tabs-line.sticks>*{pointer-events:auto}
}

/* ---- Segmented ---- */
.seg{display:flex;gap:4px;margin-top:12px;padding:6px;border-radius:var(--r-compact)}
/* One segmented control everywhere (2026-10-03): the same 13.5px label and 6px inset on every screen.
   Tabs share the width while they fit; a long label takes what it needs rather than breaking onto two lines. */
.seg-tab{flex:1 1 0;min-width:max-content;white-space:nowrap;min-height:44px;padding:0 6px;border:0;border-radius:var(--r-row);background:none;color:var(--vx-ink);font:inherit;font-size:var(--verser-tabs-seg-font-size,var(--font-size-small));font-weight:600;line-height:1.2;transition:transform 160ms var(--ease-out),opacity 120ms ease}
.seg-tab:active{opacity:.72}
/* data-size="compact": a short two-choice control (HR's Mine / HR) keeps to its own width on a wide page. */
.seg[data-size="compact"]{max-inline-size:var(--verser-seg-compact-max)}
.seg-tab[aria-selected="true"]{background:var(--vx-nav-current);box-shadow:inset 0 0 0 1px var(--tab-edge);color:var(--text)}
/* Segmented controls: the picked tab's pill is one thumb that slides between tabs (workspace.js measures it). The
   control is its offset parent and its own layer, so the thumb sits over the glass and under the labels even where a
   control drops its blur. The slide is quick and lands hard: it answers a tap. */
.seg:not(.task-seg){position:relative;isolation:isolate}
/* The thumb keeps one width (--thumb-w: the picked tab's when the row was laid out) and reaches another tab's width by
   scaleX (--thumb-sx), so the slide moves by transform only (2 Nov, the live review C13). Segmented tabs share the width,
   so the scale is 1 almost everywhere and the rounded ends keep their shape. */
.seg.has-thumb::after{content:"";position:absolute;left:0;top:0;z-index:-1;width:var(--thumb-w);height:var(--thumb-h);transform-origin:0 0;transform:translate(var(--thumb-x),var(--thumb-y)) scaleX(var(--thumb-sx,1));border-radius:var(--r-row);background:var(--vx-nav-current);box-shadow:inset 0 0 0 1px var(--tab-edge);pointer-events:none}
.seg.thumb-move::after{transition:transform var(--verser-tabs-seg-thumb-duration,240ms) var(--ease-out)}
.seg.has-thumb>.seg-tab[aria-selected="true"]{background:none;box-shadow:none}
/* The picked tab has no hover light: under a pointer it would read as a second pill waiting for the thumb. */
@media (hover:hover) and (pointer:fine){.seg.has-thumb>.seg-tab[aria-selected="true"]:not(:disabled):not(:active):hover{box-shadow:none}}
@media (prefers-reduced-motion:reduce){.seg.thumb-move::after{transition:none}}

/* Segmented choice in a form: a radio group drawn as the switch. Each choice is a label round a hidden radio; the
   checked one carries the picked look. A group inside a panel carries no blur of its own. */
.seg[role="radiogroup"]{-webkit-backdrop-filter:none;backdrop-filter:none}
.seg[role="radiogroup"]>.seg-tab{display:flex;align-items:center;justify-content:center;gap:8px;text-align:center;cursor:pointer;-webkit-tap-highlight-color:transparent}
.seg[role="radiogroup"]>.seg-tab .icon{inline-size:16px;block-size:16px;flex:none}
.seg[role="radiogroup"]>.seg-tab:has(input:checked){background:var(--vx-nav-current);box-shadow:inset 0 0 0 1px var(--tab-edge);color:var(--text)}
.seg[role="radiogroup"]>.seg-tab:has(input:focus-visible),.seg>.seg-tab:focus-visible{outline:var(--ring-width) solid var(--ring);outline-offset:var(--ring-offset)}

/* ---- Four tabs on a phone (Projects kit addition #9, 2026-10-30; the lead approved the mockup the same day, Q10):
   Projects · My tasks · Team · Approvals fit a 360px phone in English and Arabic once their icons go. Mark the row
   data-icons="desk": its tabs keep their icons in the desktop layout (body.desk) and drop them on a phone, where the
   labels and the count badges stay. Tabs without the mark are as before. ---- */
body:not(.desk) .seg[data-icons="desk"]>.seg-tab>:is(svg,.icon){display:none}

/* ---- One width rule (the lead, B4, 2 Nov): every line tab is as wide as its label, packed at the start, on every
   screen; a screen never stretches its tabs into equal columns. The old opt-in (data-fit="content") is now the
   default, so the attribute does nothing. ---- */


/* ---- Edge fade on a scrolling row (2 Nov): the start edge fades once the row has scrolled away from its start, the end
   edge while there is more to come, in Arabic mirrored. Driven by the row's own scroll (a scroll timeline), so no JS;
   a row that fits has no fade. Where scroll timelines are missing, no fade. ---- */
@property --verser-tabs-fade-start{syntax:"<length>";inherits:false;initial-value:0px}
@property --verser-tabs-fade-end{syntax:"<length>";inherits:false;initial-value:0px}
@keyframes verser-tabs-fade{
  0%{--verser-tabs-fade-start:0px;--verser-tabs-fade-end:var(--verser-tabs-line-fade-size,28px)}
  12%{--verser-tabs-fade-start:var(--verser-tabs-line-fade-size,28px)}
  88%{--verser-tabs-fade-end:var(--verser-tabs-line-fade-size,28px)}
  100%{--verser-tabs-fade-start:var(--verser-tabs-line-fade-size,28px);--verser-tabs-fade-end:0px}
}
@supports (animation-timeline:scroll()){
  .tabs-line.scrolls{
    --_verser-tabs-mask:linear-gradient(to right,transparent 0,var(--mask-opaque) var(--verser-tabs-fade-start),var(--mask-opaque) calc(100% - var(--verser-tabs-fade-end)),transparent 100%);
    -webkit-mask-image:var(--_verser-tabs-mask);mask-image:var(--_verser-tabs-mask);
    animation:verser-tabs-fade linear both;animation-timeline:scroll(self inline)
  }
  .tabs-line.scrolls:dir(rtl){
    --_verser-tabs-mask:linear-gradient(to left,transparent 0,var(--mask-opaque) var(--verser-tabs-fade-start),var(--mask-opaque) calc(100% - var(--verser-tabs-fade-end)),transparent 100%)
  }
  /* A stuck row that also scrolls sideways (Studio, Drive) keeps its glass coming in with the page scroll on every
     width, and fades its edges with its own scroll (the edge fade alone took the glass's place on the desktop). */
  .tabs-line.scrolls.sticks{
    animation:sticks-fill linear both,verser-tabs-fade linear both;animation-timeline:scroll(root),scroll(self inline);
    animation-range:40px 120px,normal
  }
}

/* ---- Compact segmented (2 Nov): data-size="sm" on a .seg sits in a title row: no top margin, a tighter inset, and
   36px tabs where there is a mouse (touch keeps the 44px target). ---- */
.seg[data-size="sm"]{margin-top:0;padding:var(--space-1);gap:var(--space-1)}
.seg[data-size="sm"]>.seg-tab{padding-inline:var(--space-3)}
@media (pointer:fine){.seg[data-size="sm"]>.seg-tab{min-height:var(--control-height-sm)}}
