@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary-color: #b74b4b;
    --bg-dark: #000000;
    --bg-surface: #111111;
    --bg-sidebar: #1a1a1a;
    --text-white: #ffffff;
    --text-gray: #cccccc;
    --transition: 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    text-decoration: none;
    border: none;
    outline: none;
    font-family: 'Poppins', sans-serif;
}

html {
    font-size: 62.5%;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

body {
    width: 100%;
    min-height: 100vh;
    background-color: var(--bg-dark);
    color: var(--text-white);
}

/* --- Utility Classes --- */
.centered-text { font-size: 1.6rem; text-align: center; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.gap-10 { gap: 10px; }
.margin-b-15 { margin-bottom: 1.5rem; }
.margin-b-20 { margin-bottom: 2rem; }
.secondary-btn { background-color: #555 !important; border-color: #555 !important; }
.instruction-text { font-size: 1.4rem; color: var(--text-gray); margin-bottom: 3rem; text-align: center; }
.ex3-list-style { color: white; font-size: 1.6rem; list-style: none; padding: 0; }
.small-label { font-size: 1.4rem; color: var(--text-gray); }
.divider { border: 0; border-top: 1px solid #333; margin: 2rem 0; }
.no-padding { padding: 0; }
.todo-title { font-size: 2rem; color: var(--text-white); margin-bottom: 1rem; text-align: left; }

.activity-img {
    width: 300px; 
    height: 350px; 
    object-fit: cover; 
    border-radius: 10px; 
    border: 2px solid var(--primary-color);
}

/* Hide activities by default */
.activity-content {
    display: none;
    background: var(--bg-surface);
    padding: 3rem;
    margin-top: 2rem;
    border-radius: 1.5rem;
    width: 100%;
    max-width: 700px;
    border: 1px solid var(--primary-color);
    box-shadow: 0 0 15px rgba(183, 75, 75, 0.2);
}

.activity-content.active-content {
    display: block;
}

/* Exercise 4 gets a wider card */
.ex4-wide {
    max-width: 960px !important;
}

header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 2rem 9%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    border-bottom: 1px solid #333;
    backdrop-filter: blur(10px);
}

.logo {
    font-size: 3rem;
    color: var(--primary-color);
    font-weight: 800;
    cursor: pointer;
    transition: 0.5s ease;
}

.logo:hover { transform: scale(1.1); }

nav { display: flex; align-items: center; }

nav a {
    font-size: 1.8rem;
    color: var(--text-white);
    margin-left: 4rem;
    font-weight: 500;
    transition: var(--transition);
    border-bottom: 3px solid transparent;
}

nav a:hover, 
nav a.active {
    color: var(--primary-color);
    border-bottom: 3px solid var(--primary-color);
}

.dropdown {
    position: relative;
    display: inline-block;
    margin-left: 4rem;
}

.dropbtn {
    font-size: 1.8rem;
    color: var(--text-white);
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: var(--bg-sidebar);
    min-width: 200px;
    box-shadow: 0px 8px 16px rgba(0,0,0,0.5);
    z-index: 1;
    border: 1px solid #333;
    top: 100%;
    left: 0;
    max-height: 400px;
    overflow-y: auto;
}

.dropdown:hover .dropdown-content { display: block; }

.ex-title {
    display: block;
    padding: 10px 15px;
    background: #261a1a;
    color: var(--primary-color);
    font-weight: bold;
    font-size: 1.4rem;
    border-bottom: 1px solid #333;
}

.dropdown-content a {
    color: var(--text-gray);
    padding: 10px 20px;
    font-size: 1.3rem;
    display: block;
    margin-left: 0;
    border-bottom: 1px solid #222;
}

.dropdown-content a:hover {
    background-color: var(--primary-color);
    color: black;
    border-bottom: 1px solid var(--primary-color);
}

section.home {
    min-height: 100vh;
    padding: 10rem 9% 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8rem;
}

.home-img img {
    width: 32vw;
    border-radius: 50%;
    box-shadow: 0 0 25px var(--primary-color);
    transition: 0.4s ease-in-out;
}

.home-content h1 { font-size: 4rem; font-weight: 700; }
.home-content h3 { font-size: 3rem; margin-bottom: 1rem; }
.home-content p { font-size: 1.6rem; margin-bottom: 2rem; }
span { color: var(--primary-color); }

.activity-section {
    display: none;
    min-height: 100vh;
    padding: 10rem 2rem 4rem;
    width: 100%;
    justify-content: center;
}

.main-content {
    flex: 1;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#activitySection h2, 
.activity-title { 
    font-size: 3.5rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 20px;
    color: var(--text-white);
}

.activity-content h3 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    color: var(--primary-color);
    text-align: center;
}

.activity-content input {
    width: 100%;
    padding: 1.2rem;
    margin-bottom: 1.5rem;
    background: #222;
    color: white;
    border: 1px solid #444;
    border-radius: 0.5rem;
    font-size: 1.4rem;
}

.output {
    margin-top: 2rem;
    color: #0ff;
    font-family: monospace;
    background: #000;
    padding: 1.5rem;
    border-radius: 0.8rem;
    min-height: 50px;
    font-size: 1.4rem;
}

.btn {
    display: inline-block;
    padding: 1rem 2.8rem;
    background-color: var(--primary-color);
    border-radius: 4rem;
    font-size: 1.6rem;
    color: black;
    letter-spacing: 0.1rem;
    font-weight: 600;
    border: 2px solid var(--primary-color);
    transition: var(--transition);
    cursor: pointer;
}

.btn:hover {
    background-color: transparent;
    color: var(--primary-color);
    box-shadow: 0 0 25px var(--primary-color);
}

#todoList {
    margin-top: 2rem;
    list-style: none;
    width: 100%;
}

#todoList li {
    font-size: 1.6rem;
    color: var(--text-white);
    padding: 1rem;
    border-bottom: 1px solid #333;
    cursor: pointer;
}

#todoList li:hover {
    color: #ff4d4d;
    text-decoration: line-through;
}

.image-container {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

#ex3List li {
    background: rgba(255, 255, 255, 0.1);
    margin-top: 10px;
    padding: 12px;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
    word-wrap: break-word;
}

.switch-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    padding: 2rem;
}

.mode-label {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-gray);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #333;
    transition: var(--transition);
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: var(--transition);
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

input:checked + .slider { background-color: var(--primary-color); }
input:checked + .slider:before { transform: translateX(26px); }

body.light-mode {
    --bg-dark: #f5f5f5;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --text-white: #121212;
    --text-gray: #555555;
}

body.light-mode header {
    background-color: rgba(255, 255, 255, 0.85);
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

body.light-mode .activity-content {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border-color: #ddd;
}

body.light-mode .output {
    background: #e9e9e9;
    color: #121212;
}

.small-label {
    display: block;
    font-size: 1.4rem;
    color: var(--text-gray);
    margin-bottom: 0.5rem;
    text-align: left;
    width: 100%;
}

.secondary-btn {
    background-color: #444 !important;
    border-color: #444 !important;
    color: white !important;
}

.secondary-btn:hover {
    background-color: transparent !important;
    color: white !important;
    box-shadow: 0 0 15px #444 !important;
}

.output p {
    margin: 5px 0;
    font-size: 1.6rem;
}

.output span {
    font-weight: bold;
}

/* --- Exercise 4 Output --- */
.output {
    margin-top: 2rem;
    background: #000;
    padding: 2.5rem;
    border-radius: 1rem;
    width: 100%;
    max-width: 960px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
}

#resultContainer {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.ex4-heading {
    font-size: 2.4rem;
    color: #00ffff;
    font-weight: 800;
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.ex4-label {
    font-size: 1.6rem;
    color: #00ffff;
    margin: 0.8rem 0;
    width: 100%;
    display: block;
}

.ex4-value {
    color: #ffffff !important;
    font-weight: 700;
    margin-left: 1rem;
}

.ex4-divider {
    border: 0;
    border-top: 1px solid #333;
    margin: 2rem 0;
    width: 100%;
}

.ex4-error {
    color: #ff4d4d;
    font-size: 1.6rem;
    font-weight: bold;
    margin-bottom: 1rem;
}

/* ---- Exercise 4: Grade Category Cards ---- */
.ex4-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    width: 100%;
    margin-top: 1rem;
}

.grade-category-card {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 1.2rem;
    padding: 1.8rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: border-color var(--transition);
}

.grade-category-card:hover {
    border-color: var(--primary-color);
}

.grade-card-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.5rem;
}

.grade-card-header h4 {
    font-size: 1.6rem;
    color: var(--text-white);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.grade-card-icon {
    font-size: 2rem;
}

.weight-badge {
    background: var(--primary-color);
    color: #fff !important;
    font-size: 1.1rem;
    padding: 0.2rem 0.7rem;
    border-radius: 2rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.score-inputs-container {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    max-height: 240px;
    overflow-y: auto;
    padding-right: 4px;
}

.score-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.score-num {
    font-size: 1.2rem;
    color: var(--text-gray);
    min-width: 52px;
    white-space: nowrap;
}

.score-input {
    flex: 1;
    padding: 0.8rem 1rem !important;
    margin-bottom: 0 !important;
    background: #2a2a2a;
    color: white;
    border: 1px solid #444 !important;
    border-radius: 0.5rem;
    font-size: 1.3rem !important;
    width: auto !important;
}

.score-input:focus {
    border-color: var(--primary-color) !important;
    outline: none;
}

.remove-score-btn {
    background: transparent;
    color: #666;
    border: 1px solid #444 !important;
    border-radius: 0.4rem;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.4rem 0.7rem;
    transition: all var(--transition);
    line-height: 1;
    flex-shrink: 0;
}

.remove-score-btn:hover {
    background: #ff4d4d22;
    color: #ff4d4d;
    border-color: #ff4d4d !important;
}

.add-score-btn {
    background: transparent;
    color: var(--primary-color);
    border: 1px dashed var(--primary-color) !important;
    border-radius: 0.6rem;
    cursor: pointer;
    font-size: 1.3rem;
    padding: 0.7rem 1rem;
    transition: all var(--transition);
    width: 100%;
    text-align: center;
    font-family: 'Poppins', sans-serif;
    font-weight: 500;
    margin-top: 0.4rem;
}

.add-score-btn:hover {
    background: rgba(183, 75, 75, 0.1);
}

/* ---- Exercise 4: Averages Result Row ---- */
.ex4-averages-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.2rem;
    width: 100%;
    margin-bottom: 1rem;
}

.ex4-avg-card {
    background: #111;
    border: 1px solid #2a2a2a;
    border-radius: 1rem;
    padding: 1.4rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    text-align: center;
}

.ex4-avg-label {
    font-size: 1.2rem;
    color: var(--text-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ex4-avg-value {
    font-size: 2.2rem;
    font-weight: 800;
    color: #00ffff;
}

.ex4-avg-sub {
    font-size: 1.1rem;
    color: #555;
}

.ex4-avg-weighted {
    font-size: 1.3rem;
    color: #fff;
    font-weight: 600;
}

.hidden {
    display: none !important;
}

.visible {
    display: flex !important; 
}

@media(max-width: 995px) {
    header { padding: 2rem 4%; }
    .home { 
        flex-direction: column-reverse; 
        text-align: center; 
        gap: 4rem;
    }
    .home-img img { width: 60vw; }
    .dropdown { margin-left: 2rem; }
    nav a { margin-left: 2rem; }
    .ex4-grid { grid-template-columns: 1fr; }
    .ex4-averages-row { grid-template-columns: 1fr; }
}
