/*
 * account.css: the account pages (modules/DASHBOARD#account-pages): the sign-in and registration card with its
 * timeline, the portfolio card grid, the equity line (modules/DASHBOARD#equity-line) and the rail-and-pane dialogs of
 * New portfolio, Rotate keys and Verify keys. Geometry arrives as per-element custom properties, state as classes and
 * `data-*` attributes (CODING_STYLE#frontend).
 */

/* ==== 1. The account card ==== */

.stage {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-block: max(24px, 12vh) 24px;
}

.account-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.foot {
  font-size: 11.5px;
  color: var(--text-dim);
  text-align: center;
}

.foot a {
  color: var(--accent);
  text-decoration: none;
}

.foot a:hover {
  text-decoration: underline;
}

.passkey-glyph {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.strip {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 10px;
  font-size: 11.5px;
  line-height: 1.4;
  border-radius: var(--radius-small);
}

.strip.error {
  background: var(--red-dim);
  color: var(--red-ink);
}

.strip.warn {
  background: var(--amber-dim);
  color: var(--amber-ink);
}

.strip.success {
  background: var(--green-dim);
  color: var(--green-ink);
}

.strip-glyph {
  flex: none;
  font-weight: 700;
}

.note {
  font-size: 11.5px;
  color: var(--text-dim);
  background: var(--bg-inset);
  border-left: 2px solid var(--border);
  padding: 7px 10px;
  border-radius: 0 var(--radius-small) var(--radius-small) 0;
  line-height: 1.45;
}

/* ==== 2. Fields ==== */

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.field label,
.field .field-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.field .help {
  font-size: 11px;
  color: var(--text-faint);
}

.input {
  position: relative;
  display: flex;
  align-items: center;
}

.input input,
.input select,
.callout-input {
  width: 100%;
  min-width: 0;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  color: var(--text);
  font: 400 13px/1.2 var(--mono);
  padding: 8px 10px;
  outline: none;
}

.input input:focus,
.input select:focus,
.callout-input:focus {
  border-color: var(--accent);
}

.field.bad .input input {
  border-color: var(--red);
}

.field-error {
  font-size: 11px;
  color: var(--red-ink);
}

.input .reveal {
  position: absolute;
  right: 4px;
  width: 26px;
  height: 26px;
  border: 0;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-control);
}

.input .reveal svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
}

.input .reveal + input,
.input input[name="apiSecret"] {
  padding-right: 34px;
}

.input .select-badge {
  position: absolute;
  left: 9px;
  pointer-events: none;
}

.input .select-badge + select {
  padding-left: 32px;
}

.two-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
}

.segments {
  display: flex;
  gap: 6px;
}

.segment {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--bg-inset);
  color: var(--text-dim);
  cursor: pointer;
  font: 600 11px/1 var(--sans);
  letter-spacing: 0.04em;
}

.segment[aria-pressed="true"] {
  color: var(--text);
  border-color: var(--text-dim);
  background: var(--bg-panel);
}

/* ==== 3. The timeline (registration, the dialogs' rail) ==== */

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.timeline-step {
  position: relative;
  display: grid;
  grid-template-columns: 18px 1fr;
  column-gap: 12px;
  padding-bottom: 16px;
}

.timeline-step:last-child {
  padding-bottom: 0;
}

.timeline-step::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 20px;
  bottom: -1px;
  width: 2px;
  background: var(--border);
}

.timeline-step:last-child::before {
  display: none;
}

.timeline-step[data-state="done"]::before {
  background: var(--green);
}

.timeline-node {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--text-faint);
  display: grid;
  place-items: center;
  font: 700 9.5px/1 var(--mono);
  color: var(--text-faint);
  background: var(--bg-panel);
  position: relative;
  z-index: var(--z-lifted);
}

.timeline-node svg {
  width: 10px;
  height: 10px;
  display: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.timeline-step[data-state="active"] .timeline-node {
  background: var(--pop-border);
  border-color: var(--pop-border);
  color: var(--on-accent);
}

.timeline-step[data-state="done"] .timeline-node {
  background: var(--green-dim);
  border-color: var(--green);
  color: var(--green);
}

.timeline-step[data-state="failed"] .timeline-node {
  background: var(--red-dim);
  border-color: var(--red);
  color: var(--red);
}

.timeline-step[data-state="done"] .node-number,
.timeline-step[data-state="failed"] .node-number {
  display: none;
}

.timeline-step[data-state="done"] .node-done,
.timeline-step[data-state="failed"] .node-failed {
  display: block;
}

.timeline-step[data-state="busy"] .timeline-node {
  color: transparent;
}

.timeline-step[data-state="busy"] .timeline-node::after {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--text);
}

@media (prefers-reduced-motion: no-preference) {
  .timeline-step[data-state="busy"] .timeline-node::after {
    animation: spin 1s linear infinite;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.timeline-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-height: 18px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.timeline-step[data-state="active"] .timeline-title,
.timeline-step[data-state="busy"] .timeline-title {
  color: var(--text);
}

.timeline-when {
  margin-left: auto;
  font: 400 10px/1 var(--mono);
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-faint);
}

.timeline-description {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 3px;
  line-height: 1.4;
}

.timeline-summary {
  font: 500 11.5px/1.35 var(--mono);
  color: var(--text);
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.timeline-summary:empty {
  display: none;
}

.timeline-step[data-state="failed"] .timeline-summary {
  color: var(--red);
}

.timeline-body {
  margin-top: 9px;
  display: none;
  flex-direction: column;
  gap: 9px;
}

.timeline-step[data-state="active"] .timeline-body,
.timeline-step[data-state="busy"] .timeline-body {
  display: flex;
}

/* ==== 4. The card grid (modules/PORTFOLIOS#cards) ==== */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  grid-auto-rows: 1fr;
  gap: 10px;
  padding: var(--gap);
}

.portfolio-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font: inherit;
}

.portfolio-card:hover {
  border-color: var(--text-faint);
  background: var(--bg-hover);
}

.portfolio-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.portfolio-card.dragged {
  opacity: 0.4;
}

.portfolio-card.drop-target {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.portfolio-card.new {
  border-style: dashed;
  background: transparent;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-weight: 600;
  gap: 6px;
  min-height: 180px;
}

.portfolio-card.new:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.new-plus {
  font-size: 20px;
  line-height: 1;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.card-name {
  font-size: 14px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-figures {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px 16px;
  font: 400 11px/1.1 var(--mono);
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.card-figures.two {
  grid-template-columns: repeat(2, 1fr);
}

.figure {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.figure .ring-host {
  position: absolute;
  margin: 1px 0 0 -20px;
}

.figure:has(.ring-host) {
  position: relative;
  padding-left: 20px;
}

.figure-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.card-reason {
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--red-ink);
  background: var(--red-dim);
  padding: 4px 8px;
  border-radius: var(--radius-small);
}

.card-keys {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.card-callout .callout-input {
  min-width: 220px;
}

/* ==== 5. The equity line (modules/DASHBOARD#equity-line) ==== */

.equity-line {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  --equity-ink: var(--text-dim);
  --equity-fill: var(--gray-dim);
}

.equity-line[data-sign="positive"] {
  --equity-ink: var(--green);
  --equity-fill: var(--green-dim);
}

.equity-line[data-sign="negative"] {
  --equity-ink: var(--red);
  --equity-fill: var(--red-dim);
}

.equity-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.equity-label {
  font: 600 10.5px/1.1 var(--sans);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.equity-change {
  font: 600 11px/1.1 var(--mono);
  color: var(--text-dim);
}

.equity-change.positive {
  color: var(--green);
}

.equity-change.negative {
  color: var(--red);
}

.equity-plot {
  position: relative;
  width: 100%;
  height: 56px;
  cursor: crosshair;
  outline: none;
  border-radius: var(--radius-control);
}

.equity-plot:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.equity-plot.empty {
  cursor: default;
}

.equity-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.equity-fill {
  fill: var(--equity-fill);
  stroke: none;
}

/* REQUIREMENT (modules/DASHBOARD#equity-line): over a gap the fill is the diagonal hatch, whose pattern the line sets
   on the segment as `--equity-gap-fill`. */
.equity-fill.gap {
  fill: var(--equity-gap-fill);
}

/* REQUIREMENT (modules/DASHBOARD#equity-line): over a gap the fill is a diagonal hatch in the same color as the fill. */
.equity-hatch {
  stroke: var(--equity-fill);
  stroke-width: 2;
}

.equity-stroke {
  fill: none;
  stroke: var(--equity-ink);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.equity-baseline {
  stroke: var(--border);
  stroke-width: 1;
  stroke-dasharray: 2 3;
}

.equity-crosshair {
  stroke: var(--text-faint);
  stroke-width: 1;
  display: none;
}

.equity-marker {
  display: none;
  fill: var(--equity-ink);
  stroke: var(--bg-inset);
  stroke-width: 2;
}

.equity-plot.live .equity-crosshair,
.equity-plot.live .equity-marker {
  display: block;
}

.equity-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: var(--tooltip-left, 0);
  z-index: var(--z-callout);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px;
  background: var(--bg-panel);
  border: 1px solid var(--pop-border);
  border-radius: var(--radius-small);
  box-shadow: var(--shadow);
  font: 400 11px/1.3 var(--mono);
  color: var(--text-dim);
  white-space: nowrap;
}

.equity-tooltip.leftward {
  transform: translateX(-100%);
}

.equity-value {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}

.equity-delta.positive {
  color: var(--green-ink);
}

.equity-delta.negative {
  color: var(--red-ink);
}

/* ==== 6. The rail-and-pane dialogs ==== */

.dialog-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px var(--gutter) 24px;
  z-index: var(--z-dialog);
  overflow-y: auto;
}

.dialog {
  width: 720px;
  max-width: 100%;
  background: var(--bg-panel);
  border: 1px solid var(--pop-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-dialog);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dialog-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px var(--gutter);
  border-bottom: 1px solid var(--border);
}

.dialog-head h3 {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.dialog-body {
  display: grid;
  grid-template-columns: 196px 1fr;
}

.dialog-rail {
  padding: 18px var(--gutter) 18px 18px;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-inset) 45%, var(--bg-panel));
}

.dialog-pane {
  padding: var(--gutter) 18px;
  min-height: 320px;
  display: flex;
  flex-direction: column;
}

.dialog-step {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  flex: 1;
}

.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: auto;
  padding-top: 6px;
}

.dialog-actions .button.quiet {
  margin-right: auto;
}

.rotation-identity,
.verify-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
}

/* ==== 7. The check list (modules/PORTFOLIOS#preflight) ==== */

.check-list {
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  overflow: hidden;
}

.check-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-inset);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.check-count[data-state="passed"] {
  color: var(--green);
}

.check-count[data-state="failed"] {
  color: var(--red);
}

.check-rows {
  list-style: none;
  margin: 0;
  padding: 4px 0;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 5px 10px;
  font-size: 12px;
}

.check-mark {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font: 700 9px/1 var(--mono);
  flex: none;
  margin-top: 2px;
  background: var(--gray-dim);
  color: var(--text-faint);
}

.check-row[data-state="passed"] .check-mark {
  background: var(--green-dim);
  color: var(--green);
}

.check-row[data-state="failed"] .check-mark {
  background: var(--red-dim);
  color: var(--red);
}

.check-row[data-state="running"] .check-mark {
  color: transparent;
  box-shadow: inset 0 0 0 2px var(--border);
}

.check-text {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.check-detail {
  font-size: 11px;
  color: var(--text-dim);
  overflow-wrap: anywhere;
}

.check-row[data-state="failed"] .check-detail {
  color: var(--red);
}
