/* Pantalla: a clean, full-width grid of square cards.
   The square comes from aspect-ratio on each card (pure CSS, no JS).
   The page itself scrolls; the board is a normal grid, so cards never
   collapse or overlap the way an inner-scroll + aspect-ratio layout can. */

.precyos.pantalla {
  width: 100%;
  max-width: none;
  box-sizing: border-box;
  min-height: 100vh;
  padding: 10px 14px calc(14px + env(safe-area-inset-bottom));
  background: var(--paper, #f3f5f8);
}

.pantalla-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 12px;
}
.pantalla-top .wordmark { font-size: 20px; }
.pantalla-top .wordmark span { font-size: 11px; }
.pantalla-tools { display: flex; align-items: center; gap: 8px; }
.pantalla-home { white-space: nowrap; }

/* Fill as many ~150px columns as fit → 11 on 1920, 8 on 1366, 3 on a phone. */
.pantalla-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  align-content: start;
}
@media (min-width: 1500px) {
  .pantalla-board { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); }
}

.pcard {
  aspect-ratio: 1 / 1;
  min-width: 0;
  background: #fff;
  border: 1px solid var(--line, #e3e8ee);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  overflow: hidden;
  transition: transform 0.45s ease;
}
.pcard-inner {
  height: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.pcard .code {
  font-size: 9px;
  color: var(--muted, #5f6b76);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pcard .name {
  font-size: 12px;
  font-weight: 650;
  line-height: 1.15;
  color: var(--ink, #1b1f23);
  /* full name, wrapping as needed (no clamp) */
  margin: 2px 0 0;
  word-break: break-word;
}
.pcard .phead { display: flex; align-items: flex-start; gap: 6px; min-width: 0; margin-bottom: auto; }
.pcard .ptitle { min-width: 0; flex: 1 1 auto; }
.pcard .pthumb {
  flex: 0 0 34px; width: 34px; height: 34px; box-sizing: border-box;
  border-radius: 6px; border: 1px solid var(--line, #e3e8ee); background: #fff; object-fit: contain;
}
.pcard .pthumb-ph { display: inline-flex; align-items: center; justify-content: center; background: #e8f0f8; color: #16324f; font-weight: 700; font-size: 14px; }
@media (min-width: 1500px) { .pcard .pthumb { flex-basis: 38px; width: 38px; height: 38px; } }
.pcard .prow {
  margin: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
  margin-top: 4px;
}
.pcard .price {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink, #1b1f23);
  white-space: nowrap;
}
.pcard .change {
  font-size: 11px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex: 0 0 auto;
}
.pcard .cstack { display: inline-flex; flex-direction: column; align-items: flex-end; flex: 0 0 auto; line-height: 1.1; }
.pcard .since { font-size: 9px; color: var(--muted, #6b7280); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pcard .change.up { color: #b3261e; }
.pcard .change.down { color: #0b7a3b; }
.pcard .change.same { color: var(--muted, #6b7280); font-weight: 500; }
.pcard .unit {
  font-size: 10px;
  color: var(--muted, #6b7280);
  line-height: 1.1;
  margin-top: 2px;
  /* long units wrap instead of being cut off */
  white-space: normal;
  overflow-wrap: anywhere;
}
.pcard .spark { width: 100%; height: 26px; display: block; margin-top: 4px; }
.pcard .spark path { fill: none; stroke: var(--accent, #1565c0); stroke-width: 1.4; }

/* Phones: three square cards per row, slightly smaller type. */
@media (max-width: 560px) {
  .precyos.pantalla { padding: 8px 9px calc(10px + env(safe-area-inset-bottom)); }
  .pantalla-top { margin-bottom: 8px; }
  .pantalla-top .wordmark { font-size: 17px; }
  .pantalla-board { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .pcard { border-radius: 8px; }
  .pcard-inner { padding: 5px 7px; }
  .pcard .name { font-size: 10px; line-height: 1.1; }
  .pcard .price { font-size: 13px; }
  .pcard .change { font-size: 10px; }
  .pcard .cstack { flex-direction: row; align-items: baseline; gap: 4px; }
  .pcard .since { font-size: 8px; }
  .pcard .spark { height: 14px; margin-top: 1px; flex: 0 1 auto; min-height: 6px; }
  .pcard .phead, .pcard .prow, .pcard .unit { flex-shrink: 0; }
  .pcard .unit { font-size: 8px; margin-top: 0; letter-spacing: -0.01em; }
  .pcard .code { font-size: 8px; }
  .pcard .pthumb { flex-basis: 20px; width: 20px; height: 20px; border-radius: 5px; font-size: 11px; }
  /* phones: thumbnail beside the code, name full width below */
  .pcard .phead { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 2px 4px; }
  .pcard .ptitle { display: contents; }
  .pcard .phead .name { grid-column: 1 / -1; margin: 0; }
  /* keep price and % from colliding on the narrowest cards */
  /* price and % share a line, wrapping only when they do not fit */
  .pcard .prow { margin: 1px 0 0; flex-wrap: wrap; gap: 0 4px; }
  .auth-name { max-width: 70px; }
  .auth-toggle { padding: 3px 8px 3px 3px; }
  .pantalla-home { padding: 6px 10px; font-size: 13px; }
}
@media (max-width: 360px) {
  .pantalla-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
