/* Periodic table: the styles for periodic-table.js. Everything is scoped to .pt, and the table sizes itself to
   its container: names and weights on wide screens, fewer details as it narrows, and a sideways scroll on a phone. */
.pt {
    --pt-ink: #18202b; --pt-soft: #586170; --pt-line: #dde2e9; --pt-paper: #fff; --pt-accent: #2454eb;
    --pt-mono: ui-monospace, "Cascadia Code", Consolas, monospace;
    --pt-gap: 4px;
    --pt-color: #e7ebf1;
    container-type: inline-size;
    color: var(--pt-ink);
    line-height: 1.65;
}
/* Self-contained: the table looks the same on any page, whatever that page's own base styles are. */
.pt, .pt * { box-sizing: border-box; }
.pt [hidden] { display: none; }
/* One color per family. Change these freely: the data only says which family an element is in. */
.pt [data-family="alkali-metal"] { --pt-color: #ff9aac; }
.pt [data-family="alkaline-earth-metal"] { --pt-color: #ffc56b; }
.pt [data-family="transition-metal"] { --pt-color: #b4c6ff; }
.pt [data-family="post-transition-metal"] { --pt-color: #ff7957; }
.pt [data-family="metalloid"] { --pt-color: #8bd8c4; }
.pt [data-family="nonmetal"] { --pt-color: #c3e58f; }
.pt [data-family="halogen"] { --pt-color: #f4e373; }
.pt [data-family="noble-gas"] { --pt-color: #cfbcff; }
.pt [data-family="lanthanide"] { --pt-color: #9fdcf1; }
.pt [data-family="actinide"] { --pt-color: #f1b3ec; }

.pt button { font: inherit; color: inherit; cursor: pointer; }
.pt button:focus-visible, .pt input:focus-visible { outline: 3px solid var(--pt-accent); outline-offset: 2px; }

.pt-legend { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 18px; }
.pt-family { display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px; border: 1px solid var(--pt-line); border-radius: 999px; background: var(--pt-paper); font-size: .78rem; line-height: 1.5; }
.pt-family::before { content: ""; width: 10px; height: 10px; border-radius: 2px; background: var(--pt-color); }
.pt-family:hover { border-color: var(--pt-soft); }
.pt-family[aria-pressed="true"] { border-color: var(--pt-ink); box-shadow: inset 0 0 0 1px var(--pt-ink); }

.pt-grid {
    --pt-cell: calc((100cqi - 17 * var(--pt-gap)) / 18);
    display: grid; gap: var(--pt-gap);
    grid-template-columns: repeat(18, minmax(0, 1fr));
    grid-template-rows: repeat(7, calc(var(--pt-cell) * 1.12)) calc(var(--pt-cell) * .3) repeat(2, calc(var(--pt-cell) * 1.12)) auto;
}
.pt-tile { min-width: 0; padding: 0; border: 0; border-radius: 3px; background: var(--pt-color); text-align: left; transition: opacity .2s, transform .15s, box-shadow .15s, background-color .2s; }
.pt-face { display: flex; flex-direction: column; justify-content: space-between; height: 100%; padding: calc(var(--pt-cell) * .07) calc(var(--pt-cell) * .09); overflow: hidden; }
.pt-number, .pt-weight { font-family: var(--pt-mono); font-size: clamp(.5rem, calc(var(--pt-cell) * .16), .68rem); line-height: 1; }
.pt-symbol { font-size: clamp(.78rem, calc(var(--pt-cell) * .36), 1.45rem); font-weight: 600; line-height: 1; letter-spacing: -.03em; }
.pt-name { font-size: clamp(.5rem, calc(var(--pt-cell) * .14), .62rem); line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt-tile:hover { transform: translateY(-2px); box-shadow: 0 5px 12px rgb(24 32 43 / .16); }
.pt-tile.is-selected { position: relative; z-index: 1; box-shadow: 0 0 0 2px var(--pt-paper), 0 0 0 4px var(--pt-ink); }
.pt-tile.is-future { background: transparent; color: var(--pt-soft); box-shadow: inset 0 0 0 1px var(--pt-line); }
.pt-tile.is-future.is-selected { box-shadow: inset 0 0 0 1px var(--pt-line), 0 0 0 2px var(--pt-paper), 0 0 0 4px var(--pt-ink); }
.pt-tile.is-new { box-shadow: 0 0 0 3px var(--pt-accent); }
.pt-tile.is-dim { opacity: .18; }
.pt-row-label { display: flex; align-items: center; justify-content: flex-end; padding-right: 6px; font: clamp(.5rem, calc(var(--pt-cell) * .17), .7rem) var(--pt-mono); color: var(--pt-soft); }

/* Details: in the empty space above the transition metals, or under the table when that space is too small. */
.pt-detail { grid-area: 1 / 3 / 4 / 13; display: flex; gap: 20px; min-width: 0; margin: 0 14px; overflow: hidden; }
.pt-detail .pt-face { flex: 0 0 auto; height: 100%; aspect-ratio: 1; padding: 12px 14px; background: var(--pt-color); border-radius: 3px; }
.pt-detail .pt-number, .pt-detail .pt-weight { font-size: .78rem; }
.pt-detail .pt-symbol { font-size: calc(var(--pt-cell) * 1.05); font-weight: 500; letter-spacing: -.06em; }
.pt-detail .pt-name { font-size: .9rem; font-weight: 600; white-space: normal; }
.pt-info { min-width: 0; padding-top: 2px; }
.pt-facts { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; margin: 0; font-size: .82rem; line-height: 1.4; }
.pt-facts dt { padding-top: 2px; font: .62rem/1.6 var(--pt-mono); text-transform: uppercase; letter-spacing: .06em; color: var(--pt-soft); }
.pt-facts dd { margin: 0; }
.pt-note { margin: 8px 0 0; font-size: .74rem; line-height: 1.45; color: var(--pt-soft); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.pt-timeline { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; align-items: center; margin-top: 22px; }
.pt-play { min-width: 76px; padding: 7px 16px; border: 1px solid var(--pt-ink); border-radius: 4px; background: var(--pt-paper); font-weight: 600; }
.pt-play:hover { background: var(--pt-ink); color: var(--pt-paper); }
.pt-timeline input { width: 100%; margin: 0; accent-color: var(--pt-accent); }
.pt-year, .pt-timeline-note { grid-column: 1 / -1; margin: 0; }
.pt-year { font-size: .88rem; }
.pt-year strong { font-family: var(--pt-mono); }
.pt-timeline-note { font-size: .76rem; color: var(--pt-soft); }
.pt-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@container (max-width: 999px) {
    .pt-name { display: none; }
    .pt-detail { grid-area: 11 / 1 / 12 / -1; margin: 14px 0 0; }
    .pt-detail .pt-face { height: 132px; }
    .pt-detail .pt-symbol { font-size: 3rem; }
    .pt-detail .pt-name { display: block; }
}
/* Phones: tiles stay large enough to tap and the table scrolls sideways; the details stay in view. */
@container (max-width: 639px) {
    .pt-legend { gap: 5px; }
    .pt-family { gap: 5px; padding: 2px 8px; font-size: .7rem; }
    .pt-grid { --pt-cell: 34px; grid-template-columns: repeat(18, var(--pt-cell)); overflow-x: auto; padding: 4px; }
    .pt-weight { display: none; }
    .pt-face { justify-content: center; gap: 1px; padding: 2px 3px; }
    .pt-detail { position: sticky; left: 0; width: calc(100cqi - 8px); flex-direction: column; gap: 12px; }
    .pt-detail .pt-face { width: 128px; height: 128px; justify-content: space-between; }
    .pt-detail .pt-symbol { font-size: 2.6rem; }
    .pt-detail .pt-weight { display: block; }
}
@media (prefers-reduced-motion: reduce) {
    .pt-tile { transition: none; }
    .pt-tile:hover { transform: none; }
}
