/* On-chain blocks. Built on the site's components (styles.css); only what they lack lives here. */

.chain-divider {
  margin: 20px 0;
  height: 1px;
  border: none;
  background: linear-gradient(to right, #e0e0e0, #f8f8f8, #e0e0e0);
  opacity: 0.7;
}

.chain-subtitle {
  margin-bottom: 12px;
  font-weight: 600;
  line-height: 1.5;
}

/* offers in the round card: who · how many · price */
.chain-offers {
  display: grid;
  row-gap: 8px;
}

.chain-offers__row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  column-gap: 16px;
  align-items: baseline;
  padding: 10px 12px;
  border-radius: 8px;
  background-color: #f7f7f7;
  color: var(--color-second);
  font-size: 14px;
  line-height: 1.4;
}

.chain-offers__row--round {
  background-color: rgba(103, 80, 239, 0.06);
}

.chain-offers__who {
  font-weight: 600;
}

.chain-offers__price {
  font-weight: 600;
  white-space: nowrap;
}

.chain-link {
  font-size: 14px;
  color: var(--color-second);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* the site resets native checkboxes (appearance: none, zero size) */
.chain-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 16px;
  font-size: 14px;
  line-height: 1.4;
  cursor: pointer;
}

.chain-checkbox input {
  appearance: auto;
  -webkit-appearance: checkbox;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 0;
}

.note--info {
  color: #0366d6;
  background-color: #0366d60d;
}

/* the icon stays by the first line, also when the note wraps (on one line it sits as before) */
.note {
  align-items: flex-start;
}

.note:before {
  margin-top: 2px;
}

/* the site's "!" icon turned upside down reads as "i"; keeps info and warning text on one edge */
.note--info:before {
  background: currentColor;
  -webkit-mask: url("../img/icons/warning.svg") center/14px 14px no-repeat;
  mask: url("../img/icons/warning.svg") center/14px 14px no-repeat;
  transform: rotate(180deg);
}

/* a stack of notes is one column of equal width, not a ragged edge */
.chain-notes {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  margin-top: 16px;
}

.chain-notes--top {
  margin: 0 0 24px;
}

.chain-balance {
  margin-bottom: 24px;
}

.chain-balance__label {
  color: var(--color-second);
  font-size: 14px;
}

.chain-balance__value {
  margin-top: 4px;
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
}

.chain-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  word-break: break-all;
}

/* a shortened address 0x1234…abcd never breaks in the middle */
.chain-mono--short {
  white-space: nowrap;
  word-break: normal;
}

/* a 14px mono field stays as tall as the 16px field next to it */
.input.chain-mono {
  line-height: 24px;
}

.chain-key {
  margin-top: 16px;
  padding: 16px;
  border-radius: 12px;
  border: 1px dashed #f5a623;
  background-color: #fffaf0;
}

@media (max-width: 767px) {
  .chain-balance__value {
    font-size: 26px;
  }

  .balance-form__group-field {
    width: 100%;
  }

  .chain-offers:not(.chain-offers--dividends) .chain-offers__row {
    grid-template-columns: 1fr auto;
  }

  .chain-offers__row .chain-offers__count {
    grid-column: 1;
  }
}

/* our tables: header and rows share one grid — fixed column widths, a hairline between rows
   instead of the site's per-cell vertical rules, the header on one line */
@media (min-width: 768px) {
  .table.chain-table td {
    border: 0;
    border-top: 1px solid var(--line-soft, #f0f0f5);
  }

  .table.chain-table th {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .table.chain-table .table__status {
    margin: 0;
  }

  /* history: the trade table is laid out for 6 columns, ours has 4; a failure reason adds a line */
  .table--trade.chain-history td {
    height: auto;
    min-height: 44px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .table--trade.chain-history th:nth-child(1),
  .table--trade.chain-history td:nth-child(1) {
    flex: 0 0 16%;
  }

  .table--trade.chain-history th:nth-child(2),
  .table--trade.chain-history td:nth-child(2) {
    flex: 0 0 46%;
  }

  .table--trade.chain-history th:nth-child(3),
  .table--trade.chain-history td:nth-child(3) {
    flex: 0 0 18%;
  }

  .table--trade.chain-history th:nth-child(4),
  .table--trade.chain-history td:nth-child(4) {
    flex: 0 0 20%;
  }

  /* portfolio: rows carry a hidden phone-only cell, so the right-hand columns count from the end */
  .table--project.chain-portfolio th:nth-child(2),
  .table--project.chain-portfolio td:nth-child(2) {
    flex: 1 1 auto;
    min-width: 0;
  }

  .table--project.chain-portfolio th:nth-last-child(4),
  .table--project.chain-portfolio td:nth-last-child(4),
  .table--project.chain-portfolio th:nth-last-child(3),
  .table--project.chain-portfolio td:nth-last-child(3) {
    flex: 0 0 13%;
  }

  .table--project.chain-portfolio th:nth-last-child(2),
  .table--project.chain-portfolio td:nth-last-child(2) {
    flex: 0 0 24%;
  }

  .table--project.chain-portfolio th:nth-last-child(1),
  .table--project.chain-portfolio td:nth-last-child(1) {
    flex: 0 0 20%;
  }
}

/* my listings: one card per listing */
.chain-listings {
  display: grid;
  row-gap: 12px;
}

.chain-listing {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 24px;
  border: 1px solid var(--line, #e8e8f0);
  border-radius: var(--card-radius, 16px);
  background-color: #fff;
  box-shadow: var(--card-shadow, none);
}

.chain-listing__title {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 600;
}

.chain-listing__meta {
  color: var(--color-second);
  font-size: 14px;
  font-weight: 400;
}

.chain-listing__price {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chain-listing__price .input {
  width: 110px;
}

@media (max-width: 767px) {
  .chain-listing {
    flex-direction: column;
    align-items: stretch;
  }

  .chain-listing__price {
    flex-wrap: wrap;
  }
}

/* key figures as tiles */
.chain-stats {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.chain-stats--plain {
  margin-top: 16px;
}

.chain-stat {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 12px;
  background-color: #f6f6fa;
}

.chain-stat__label {
  color: var(--text-muted, rgba(47, 43, 67, 0.56));
  font-size: 12px;
  line-height: 1.3;
}

.chain-stat__value {
  color: var(--color-second);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
}

.chain-stat__value small {
  color: var(--text-muted, rgba(47, 43, 67, 0.56));
  font-size: 12px;
  font-weight: 500;
}

@media (max-width: 400px) {
  .chain-stat {
    padding: 10px 10px;
  }

  .chain-stat__value {
    font-size: 15px;
  }

  .chain-stat__value small {
    display: block;
  }
}

@media (max-width: 340px) {
  .chain-stats {
    grid-template-columns: minmax(0, 1fr);
  }
}

.chain-stat--accent {
  background: linear-gradient(135deg, rgba(100, 77, 237, 0.12), rgba(79, 123, 255, 0.08));
}

.chain-stat--accent .chain-stat__value {
  color: var(--color-primary);
}

.chain-progress {
  margin-top: 12px;
}

.chain-progress__label {
  display: block;
  margin-top: 6px;
  color: var(--text-muted, rgba(47, 43, 67, 0.56));
  font-size: 12px;
}

.chain-onchain {
  display: inline-block;
  margin-top: 12px;
}

/* round browser + market card in the project's right column */
.chain-round-title {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  text-align: center;
}

.status--muted {
  background-color: #efeff4;
  color: var(--text-muted, rgba(47, 43, 67, 0.56));
}

.chain-market {
  margin-top: 16px;
}

.chain-market__title {
  margin-bottom: 16px;
}

/* "Start a new round" is a link: as wide as the button-elements around it */
.chain-market a.btn {
  display: block;
  text-align: center;
}

/* phones: long operation names wrap instead of leaving the card; four balance tabs fit */
@media (max-width: 767px) {
  .chain-history td > span:not(.table__label) {
    min-width: 0;
    white-space: normal;
    overflow-wrap: break-word;
    text-align: right;
  }

  .chain-history .chain-link {
    white-space: nowrap;
  }
}

/* wider screens: a balance tab label stays on one line ("Top up") */
@media (min-width: 768px) {
  .content__header-btns .tabs-btns__btn {
    white-space: nowrap;
  }
}

@media (max-width: 400px) {
  .content__header-btns .tabs-btns__btn {
    padding-left: 10px;
    padding-right: 10px;
  }
}

/* own listing in the offers list: edit button; owner block buttons */
.chain-offers__row--mine {
  grid-template-columns: 1fr auto auto auto;
}
.chain-offers__actions {
  white-space: nowrap;
}
.chain-offers__actions .chain-link {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font: inherit;
}
.chain-manage__btns .btn {
  width: 100%;
  margin-top: 12px;
}
.chain-lot-popup {
  padding: 32px;
}

/* dividend history: per-share amount with the on-chain total under it (stacked, also in phone cards) */
.chain-dividend-cell {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
}
.chain-dividend-cell__more {
  font-size: 13px;
}
@media (max-width: 767px) {
  .chain-dividend-cell {
    align-items: flex-end;
    text-align: right;
  }
}

/* the project-in-numbers card: same gap to the round card as between the other cards */
.chain-summary {
  margin-bottom: 20px;
}

/* owner block: the last card of the column */
.chain-manage {
  margin-top: 20px;
}

/* "in progress" card: operations sent to the network, not shown on the page yet */
.chain-pending {
  margin-bottom: 20px;
  padding: 16px 20px;
  border-left: 4px solid var(--color-primary, #644ded);
}
.chain-pending--hidden {
  display: none;
}
.chain-pending__title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}
.chain-pending--done .chain-spinner,
.chain-pending--done .chain-pending__tip {
  display: none;
}
.chain-pending__list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}
.chain-pending__item {
  padding: 2px 0;
}
.chain-pending__item--failed {
  color: var(--color-red, #e5484d);
}
.chain-pending__tip {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-muted, rgba(47, 43, 67, 0.56));
}
.chain-spinner {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border: 2px solid rgba(100, 77, 237, 0.25);
  border-top-color: var(--color-primary, #644ded);
  border-radius: 50%;
  animation: chain-spin 0.8s linear infinite;
}
@keyframes chain-spin {
  to { transform: rotate(360deg); }
}

.chain-pending__failed-title,
.chain-pending--done .chain-pending__now {
  display: none;
}
.chain-pending--done .chain-pending__failed-title {
  display: inline;
}
.chain-pending--done {
  border-left-color: var(--color-red, #e5484d);
}

/* «Для акционеров» on the project page */
.project-shareholders__text {
  margin-bottom: 16px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.project-shareholders__tip {
  display: block;
  margin-top: 8px;
}
.project-shareholders__edit {
  width: 100%;
  margin-top: 12px;
}
/* MAX in the buy form: a small pill inside the count field */
.chain-buy__count {
  padding-right: 72px;
  -moz-appearance: textfield;
  appearance: textfield;
}

.chain-buy__count::-webkit-outer-spin-button,
.chain-buy__count::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.chain-max {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  z-index: 1;
  padding: 5px 10px;
  border-radius: 8px;
  background-color: rgba(var(--color-primary--rgb), 0.1);
  color: var(--color-primary);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

.chain-max:hover,
.chain-max:focus-visible {
  background-color: var(--color-primary);
  color: #fff;
  outline: none;
}

.chain-max:disabled {
  background-color: rgba(var(--color-second--rgb), 0.06);
  color: rgba(var(--color-second--rgb), 0.35);
  cursor: not-allowed;
}

.chain-max__tip {
  margin-top: 6px;
  font-size: 13px;
}

.chain-max__tip[hidden] {
  display: none;
}

/* header: BTC left on the old balance, next to the USD balance */
.user-balance__value--btc {
  background-color: #f7931a;
  box-shadow: 0 6px 16px -8px rgba(247, 147, 26, 0.7);
}

/* a text amount field with MAX inside (withdraw, BTC) */
.chain-max-input {
  padding-right: 72px;
}
