/*
 * Hartii Biome Explorer — homepage room + the three detail pages.
 *
 * Uses base.css's tokens only (ink/line/red/fg/mono/etc) — no new palette, no new font. Loaded on
 * the homepage (after rooms.css, inside the room stage) and standalone on block.html/tx.html/
 * address.html (plain pages, same as documents.html), so every rule here has to stand on its own
 * without assuming rooms.css is present.
 */

/* ------------------------------------------------------------ shared bits (home + detail pages) */
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.sw-empty { padding: 14px 16px; font-size: 12.5px; color: var(--fg-3); }

/* ------------------------------------------------------------------------------ home room search */
.xp-search { display: flex; gap: 10px; margin-top: 24px; max-width: 520px; }
.xp-search input {
  flex: 1; min-width: 0; font: 400 14px/1 var(--mono); color: var(--fg);
  background: rgba(255,255,255,.03); border: 1px solid var(--line-2); border-radius: 11px;
  padding: 13px 14px; outline-offset: 2px;
}
.xp-search input::placeholder { color: var(--fg-3); }
.xp-search input:focus-visible { border-color: var(--red-hi); }
.xp-search-status { min-height: 1.2em; margin-top: 8px; font-size: 12.5px; color: var(--warn); }

.xp-search-inline { max-width: 460px; margin-top: 18px; }

/* ------------------------------------------------------------------------------ stats strip */
.xp-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 26px; max-width: 640px; }
.xp-stat {
  padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line-2);
  background: linear-gradient(160deg, rgba(25,17,19,.92), rgba(11,7,8,.8));
}
.xp-stat .v { font: 700 clamp(1.05rem, 2vw, 1.35rem)/1.1 var(--display); letter-spacing: -.02em; }
.xp-stat .k { font-size: 10.5px; color: var(--fg-3); margin-top: 5px; text-transform: uppercase; letter-spacing: .06em; }

/* ------------------------------------------------------------------------------ two live lists */
.explorer-scene { grid-template-columns: minmax(0, 1fr) !important; max-width: 1040px; gap: 22px !important; }
.xp-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 26px; }
.xp-panel { max-height: 420px; overflow-y: auto; }
.xp-panel-link { font-size: 11.5px; color: var(--fg-3); text-decoration: none; white-space: nowrap; }
.xp-panel-link:hover { color: var(--fg); }

.xp-row {
  display: grid; grid-template-columns: 1fr auto auto auto auto; align-items: center; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--fg);
  transition: background .15s;
}
.xp-row:hover { background: rgba(255,255,255,.03); }
.xp-row:last-child { border-bottom: 0; }
.xp-row-main { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xp-row-sub { font-size: 12px; color: var(--fg-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xp-row-meta { font-size: 11.5px; color: var(--fg-3); }
.xp-row-time { font-size: 11px; color: var(--fg-3); }
.xp-row-tags { display: inline-flex; align-items: center; justify-content: flex-end; gap: 5px; min-width: 0; }
.xp-miner-tag { display: inline-flex; align-items: center; gap: 4px; max-width: 180px; min-width: 0; padding: 2px 5px 2px 3px; border: 1px solid color-mix(in srgb, var(--miner-tag-color, var(--line-2)) 52%, var(--line-2)); border-radius: 999px; background: rgba(255,255,255,.025); color: var(--fg-2); }
.xp-miner-tag-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 10px/1 var(--mono); max-width: 128px; }
.xp-miner-tag-badge .pixel-badge, .xp-wall-event-badge .pixel-badge { width: 26px; height: 18px; border: 0; border-radius: 4px; box-shadow: none; }
.xp-wall-event-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; padding: 1px; border: 1px solid color-mix(in srgb, var(--red-hi) 48%, var(--line-2)); border-radius: 5px; background: rgba(255, 86, 148, .06); text-decoration: none; }

@keyframes xpRowIn { from { opacity: 0; transform: translateY(-6px); background: color-mix(in srgb, var(--ok) 12%, transparent); } to { opacity: 1; transform: none; } }
.xp-row-in { animation: xpRowIn .6s ease-out; }
@media (prefers-reduced-motion: reduce) { .xp-row-in { animation: none; } }

/* ------------------------------------------------------------------------------ detail pages (plain, non-room) */
.xp-addr-h1 { font-size: clamp(1.1rem, 3vw, 1.6rem); word-break: break-all; }
.xp-status { color: var(--fg-2); font-size: 14px; padding: 16px 0; }

.xp-panel-box {
  border-radius: 14px; border: 1px solid var(--line-2); overflow: hidden;
  background: linear-gradient(160deg, rgba(25,17,19,.94), rgba(11,7,8,.82));
  margin-bottom: 16px;
}
.xp-panel-box-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.xp-panel-box-head h2 { font: 500 11px/1 var(--body); letter-spacing: .16em; text-transform: uppercase; color: var(--fg-3); }

.xp-pill { display: inline-block; margin-top: 10px; font: 600 11.5px/1 var(--body); letter-spacing: .04em; padding: 6px 11px; border-radius: 999px; }
.xp-pill-ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.xp-pill-bad { background: color-mix(in srgb, var(--red-hi) 20%, transparent); color: var(--red-hi); }
.xp-pill-pending { background: rgba(255,255,255,.06); color: var(--fg-3); }

/* key/value rows */
.xp-kv { display: flex; gap: 16px; padding: 11px 18px; border-bottom: 1px solid var(--line); font-size: 13.5px; align-items: baseline; }
.xp-kv:last-child { border-bottom: 0; }
.xp-kv-k { flex: 0 0 190px; color: var(--fg-3); font-size: 12.5px; }
.xp-kv-v { flex: 1; min-width: 0; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xp-kv-v a { color: var(--fg); text-decoration: none; border-bottom: 1px solid var(--line-2); }
.xp-kv-v a:hover { color: var(--red-hi); border-color: var(--red-hi); }
.xp-kv-wrap { white-space: normal; word-break: break-all; }
.xp-kv-v:has(.xp-copy) { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.xp-copy {
  flex: 0 0 auto; min-width: 44px; min-height: 44px; padding: 8px 9px;
  border: 1px solid var(--line-2); border-radius: 8px; background: rgba(255,255,255,.03);
  color: var(--fg-2); font: 500 10px/1 var(--mono); cursor: pointer;
}
.xp-copy:hover { color: var(--fg); border-color: var(--red-hi); }

/* raw input data / code */
.xp-code-wrap { padding: 14px 18px; }
.xp-code { display: block; font: 400 12px/1.6 var(--mono); color: var(--fg-2); word-break: break-all; white-space: pre-wrap; max-height: 260px; overflow-y: auto; }

/* event logs */
.xp-log { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.xp-log:last-child { border-bottom: 0; }
.xp-log-head { font: 500 11px/1 var(--body); letter-spacing: .1em; text-transform: uppercase; color: var(--red-hi); margin-bottom: 8px; }
.xp-log .xp-kv { padding: 6px 0; border-bottom: 0; }
.xp-log .xp-kv-k { flex-basis: 90px; }

/* ------------------------------------------------------------------------------ responsive table -> cards */
.xp-table-wrap { overflow-x: auto; }
.xp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.xp-table th { text-align: left; font: 500 10.5px/1 var(--body); letter-spacing: .1em; text-transform: uppercase; color: var(--fg-3); padding: 12px 16px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.xp-table td { padding: 11px 16px; border-bottom: 1px solid var(--line); color: var(--fg-2); white-space: nowrap; }
.xp-table tr:last-child td { border-bottom: 0; }
.xp-table td a { color: var(--fg); text-decoration: none; border-bottom: 1px solid var(--line-2); }
.xp-table td a:hover { color: var(--red-hi); border-color: var(--red-hi); }

@media (max-width: 700px) {
  .xp-table thead { display: none; }
  .xp-table, .xp-table tbody, .xp-table tr, .xp-table td { display: block; width: 100%; }
  .xp-table tr { border-bottom: 1px solid var(--line-2); padding: 10px 4px; }
  .xp-table td {
    border-bottom: 0; padding: 5px 12px; white-space: normal; word-break: break-all;
    display: flex; justify-content: space-between; gap: 12px; text-align: right;
  }
  .xp-table td::before { content: attr(data-label); color: var(--fg-3); font-size: 11px; text-align: left; flex: none; padding-top: 1px; }
}

@media (max-width: 900px) {
  .xp-cols { grid-template-columns: minmax(0, 1fr); }
  .xp-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: none; }
}

@media (max-width: 560px) {
  .xp-row { grid-template-columns: 1fr auto auto; grid-template-rows: auto auto; row-gap: 3px; }
  .xp-row-sub { order: 3; }
  .xp-row-meta { display: none; }
  .xp-row-tags { grid-column: 2 / -1; grid-row: 2; }
  .xp-miner-tag { max-width: 150px; }
  .xp-kv { flex-direction: column; gap: 3px; }
  .xp-kv-k, .xp-kv-v, .xp-log .xp-kv-k { flex: none; }
  .xp-search { flex-direction: column; }
  .xp-search button { align-self: flex-start; }
  .xp-kv-v:has(.xp-copy) { align-items: flex-start; flex-wrap: wrap; justify-content: flex-start; }
  .xp-wall-index-row { grid-template-columns: auto minmax(0, 1fr); gap: 4px 8px; padding: 6px 0; }
  .xp-wall-index-message { grid-column: 2; white-space: normal; overflow-wrap: anywhere; }
  .xp-wall-index-chain { grid-column: 2; }
}

/* ------------------------------------------------------------------------- Wall of Blocks strip */
/* "Tagged blocks" strip (homepage) + "Tagged on the Wall" sections (block/tx pages) — the animated
   CSS-3D slab/tile DOM lives in wall3d/wallBlock3d.css; these rules just place it in the page. */
.xp-wall-panel { margin-top: 12px; max-height: none; padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }

/* ---------------------------------------------------------------------------------- PayLink promo */
.xp-paylink-panel { margin-top: 12px; max-height: none; }
.xp-paylink-body { padding: 14px 16px 18px; }
.xp-paylink-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.xp-paylink-actions .btn { flex: 1 1 160px; justify-content: center; min-height: 44px; }
.xp-wall-hero-link, .xp-wall-tile-link { display: block; text-decoration: none; color: inherit; }
.xp-wall-hero-host { position: relative; max-width: 360px; margin: 0 auto; }
.xp-wall-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  padding: 4px 16px 16px;
}
.xp-wall-tile-host { aspect-ratio: 1; perspective: 500px; }
.xp-wall-block-section, .xp-wall-tx-section { margin-bottom: 16px; }
.xp-wall-block-slabs, .xp-wall-tx-slabs {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  justify-content: flex-start;
}
.xp-wall-block-slabs .w3d-slab-scene, .xp-wall-tx-slabs .w3d-slab-scene { padding: 24px 12px 40px; }
.xp-wall-block-slabs .w3d-slab, .xp-wall-tx-slabs .w3d-slab { width: 220px; }
.xp-wall-slab-item { min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.xp-wall-slab-link { display: block; min-width: 0; max-width: 100%; }
.xp-wall-external-link { min-height: 44px; display: inline-flex; align-items: center; color: var(--fg-2); font-size: 11px; }
.xp-wall-index { border-top: 1px solid var(--line); padding: 14px 16px 4px; }
.xp-wall-index h4 { font: 500 11px/1 var(--body); letter-spacing: .16em; text-transform: uppercase; color: var(--fg-3); margin: 0 0 8px; }
.xp-wall-index-link { display: inline-flex; align-items: center; min-height: 44px; margin-bottom: 6px; color: var(--red-hi); text-decoration: none; font: 500 12px/1 var(--body); }
.xp-wall-index-list { display: grid; gap: 0; }
.xp-wall-index-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 10px; min-height: 44px; border-top: 1px solid var(--line); }
.xp-wall-index-block, .xp-wall-index-chain { color: var(--fg-2); text-decoration: none; white-space: nowrap; }
.xp-wall-index-block { color: var(--red-hi); font: 600 12px/1 var(--mono); }
.xp-wall-index-message { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg-2); font-size: 12px; }
.xp-wall-index-chain { font-size: 10px; }
.xp-wall-index-chain:hover, .xp-wall-index-block:hover { color: var(--fg); }

@media (max-width: 760px) {
  .nav-links a, .xp-search button, .xp-panel-link { min-height: 44px; display: inline-flex; align-items: center; }
  .xp-panel-box-head { align-items: flex-start; }
  .xp-wall-block-slabs, .xp-wall-tx-slabs { flex-direction: column; align-items: stretch; gap: 12px; }
  .xp-wall-slab-item { width: 100%; }
  .xp-wall-block-slabs .w3d-slab, .xp-wall-tx-slabs .w3d-slab { width: min(78vw, 300px); }
}

@media (hover: hover) and (pointer: fine) {
  .xp-wall-tile-link:hover .w3d-tile {
    transform: rotateY(var(--w3d-tilt-y, 0deg)) rotateX(var(--w3d-tilt-x, 0deg)) scale(1.1) translateZ(10px);
    box-shadow: 0 10px 22px -8px rgba(0, 0, 0, 0.6);
  }
}

/* Country-flag emoji inside Wall of Blocks messages, rasterized onto the pixel-grid
   canvas (see wall3d/wallPixelGrid.js's GRID_FONT_STACK, which names this same family
   directly in ctx.font — Windows ships no flag glyphs otherwise). Self-hosted (CSP
   font-src 'self'); unicode-range limits it to flag code points only. MIT, Twemoji.
   Copy of hartii-labs/public/fonts/TwemojiCountryFlags.woff2 — keep in sync with that
   file. Declared here (not just in wallBlock3d.css) so the face starts loading as
   early as possible on every page that can render a Wall block. */
@font-face {
  font-family: 'Twemoji Country Flags';
  src: url('/fonts/TwemojiCountryFlags.woff2') format('woff2');
  unicode-range: U+1F1E6-1F1FF, U+1F3F4, U+E0062-E0063, U+E0065, U+E0067, U+E006C, U+E006E, U+E0073-E0074, U+E0077, U+E007F;
  font-display: swap;
}
