/* ══════════════════════════════════════════════════════════════
   AEROFIELD — PERIODIC TABLE · QUANTUM OBSERVATORY
   118 Elements · |ψ|² Probability Cloud Visualization
   VIEWPORT-FIT · NO SCROLL · GLOWING TILES
   ══════════════════════════════════════════════════════════════ */

/* ── LOADING ──────────────────────────────────────────────── */
.pt-loading {
    position: fixed; inset: 0; z-index: 9999;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    background: #060610;
    transition: opacity 0.8s ease;
}
.pt-loading.hidden { opacity: 0; pointer-events: none; }
.pt-loading-atom {
    font-size: 64px;
    animation: ptAtomSpin 2s linear infinite;
    filter: drop-shadow(0 0 30px rgba(99,102,241,0.7));
}
.pt-loading-text {
    font-family: var(--font-display, 'Cinzel', serif);
    font-size: 18px; color: #9d9aff; letter-spacing: 3px;
    margin-top: 16px; text-transform: uppercase;
}
.pt-loading-sub {
    font-family: var(--font-ui, 'Rajdhani', sans-serif);
    font-size: 12px; color: rgba(139,142,255,0.4); margin-top: 6px;
}
@keyframes ptAtomSpin { to { transform: rotate(360deg); } }

/* ── PAGE BASE — NO SCROLL ────────────────────────────────── */
html, body {
    margin: 0; padding: 0;
    width: 100vw; height: 100vh;
    overflow: hidden;
    background: #060610;
    color: var(--text-primary, #e8e4dc);
    font-family: var(--font-body, 'Inter', sans-serif);
}

/* ── NAVBAR ───────────────────────────────────────────────── */
.pt-nav {
    position: fixed; top: 0; left: 0; right: 0;
    height: 40px; z-index: 100;
    display: flex; align-items: center;
    padding: 0 20px; gap: 12px;
    background: rgba(6,6,16,0.92);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(99,102,241,0.1);
}
.pt-nav-brand {
    font-family: var(--font-display, 'Cinzel', serif);
    font-size: 12px; font-weight: 700;
    color: #8b8eff; text-decoration: none;
    letter-spacing: 2px; white-space: nowrap;
}
.pt-nav-sub {
    font-family: var(--font-ui, 'Rajdhani', sans-serif);
    font-size: 10px; color: rgba(139,142,255,0.3);
    letter-spacing: 1px; white-space: nowrap;
}
.pt-nav-right { margin-left: auto; }
.pt-search {
    background: rgba(99,102,241,0.06);
    border: 1px solid rgba(99,102,241,0.15);
    border-radius: 5px; padding: 4px 12px;
    color: #c8c6ff; font-family: var(--font-ui, 'Rajdhani', sans-serif);
    font-size: 12px; outline: none; width: 170px;
    transition: border-color 0.2s, background 0.2s;
}
.pt-search:focus {
    border-color: rgba(99,102,241,0.4);
    background: rgba(99,102,241,0.1);
}
.pt-search::placeholder { color: rgba(139,142,255,0.25); }

/* ── TABLE WRAPPER — FILLS ENTIRE VIEWPORT ────────────────── */
.pt-wrapper {
    position: fixed;
    top: 40px; left: 0; right: 0; bottom: 24px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 4px 10px 2px;
    overflow: hidden;
}

/* ══════════════════════════════════════════════════════════════
   PERIODIC TABLE GRID — viewport-proportioned
   18 columns x 10 rows (7 periods + thin gap + 2 f-block)
   Uses 1fr to auto-fill entire available area
   ══════════════════════════════════════════════════════════════ */
.pt-grid {
    display: grid;
    grid-template-columns: repeat(18, 1fr);
    grid-template-rows: repeat(7, 1fr) 0.25fr repeat(2, 1fr);
    gap: 2px;
    width: 100%;
    max-width: min(98vw, 1380px);
    height: calc(100vh - 40px - 24px - 24px - 14px);
    position: relative;
}

/* ══════════════════════════════════════════════════════════════
   ELEMENT TILE — GLOWING, VIVID, UNIQUE
   ══════════════════════════════════════════════════════════════ */
.pt-tile {
    position: relative;
    border: 1px solid var(--tile-clr, rgba(255,255,255,0.08));
    border-radius: 3px;
    background: var(--tile-bg, rgba(255,255,255,0.02));
    cursor: pointer;
    text-align: center;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 0;
    overflow: hidden;
    user-select: none;
    box-shadow:
        0 0 4px var(--tile-shadow, rgba(255,255,255,0.08)),
        0 0 12px var(--tile-shadow-outer, rgba(255,255,255,0.04)),
        inset 0 0 8px var(--tile-glow-inner, rgba(255,255,255,0.04));
    transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1),
                box-shadow 0.2s ease,
                border-color 0.2s ease,
                filter 0.2s ease;
}

/* Inner ambient glow — dual radial highlight */
.pt-tile::before {
    content: '';
    position: absolute; inset: 0;
    background:
        radial-gradient(ellipse at 35% 25%, var(--tile-glow, rgba(255,255,255,0.06)), transparent 60%),
        radial-gradient(ellipse at 70% 80%, var(--tile-glow-2, rgba(255,255,255,0.02)), transparent 50%);
    pointer-events: none;
    transition: opacity 0.2s;
}

/* Persistent bottom edge glow line */
.pt-tile::after {
    content: '';
    position: absolute; bottom: 0; left: 15%; right: 15%;
    height: 1px;
    background: var(--tile-clr-full, rgba(255,255,255,0.15));
    opacity: 0.3;
    filter: blur(0.5px);
    pointer-events: none;
    transition: opacity 0.2s, left 0.2s, right 0.2s;
}

/* HOVER — scale up + full glow bloom */
.pt-tile:hover {
    transform: scale(1.65);
    z-index: 20;
    border-color: var(--tile-clr-full, #fff);
    box-shadow:
        0 0 6px var(--tile-shadow, rgba(255,255,255,0.12)),
        0 0 18px var(--tile-shadow, rgba(255,255,255,0.06)),
        0 0 40px var(--tile-shadow-outer, rgba(255,255,255,0.03)),
        inset 0 0 16px var(--tile-glow-inner, rgba(255,255,255,0.1));
    filter: brightness(1.4) saturate(1.3);
}
.pt-tile:hover::after {
    opacity: 0.7; left: 5%; right: 5%;
}

/* Dimmed and highlight states */
.pt-tile.pt-dim { opacity: 0.06; pointer-events: none; filter: grayscale(1) brightness(0.5); }
.pt-tile.pt-highlight { transform: scale(1.2); z-index: 15; }

/* Click pop animation */
.pt-tile.pt-clicked {
    animation: ptPop 0.35s ease-out;
}
@keyframes ptPop {
    0%   { transform: scale(1.65); filter: brightness(1.4); }
    40%  { transform: scale(1.9); filter: brightness(2.0); }
    100% { transform: scale(1.65); filter: brightness(1.4); }
}

/* ── Tile text content — clamp for viewport scaling ──────── */
.pt-tile-z {
    font-family: var(--font-ui, 'Rajdhani', sans-serif);
    font-size: clamp(5px, 0.55vw, 9px);
    font-weight: 600;
    color: rgba(255,255,255,0.3);
    position: absolute; top: 1px; left: 3px;
    line-height: 1;
}
.pt-tile-sym {
    font-family: var(--font-display, 'Cinzel', serif);
    font-size: clamp(10px, 1.15vw, 22px);
    font-weight: 700;
    color: var(--tile-clr-full, #fff);
    line-height: 1;
    text-shadow: 0 0 10px var(--tile-shadow, rgba(255,255,255,0.2));
}
.pt-tile-name {
    font-family: var(--font-ui, 'Rajdhani', sans-serif);
    font-size: clamp(4px, 0.42vw, 7px);
    font-weight: 500;
    color: rgba(255,255,255,0.3);
    letter-spacing: 0.2px;
    line-height: 1; margin-top: 1px;
    max-width: 94%; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
}
.pt-tile-mass {
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(4px, 0.32vw, 6px);
    color: rgba(255,255,255,0.15);
    line-height: 1; margin-top: 0;
}

/* Shell dot indicators with glow */
.pt-tile-shells {
    display: flex; gap: 1px;
    margin-top: 1px; justify-content: center;
}
.pt-tile-shells .shell-dot {
    width: clamp(2px, 0.2vw, 3px);
    height: clamp(2px, 0.2vw, 3px);
    border-radius: 50%;
    background: var(--tile-clr-full, rgba(255,255,255,0.3));
    opacity: 0.5;
    box-shadow: 0 0 4px var(--tile-shadow, rgba(255,255,255,0.15));
}

/* ── F-BLOCK MARKERS ──────────────────────────────────────── */
.pt-fblock-marker {
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-ui, 'Rajdhani', sans-serif);
    font-size: clamp(5px, 0.45vw, 8px);
    font-weight: 500;
    color: rgba(255,255,255,0.12);
    border: 1px dashed rgba(255,255,255,0.04);
    border-radius: 3px; text-align: center;
    cursor: default; line-height: 1.2;
}
.pt-fblock-label {
    font-family: var(--font-ui, 'Rajdhani', sans-serif);
    font-size: clamp(6px, 0.5vw, 10px);
    font-weight: 600;
    color: rgba(255,255,255,0.1);
    display: flex; align-items: center; justify-content: flex-end;
    padding-right: 4px; text-align: right;
    letter-spacing: 0.3px;
}

/* ── LEGEND — compact row below grid ─────────────────────── */
.pt-legend {
    display: flex; flex-wrap: nowrap;
    gap: 4px; justify-content: center;
    max-width: min(98vw, 1380px);
    margin: 2px auto 0;
    flex-shrink: 0;
}
.pt-legend-item {
    display: flex; align-items: center; gap: 3px;
    font-family: var(--font-ui, 'Rajdhani', sans-serif);
    font-size: clamp(7px, 0.6vw, 10px);
    color: rgba(255,255,255,0.3);
    cursor: pointer; padding: 2px 5px;
    border-radius: 3px; border: 1px solid transparent;
    transition: all 0.2s; white-space: nowrap;
}
.pt-legend-item:hover {
    color: rgba(255,255,255,0.8);
    background: rgba(255,255,255,0.03);
}
.pt-legend-item.pt-legend-active {
    border-color: rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.05);
    color: rgba(255,255,255,0.7);
}
.pt-legend-swatch {
    width: clamp(6px, 0.5vw, 10px);
    height: clamp(6px, 0.5vw, 10px);
    border-radius: 2px;
    box-shadow: 0 0 6px currentColor;
}

/* ══════════════════════════════════════════════════════════════
   ATOM DETAIL MODAL
   ══════════════════════════════════════════════════════════════ */
.atom-modal {
    position: fixed; inset: 0; z-index: 200;
    display: none; align-items: center; justify-content: center;
}
.atom-modal.visible { display: flex; }
.atom-modal-bg {
    position: absolute; inset: 0;
    background: rgba(3,3,8,0.9);
    backdrop-filter: blur(10px);
    animation: ptFadeIn 0.3s ease;
}
.atom-modal-box {
    position: relative; z-index: 1;
    width: min(92vw, 880px);
    height: min(82vh, 560px);
    display: flex;
    background: rgba(10,10,20,0.97);
    border: 1px solid rgba(99,102,241,0.1);
    border-radius: 12px;
    overflow: hidden;
    animation: ptSlideUp 0.35s ease-out;
    box-shadow: 0 0 60px rgba(99,102,241,0.05), 0 0 120px rgba(99,102,241,0.02);
}
@keyframes ptFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes ptSlideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.atom-close {
    position: absolute; top: 10px; right: 14px; z-index: 5;
    background: none; border: none;
    color: rgba(255,255,255,0.25); font-size: 24px;
    cursor: pointer; transition: color 0.2s; line-height: 1;
}
.atom-close:hover { color: rgba(255,255,255,0.8); }

/* Modal left — 3D viewport */
.atom-left {
    flex: 0 0 55%; position: relative;
    background: radial-gradient(ellipse at center, rgba(14,14,30,1), rgba(5,5,12,1));
    border-right: 1px solid rgba(99,102,241,0.05);
}
.atom-viewport {
    width: 100%; height: 100%;
}
.atom-controls-hint {
    position: absolute; bottom: 8px; left: 0; right: 0;
    text-align: center;
    font-family: var(--font-ui, 'Rajdhani', sans-serif);
    font-size: 8px; color: rgba(99,102,241,0.18);
    letter-spacing: 1px; pointer-events: none;
}

/* Modal right — info panel */
.atom-right {
    flex: 1; overflow-y: auto;
    padding: 20px 16px;
}
.atom-right::-webkit-scrollbar { width: 3px; }
.atom-right::-webkit-scrollbar-track { background: transparent; }
.atom-right::-webkit-scrollbar-thumb { background: rgba(99,102,241,0.12); border-radius: 2px; }

.atom-header { margin-bottom: 12px; }
.atom-symbol {
    font-family: var(--font-display, 'Cinzel', serif);
    font-size: 42px; font-weight: 700;
    line-height: 1;
}
.atom-name {
    font-family: var(--font-ui, 'Rajdhani', sans-serif);
    font-size: 14px; font-weight: 600;
    color: rgba(255,255,255,0.5); letter-spacing: 1px;
}
.atom-z {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px; color: rgba(255,255,255,0.25);
}
.atom-cat-badge {
    display: inline-block;
    font-family: var(--font-ui, 'Rajdhani', sans-serif);
    font-size: 9px; font-weight: 600;
    padding: 2px 7px; border-radius: 3px;
    letter-spacing: 1px; text-transform: uppercase;
    margin-top: 3px;
}

.atom-section-title {
    font-family: var(--font-display, 'Cinzel', serif);
    font-size: 10px; font-weight: 700;
    color: rgba(99,102,241,0.45);
    letter-spacing: 2px; text-transform: uppercase;
    margin: 14px 0 6px; padding-bottom: 3px;
    border-bottom: 1px solid rgba(99,102,241,0.06);
}
.atom-prop {
    display: flex; justify-content: space-between;
    font-size: 11px; padding: 2px 0;
    border-bottom: 1px solid rgba(255,255,255,0.015);
}
.atom-prop-label {
    font-family: var(--font-ui, 'Rajdhani', sans-serif);
    color: rgba(255,255,255,0.3); font-weight: 500;
}
.atom-prop-value {
    font-family: 'JetBrains Mono', monospace;
    color: rgba(255,255,255,0.6); font-size: 10px;
}

/* Orbital shell visual */
.atom-shells-vis {
    display: flex; gap: 3px; margin: 6px 0;
    align-items: flex-end;
}
.atom-shell-bar {
    flex: 1;
    border-radius: 2px;
    min-height: 4px;
    transition: height 0.3s ease;
}

/* Orbital config display */
.atom-config {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px; color: rgba(255,255,255,0.45);
    background: rgba(99,102,241,0.03);
    border: 1px solid rgba(99,102,241,0.06);
    border-radius: 4px; padding: 6px 8px;
    line-height: 1.6; word-break: break-all;
    margin: 6px 0;
}
.atom-config .cfg-s { color: #60a5fa; }
.atom-config .cfg-p { color: #34d399; }
.atom-config .cfg-d { color: #fbbf24; }
.atom-config .cfg-f { color: #f472b6; }
.atom-config .cfg-core { color: rgba(255,255,255,0.2); }

/* Quantum numbers display */
.atom-quantum {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px; line-height: 1.5;
    color: rgba(255,255,255,0.35);
}
.atom-quantum strong { color: rgba(99,102,241,0.55); }

/* ── STATS BAR — fixed bottom ─────────────────────────── */
.pt-stats {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: 24px; display: flex;
    align-items: center; justify-content: center;
    gap: 6px; z-index: 90;
    background: rgba(6,6,16,0.95);
    border-top: 1px solid rgba(99,102,241,0.06);
    font-family: var(--font-ui, 'Rajdhani', sans-serif);
    font-size: 9px; color: rgba(99,102,241,0.25);
    letter-spacing: 0.4px;
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — always stay viewport-fit
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 980px) {
    .pt-tile-mass { display: none; }
    .pt-tile-shells { display: none; }
    .pt-nav-sub { display: none; }
    .atom-modal-box { width: 96vw; height: 88vh; flex-direction: column; }
    .atom-left { flex: 0 0 50%; }
    .atom-right { padding: 14px; }
}
@media (max-width: 768px) {
    .pt-tile-name { display: none; }
    .pt-grid { gap: 1px; }
    .pt-legend { gap: 2px; }
    .pt-legend-item { padding: 1px 3px; font-size: 7px; }
}
@media (max-height: 650px) {
    .pt-nav { height: 32px; }
    .pt-wrapper { top: 32px; bottom: 20px; padding: 4px 8px 2px; }
    .pt-stats { height: 20px; font-size: 8px; }
    .pt-legend { margin-top: 2px; }
}

/* ── SCROLLBAR ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(99,102,241,0.12); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: rgba(99,102,241,0.25); }
