/* Tokens, reset, and the primitives every screen uses: buttons, inputs, chips, meta text. */

/* The portal's names for Astryx's neutral theme (css/astryx.css, generated). Every screen's
   stylesheet reads these, so this block is the whole of the mapping. Light and dark are not
   repeated here: each Astryx token is a light-dark() pair, and the theme toggle's data-theme
   on <html> is the attribute Astryx already reads to pick one. */
:root{
  --bg:var(--color-background-body); --bg-elev:var(--color-background-surface);
  --surface:var(--color-background-card); --surface-2:var(--color-neutral);
  --border:var(--color-border); --border-strong:var(--color-border-emphasized);
  --text:var(--color-text-primary); --text-muted:var(--color-text-secondary);
  --text-faint:var(--color-text-disabled);
  --accent:var(--color-accent); --accent-fill:var(--color-accent); --accent-strong:var(--color-accent);
  --accent-soft:var(--color-overlay-pressed); --accent-ink:var(--color-on-accent);
  --accent-dim:var(--color-accent-muted);
  --blue:var(--color-text-info); --amber:var(--color-text-warning); --red:var(--color-text-error);
  --violet:var(--color-text-purple); --green:var(--color-text-success);
  --side:var(--color-background-body); --sel:var(--color-neutral);
  --hover:var(--color-overlay-hover); --active:var(--color-overlay-pressed);
  --shadow-sm:none; --shadow:var(--shadow-low); --shadow-lg:var(--shadow-high);
  --ease:var(--ease-standard);
  --r-sm:var(--radius-inner); --r:var(--radius-element); --r-lg:var(--radius-container);
  --scroll:color-mix(in srgb,var(--color-text-primary) 18%,transparent);
  --scroll-hover:color-mix(in srgb,var(--color-text-primary) 30%,transparent);
  --mono:var(--font-family-code);
  --sans:var(--font-family-body);

  --panel:var(--surface); --panel-2:var(--surface-2); --line:var(--border);
  --ink:var(--text); --ink-dim:var(--text-muted); --ink-faint:var(--text-faint);
  --warn:var(--amber); --err:var(--red);
  --ruled:var(--blue); --measured:var(--green); --derived:var(--violet);
}

*{box-sizing:border-box}
/* `hidden` loses to any author rule that sets `display`, which is most of them: a hidden
   `.field` is still `display:grid` and a hidden `.btn` is still `display:block`. Every element
   the page hides would otherwise need its own `[hidden]` rule, and the ones nobody remembered
   just stayed on screen. Said once, here. */
[hidden]{display:none!important}

html{background:var(--bg)}
body{margin:0;background:var(--bg);color:var(--ink);
     font:var(--text-body-weight) var(--text-body-size)/var(--text-body-leading) var(--sans);
     -webkit-font-smoothing:antialiased;
     -moz-osx-font-smoothing:grayscale;text-rendering:optimizeLegibility}
a{color:inherit}
::selection{background:color-mix(in srgb,var(--accent) 28%,transparent)}
:focus-visible{outline:none}

/* Scrollbars that belong to the page rather than to the operating system of 2009. */
*{scrollbar-width:thin;scrollbar-color:var(--scroll) transparent}
::-webkit-scrollbar{width:10px;height:10px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:var(--scroll);border-radius:10px;
      border:3px solid transparent;background-clip:padding-box}
::-webkit-scrollbar-thumb:hover{background:var(--scroll-hover);background-clip:padding-box;
      border:3px solid transparent}
::-webkit-scrollbar-corner{background:transparent}

/* Size and weight are the theme's heading scale, which css/astryx.css sets on h1–h6. */
h1{margin:0 0 6px}
.sub{color:var(--ink-dim);margin:0 0 26px;font-size:13.5px}
.row{display:flex;gap:10px;flex-wrap:wrap;align-items:center}
.meta{color:var(--ink-faint);font:11.5px var(--mono);font-variant-numeric:tabular-nums}
.empty{color:var(--ink-faint);padding:32px 0;text-align:center;font-size:13px}
.err{color:var(--err)} .warn{color:var(--warn)} .ok{color:var(--accent)}

/* The surface is Astryx's Card (css/astryx.css); this is only how cards stack. */
.card{margin-bottom:12px}
.card h3{margin:0 0 4px;font:var(--text-heading-4-weight) var(--text-heading-4-size)/var(--text-heading-4-leading) var(--font-family-heading)}
.grid{display:grid;gap:12px;grid-template-columns:repeat(auto-fill,minmax(250px,1fr))}

/* ---------- controls ----------
   What these look like is Astryx's, in css/astryx.css: inputs and textareas are its TextInput
   and TextArea, `.ghbtn` its Button (`.primary`, `.danger` its variants), `.iconbtn` its
   IconButton. What is left here is only what the portal needs on top. */
input[type=search]{width:280px}
/* A dropdown is Astryx's Selector (js/select.js) standing in for the hidden native one. */
select.axnative{display:none!important}
.axselect{display:inline-flex;vertical-align:middle;max-width:100%;min-width:0}
.axselect > [data-variant]{flex:1;min-width:0}
.field .axselect{display:flex}
/* `.ghbtn` is an <a> as often as a <button>, in the same rows. */
a.ghbtn{text-decoration:none}
.iconbtn .sync{display:inline-flex;--ic:15px}
.iconbtn.spin .sync{animation:spin .9s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}

/* ---------- icons ----------
   Lucide, vendored in js/icons.js. They take colour from `currentColor` and size from the
   `--ic` custom property, so a component sets both in CSS and never touches the SVG. */
svg.ic{width:var(--ic,15px);height:var(--ic,15px);display:block;flex:none}
/* A slot that holds one, centred, wherever a text glyph used to sit on a baseline. */
.icslot{display:inline-flex;align-items:center;justify-content:center;flex:none}

/* `.chip` is Astryx's Badge: `.hot`, `.warm`, `.cool` and `.ok` its error, warning, info and
   success variants. */
.pill{font:11px var(--mono);color:var(--ink-dim);border:1px solid transparent;
      background:color-mix(in srgb,var(--ink) 4%,transparent);
      border-radius:999px;padding:2px 9px;font-variant-numeric:tabular-nums}

/* ---------- waiting ----------
   The inbox reads every repo in the org, which is seconds on a cold cache. What used to stand
   there was one line of grey text in an otherwise empty panel beside a second empty panel,
   which reads as a page that has failed rather than one that is working. These are the shape
   of what is coming: rows in the list, a title and paragraphs in the viewer. */
.sk{--skbg:color-mix(in srgb,var(--ink) 7%,transparent);border-radius:6px;
    background:var(--skbg);animation:pulse 1.4s ease-in-out infinite}
.sk-row{background:none;animation:none;padding:11px 10px;border-top:1px solid var(--line)}
.sk-row:first-of-type{border-top:0}
.sk-row .skbar{height:11px;border-radius:6px;
    background:var(--skbg);animation:pulse 1.4s ease-in-out infinite}
.sk-row .skbar.t{width:84%}
.sk-row .skbar.m{width:38%;height:8px;margin-top:8px}
/* Staggered, so the list reads as several things loading rather than one block flashing. */
.sk-row:nth-child(2n) .skbar.t{width:68%}
.sk-row:nth-child(3n) .skbar.t{width:92%}
.sk-row:nth-child(3n) .skbar.m{width:52%}
.sk-head{height:19px;width:56%;margin:6px 0 18px}
.sk-line{height:10px;width:100%;margin:9px 0}
.sk-line:nth-child(2n){width:88%}
.sk-line:nth-child(3n){width:94%}
.sk-line:last-child{width:42%}
/* The word beside them. It is the only part a screen reader gets, so it stays real text. */
.skhead{color:var(--ink-faint);font-size:12.5px;padding:4px 10px 8px}
/* A count that is still being fetched is not zero, and an empty badge reads as zero. */
.nav .n.wait{display:inline-block;width:15px;height:8px;border-radius:5px;
    background:color-mix(in srgb,var(--ink) 10%,transparent);animation:pulse 1.3s ease-in-out infinite}
@keyframes pulse{0%,100%{opacity:.35}50%{opacity:.85}}
@media (prefers-reduced-motion:reduce){
  .sk,.sk-row .skbar,.nav .n.wait{animation:none}
}

.notice{background:color-mix(in srgb,var(--warn) 10%,transparent);border:1px solid transparent;color:var(--ink-dim);border-radius:var(--r);
      padding:11px 14px;margin-bottom:16px;font-size:12.5px;line-height:1.6}
.notice b{color:var(--ink)}

/* ---------- a dialog that asks for more than a line ----------
   Native <dialog>, so the backdrop, the focus trap and Escape are the browser's job. */
dialog.ask{border:1px solid var(--border-strong);border-radius:var(--r-lg);background:var(--bg-elev);
      color:var(--ink);padding:22px 24px;width:min(560px,92vw);
      box-shadow:var(--shadow-lg)}
dialog.ask[open]{animation:dlgin .18s var(--ease)}
@keyframes dlgin{from{opacity:0;transform:translateY(6px) scale(.985)}}
dialog.ask::backdrop{background:rgba(0,0,0,.35);backdrop-filter:blur(8px)}
dialog.ask h3{margin:0;font:600 16px var(--sans);letter-spacing:-.018em}
dialog.ask .askhint{margin:6px 0 14px;font:12.5px/1.55 var(--sans);color:var(--ink-dim)}
/* With no hint under the title, the field still needs the room the hint would have left. */
dialog.ask h3 + textarea{margin-top:14px}
dialog.ask textarea{font:13.5px/1.6 var(--sans);min-height:96px;max-height:44vh}
/* The attach control, when the dialog is a reply rather than a question. */
dialog.ask .attach{margin-top:9px}
dialog.ask .askrow{margin-top:14px;justify-content:flex-end}
dialog.ask .askrow .meta{margin-right:auto}

/* The lightbox: an image, over the page, that zooms.
 *
 * Not a <dialog>, so the stacking and the backdrop are declared here rather than inherited
 * from ::backdrop. 60 puts it over the `@` mention list (30) and over the dialog, which is
 * correct: a picture opened from inside a reply box should still open. */
.lightbox{position:fixed;inset:0;z-index:60;display:flex;
          background:rgba(0,0,0,.82)}
/* The stage is inset rather than the whole window, and that is not decoration.
   Most images here are screenshots *of this interface*, and one fitted edge to edge reads as
   the app having navigated rather than as a picture of it. The margin of backdrop around it,
   and the border on it, are the only things that say which you are looking at.

   Fit and centring are arithmetic in the module rather than layout: the transform has to be
   the single source of truth, or zooming fights the flexbox. The module measures this box, so
   changing the inset here is all it takes to change what "fitted" means. */
.lightbox .lbstage{position:absolute;inset:46px 56px 52px;overflow:hidden}
.lightbox img{position:absolute;top:0;left:0;transform-origin:0 0;
              max-width:none;max-height:none;border-radius:8px;
              border:1px solid rgba(255,255,255,.14);
              box-shadow:0 18px 50px rgba(0,0,0,.5);
              cursor:zoom-in;user-select:none;-webkit-user-drag:none}
/* Zoomed past fitted it is being read, not looked at, so the frame comes off: a border and a
   drop shadow in the middle of a diff you are inspecting is furniture in the way. */
.lightbox[data-zoomed="true"] img{border-radius:0;border-color:transparent;box-shadow:none}
.lightbox[data-zoomed="true"] img{cursor:grab}
.lightbox[data-zoomed="true"] img:active{cursor:grabbing}

.lightbox .lbx,.lightbox .lbctl{--ic:17px;
               display:inline-flex;align-items:center;justify-content:center;
               width:34px;height:34px;padding:0;border-radius:9px;
               border:1px solid var(--line);background:var(--panel);color:var(--ink-dim);
               cursor:pointer}
.lightbox .lbx{position:absolute;top:14px;right:16px;--ic:18px}
.lightbox .lbx:hover,.lightbox .lbctl:not(:disabled):hover{color:var(--ink);
               border-color:var(--ink-faint)}
/* At a stop the button stays where it is and stops responding. Removing it would move the two
   beside it, which reads as the control having changed rather than as a limit being reached. */
.lightbox .lbctl:disabled{opacity:.35;cursor:default}

/* Bottom right, which is the one corner nothing else uses: close is top right, the hint is top
   centre and the caption is bottom centre. */
.lightbox .lbzoom{position:absolute;bottom:12px;right:16px;display:flex;gap:6px;align-items:center}
/* Wide enough for "1600%" so the group does not resize as the number grows, and tabular so the
   digits do not shuffle while you hold the button down. */
.lightbox .lblevel{width:auto;min-width:60px;padding:0 9px;
                   font:12px var(--mono);font-variant-numeric:tabular-nums;
                   color:var(--ink-dim)}

/* Both of these are over the picture, so they are quiet and they do not take the pointer:
   a click that lands on the caption still means "fit", not "nothing happened". */
.lightbox .lbhint,.lightbox .lbcap{position:absolute;left:0;right:0;margin:0;
                                   pointer-events:none;text-align:center;
                                   font:11.5px var(--sans);color:var(--ink-faint)}
.lightbox .lbhint{top:16px;padding:0 60px}
.lightbox .lbcap{bottom:19px;padding:0 200px;color:var(--ink-dim);font-size:12.5px;
                 white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

/* The page behind must not scroll under an overlay. A wheel event that misses the image
   would otherwise scroll the document instead of doing nothing. */
body[data-lightbox] {overflow:hidden}

/* And the affordance on the document side: an image you can open should say so. */
.md img,img.zoomable{cursor:zoom-in}

/* ---------- a dialog for a whole task (sheet() in dialog.js) ---------- */
dialog.sheet{border:1px solid var(--border-strong);border-radius:var(--r-lg);background:var(--bg);
      color:var(--ink);padding:0;width:min(860px,calc(100vw - 32px));max-height:calc(100vh - 48px);
      box-shadow:var(--shadow-lg)}
dialog.sheet[open]{animation:dlgin .18s var(--ease)}
/* Pinned to the window. The graph's own `.sheet` panel is position:absolute, and that rule
   reached this dialog too, so one opened on a scrolled page sat at the top of the document,
   half off the screen. */
dialog.sheet{position:fixed}
dialog.sheet::backdrop{background:rgba(0,0,0,.35);backdrop-filter:blur(8px)}
.sheetbody{padding:22px 24px 26px;overflow:auto;max-height:calc(100vh - 50px)}

/* The side sheet: a thread opened from Home, full height on the right. */
dialog.sheet.side{margin:0 0 0 auto;height:100vh;max-height:100vh;width:min(780px,100vw);
      border-radius:0;border-width:0 0 0 1px}
dialog.sheet.side[open]{animation:sidein .22s var(--ease)}
dialog.sheet.side .sheetbody{max-height:100vh;height:100%;box-sizing:border-box;padding:18px 22px 40px}
@keyframes sidein{from{transform:translateX(24px);opacity:0}}
@media (prefers-reduced-motion:reduce){dialog.sheet.side[open]{animation:none}}
.sidebar-x{position:sticky;top:0;display:flex;justify-content:flex-end;margin:-6px -6px 4px;z-index:1}
dialog.sheet.side .viewer{border:0;box-shadow:none;padding:0;min-height:0;background:none}
/* The title and its actions stay in view while a long thread scrolls under them. The close
   button floats over the header's top right, so the lines beside it leave room for it; the
   actions below it run to the edge, so Open in GitHub lines up with the close button. */
dialog.sheet.side .thead{position:sticky;top:-18px;z-index:1;background:var(--bg);
      padding-top:18px;margin-top:-18px}
dialog.sheet.side .thead > :not(.tacts){padding-right:44px}
dialog.sheet.side .sidebar-x{position:sticky;top:0;height:0;margin:0;z-index:2;overflow:visible}
dialog.sheet.side .sidebar-x .iconbtn{margin-top:-4px}
.sheettitle{margin:0 0 14px;font:600 18px var(--sans);letter-spacing:-.02em}
.sheetloading{display:grid;place-items:center;min-height:260px}
.spinner{width:22px;height:22px;border-radius:50%;border:2px solid var(--line);border-top-color:var(--accent);
      animation:spin .7s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}

/* The first load, while the org is read from GitHub: a row per repository. */
.loadlist{display:flex;flex-direction:column;gap:2px;max-width:520px}
.loadrow{display:grid;grid-template-columns:18px 140px 1fr;align-items:center;gap:10px;padding:7px 0;
  font-size:13.5px;border-bottom:1px solid var(--line)}
.loadrow b{font-weight:500}
.loadrow .meta{color:var(--ink-dim)}
.loadmark{width:10px;height:10px;border-radius:50%;border:2px solid var(--accent-dim);
  border-top-color:var(--accent);animation:loadspin .8s linear infinite}
.loadrow.done .loadmark{animation:none;border-color:var(--accent);background:var(--accent)}
.loadrow.done .meta{color:var(--ink-faint)}
@keyframes loadspin{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion:reduce){.loadmark{animation:none}}
