/* map.arbou.live, the board: the rectangles of one GICS level, their badges and chart icon, the
   hover card. Its custom properties (--hm-*) come from shell.css. */

/* The board. */
.hm__canvas {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    margin: 0 12px 12px;
    padding: 10px;
    overflow-x: hidden;
    overflow-y: auto;
    border-radius: 18px;
    background:
        radial-gradient(1200px 600px at 50% -20%, rgb(80 100 160 / 18%), rgb(80 100 160 / 0%) 70%),
        #0b0e14;
    scrollbar-color: #2b3240 transparent;
}

.hm__stage {
    --hm-name: 14px;
    --hm-change: 20px;
    --hm-meta: 11.5px;
    position: relative;
}

/* Rectangles: one level per view. The type scale is set per view from the size they share
   (--hm-name, --hm-change, --hm-meta), so every rectangle of a view reads the same. */
.hm-tile {
    position: absolute;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 8px;
    margin: 0;
    padding: clamp(9px, .9vw, 14px) clamp(11px, 1vw, 16px);
    overflow: hidden;
    border: 0;
    border-radius: 12px;
    background:
        linear-gradient(155deg, rgb(255 255 255 / 12%), rgb(255 255 255 / 0%) 48%, rgb(0 0 0 / 14%)),
        var(--tile);
    box-shadow: inset 0 0 0 1px rgb(255 255 255 / 7%), 0 12px 26px -20px rgb(0 0 0 / 85%);
    color: #ffffff;
    font: inherit;
    text-align: left;
    cursor: default;
    transition: transform .2s cubic-bezier(.2, .8, .2, 1), box-shadow .2s ease, filter .2s ease;
}

.hm-tile:hover {
    filter: brightness(1.06);
    box-shadow: inset 0 0 0 1.5px rgb(255 255 255 / 50%), 0 12px 26px -20px rgb(0 0 0 / 85%);
}

/* A segment opens its next level: it lifts, and its arrow shows. */
.hm-tile.is-link {
    cursor: pointer;
}

.hm-tile.is-link:hover {
    filter: brightness(1.09) saturate(1.05);
    box-shadow: inset 0 0 0 2px rgb(255 255 255 / 70%), 0 18px 34px -18px rgb(0 0 0 / 90%);
    transform: translateY(-2px);
}

.hm-tile.is-link:focus-visible {
    outline: 3px solid #8fb0ff;
    outline-offset: 2px;
}

/* Bottom right: the TOP N rank, and the market cap under it, in the same type. */
.hm-tile__side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    min-width: 0;
    text-align: right;
}

.hm-tile__head {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.hm-tile__name {
    display: -webkit-box;
    min-width: 0;
    overflow: hidden;
    font-size: var(--hm-name);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -.01em;
    overflow-wrap: break-word;
    hyphens: auto;
    text-shadow: 0 1px 2px rgb(0 0 0 / 22%);
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.hm-tile__company {
    overflow: hidden;
    font-size: var(--hm-meta);
    font-weight: 560;
    opacity: .82;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hm-tile__foot {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 10px;
    min-width: 0;
}

.hm-tile__change {
    font-size: var(--hm-change);
    font-weight: 800;
    line-height: 1;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
    flex: none;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgb(0 0 0 / 18%);
}

.hm-tile__meta {
    overflow: hidden;
    font-size: var(--hm-meta);
    font-weight: 620;
    font-variant-numeric: tabular-nums;
    opacity: .82;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Entrance: the rectangles rise one after the other when a view opens. */
.hm__stage.is-entering .hm-tile {
    animation: hm-rise .5s cubic-bezier(.2, .8, .2, 1) both;
    animation-delay: calc(var(--i, 0) * 28ms);
}

@keyframes hm-rise {
    from {
        opacity: 0;
        transform: translateY(12px) scale(.98);
    }
}

.hm__loading {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #aab3c2;
    font-size: 14px;
}

.hm.is-loading .hm__loading {
    display: flex;
}

.hm__loading span {
    width: 16px;
    height: 16px;
    border: 2px solid #3a4150;
    border-top-color: #aab3c2;
    border-radius: 50%;
    animation: hm-spin .8s linear infinite;
}

@keyframes hm-spin {
    to { transform: rotate(360deg); }
}

.hm__error {
    position: absolute;
    bottom: 28px;
    left: 50%;
    z-index: 5;
    max-width: min(560px, calc(100% - 48px));
    margin: 0;
    padding: 10px 16px;
    border-radius: 12px;
    background: #fff4e5;
    color: #8a4b00;
    font-size: 13px;
    box-shadow: 0 12px 30px -12px rgb(0 0 0 / 45%);
    transform: translateX(-50%);
}

/* Hover card: dark, like the board it describes. */
.hm-tip {
    position: absolute;
    z-index: 20;
    width: 290px;
    padding: 14px 16px;
    border: 1px solid #2a303c;
    border-radius: 14px;
    background: rgb(15 18 25 / 96%);
    color: #e8ecf3;
    font-size: 12.5px;
    line-height: 1.4;
    box-shadow: 0 24px 48px -18px rgb(0 0 0 / 65%);
    backdrop-filter: blur(6px);
    pointer-events: none;
}

.hm-tip p {
    margin: 0;
}

.hm-tip__title {
    font-size: 14px;
    font-weight: 720;
    letter-spacing: -.01em;
}

.hm-tip dl {
    display: grid;
    gap: 5px;
    margin: 10px 0 0;
}

.hm-tip dl div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.hm-tip dt {
    color: #949fb2;
}

.hm-tip dd {
    margin: 0;
    font-weight: 660;
    font-variant-numeric: tabular-nums;
}

.hm-tip .is-up {
    color: #5fe39a;
}

.hm-tip .is-down {
    color: #ff8a93;
}

.hm-tip__moves {
    display: grid;
    gap: 3px;
    margin: 11px 0 0;
    padding: 10px 0 0;
    border-top: 1px solid #262c37;
    list-style: none;
    font-variant-numeric: tabular-nums;
}

.hm-tip__moves li {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.hm-tip__moves li span:first-child {
    min-width: 0;
    overflow: hidden;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hm-tip__moves em {
    color: #7f8a9e;
    font-style: normal;
    font-weight: 500;
}

.hm-tip__gap {
    justify-content: center !important;
    color: #5d6779;
}

@media (max-width: 760px) {
    .hm {
        padding: 8px;
    }

    .hm__card {
        height: calc(100dvh - 16px);
        border-radius: 16px;
    }

    .hm__bar {
        padding: 10px 10px 8px;
    }

    .hm__canvas {
        margin: 0 8px 8px;
        padding: 8px;
        border-radius: 14px;
    }

    .hm-tip {
        width: min(290px, calc(100vw - 96px));
    }
}

@media (prefers-reduced-motion: reduce) {
    .hm-tile {
        transition: none;
    }

    .hm__stage.is-entering .hm-tile,
    .hm__loading span,
    .hm__filter--period[aria-busy="true"] span {
        animation: none;
    }
}

.hm-tip__note {
    margin-top: 10px !important;
    color: #8590a4;
    font-size: 11.5px;
}

/* Index badges (Nasdaq, SOX, S&P 400, S&P 600), on a company the S&P 500 does not hold; segments and
   categories wear none. The name keeps the row; the badge sits at its right, and drops under it when
   the rectangle is too narrow for both. */
.hm-tile__top {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 6px 10px;
    min-width: 0;
}

.hm-tile__top > .hm-tile__head {
    flex: 1 1 110px;
    min-width: 0;
}

.hm-tile__indexes {
    display: flex;
    flex: none;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    margin-left: auto;
}

.hm-tile__index {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px 4px 6px;
    border-radius: 999px;
    background: rgb(255 255 255 / 94%);
    box-shadow: 0 2px 8px rgb(0 0 0 / 18%);
    color: #0b2a4a;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: .01em;
    white-space: nowrap;
    text-shadow: none;
}

.hm-tile__index svg {
    flex: none;
    width: 16px;
    height: 16px;
}

/* Chart icon at the top right of every rectangle, down to the companies. It is placed
   beside the rectangle at its top right corner; the name and the badges leave it room. */
.hm-tile.has-chart > :first-child {
    margin-right: 34px;
}

.hm-tile__chart {
    position: absolute;
    z-index: 2;
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    margin: calc(clamp(9px, .9vw, 14px) - 3px) 0 0 calc(-28px - clamp(11px, 1vw, 16px) + 3px);
    padding: 0;
    border: 1px solid rgb(255 255 255 / 30%);
    border-radius: 9px;
    background: rgb(255 255 255 / 16%);
    box-shadow: 0 2px 8px rgb(0 0 0 / 18%);
    color: #ffffff;
    cursor: pointer;
    transition: background-color .16s ease, color .16s ease, transform .16s ease;
}

.hm-tile__chart svg {
    width: 16px;
    height: 16px;
}

.hm-tile__chart:hover {
    border-color: #ffffff;
    background: #ffffff;
    color: var(--hm-ink);
    transform: translateY(-1px);
}

.hm-tile__chart:focus-visible {
    outline: 3px solid #8fb0ff;
    outline-offset: 2px;
}

.hm__stage.is-entering .hm-tile__chart {
    animation: hm-rise .5s cubic-bezier(.2, .8, .2, 1) both;
    animation-delay: calc(var(--i, 0) * 28ms);
}
