/* -------------------------------------------------------------------------------------------- UPDATED */

* {
   box-sizing: border-box; 
}

:root {
    /* Enable light-dark() function */
    color-scheme: light dark;

    /* Light mode colours */
    --light-text: #222;
    --light-bg: antiquewhite;

    /* Dark mode colors */
    --dark-text: #888;
    --dark-bg: #5b4c38;
}

html {
    font-size: 20px; 
}
body {
    display: flex;
    flex-direction: column;
    width: 100vw;
    box-sizing: border-box;
    font-family: monospace;
    margin: 2%;
    background-color: light-dark(var(--light-bg), var(--dark-bg));
    transition: background-color 0.7s ease;
}
header {
    display: flex;
}
button {
    cursor: pointer;
    align-self: flex-start;
    margin-left: 9%;
    background-color: #9f8a1699;
    padding: 5px;
    border: solid black 1px;
    color: #111;
    font-weight: bold;
}
button:active {
    animation: pop 0.2s;
}

h1 {
    font-size: 34px;
}

h6 {
    text-decoration: underline;
    font-size: 0.8rem;
}

.element-number {
    margin-bottom: 1px;
}

.element-div {
    display: flex;
    align-items: center;
    border: solid 2px black;
    flex-direction: column;
    margin: 2px;
    max-height: min-content;
    min-width: 111px;
    border-radius: 3px;
    padding: 3px;
    transition: all ease-in 0.3s;
}

.element-div:hover {
    /* animation: pop 0.2s; */
    transform: scale(1.4);
    box-shadow: black 3px 5px 6px;
    z-index: 3;
    
}

.element-div.blue-background:hover {
    background-color: rgba(76, 76, 223, 1);
}
.element-div.peach-background:hover {
    background-color: rgba(255, 127, 80, 1);
}
.element-div.yellow-background:hover {
    background-color: rgba(255, 255, 0, 1);
}
/* -------------------------------------------------------- upper and lower flex-containers  */ 
.flex-container-upper, .flex-container-lower {
    display: flex;
    align-items: flex-end;
    width: 99%;
    column-gap: 2px;
}
.flex-container-lower {
    margin-top: 30px;
    margin-left: 17em;
}

/* ---------------------------------   END -------------------------------------------------------- */
/* --------------------------------   column and child elements styling ------------------------------ */
.column {
    min-width: fit-content;
}
.description {
    margin: 1%;
    width: 61%;
    font-size: 77%;
    display: contents;
}
.element-symbol {
    margin: 2px;
    font-size: 26px;
    font-weight: bolder;
}
#transparent1, #transparent2 {
    visibility: hidden;
}
/* -----------------------------------------------   END  -------------------------------------------------- */
/* ------------------------------  Element Background Colours ---------------------------------------*/
.peach-background {
    background-color: rgba(255, 127, 80, 0.658);
}
.blue-background {
    background-color: rgba(76, 76, 223, 0.589);
}
.yellow-background {
    background-color: rgba(255, 255, 0, 0.356);
}
.aqua-background {
    background-color: aquamarine;
}    
/* -----------------------------------------------  END --------------------------------------------- */


/* element popup styling ----------------------------------- 2025 */

#name, #discovered-by, #appearance, h6 {
    text-align: justify;
}

#melt-boil-point {
    text-align: center;
}

.popup-container {
    -webkit-overflow-scrolling: touch;
}

/* .popup-container {
    position: fixed;
    transform: translateX(-50%);
    height: 85dvh;
    left: 50%;
    border: 2px solid transparent;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.1),
        rgba(255, 255, 255, 0.05)
    );
    width: 75vw;
    backdrop-filter: blur(23px);
    box-shadow: black 3px 3px 12px;
    border-radius: 7px;
    padding: 15px;
    transition: opacity 0.3s ease;
    top: 10vh;
    overflow: scroll;
} */

/* TESTING -------------------------------------------------------------------*/
.popup-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: 85vw;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 101;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.popup-container:not(.hide) {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: all;
}
/* ------------------------------------------------------------------ */

.popup-container.hide {
    opacity: 0;
    pointer-events: none; 
}

/* #el-image {
    width: 70%;
    border-radius: 7px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
    max-height: 400px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#el-image:hover {
    transform: scale(1.05); 
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2); 
} */

/* TESTING -------------------------------- */

#el-image {
    width: 100%;
    max-height: 250px;
    object-fit: contain;
    border-radius: 8px;
    margin: 10px auto;
    display: block;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

#el-image:hover {
    transform: scale(1.02);
}


.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.overlay:not(.hide) {
    opacity: 1;
    pointer-events: all;
}

.popup-container.active + .overlay {
    display: block;
}

/* #name {
    font-family: 'Poppins', sans-serif;
    font-size: 2.5rem;
    font-weight: 600;
    color: #ea339a;;
    text-align: center;
    margin: 10px 0;
    text-shadow: 2px 2px black;
} */
/* TESTING */
#name {
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    margin: 15px 0;
    background: linear-gradient(90deg, #ff8a00, #e52e71);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

#discovered-by, #appearance, #melt-boil-point, #summary {
    font-family: 'Open Sans', sans-serif;
    color: #222;
    line-height: 1.6;
}

#melt-point, #boil-point {
    border: #144b81 solid 1px;
    border-radius: 2px;
    padding: 4px;
    display: flex;
}

/* #facts {
    font-family: 'Roboto Mono', monospace;
    color: #222;
    width: 80%;
    margin: 0 auto;
} */

/* TESTING */
#facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin: 20px 0;
}

#facts li {
    background: rgba(255, 255, 255, 0.7);
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    font-size: 0.9rem;
}

/* .close-btn {
    position: absolute; 
    top: 3px;
    right: 10px;
    font-size: 34px;
    font-weight: bold;
    color: #333;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close-btn:hover {
    color: red;
} */

/*  TESTING */
.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: rgba(0, 0, 0, 0.2);
    transform: rotate(90deg);
}

.popup-container::-webkit-scrollbar {
    width: 8px; 
}

.popup-container::-webkit-scrollbar-track {
    background: rgba(17, 17, 17, 0.3); 
    border-radius: 4px;
}

.popup-container::-webkit-scrollbar-thumb {
    background: rgba(7, 171, 254, 0.4);
    border-radius: 4px;
}

.popup-container::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.4); 
}

#source-div #source {
    text-decoration: none;
    text-align: center;
    color: #1a73e8;
    font-family: 'Roboto', sans-serif;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background-color: rgba(26, 115, 232, 0.08);
}

#source-div #source:hover {
    background-color: rgba(26, 115, 232, 0.12);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(26, 115, 232, 0.1);
}

#source-div #source:active {
    transform: translateY(0);
}

#source-div #source::after {
    content: '→';
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.2s ease;
}

#source-div #source:hover::after {
    opacity: 1;
}

/* ===== MOBILE RESPONSIVENESS ===== */
@media screen and (max-width: 768px) {
    /* TESTING - 07/08/2025 */
    /* .popup-container {
        width: 95vw;
        max-height: 90vh;
        top: 50%;
        transform: translate(-50%, -50%) scale(0.95);
        padding: 15px;
    } */

    .popup-container {
        width: 92vw;
        height: auto;
        max-height: 90vh;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) scale(1);
        padding: 15px;
        position: fixed;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    }

    .popup-container:not(.hide) {
        transform: translate(-50%, -50%) scale(1);
    }
    
    /* TESTING - 07/08/2025 ---------------------------------------------------------- */
    /* Ensure content doesn't overflow */
    #el-image {
        max-height: 25vh;
    }

    /* Make close button more accessible */
    .close-btn {
        top: 8px;
        right: 8px;
        width: 28px;
        height: 28px;
        background: rgba(255,255,255,0.9);
    }
    /* ------------------------------------------------------------ */
    #name {
        font-size: 1.8rem;
    }
    
    #facts {
        grid-template-columns: 1fr;
    }
    
    #el-image {
        max-height: 180px;
    }
}

@media screen and (max-width: 480px) {
    #facts {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    #name {
        font-size: 1.6rem;
        margin: 10px 0;
    }
    
    #el-image {
        max-height: 20vh;
    }
    
    .popup-container {
        padding: 12px;
        width: 95vw;
    }
}

/* button pop effect */

@keyframes pop {
    0% {
      transform: scale(1);
    }
    50% {
      transform: scale(1.2);
    }
    100% {
      transform: scale(1);
    }
  }
  
  /* ===== DARK MODE SUPPORT ===== */
@media (prefers-color-scheme: dark) {
    .popup-container {
        background: rgba(30, 30, 30, 0.95);
        border: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    #facts li {
        background: rgba(50, 50, 50, 0.7);
        color: #eee;
    }
    
    #discovered-by, #appearance, #summary {
        color: #eee;
    }
}