/* The app shell: a rail, a section, and no scrolling to find the thing you came for.
 *
 * The dashboard was one long page with a row of four tabs above it, which works while there are
 * four things and stops working the moment there are nine. Renting, providing, licences and
 * earnings are different jobs done at different times, and stacking them into a single scroll made
 * every one of them start with a hunt.
 *
 * So: a rail that is always visible and always says where you are, one section at a time in the
 * pane beside it, and the wallet as the thing that decides which sections mean anything. On a
 * phone the rail becomes a bar across the bottom, because a thumb reaches the bottom of a phone
 * and does not reach a menu at the top. */

.shell {
  display: block;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--gut);
}

@media (min-width: 1000px) {
  .shell {
    display: grid;
    grid-template-columns: 236px minmax(0, 1fr);
    gap: 34px;
    align-items: start;
  }
}

/* ------------------------------------------------------------------- the rail */

.rail {
  position: sticky;
  top: calc(var(--chrome-top) + 20px);
  display: none;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 40px;
}
@media (min-width: 1000px) { .rail { display: flex; } }

.rail-head {
  margin: 18px 12px 6px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dimmer);
}
.rail-head:first-child { margin-top: 0; }

.rail a,
.rail button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: none;
  font: inherit;
  font-size: 14px;
  color: var(--dim);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.rail a:hover,
.rail button:hover { background: var(--panel); color: var(--ink); }

.rail [aria-current="page"],
.rail [aria-selected="true"] {
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
}
.rail [aria-selected="true"] { box-shadow: inset 2px 0 0 var(--teal); }

/* A count, or a dot when something needs attention. Kept to the right so the labels stay aligned. */
.rail .rail-badge {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dimmer);
}
.rail .rail-badge[data-alert] { color: var(--amber); }

/* ------------------------------------------------------- the bar, on a phone */


/* app.css stacks page content above the ambient canvas with
   `body > *:not(#ambient) { position: relative }`. The :not(#ambient) argument carries id-level
   specificity, so that rule beats any class selector and quietly un-fixes anything fixed that
   happens to be a direct child of body - which these two are, deliberately, so that the header's
   backdrop-filter cannot trap them. Hence the override rather than a louder selector. */
.railbar {
  position: fixed !important;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: rgba(6, 7, 11, 0.94);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
@media (min-width: 1000px) { .railbar { display: none; } }

.railbar button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 4px;
  border: 0;
  border-radius: 9px;
  background: none;
  font: inherit;
  font-size: 11px;
  color: var(--dimmer);
  cursor: pointer;
}
.railbar button[aria-selected="true"] { color: var(--teal); background: var(--panel); }
.railbar b { font-size: 15px; line-height: 1; font-weight: 400; }

/* A count on the phone rail, which never had one - the badges lived only on the wide layout, so
   the reader most likely to be glancing was the one told nothing.

   It cannot join the flow: these buttons stack their glyph over their label, so an appended badge
   became a third row and grew the bar. Pinned to the glyph's corner instead, the way a count on a
   tab bar is read everywhere else. */
.railbar button { position: relative; }
.railbar .rail-badge {
  position: absolute;
  top: 3px;
  left: 50%;
  margin-left: 3px;
  min-width: 16px;
  padding: 0 4px;
  font-size: 9.5px;
  line-height: 15px;
  text-align: center;
  pointer-events: none;
}

/* The bar covers the last of the page, and on a phone that is where the last row of a table is. */
@media (max-width: 999px) {
  body.has-railbar { padding-bottom: 78px; }
}

/* ---------------------------------------------------------------- the section */

.pane { display: none; }
.pane[data-active] { display: block; }

.pane-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 20px;
  padding: 22px 0 18px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 24px;
}
.pane-head h2 {
  margin: 0;
  font-size: clamp(21px, 2.4vw, 27px);
  letter-spacing: -0.01em;
}
.pane-head p { margin: 4px 0 0; color: var(--dim); font-size: 14px; max-width: 68ch; }
.pane-head .pane-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* --------------------------------------------------------- connect to continue */

/* A section that only means something for a particular wallet. Rather than rendering an empty
   table and letting somebody wonder whether they have no jobs or are simply not signed in, the
   section says which it is. */
.needs-wallet {
  display: grid;
  place-items: center;
  gap: 14px;
  text-align: center;
  padding: 64px 24px;
  border: 1px dashed var(--line);
  border-radius: var(--r);
  background: var(--panel);
}
.needs-wallet h3 { margin: 0; font-size: 17px; }
.needs-wallet p { margin: 0; max-width: 44ch; color: var(--dim); font-size: 14px; line-height: 1.65; }

/* -------------------------------------------------------------- the identity */

.who {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px 7px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--ink);
  cursor: pointer;
}
/* It has always had a pointer cursor and never done anything on click. It signs out now, so it
   answers to a hover the way the other controls do - a pill that reacts is a pill you can press. */
.who:hover,
.who:focus-visible {
  border-color: color-mix(in srgb, var(--teal) 45%, transparent);
  color: var(--teal);
}
.who:hover small,
.who:focus-visible small {
  color: var(--teal);
}
.who i {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--wraith), var(--teal));
  flex: none;
}
.who small { color: var(--dimmer); font-family: var(--display); }
@media (max-width: 560px) { .who small { display: none; } }

/* On a phone the page header is competing with the section for the first screen. A hero that
   explains the page is worth half a viewport on a desktop and is in the way on a phone, where the
   thing below it is the console somebody opened the page to use. */
@media (max-width: 999px) {
  .app-head { padding-top: 18px; }
  .app-head h1 { font-size: clamp(24px, 7vw, 32px); margin-bottom: 8px; }
  .app-head .lede { font-size: 15px; }
  .shell .pane-head { padding-top: 14px; }
}


/* ------------------------------------------------------- how the shell feels
   The rail worked and read like a settings list. This is the same geometry with the brand's own
   character put back: the teal edge that marks the current section grows into place rather than
   appearing, the labels sit on the mono type the rest of the product uses for anything machine-
   read, and an item that wants attention pulses once rather than shouting permanently.

   Nothing here changes a hit target or a colour contrast - it is the difference between a menu
   that works and one that feels like instrumentation. */

.rail a,
.rail button { position: relative; overflow: hidden; }

/* The active marker is drawn rather than boxed, so switching sections reads as the marker moving. */
.rail [aria-selected="true"] { box-shadow: none; }
.rail [aria-selected="true"]::before,
.rail [aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 2px;
  height: 0;
  border-radius: 2px;
  background: var(--teal);
  box-shadow: 0 0 12px var(--teal);
  transform: translateY(-50%);
  animation: railMark 0.22s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}
@keyframes railMark { to { height: 62%; } }

@media (prefers-reduced-motion: reduce) {
  .rail [aria-selected="true"]::before,
  .rail [aria-current="page"]::before { animation: none; height: 62%; }
}

.rail-badge {
  font-variant-numeric: tabular-nums;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--line-soft);
  background: var(--panel-2);
}
.rail-badge:empty { display: none; }
.rail-badge[data-alert] {
  color: var(--ground);
  background: var(--amber);
  border-color: var(--amber);
}

/* The section title carries the same eyebrow treatment the rest of the site uses, so a pane reads
   as part of the product rather than as a page that happens to be inside it. */
.pane-head h2 { font-family: var(--display); }
.pane-head::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 46px;
  height: 1px;
  background: linear-gradient(90deg, var(--teal), transparent);
}
.pane-head { position: relative; }

/* The phone bar: the selected tab lifts, rather than only changing colour. */
.railbar button { transition: color 0.16s, transform 0.16s; }
.railbar button[aria-selected="true"] { transform: translateY(-1px); }
.railbar button[aria-selected="true"] b { text-shadow: 0 0 14px var(--teal); }

/* Switching section should feel like the pane arrived, not like the page repainted. */
.pane[data-active] { animation: paneIn 0.22s ease both; }
@keyframes paneIn { from { opacity: 0; transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) { .pane[data-active] { animation: none; } }


/* ------------------------------------------------------------ filters, folded

   Four filter groups stacked is 386px on a 390px screen - a full phone screen of controls for
   narrowing a list, shown before any of the list. On a desktop the same four sit in one row and
   there is nothing to fix, so this is a phone-only fold. */

.filter-toggle { display: none; }

@media (max-width: 899px) {
  .filter-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin: 0 0 14px;
    padding: 11px 14px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--panel);
    font: inherit;
    font-size: 14px;
    color: var(--ink);
    text-align: left;
    cursor: pointer;
  }
  .filter-toggle i {
    margin-left: auto;
    width: 0;
    height: 0;
    border: 5px solid transparent;
    border-top-color: var(--dim);
    margin-top: 4px;
    transition: transform 0.18s;
    flex: none;
  }
  .filter-toggle[aria-expanded="true"] i { transform: rotate(180deg); margin-top: -4px; }
  /* When a slice is applied, the bar says so in the colour the product uses for "this is live". */
  .filter-toggle[data-filtered] { border-color: rgba(111, 227, 210, 0.4); }
  .filter-toggle[data-filtered] #filterSummary { color: var(--teal); }

  /* The fold is a CSS consequence of the button state, never a JS-set attribute: an author
     display rule beats [hidden], so driving it that way shows the panel while telling a screen
     reader it is gone. */
  .filter-toggle[aria-expanded="false"] + .filters { display: none; }
}


/* ------------------------------------------------------------- how old this is
   The grid re-reads every thirty seconds and repaints only when something changed, which is right
   and leaves a live view looking like a screenshot. This says when it last managed to read - in the
   past tense, because what a reader needs is not "something is happening" but "what you are looking
   at is this old". */
.freshness {
  display: inline-flex;
  vertical-align: middle;
  font-weight: 400;
  letter-spacing: 0;
  align-items: center;
  gap: 7px;
  margin-left: 14px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dimmer);
}
.freshness[hidden] { display: none; }
.freshness i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: freshPulse 2.6s ease-in-out infinite;
}
@keyframes freshPulse { 50% { opacity: 0.3; } }

/* Past two minutes the poll has plainly not completed. The dot stops implying otherwise. */
.freshness[data-stale] i { background: var(--amber); box-shadow: none; animation: none; }
.freshness[data-stale] { color: var(--amber); }

/* The second column of the shell grid.
   The track is minmax(0, 1fr), which stops the TRACK growing - but a grid item's own automatic
   minimum size is its content, so a wide table or an unbroken hash inside a pane could still push
   the column out from the inside and take the rail off the screen with it. */
.shell-main {
  min-width: 0;
}
