/* Foinse signed-in app shell. Item 7-9 of the front-end gap list.
 *
 * One shell, three rails: a left icon rail for the five jobs, a top bar
 * carrying the search field, and a right action rail for the four money
 * moves. Every value resolves through tokens.css; this file adds no color
 * and no type size of its own. The shell is opt-in: a page carries
 * `class="app-shell"` on <body> and the shell renders. Pages that do not
 * carry the class are untouched, so the marketing header survives on the
 * marketing surfaces and disappears only where the shell is on.
 */

.app-shell {
  --shell-rail-width: 110px;
  --shell-action-width: 460px;
  --shell-top-height: 66px;
  display: grid;
  grid-template-columns: var(--shell-rail-width) minmax(0, 1fr) var(--shell-action-width);
  grid-template-rows: var(--shell-top-height) minmax(0, 1fr);
  grid-template-areas:
    "rail top actions"
    "rail main actions";
  min-height: 100vh;
  background: var(--foinse-surface-page);
  color: var(--foinse-text-primary);
}

/* The marketing header is suppressed wherever the shell is on. */
.app-shell > .site-head,
.app-shell .site-head {
  display: none;
}

/* Left icon rail: Home, Market, Transactions, Earn, Account. */
.shell-rail {
  grid-area: rail;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--foinse-space-2);
  padding: var(--foinse-space-3) 0;
  border-right: var(--foinse-border);
  background: var(--foinse-surface-card);
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
}

.shell-rail__brand {
  display: grid;
  place-items: center;
  width: var(--foinse-hit-area-pointer);
  height: var(--foinse-hit-area-pointer);
  margin-bottom: var(--foinse-space-2);
  border-radius: var(--foinse-radius-control);
}

.shell-rail__brand img {
  width: var(--foinse-icon-size-default);
  height: var(--foinse-icon-size-default);
}

/* Rail item: icon stacked over a 13px label, Coinbase trade shape. */
.shell-rail__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--foinse-space-1, 4px);
  width: calc(var(--shell-rail-width) - var(--foinse-space-4));
  min-height: var(--foinse-hit-area-pointer);
  padding: var(--foinse-space-2) 0;
  border-radius: var(--foinse-radius-control);
  color: var(--foinse-text-muted);
  text-decoration: none;
  transition: color var(--foinse-motion-duration-ui) var(--foinse-motion-easing),
    background-color var(--foinse-motion-duration-ui) var(--foinse-motion-easing);
}

.shell-rail__item:hover,
.shell-rail__item.is-hover {
  color: var(--foinse-text-primary);
  background: var(--foinse-surface-recessed);
}

.shell-rail__item[aria-current="page"],
.shell-rail__item.is-current {
  color: var(--foinse-text-primary);
  background: var(--foinse-surface-recessed);
}

.shell-rail__item:focus-visible {
  outline: var(--foinse-focus-ring);
  outline-offset: var(--foinse-focus-offset);
}

.shell-rail__item svg {
  width: var(--foinse-icon-size-default);
  height: var(--foinse-icon-size-default);
  stroke: currentColor;
  fill: none;
  stroke-width: var(--foinse-icon-stroke-compact);
}

.shell-rail__item span {
  font-size: var(--foinse-font-size-label);
  line-height: var(--foinse-font-line-label);
  color: inherit;
}

/* Top bar: search, always present, always the same width as the main column. */
.shell-top {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: var(--foinse-space-4);
  padding: 0 var(--foinse-space-6);
  border-bottom: var(--foinse-border);
  background: var(--foinse-surface-page);
  position: sticky;
  top: 0;
  z-index: var(--foinse-z-sticky);
}

.shell-search {
  flex: 1 1 auto;
  max-width: var(--foinse-content-max-prose);
  display: flex;
  align-items: center;
  gap: var(--foinse-space-2);
  min-height: var(--foinse-input-height);
  margin: 0;
  padding: 0 var(--foinse-space-4);
  border: var(--foinse-border);
  border-radius: var(--foinse-radius-control);
  background: var(--foinse-surface-card);
  color: var(--foinse-text-muted);
}

.shell-search:focus-within {
  border-color: var(--foinse-color-accent);
  outline: var(--foinse-focus-width) solid var(--foinse-color-accent);
  outline-offset: var(--foinse-focus-offset);
}

.shell-search svg {
  width: var(--foinse-icon-size-inline);
  height: var(--foinse-icon-size-inline);
  flex: 0 0 var(--foinse-icon-size-inline);
  stroke: currentColor;
  fill: none;
  stroke-width: var(--foinse-icon-stroke-compact);
}

.shell-search input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--foinse-text-primary);
  font-family: var(--foinse-font-family-ui);
  font-size: var(--foinse-font-size-body);
  line-height: var(--foinse-font-line-body);
}

.shell-search input::placeholder {
  color: var(--foinse-text-muted);
  opacity: 1;
}

.shell-search input:focus {
  outline: none;
}

/* Right rail: order ticket on top (the market page moves its ticket in),
 * money moves as plain icon+text rows under it. No boxed buttons. */
.shell-actions {
  grid-area: actions;
  display: flex;
  flex-direction: column;
  gap: var(--foinse-space-2);
  padding: var(--foinse-space-5) var(--foinse-space-4);
  border-left: var(--foinse-border);
  background: var(--foinse-surface-card);
  position: sticky;
  top: var(--shell-top-height);
  align-self: start;
  max-height: calc(100vh - var(--shell-top-height));
  overflow-y: auto;
  width: var(--shell-action-width);
}

.shell-move {
  display: flex;
  align-items: center;
  gap: var(--foinse-space-3);
  padding: var(--foinse-space-2);
  color: var(--foinse-text-primary);
  text-decoration: none;
  font-size: var(--foinse-font-size-body);
  border-radius: var(--foinse-radius-control);
}

.shell-move:hover {
  background: var(--foinse-surface-recessed);
}

.shell-move svg {
  width: var(--foinse-icon-size-inline);
  height: var(--foinse-icon-size-inline);
  stroke: var(--foinse-color-accent);
  fill: none;
  stroke-width: var(--foinse-icon-stroke-compact);
  flex: 0 0 auto;
}

/* Main column: the page's content moved inside one wrapper. The wrapper's
 * parent <main> carries `shell` and dissolves into the grid, so the rails
 * and the wrapper sit directly on the body's grid areas. */
.shell {
  display: contents;
}

/* The marketing footer comes out with the marketing header. */
.app-shell > footer {
  display: none;
}

/* The shell fills the window: the page's boxed card chrome and centered
 * column come off inside it. */
.app-shell .account-state,
.app-shell .account-state--wide {
  border: 0;
  background: transparent;
  padding: 0;
  box-shadow: none;
  max-width: none;
}

/* The session line is one quiet line, not a banner box. */
.app-shell .market-session-line {
  display: flex;
  justify-content: flex-end;
  gap: var(--foinse-space-3);
  border: 0;
  padding: 0 0 var(--foinse-space-3);
  color: var(--foinse-text-muted);
  font-size: var(--foinse-font-size-label);
}

.app-shell h1 {
  margin: 0 0 var(--foinse-space-4);
}

.shell-main {
  grid-area: main;
  min-width: 0;
  padding: var(--foinse-space-8) var(--foinse-space-6) var(--foinse-space-16);
}

.shell-main .wrap {
  max-width: none;
  padding: 0;
}

/* The shell's main column runs edge to edge; no centered content card. */
.app-shell .foinse-section {
  padding-left: 0;
  padding-right: 0;
}

.shell-main .account-section {
  max-width: none;
}

/* The hero band comes out inside the shell: no marketing paragraph on a
 * product surface. Item 13. */
.app-shell .hero {
  display: none;
}

/* Zero prose on product surfaces: the vocabulary section is marketing
 * copy and never renders inside the shell. */
.app-shell .foinse-vocabulary {
  display: none;
}

/* Below the wide breakpoint the action rail folds under the main column
 * rather than squeezing it. */
@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: var(--shell-rail-width) minmax(0, 1fr);
    grid-template-areas:
      "rail top"
      "rail main"
      "rail actions";
  }

  .shell-actions {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    width: auto;
    max-width: 100%;
    max-height: none;
    border-left: 0;
    border-top: var(--foinse-border);
  }

  .shell-actions .foinse-btn {
    width: auto;
    flex: 1 1 auto;
  }

  .shell-actions__title,
  .shell-actions__sep {
    display: none;
  }
}

@media (max-width: 640px) {
  .app-shell {
    --shell-rail-width: 56px;
    grid-template-columns: var(--shell-rail-width) minmax(0, 1fr);
  }

  .shell-rail__item {
    width: 100%;
    padding: var(--foinse-space-2) 0;
  }

  .shell-rail__item span {
    display: none;
  }

  .shell-top {
    padding: 0 var(--foinse-space-4);
  }

  .shell-main {
    padding: var(--foinse-space-6) var(--foinse-space-4) var(--foinse-space-12);
  }
}

/* ============================================================
   EXCHANGE DEPTH PASS: the shell sections become real product
   surfaces. Warm cards, tabular numerals, a real trade ticket.
   Scoped to .app-shell; no effect on marketing pages.
   ============================================================ */

/* Main column sections read as cards on the page wash. */
.shell-main > section {
  margin-bottom: var(--foinse-space-5);
  padding: var(--foinse-space-6);
  background: var(--foinse-surface-card);
  border: var(--foinse-border);
  border-radius: var(--foinse-radius-card);
  box-shadow: 0 1px 2px rgb(28 25 23 / 0.04), 0 6px 16px rgb(28 25 23 / 0.05);
}

.shell-main > section > h1,
.shell-main > section > h2 {
  margin: 0 0 var(--foinse-space-2);
  letter-spacing: -0.01em;
}

.shell-main > section > p {
  max-width: 64ch;
  color: var(--foinse-text-muted);
}

/* Numbers line up. Prices carry weight. */
.shell-main table,
.shell-actions table {
  width: 100%;
  margin-top: var(--foinse-space-4);
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.shell-main th,
.shell-actions th {
  padding: 10px 12px;
  color: var(--foinse-text-muted);
  font-size: var(--foinse-font-size-label);
  font-weight: 600;
  text-align: left;
  border-bottom: var(--foinse-border);
}

.shell-main td,
.shell-actions td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--foinse-color-rule-100);
  color: var(--foinse-text-primary);
}

.shell-main tbody tr {
  transition: background-color var(--foinse-motion-duration-ui) var(--foinse-motion-easing);
}

.shell-main tbody tr:hover {
  background: var(--foinse-surface-recessed);
}

.shell-main tbody tr:last-child td,
.shell-actions tbody tr:last-child td {
  border-bottom: 0;
}

/* Forms inside the shell: quiet labels, warm inputs. */
.shell-main label,
.shell-actions label {
  display: grid;
  gap: 6px;
  color: var(--foinse-text-muted);
  font-size: var(--foinse-font-size-label);
  font-weight: 550;
}

.shell-main input,
.shell-actions input {
  min-height: var(--foinse-input-height);
  padding: 0 14px;
  background: var(--foinse-surface-card);
  border: var(--foinse-border);
  border-radius: var(--foinse-radius-control);
  color: var(--foinse-text-primary);
  font: inherit;
  font-variant-numeric: tabular-nums;
}

.shell-main input:focus-visible,
.shell-actions input:focus-visible {
  outline: var(--foinse-focus-width) solid var(--foinse-color-accent);
  outline-offset: var(--foinse-focus-offset);
  border-color: var(--foinse-color-accent);
}

/* Definition lists post as receipt rows: label left, value right. */
.shell-main dl,
.shell-actions dl {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px var(--foinse-space-4);
  margin: var(--foinse-space-4) 0;
  padding: var(--foinse-space-4);
  background: var(--foinse-surface-recessed);
  border-radius: var(--foinse-radius-control);
  font-size: var(--foinse-font-size-label);
}

.shell-main dl:empty,
.shell-actions dl:empty {
  display: none;
}

.shell-main dt,
.shell-actions dt {
  color: var(--foinse-text-muted);
}

.shell-main dd,
.shell-actions dd {
  margin: 0;
  color: var(--foinse-text-primary);
  font-variant-numeric: tabular-nums;
  text-align: right;
  overflow-wrap: anywhere;
}

/* The trade ticket: one decisive card at the top of the action rail. */
.shell-actions > section {
  padding: var(--foinse-space-5);
  background: var(--foinse-surface-page);
  border: var(--foinse-border);
  border-radius: var(--foinse-radius-card);
  box-shadow: 0 1px 2px rgb(28 25 23 / 0.04), 0 6px 16px rgb(28 25 23 / 0.05);
}

.shell-actions > section > h2 {
  margin: 0 0 var(--foinse-space-3);
  font-size: var(--foinse-font-size-heading-2);
  letter-spacing: -0.01em;
}

.shell-actions .foinse-btn {
  width: 100%;
  justify-content: center;
  margin-top: var(--foinse-space-2);
}

.shell-actions .foinse-btn--tertiary {
  width: auto;
}

/* Rail choice options post as selectable rows. */
.exchange-rail-option {
  display: flex;
  align-items: center;
  gap: var(--foinse-space-3);
  padding: var(--foinse-space-3);
  border: var(--foinse-border);
  border-radius: var(--foinse-radius-control);
  cursor: pointer;
}

.exchange-rail-option + .exchange-rail-option {
  margin-top: var(--foinse-space-2);
}

.exchange-rail-option:has(:checked) {
  border-color: var(--foinse-color-accent);
  background: var(--foinse-color-accent-tint);
}

/* Holdings blocks in the sell section. */
.exchange-holdings {
  padding: var(--foinse-space-4);
  border: var(--foinse-border);
  border-radius: var(--foinse-radius-control);
}

.exchange-holdings + .exchange-holdings {
  margin-top: var(--foinse-space-3);
}

/* Dashboard pages in the shell: the hero panel folds back to a plain
 * page heading, and prose-doc gives up its centered measure. */
.app-shell .page-hero {
  margin: 0 0 var(--foinse-space-5);
  padding: 0 0 var(--foinse-space-5);
  background: none;
  border: 0;
  border-bottom: var(--foinse-border);
  border-radius: 0;
  box-shadow: none;
}

.app-shell .page-hero h1 {
  font-size: var(--foinse-font-size-heading-1);
}

.app-shell .prose-doc,
.app-shell .prose-doc--wide {
  max-width: none;
  padding-bottom: 0;
}

.app-shell .prose-doc h2 {
  border-top: 0;
  padding-top: 0;
}

/* Shell controls: plain buttons and selects inside shell pages get the
 * same warm treatment as classed components. */
.shell-main button:not(.foinse-btn) {
  min-height: 40px;
  padding: 0 20px;
  color: var(--foinse-text-primary);
  background: var(--foinse-surface-card);
  border: var(--foinse-border);
  border-radius: 999px;
  font: inherit;
  font-size: var(--foinse-font-size-label);
  font-weight: 600;
  cursor: pointer;
}

.shell-main button:not(.foinse-btn):hover {
  border-color: var(--foinse-color-ink-300);
}

.shell-main button:not(.foinse-btn):disabled {
  color: var(--foinse-text-muted);
  background: var(--foinse-surface-recessed);
  cursor: not-allowed;
}

.shell-main select {
  min-height: var(--foinse-input-height);
  padding: 0 14px;
  background: var(--foinse-surface-card);
  border: var(--foinse-border);
  border-radius: var(--foinse-radius-control);
  color: var(--foinse-text-primary);
  font: inherit;
}

.shell-main textarea {
  padding: 12px 14px;
  background: var(--foinse-surface-card);
  border: var(--foinse-border);
  border-radius: var(--foinse-radius-control);
  color: var(--foinse-text-primary);
  font: inherit;
}

/* Ticket hint: fills the action rail until a listing is selected. */
.ticket-hint {
  display: none;
  padding: var(--foinse-space-5);
  background: var(--foinse-surface-page);
  border: 1px dashed var(--foinse-color-rule-200);
  border-radius: var(--foinse-radius-card);
}

.ticket-hint h2 {
  margin: 0 0 var(--foinse-space-2);
  font-size: var(--foinse-font-size-heading-3);
}

.ticket-hint p {
  margin: 0;
  color: var(--foinse-text-muted);
  font-size: var(--foinse-font-size-label);
  line-height: 1.5;
}

.shell-actions:has(#trade[hidden]) .ticket-hint {
  display: block;
}
