/*
 * Chisel Portal — compact transaction stream for phones.
 *
 * Media remains visible and independently clickable. The +/- button controls
 * only the transaction details. Explorer verification appears after expansion.
 */

/* Decoded ledger text is readable without opening the transaction. */
.portalStreamItem.hasOpReturnText .portalStreamRow > .portalStreamTitle {
  display: block;
  min-width: 0;
  overflow: visible;
  white-space: normal;
  -webkit-line-clamp: unset;
}
.portalStreamOpReturn {
  display: block;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-weight: 500;
}

/* No redundant "details" or "verify" links on a collapsed transaction. */
.portalStreamItem:not(.isExpanded) .portalStreamVerify {
  display: none;
}

/* Reclaim the unused action column on desktop as well. */
.portalStreamItem:not(.isExpanded) .portalStreamRow {
  grid-template-columns: 40px 112px 128px 70px minmax(0, 1fr);
}

@media (max-width: 760px) {
  body[data-mode="portal"] main {
    width: 100%;
    padding: 8px;
  }

  body[data-mode="portal"] .panel {
    padding: 10px;
  }

  .portalStreamPanel {
    min-height: 0;
  }

  .portalStreamHeader {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    margin-bottom: 8px;
  }

  .portalStreamHeader .actions {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .portalStreamHeader .actions > button {
    width: 100%;
    min-width: 0;
    padding: 10px 8px;
  }

  .portalStreamHeader .compactOption {
    min-width: 0;
    margin: 0;
  }

  .portalFilterBar {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: center;
    gap: 7px;
    padding: 10px;
  }

  .portalFilterBar .filterLabel,
  .portalFilterBar input[type="search"] {
    grid-column: 1 / -1;
  }

  .portalFilterBar .compactOption {
    min-width: 0;
    margin: 0;
    white-space: nowrap;
    font-size: 0.78rem;
  }

  .portalFilterBar input[type="search"] {
    width: 100%;
    min-width: 0;
    font-size: 16px;
  }

  .portalFilterBar .portalPageButton {
    min-width: 0;
    padding: 7px 3px;
    font-size: 11px;
    white-space: nowrap;
  }

  /* Let the page scroll naturally; there is only one page of rows at a time. */
  .portalTransactionList {
    min-height: 0;
    max-height: none;
    overflow: visible;
  }

  /* Media is always visible. The +/- button controls everything below it. */
  .portalStreamRow,
  .portalStreamItem:not(.isExpanded) .portalStreamRow,
  .portalStreamItem.isExpanded .portalStreamRow {
    grid-template-columns: 36px auto minmax(0, 1fr);
    grid-template-areas:
      "toggle coin title"
      "thumb thumb thumb"
      "time time time";
    gap: 3px 7px;
    min-height: 0;
    padding: 9px 8px;
  }

  .portalStreamRow > .portalExpandButton {
    grid-area: toggle;
    width: 30px;
    height: 30px;
  }

  .portalStreamRow > .portalStreamMeta,
  .portalStreamRow > .portalStreamFlags,
  .portalStreamRow > .portalStreamVerify {
    display: none;
  }

  .portalStreamRow > .portalStreamThumb {
    grid-area: thumb;
    display: flex;
    width: 100%;
    height: auto;
    min-height: 56px;
    max-height: none;
    margin-top: 5px;
    color: inherit;
    text-decoration: none;
  }

  .portalStreamRow > .portalStreamThumb.isEmpty {
    display: none;
  }

  .portalStreamRow > .portalStreamThumb.isLinked {
    cursor: pointer;
    touch-action: manipulation;
  }

  .portalStreamRow > .portalStreamThumb.isLinked:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
  }

  .portalStreamRow > .portalStreamThumb .portalStreamThumbImage {
    width: 100%;
    height: auto;
    max-height: none;
    object-fit: contain;
  }

  .portalStreamRow > .portalStreamThumb .portalStreamThumbCanvas {
    width: auto;
    height: auto;
    max-width: 100%;
  }

  .portalStreamRow > .portalStreamCoin {
    grid-area: coin;
    min-width: 38px;
    padding: 2px 5px;
    font-size: 11px;
  }

  .portalStreamRow > .portalStreamTitle {
    grid-area: title;
    display: block;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 14px;
    line-height: 1.35;
  }

  .portalStreamRow > .portalStreamTime {
    grid-area: time;
    display: block;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: #3b4652;
    font-size: 11px;
  }

  /* Verification is useful only once the row is open. */
  .portalStreamItem.isExpanded .portalStreamRow {
    grid-template-areas:
      "toggle coin title"
      "thumb thumb thumb"
      "time time verify";
  }

  .portalStreamItem.isExpanded .portalStreamRow > .portalStreamVerify {
    display: block;
    grid-area: verify;
    justify-self: end;
    align-self: center;
    margin: 0;
    white-space: nowrap;
    font-size: 12px;
  }

  .portalStreamItem.isExpanded .portalStreamVerify > a {
    margin: 0;
  }

  .portalInlineDetails {
    margin: 0 6px 8px;
    padding: 10px;
    gap: 10px;
  }

  .portalEvmMediaGrid,
  .portalEvmMediaCard {
    grid-template-columns: 1fr;
  }

  .portalEvmMediaThumb {
    width: 100%;
    height: auto;
  }

  .portalInlineImageCanvasWrap {
    padding: 6px;
  }

  .portalInlineDetails .json {
    max-height: 48vh;
  }
}

/* 2026-10 portrait: use viewport width, never desktop minimums. */
@media (max-width:760px) {
  html, body { max-width:100%; overflow-x:clip; }
  header, header .shell, main, main > section, .modePanel,
  .portalExplorerShell, .portalStreamPanel, .portalPersonalAccount,
  .portalStreamHeader, .portalTransactionList, .portalStreamItem {
    min-width:0; max-width:100%; box-sizing:border-box;
  }
  header .shell { width:100%; padding:10px 12px; }
  .topBar { min-width:0; width:100%; gap:6px; }
  .topBar > div { min-width:0; }
  .topBar h1 { font-size:1.2rem; }
  .appMenu { flex-shrink:0; }
  .appMenuContents { width:min(92vw,360px); right:0; }
  body[data-mode="portal"] main { width:100%; max-width:100%; padding:6px; }
  body[data-mode="portal"] .panel { padding:9px; }
  .portalIndexBar { grid-template-columns:minmax(0,1fr); }
  .portalIndexBar > *, .portalPersonalAccount > *, .portalPersonalAccountTop > * { min-width:0; max-width:100%; }
  .portalPersonalAccountTop, .portalStreamHeader .actions,
  .portalPersonalAccount .actions { gap:6px; }
  .portalPersonalAccount .actions { display:flex; flex-wrap:wrap; }
  .portalPersonalAccount .actions button { flex:1 1 auto; min-width:0; font-size:12px; padding:9px 8px; }
  .portalFilterBar { grid-template-columns:repeat(3,minmax(0,1fr)); padding:7px; gap:5px; }
  .portalFilterBar .compactOption { font-size:11px; overflow:hidden; }
  .portalFilterBar .compactOption input { width:15px; height:15px; }
  .portalStreamRow,
  .portalStreamItem:not(.isExpanded) .portalStreamRow,
  .portalStreamItem.isExpanded .portalStreamRow {
    grid-template-columns:16px minmax(0,1fr) auto;
    grid-template-areas:"toggle title coin" "thumb thumb thumb" "time time time";
    padding:7px 6px; gap:2px 5px; width:100%;
  }
  .portalStreamRow > .portalExpandButton {
    width:16px; height:24px; min-width:0; padding:0; border:0;
    background:transparent; color:#5b6777; box-shadow:none;
    font-size:15px; line-height:24px; grid-area:toggle;
  }
  .portalStreamRow > .portalStreamThumb {
    width:auto; min-height:0; margin-top:2px; justify-content:flex-start;
    border:0; background:transparent;
  }
  .portalStreamRow > .portalStreamThumb .portalStreamThumbImage {
    width:auto; max-width:120px; max-height:65px; object-fit:contain;
  }
  .portalStreamRow > .portalStreamTime { font-size:10px; line-height:1.1; color:#66717b; }
  .portalStreamRow > .portalStreamTitle { font-size:12px; }
  .portalStreamRow > .portalStreamCoin { font-size:10px; min-width:0; }
  .portalStreamItem.isExpanded .portalStreamRow {
    grid-template-areas:"toggle title coin" "thumb thumb thumb" "time time verify";
  }
  .portalInlineDetails, .portalExpandedBody, .portalInlineImageSide { min-width:0; max-width:100%; }
  .portalExpandedBody { grid-template-columns:minmax(0,1fr); }
}

/* 2.7.31J portrait rows: thumbnail spans metadata and descriptor lines. */
@media(max-width:760px) {
  .portalStreamRow,
  .portalStreamItem:not(.isExpanded) .portalStreamRow,
  .portalStreamItem.isExpanded .portalStreamRow {
    display:grid;
    grid-template-columns:18px 76px minmax(0,1fr) auto;
    grid-template-areas:
      "toggle thumb time coin"
      "toggle thumb title title";
    gap:3px 7px;
    align-items:center;
    min-height:55px;
    width:100%;
    padding:6px 7px;
  }
  .portalStreamRow > .portalExpandButton {
    grid-area:toggle; width:18px; height:28px; font-size:15px;
    align-self:center; background:transparent; border:0; padding:0;
  }
  .portalStreamRow > .portalStreamThumb {
    grid-area:thumb; width:76px; max-width:76px; height:46px; max-height:46px;
    min-height:0; margin:0; display:flex; justify-content:center; align-items:center;
  }
  .portalStreamRow > .portalStreamThumb.isEmpty { display:block; visibility:hidden; }
  .portalStreamRow > .portalStreamThumb .portalStreamThumbImage,
  .portalStreamRow > .portalStreamThumb .portalStreamThumbCanvas {
    max-width:76px; max-height:46px; width:auto; height:auto; object-fit:contain;
  }
  .portalStreamRow > .portalStreamTime {
    grid-area:time; font-size:10px; line-height:1.25; overflow:hidden;
    white-space:nowrap; min-width:0;
  }
  .portalStreamRow > .portalStreamCoin { grid-area:coin; justify-self:end; font-size:10px; }
  .portalStreamRow > .portalStreamTitle {
    grid-area:title; font-size:12px; line-height:1.3; min-width:0;
    white-space:normal; overflow-wrap:anywhere; overflow:visible;
    display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;
  }
  .portalStreamItem.isExpanded .portalStreamRow {
    grid-template-areas:
      "toggle thumb time coin"
      "toggle thumb title title";
  }
  .portalStreamItem.isExpanded .portalStreamRow > .portalStreamVerify { display:none; }
  .portalStreamPanel, .portalTransactionList, .portalStreamItem, .portalStreamRow { min-width:0; }
  .portalFilterBar { overflow-wrap:anywhere; }
}

/* Per-transaction satoshi ledger, never a page-level running balance. */
@media (min-width: 761px) {
  .portalStreamRow,
  .portalStreamItem:not(.isExpanded) .portalStreamRow,
  .portalStreamItem.isCompactGeneric:not(.isExpanded) .portalStreamRow,
  .portalStreamItem.isExpanded .portalStreamRow {
    grid-template-columns: 40px 112px 128px 70px minmax(0,1fr) minmax(135px,auto) auto;
  }
  .portalStreamRow > .portalStreamFinance { grid-column: 6; }
  .portalStreamRow > .portalStreamVerify { grid-column: 7; }
}
@media (max-width: 760px) {
  .portalStreamRow,
  .portalStreamItem:not(.isExpanded) .portalStreamRow,
  .portalStreamItem.isCompactGeneric:not(.isExpanded) .portalStreamRow,
  .portalStreamItem.isExpanded .portalStreamRow {
    grid-template-columns: 18px 76px minmax(0,1fr) auto;
    grid-template-areas: "toggle thumb time finance" "toggle thumb title coin";
  }
  .portalStreamRow > .portalStreamFinance {
    grid-area: finance; justify-self: end; font-size: 11px;
  }
  .portalStreamRow > .portalStreamFinanceFee { display: none; }
  .portalStreamItem.isCompactGeneric:not(.isExpanded) .portalStreamCoin { display: inline-block; }
  .portalStreamItem.isCompactGeneric:not(.isExpanded) .portalStreamTime { display: block; }
  .portalStreamRow > .portalStreamVerify { display: none; }
}
