/* =========================================================
   Da Periodic Table — style.css
   ========================================================= */

/* ===== Language Selector ===== */
#lang-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    background: linear-gradient(135deg, #2a2a2a, #1a1a1a);
    color: #fff;
    border: 1px solid #555;
    border-radius: 12px;
    padding: 14px 28px;
    font-size: 1.1em;
    font-weight: bold;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(0,0,0,0.5);
    transition: all 0.2s ease;
}
#lang-btn:hover {
    background: linear-gradient(135deg, #3a3a3a, #2a2a2a);
    box-shadow: 0 8px 20px rgba(0,0,0,0.6);
    transform: translateY(-1px);
}
#lang-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 10001;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}
#lang-overlay.open { display: flex; }
#lang-panel {
    background: #1e1e1e;
    border: 1px solid #444;
    border-radius: 16px;
    padding: 30px;
    max-width: 900px;
    width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.8);
}
#lang-panel h2 {
    margin: 0 0 20px 0;
    text-align: center;
    color: #fff;
    font-size: 1.4em;
    letter-spacing: 1px;
}
#lang-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}
.lang-item {
    background: #2a2a2a;
    color: #ddd;
    border: 1px solid #3a3a3a;
    border-radius: 10px;
    padding: 12px 10px;
    text-align: center;
    cursor: pointer;
    font-size: 0.95em;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    transition: all 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.lang-item:hover {
    background: #444;
    color: #fff;
    border-color: #888;
    transform: scale(1.04);
}
.lang-item.active {
    background: #0078d4;
    color: #fff;
    border-color: #0078d4;
}

/* Hide Google's own widget visually (still needed in the DOM) */
#google_translate_element {
    position: fixed;
    top: -999px;
    left: -999px;
    opacity: 0;
    pointer-events: none;
}
.goog-te-banner-frame { display: none !important; }
body { top: 0 !important; }

/* ===== Title ===== */
h1 {
    margin-top: 40px;
    text-align: center;
}
.rainbow-title {
    background: linear-gradient(to right, red, orange, yellow, #00ff00, #00bfff, indigo, violet);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}
.rainbow-title font {
    background: inherit;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ===== Antimatter Mode ===== */
#antimatter-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 10000;
    background: linear-gradient(135deg, #3a1a52, #1a0a2a);
    color: #fff;
    border: 1px solid #7a4dff;
    border-radius: 12px;
    padding: 14px 28px;
    font-size: 1.1em;
    font-weight: bold;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(0,0,0,0.5);
    transition: all 0.2s ease;
}
#antimatter-btn:hover {
    background: linear-gradient(135deg, #4a2a62, #2a1a3a);
    box-shadow: 0 8px 20px rgba(122,77,255,0.45);
    transform: translateY(-1px);
}
#antimatter-btn.active {
    background: linear-gradient(135deg, #b14dff, #6a1aff);
    border-color: #d9b3ff;
    box-shadow: 0 0 24px rgba(177,77,255,0.7);
}
html.antimatter #pt-content { filter: invert(1); }
html.antimatter {
    background-color: #ededed !important;
    color: #111 !important;
}
html.antimatter .pt-sym,
html.antimatter .sym-val {
    text-decoration: overline;
}

/* ===== Demon Core button + overlay ===== */
#demon-btn {
    position: fixed;
    top: 20px;
    left: 215px;
    z-index: 10000;
    background: linear-gradient(135deg, #08323f, #02141c);
    color: #fff;
    border: 1px solid #0ea5e9;
    border-radius: 12px;
    padding: 14px 26px;
    font-size: 1.1em;
    font-weight: bold;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(0,0,0,0.5);
    transition: all 0.2s ease;
}
#demon-btn:hover {
    background: linear-gradient(135deg, #0c4a5e, #03222e);
    box-shadow: 0 8px 22px rgba(14,165,233,0.45);
    transform: translateY(-1px);
}

#demon-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10050;
    background: #000;
}
#demon-overlay.open { display: block; }
#demon-frame {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}
#demon-close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 10060;
    background: rgba(15,15,20,0.85);
    color: #fff;
    border: 1px solid #444;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.5em;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.6);
    transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
#demon-close:hover {
    background: rgba(239,68,68,0.35);
    border-color: #ef4444;
    transform: rotate(90deg);
}

/* Stack the demon button below the antimatter button on small screens */
@media (max-width: 720px) {
    #demon-btn {
        top: 78px;
        left: 20px;
    }
}

/* ===== Search ===== */
#pt-search-wrap {
    width: 90%;
    max-width: 760px;
    margin: 18px auto 0;
    text-align: center;
}
#pt-search {
    width: 100%;
    box-sizing: border-box;
    background: #1e1e1e;
    color: #eee;
    border: 1px solid #3a3a3a;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 1em;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#pt-search:focus {
    outline: none;
    border-color: #0078d4;
    box-shadow: 0 0 0 3px rgba(0,120,212,0.25);
}
.pt-tile.pt-dimmed {
    opacity: 0.18;
    filter: saturate(0.4);
}
#pt-table tbody tr.pt-hidden { display: none; }

/* ===== Periodic Table Grid ===== */
#pt-grid-wrap {
    margin: 24px auto 0;
    width: 90%;
    max-width: 1280px;
    overflow-x: auto;
    padding: 22px;
    background: #1a1a1a;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    box-sizing: border-box;
}
#pt-grid {
    display: grid;
    grid-template-columns: repeat(18, 1fr);
    gap: 4px;
    min-width: 940px;
}
.pt-tile {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    background: var(--cat, #444);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    overflow: hidden;
    user-select: none;
}
.pt-tile:hover {
    transform: scale(1.22);
    box-shadow: 0 6px 18px rgba(0,0,0,0.7);
    outline: 2px solid #fff;
    z-index: 5;
}
.pt-num {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 8px;
    font-weight: 700;
    opacity: 0.85;
}
.pt-sym {
    font-size: 15px;
    font-weight: 800;
    line-height: 1;
}
.pt-name {
    font-size: 6px;
    margin-top: 2px;
    max-width: 100%;
    padding: 0 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    box-sizing: border-box;
}
.pt-ghdr {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #888;
}
.pt-placeholder {
    aspect-ratio: 1 / 1;
    background: #2e2e2e;
    color: #999;
    font-size: 8px;
    font-weight: 600;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pt-fblock-label {
    display: flex;
    align-items: center;
    font-size: 9px;
    font-weight: 600;
    color: #888;
    white-space: nowrap;
}
#pt-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 18px;
    width: 90%;
    max-width: 1280px;
    margin: 14px auto 40px;
}
.pt-leg-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #ccc;
}
.pt-leg-swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
    display: inline-block;
}

/* ===== Element Names Table ===== */
#pt-table-wrap {
    width: 90%;
    max-width: 760px;
    margin: 22px auto 50px;
    overflow-x: auto;
}
#pt-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1e1e1e;
    color: #ddd;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
#pt-table thead tr { background: #2a2a2a; }
#pt-table th {
    padding: 13px 14px;
    text-align: left;
    color: #fff;
    text-transform: uppercase;
    font-size: 0.78em;
    letter-spacing: 1px;
}
#pt-table td {
    padding: 9px 14px;
    border-top: 1px solid #333;
}
#pt-table tbody tr {
    cursor: pointer;
    transition: background 0.15s ease;
}
#pt-table tbody tr:hover { background: #333; }
#pt-table .pt-t-num { color: #888; text-align: center; width: 48px; font-weight: 600; }
#pt-table .pt-t-sym { font-weight: bold; width: 64px; color: #fff; }
#pt-table .pt-t-name { font-weight: 600; }
#pt-table .pt-t-cat { color: #aaa; font-size: 0.9em; }
.pt-t-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 7px;
    vertical-align: middle;
}

/* Hide element symbols while the page is translated to Chinese */
html.hide-symbols .pt-sym,
html.hide-symbols .pt-t-sym,
html.hide-symbols .col-sym,
html.hide-symbols #element-preview .preview-symbol {
    display: none !important;
}

/* ===== Element Preview Panel ===== */
#element-preview {
    position: fixed;
    top: 80px;
    right: -420px;
    width: 380px;
    max-height: calc(100vh - 100px);
    background: linear-gradient(135deg, rgba(30,30,30,0.95), rgba(20,20,20,0.98));
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px;
    padding: 28px;
    z-index: 9999;
    box-shadow: 0 20px 60px rgba(0,0,0,0.7), 0 0 40px rgba(0,120,212,0.15);
    backdrop-filter: blur(20px);
    transition: right 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    overflow-y: auto;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
#element-preview.visible { right: 20px; }
#element-preview .preview-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    color: #aaa;
    font-size: 1.2em;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
#element-preview .preview-close:hover {
    background: rgba(255,70,70,0.3);
    color: #ff6666;
    border-color: rgba(255,70,70,0.4);
    transform: rotate(90deg);
}
#element-preview .preview-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
    padding-right: 30px;
}
#element-preview .preview-number {
    font-size: 2.2em;
    font-weight: 800;
    color: rgba(255,255,255,0.15);
    line-height: 1;
}
#element-preview .preview-title {
    font-size: 1.5em;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
}
#element-preview .preview-symbol {
    font-size: 1em;
    color: #888;
    margin-top: 2px;
}
#element-preview .preview-badge {
    display: inline-block;
    padding: 5px 14px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9em;
    margin-bottom: 14px;
}
#element-preview .preview-props {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 14px;
    font-size: 0.92em;
}
#element-preview .prop-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
}
#element-preview .prop-row + .prop-row {
    border-top: 1px solid rgba(255,255,255,0.06);
}
#element-preview .prop-label {
    color: #999;
    text-transform: uppercase;
    font-size: 0.78em;
    letter-spacing: 0.6px;
}
#element-preview .prop-val {
    color: #fff;
    font-weight: 600;
    text-align: right;
}
#element-preview .prop-val.econfig {
    font-family: 'Consolas', 'Menlo', 'Courier New', monospace;
    font-size: 0.85em;
    letter-spacing: 0.2px;
    max-width: 65%;
    word-break: break-word;
}
#element-preview .preview-image-wrapper {
    width: 100%;
    border-radius: 14px;
    overflow: hidden;
    background: #111;
    position: relative;
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
}
#element-preview .preview-image-wrapper img {
    width: 100%;
    display: block;
    opacity: 0;
    transition: opacity 0.5s ease;
}
#element-preview .preview-image-wrapper img.loaded { opacity: 1; }
#element-preview .preview-image-wrapper.shell-bg {
    background: radial-gradient(circle, #f0f4f8, #dce3ea);
    padding: 10px;
}
#element-preview .preview-loader {
    position: absolute;
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: #0078d4;
    border-radius: 50%;
    animation: previewSpin 0.8s linear infinite;
}
@keyframes previewSpin {
    to { transform: rotate(360deg); }
}
