/* Shared rules stay in public/global.css; route-specific rules live in this page CSS. */
.home-shell {
  padding-bottom: clamp(46px, 7vw, 86px);
}

.home-shell .site-footer {
  margin-top: clamp(18px, 2.2vw, 32px);
}

.treemap-home {
  display: grid;
  gap: clamp(10px, 1.6vw, 18px);
  padding-top: clamp(12px, 1.8vw, 24px);
}

.treemap-markets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: clamp(22px, 3vw, 38px);
}

.treemap-market-section {
  display: grid;
  gap: clamp(10px, 1.4vw, 16px);
}

.treemap-market-heading {
  display: grid;
  gap: 6px;
  max-width: 760px;
}

.treemap-market-heading h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(22px, 2.25vw, 31px);
  line-height: 1.05;
}

.treemap-market-heading p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.treemap-board {
  position: relative;
  aspect-ratio: 13 / 9;
  height: auto;
  min-height: 0;
  overflow: hidden;
  border-radius: 6px;
  background: #edf1f0;
}

[data-home-treemap] ~ .home-shell .treemap-board {
  background: transparent;
}

.treemap-board::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(98, 119, 127, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(98, 119, 127, 0.05) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: linear-gradient(180deg, transparent, #000 13%, #000 88%, transparent);
  pointer-events: none;
}

.treemap-board::after {
  display: none;
}

[data-home-treemap] ~ .home-shell .treemap-board::before {
  display: none;
}

.treemap-layer {
  position: absolute;
  inset: clamp(5px, 0.8vw, 10px);
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.market-tile {
  position: absolute;
  left: var(--tile-x);
  top: var(--tile-y);
  right: var(--tile-right);
  bottom: var(--tile-bottom);
  z-index: 1;
  display: grid;
  align-content: center;
  justify-items: center;
  container-type: size;
  min-width: 0;
  min-height: 0;
  padding: clamp(4px, 0.5vw, 8px);
  border: 1px solid rgba(248, 250, 249, 0.92);
  border-radius: 6px;
  color: var(--ink);
  text-align: center;
  text-decoration: none;
  opacity: 0;
  transform: scale(0.985);
  transition: background 0.16s ease;
  animation: treemap-tile-enter 0.34s cubic-bezier(0.2, 0.8, 0.24, 1) var(--tile-delay) forwards;
}

@media (min-width: 800px) {
  .treemap-layer {
    inset: 0;
  }
}

.market-tile:hover {
  color: var(--ink);
  text-decoration: none;
  outline: 0;
}

.market-tile:focus-visible {
  color: var(--ink);
  text-decoration: none;
  outline: 2px solid rgba(8, 16, 20, 0.34);
  outline-offset: -3px;
}

.market-tile[data-tone="up"] {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), transparent 62%),
    var(--tile-bg);
}

.market-tile[data-tone="down"] {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), transparent 62%),
    var(--tile-bg);
}

.market-tile[data-tone="flat"] {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), transparent 62%),
    var(--tile-bg);
}

.market-tile[data-tone]:hover {
  background:
    linear-gradient(rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.16)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 62%),
    var(--tile-bg);
}

.tile-symbol {
  max-width: 100%;
  overflow: hidden;
  color: #fff;
  font-size: clamp(9px, min(var(--tile-symbol-size), 24cqw, 36cqh), 32px);
  font-weight: 900;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-change {
  max-width: 100%;
  overflow: hidden;
  margin-top: 5px;
  color: rgba(255, 255, 255, 0.96);
  font-size: clamp(8px, min(var(--tile-change-size), 15cqw, 20cqh), 18px);
  font-weight: 800;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-tile[data-density="compact"] {
  padding: 3px;
}

.market-tile[data-density="micro"] {
  align-content: center;
  padding: 2px;
}

.market-tile[data-density="micro"] .tile-symbol {
  letter-spacing: -0.04em;
}

.market-tile[data-density="micro"] .tile-change {
  margin-top: 2px;
}

.treemap-empty {
  position: absolute;
  inset: 50% auto auto 50%;
  margin: 0;
  color: var(--muted);
  transform: translate(-50%, -50%);
}

@keyframes treemap-tile-enter {
  from {
    opacity: 0;
    transform: scale(0.985);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (max-width: 1180px) {
  .treemap-home {
    min-height: auto;
  }

  .treemap-markets {
    grid-template-columns: 1fr;
  }

  .treemap-board {
    aspect-ratio: 16 / 9;
    margin-inline: -10px;
  }

  .market-tile {
    left: var(--tile-mobile-x);
    top: var(--tile-mobile-y);
    right: var(--tile-mobile-right);
    bottom: var(--tile-mobile-bottom);
    padding: 4px;
    border-width: 1px;
  }

  .tile-symbol {
    font-size: clamp(7px, min(calc(var(--tile-mobile-symbol-size) * 0.45 + 1.45vw), 28cqw, 36cqh), 28px);
  }

  .tile-change {
    margin-top: 3px;
    font-size: clamp(6px, min(calc(var(--tile-mobile-change-size) * 0.45 + 0.95vw), 17cqw, 19cqh), 17px);
  }
}

@media (max-width: 799px) {
  [data-home-treemap] ~ .home-shell .treemap-board {
    margin-inline: calc((clamp(16px, 4vw, 64px) + 1px) * -1);
  }

  [data-home-treemap] ~ .home-shell .treemap-layer {
    inset-inline: 2px;
  }
}

@media (min-width: 800px) and (max-width: 1180px) {
  .treemap-board {
    aspect-ratio: 20 / 9;
  }

  .market-tile {
    left: var(--tile-tablet-x);
    top: var(--tile-tablet-y);
    right: var(--tile-tablet-right);
    bottom: var(--tile-tablet-bottom);
  }

  .tile-symbol {
    font-size: clamp(12px, min(calc(var(--tile-tablet-symbol-size) * 0.62 + 1.1vw), 28cqw, 36cqh), 28px);
  }

  .tile-change {
    font-size: clamp(8px, min(calc(var(--tile-tablet-change-size) * 0.58 + 0.75vw), 17cqw, 19cqh), 17px);
  }
}

@media (max-width: 680px) {

  [data-home-treemap] ~ .home-shell .treemap-board {
    margin-inline: -13px;
  }
}
