/* =====================================================================================================
   Stillwater: styles for the make, positions, wallets, add and docs pages

   Every class here starts with .sw-b- and builds on the shell's vocabulary in stillwater.css. Colours come
   from its tokens only.
   ===================================================================================================== */

/* ------------------------------------------------------------------------------------- make: layout */

.sw-b-make { max-width: 940px; margin: 0 auto; }

.sw-b-make-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  align-items: start;
  gap: 24px;
}
.sw-b-make-grid > * { min-width: 0; }

@media (max-width: 900px) {
  .sw-b-make-grid { grid-template-columns: minmax(0, 1fr); }
}

.sw-b-card {
  min-width: 0;
  padding: 8px 20px 20px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
}

.sw-b-sides { margin: 0 -8px 18px; }
.sw-b-sides > button { flex: 1 0 auto; }

/* ------------------------------------------------------------------------------------- make: the legs */

.sw-b-legs { display: grid; }

.sw-b-leg, .sw-b-price {
  min-width: 0;
  padding: 14px 16px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--bg);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.sw-b-leg-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
  min-width: 0;
  color: var(--mute);
  font-size: 12.5px;
}
.sw-b-leg-head > label { flex: none; }

.sw-b-bal {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0 6px;
  min-width: 0;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.sw-b-bal > span:first-child { color: var(--mute); }

.sw-b-max {
  padding: 0 2px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--accent);
  font: 600 12.5px/1.4 var(--sans);
  cursor: pointer;
}
.sw-b-max:hover { text-decoration: underline; text-underline-offset: 3px; }

.sw-b-leg-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.sw-b-amount {
  flex: 1;
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 500 28px/1.25 var(--sans);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.sw-b-amount::placeholder { color: var(--faint); }
.sw-b-amount[aria-invalid="true"] { color: var(--down); }

.sw-b-token {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 8px;
  max-width: 55%;
  height: 40px;
  padding: 0 12px 0 7px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  font: 600 15px/1 var(--sans);
  white-space: nowrap;
  transition: border-color 0.15s, background-color 0.15s;
}
.sw-b-token b { min-width: 0; overflow: hidden; font-weight: 600; text-overflow: ellipsis; }
button.sw-b-token { cursor: pointer; }
button.sw-b-token:hover { border-color: var(--faint); }
.sw-b-token .sw-icon { color: var(--mute); }
.sw-b-token-empty { padding-left: 14px; border-color: transparent; background: var(--accent); color: var(--accent-ink); }
button.sw-b-token-empty:hover { border-color: transparent; background: var(--accent-hover); }
.sw-b-token-empty .sw-icon { color: currentColor; }
.sw-b-token-fixed { cursor: default; }

.sw-b-leg-foot {
  min-height: 18px;
  margin-top: 6px;
  color: var(--faint);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

/* The switch sits on the seam between the two legs. */
.sw-b-flip {
  position: relative;
  z-index: 1;
  display: grid;
  justify-self: center;
  place-items: center;
  width: 36px;
  height: 36px;
  margin: -11px 0;
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: 50%;
  background: var(--surface);
  color: var(--mute);
  transition: color 0.15s, border-color 0.15s, transform 0.2s;
}
.sw-b-flip:hover { border-color: var(--faint); color: var(--ink); }
.sw-b-flip:active { transform: rotate(180deg); }

/* ------------------------------------------------------------------------------------ make: the price */

.sw-b-price { margin-top: 12px; }

.sw-b-pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font: 600 12px/1 var(--sans);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.sw-b-pill-over { background: var(--warn-soft); color: var(--warn); }

.sw-b-price-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.sw-b-step {
  display: grid;
  flex: none;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink);
  font: 500 19px/1 var(--sans);
  transition: background-color 0.15s, border-color 0.15s;
}
.sw-b-step:hover:not(:disabled) { border-color: var(--faint); background: var(--hover); }
.sw-b-step:disabled { opacity: 0.4; cursor: not-allowed; }

.sw-b-price-field {
  display: flex;
  flex: 1;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  min-width: 0;
}
.sw-b-price-input {
  flex: 0 1 auto;
  width: 3ch;
  max-width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 500 22px/1.3 var(--sans);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.sw-b-price-input::placeholder { color: var(--faint); }
.sw-b-price-input[aria-invalid="true"] { color: var(--down); }
.sw-b-price-input:disabled { color: var(--faint); cursor: not-allowed; }
.sw-b-unit { flex: none; color: var(--mute); font-size: 13px; font-weight: 600; }

.sw-b-price .sw-b-leg-foot { text-align: center; }

.sw-b-presets { display: flex; margin-top: 10px; }
.sw-b-presets > button { flex: 1 0 auto; justify-content: center; }
.sw-b-presets > button:disabled { opacity: 0.45; cursor: not-allowed; }

/* The amount and price boxes show focus on the whole box rather than a ring around the bare number. */
@supports selector(:has(*)) {
  .sw-b-amount:focus-visible, .sw-b-price-input:focus-visible { outline: none; }
  .sw-b-leg:has(.sw-b-amount:focus-visible), .sw-b-price:has(.sw-b-price-input:focus-visible) {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
  }
}

/* ---------------------------------------------------------------------------------- make: options, CTA */

.sw-b-options {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.sw-b-options > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.sw-b-options > summary::-webkit-details-marker { display: none; }
.sw-b-options > summary:hover { background: var(--hover); }
.sw-b-options > summary small {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--faint);
  font-size: 12.5px;
  font-weight: 400;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sw-b-options > summary .sw-icon { color: var(--mute); transition: transform 0.2s; }
.sw-b-options[open] > summary .sw-icon { transform: rotate(180deg); }
.sw-b-options-body { padding: 6px 14px 16px; border-top: 1px solid var(--line); }
.sw-b-options-body > .sw-field:first-child { margin-top: 10px; }
.sw-b-options .sw-error:not(:empty) { margin-top: 2px; }
.sw-b-life { justify-self: start; }

.sw-b-cta { margin-top: 16px; }
.sw-b-cta-error:not(:empty) { margin-top: 10px; }
.sw-b-funds { margin-top: 14px; }

/* ---------------------------------------------------------------------------------- make: the rail */

.sw-b-pool > .sw-hint { margin-bottom: 14px; }
.sw-b-ladder > .sw-b-you dt { color: var(--accent); font-weight: 600; }
.sw-b-ladder > .sw-b-you dd { color: var(--accent); }
.sw-b-dump { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.sw-b-dump dd small { margin-top: 6px; }

.sw-b-move {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sw-b-verdict {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  color: var(--ink);
  font-size: 13.5px;
  line-height: 1.5;
}
.sw-b-verdict-good { background: var(--up-soft); }
.sw-b-verdict-warn { background: var(--warn-soft); }

/* ----------------------------------------------------------------------------------- make: the picker */

.sw-b-pick-search { margin-top: 16px; }
.sw-b-picks {
  max-height: min(52vh, 440px);
  margin: 6px -4px 0;
  padding: 0 4px 4px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.sw-b-picks[aria-busy="true"] { opacity: 0.6; }
.sw-b-picks .sw-choices { margin-top: 6px; }
.sw-b-picks .sw-choices-label { margin-top: 14px; }
.sw-b-pick-side {
  flex: none;
  margin-left: auto;
  color: var(--mute);
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.sw-b-pick-side small { display: block; color: var(--faint); font-size: 12px; }
.sw-b-pick-none { padding: 18px 2px 4px; }
.sw-modal .sw-b-pick-foot { margin-top: 14px; }

/* ----------------------------------------------------------------------------------------- positions */

/* With no wallet connected: the page title as everywhere, then how it works, in a panel below. */
.sw-b-welcome { max-width: 720px; padding: 28px; }
.sw-b-welcome-go { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--line); }

.sw-b-cell-actions { display: inline-flex; gap: 6px; }

.sw-b-more { margin-top: 12px; text-align: center; }

.sw-b-spare > p { color: var(--mute); font-size: 14px; }
.sw-b-spare-list { display: grid; margin: 14px 0 0; padding: 0; list-style: none; }
.sw-b-spare-list > li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.sw-b-spare-list > li:last-child { padding-bottom: 0; }
.sw-b-spare-what { min-width: 0; font-variant-numeric: tabular-nums; }
.sw-b-spare-what b { display: block; font-weight: 600; overflow-wrap: anywhere; }
.sw-b-spare-what small { display: block; color: var(--faint); font-size: 12.5px; }

.sw-modal .sw-b-lower { margin-top: 18px; }
.sw-modal .sw-b-lower + .sw-hint { margin-top: 6px; }

@media (max-width: 640px) {
  .sw-b-welcome { padding: 22px 20px; }
}

/* -------------------------------------------------------------------------------------------- wallets */

.sw-b-lookup { display: flex; gap: 10px; max-width: 640px; }
.sw-b-lookup > .sw-search { flex: 1; }
.sw-b-lookup-error:not(:empty) { margin-top: 10px; }

.sw-b-recent {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}
.sw-b-recent:empty { display: none; }
.sw-b-recent-label {
  margin-right: 2px;
  color: var(--faint);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.sw-b-chip {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--mute);
  font-size: 12.5px;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.sw-b-chip:hover { border-color: var(--line-2); color: var(--ink); }
.sw-b-chip[aria-current] { border-color: var(--accent); color: var(--ink); }

.sw-b-result { margin-top: 32px; }
.sw-b-result > .sw-loading { min-height: 24vh; }

.sw-b-who {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 20px;
  margin-bottom: 16px;
}
.sw-b-who-text { min-width: 0; }
.sw-b-who-text .sw-kicker { margin-bottom: 4px; }
.sw-b-who-text p { color: var(--ink); font-size: 15px; }
.sw-b-after { margin-top: 12px; }
.sw-b-intro { max-width: 640px; }

@media (max-width: 640px) {
  .sw-b-lookup { flex-wrap: wrap; }
  .sw-b-lookup > .sw-search { flex-basis: 100%; }
  .sw-b-lookup > .sw-btn { flex: 1; }
}

/* ------------------------------------------------------------------------------------------------ add */

.sw-b-narrow { max-width: 680px; }
.sw-b-add-warn { margin-top: 16px; }
.sw-b-add-warn b { font-weight: 600; }
.sw-b-add-h2 { margin-bottom: 16px; }

@media (max-width: 520px) {
  .sw-b-add .sw-input-row { flex-wrap: wrap; }
  .sw-b-add .sw-input-row > .sw-btn { flex: 1; }
}

/* ----------------------------------------------------------------------------------------------- docs */

/* The contents come first in the page, so phones meet them at the top; wide screens move them to the side. */
.sw-b-docs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  align-items: start;
  gap: 56px;
}
.sw-b-docs > .sw-prose { grid-column: 1; grid-row: 1; min-width: 0; }

.sw-b-toc {
  position: sticky;
  top: calc(var(--top-total) + 24px);
  grid-column: 2;
  grid-row: 1;
}
.sw-b-toc ol {
  display: grid;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--line);
  list-style: none;
}
.sw-b-toc a {
  display: block;
  margin-left: -1px;
  padding: 5px 0 5px 14px;
  border-left: 1px solid transparent;
  color: var(--mute);
  font-size: 13.5px;
  line-height: 1.4;
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s;
}
.sw-b-toc a:hover { color: var(--ink); }
.sw-b-toc a[aria-current] { border-left-color: var(--accent); color: var(--ink); }

.sw-b-docs-table { margin: 4px 0 18px; }
.sw-b-docs-table .sw-table { font-size: 13.5px; }

.sw-b-key {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
}

@media (max-width: 960px) {
  .sw-b-docs { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .sw-b-toc { position: static; grid-column: 1; grid-row: auto; }
  .sw-b-docs > .sw-prose { grid-row: auto; }
  .sw-b-toc ol { display: flex; flex-wrap: wrap; gap: 6px; border-left: 0; }
  .sw-b-toc a {
    margin: 0;
    padding: 5px 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 12.5px;
  }
  .sw-b-toc a[aria-current] { border-color: var(--line); color: var(--mute); }
}

/* ------------------------------------------------------------------------------------------- phones */

@media (max-width: 520px) {
  .sw-b-card { padding: 4px 14px 16px; }
  .sw-b-sides { margin: 0 -6px 14px; }
  .sw-b-leg, .sw-b-price { padding: 12px 12px 10px; }
  .sw-b-amount { font-size: 24px; }
  .sw-b-price-input { font-size: 19px; }
  .sw-b-token { height: 38px; font-size: 14px; }
  .sw-b-presets > button { padding: 0 9px; }
}
