/* ======================================= */
/* 1. Global Styles & Variables            */
/* ======================================= */
:root {
    --primary-color: #005A9C;
    --secondary-color: #00A4E4;
    --background-color: #f0f4f8; /* Light blue-gray for scientific feel */
    --card-background: #ffffff;
    --text-color: #102a43;
    --label-color: #555;
    --border-color: #bcccdc;
    --dark-footer-bg: #1a202c;
    --light-text: #f0f4f8;
    /* Element Group Colors */
    --alkali-metal: #ff8a80;
    --alkaline-earth-metal: #ffcc80;
    --lanthanide: #d1c4e9;
    --actinide: #b39ddb;
    --transition-metal: #80deea;
    --post-transition-metal: #a5d6a7;
    --metalloid: #ce93d8;
    --reactive-nonmetal: #f4ff81;
    --noble-gas: #81d4fa;
}

body { 
    font-family: 'Lato', sans-serif;
    background-color: var(--background-color); 
    color: var(--text-color); 
    margin: 0; 
}

.site-header {
    background: var(--card-background);
    padding: 15px 0;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 90%;
    max-width: 1600px;
    margin: 0 auto;
}

.site-title a { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.logo { height: 45px; width: auto; }
.logo-text { font-family: 'Inter', sans-serif; font-size: 1.4em; font-weight: 700; color: var(--primary-color); }
.site-nav a { margin-left: 25px; font-weight: 600; color: var(--label-color); text-decoration: none; transition: color 0.2s ease; }
.site-nav a:hover { color: var(--primary-color); }

/* ======================================= */
/* 3. Page-Specific Hero Section (Title)   */
/* ======================================= */
.page-hero {
    background-color: #eaf2f8;
    text-align: center;
    padding: 40px 20px;
}

.hero-container { width: 90%; max-width: 1600px; margin: 0 auto; }
.page-hero h1 { color: var(--primary-color); margin: 0 0 10px 0; font-size: 2.5rem; font-family: 'Roboto Slab', serif; }
.page-hero p { color: var(--label-color); font-size: 1.1em; margin: 0; }

/* ======================================= */
/* 4. Main Content Wrapper & Tool Styles   */
/* ======================================= */
.page-content-wrapper {
    max-width: 1600px;
    margin: 40px auto 0 auto;
    padding: 1rem;
    box-sizing: border-box;
}

.filters { display: flex; justify-content: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 2rem; }
.filters input, .filters select { padding: 0.75rem; font-size: 1rem; border: 1px solid var(--border-color); border-radius: 8px; width: 320px; max-width: 100%; }

#periodic-table-grid { display: grid; grid-template-columns: repeat(18, 1fr); gap: 5px; width: 100%; max-width: 1400px; margin: 0 auto; }
.element-tile { background-color: var(--card-background); border: 1px solid var(--border-color); padding: 5px; text-align: center; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; aspect-ratio: 1 / 1.2; display: flex; flex-direction: column; justify-content: center; align-items: center; border-radius: 4px; }
.element-tile:hover { transform: scale(1.1); box-shadow: 0 0 15px rgba(0,0,0,0.2); z-index: 10; }
.element-tile.filtered { opacity: 0.15; pointer-events: none; }
.element-tile .atomic-number { font-size: 0.7em; }
.element-tile .symbol { font-family: 'Roboto Slab', serif; font-size: 1.5em; font-weight: bold; }
.element-tile .name { font-size: 0.6em; }

/* Modal Styles */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(16, 42, 67, 0.7); display: flex; justify-content: center; align-items: center; z-index: 1001; opacity: 0; transition: opacity 0.3s ease; }
.modal-overlay:not(.hidden) { opacity: 1; }
.modal-content { background: var(--card-background); border-radius: 12px; width: 90%; max-width: 800px; max-height: 90vh; overflow-y: auto; display: flex; position: relative; box-shadow: 0 10px 30px rgba(0,0,0,0.2); transform: scale(0.95); transition: transform 0.3s ease; }
.modal-overlay:not(.hidden) .modal-content { transform: scale(1); }
.modal-close-btn { position: absolute; top: 10px; right: 15px; background: none; border: none; font-size: 2.5rem; color: #829ab1; cursor: pointer; line-height: 1; }
.modal-left { flex-basis: 40%; padding: 2rem; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; color: white; border-radius: 12px 0 0 12px; transition: background-color 0.3s; }
.modal-symbol { font-family: 'Roboto Slab', serif; font-size: 6rem; font-weight: 700; line-height: 1; }
.modal-name { font-size: 1.5rem; margin-top: 0.5rem; }
.modal-number { font-size: 1.2rem; opacity: 0.8; margin-top: 0.5rem; }
.modal-right { flex-basis: 60%; padding: 2rem; }
.modal-right h2, .modal-right h3 { font-family: 'Roboto Slab', serif; }
.modal-right h3 { border-bottom: 2px solid var(--background-color); padding-bottom: 5px; }
.modal-right p { line-height: 1.6; }
.modal-right table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.modal-right td { padding: 8px; border-bottom: 1px solid var(--background-color); }
.modal-right td:first-child { font-weight: bold; }
.hidden { display: none; }

/* Category Coloring */
.alkali.metal, .modal-left.alkali.metal { background-color: var(--alkali-metal); }
.alkaline.earth.metal, .modal-left.alkaline.earth.metal { background-color: var(--alkaline-earth-metal); }
.lanthanide, .modal-left.lanthanide { background-color: var(--lanthanide); }
.actinide, .modal-left.actinide { background-color: var(--actinide); }
.transition.metal, .modal-left.transition.metal { background-color: var(--transition-metal); }
.post-transition.metal, .modal-left.post-transition.metal { background-color: var(--post-transition-metal); }
.metalloid, .modal-left.metalloid { background-color: var(--metalloid); }
.reactive.nonmetal, .modal-left.reactive.nonmetal { background-color: var(--reactive-nonmetal); }
.noble.gas, .modal-left.noble.gas { background-color: var(--noble-gas); }

/* Responsive Design for Table & Modal */
@media (max-width: 768px) {
    .modal-content { flex-direction: column; max-height: 85vh; }
    .modal-left { border-radius: 12px 12px 0 0; padding: 1.5rem; }
    .modal-right { padding: 1.5rem; }
    .modal-symbol { font-size: 4rem; }
    .element-tile .symbol { font-size: 1.1em; }
    .element-tile .name, .element-tile .atomic-number { display: none; }
    .filters { flex-direction: column; }
}

/* Content Section Styles */
.content-container { max-width: 1200px; margin: 3rem auto 0 auto; padding: 2.5rem; background-color: var(--card-background); border-radius: 12px; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08); }
.content-container section { margin-bottom: 2rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--background-color); }
.content-container section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.content-container h2 { font-family: 'Roboto Slab', serif; font-size: 1.8rem; margin-top: 0; margin-bottom: 1rem; color: #0b3d6f; }
.content-container p, .content-container li { line-height: 1.7; color: #486581; }
.content-container ul { list-style-type: disc; padding-left: 25px; }
.content-container li { margin-bottom: 0.75rem; }
.content-container strong { color: var(--text-color); font-weight: 700; }

.site-footer {
    background: var(--dark-footer-bg);
    color: var(--light-text);
    padding: 30px 0;
    margin-top: 50px;
    width: 100%;
}
.footer-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 90%;
    max-width: 1600px;
    margin: 0 auto;
    flex-wrap: wrap;
    gap: 15px;
}
.footer-nav a {
    margin-left: 20px;
    color: #a0aec0;
    text-decoration: none;
    transition: color 0.2s ease;
}
.footer-nav a:hover {
    color: white;
}