/* Universal Box-Sizing */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* CSS Variables for easy theme management */
:root {
    --primary-color: #667eea; /* Purple-blue */
    --secondary-color: #764ba2; /* Darker purple */
    --accent-color: #FFD700; /* Gold */
    --text-dark: #333;
    --text-light: #666;
    --background-light: #f8f9fa;
    --border-light: #e1e1e1;
    --white: #ffffff;
    --shadow-light: rgba(0, 0, 0, 0.1);
    --shadow-medium: rgba(0, 0, 0, 0.2);
    --shadow-heavy: rgba(0, 0, 0, 0.3);
    --border-radius-small: 0.5rem;
    --border-radius-medium: 0.75rem;
    --border-radius-large: 1.5rem;
    --transition-speed: 0.3s;

    /* Base font size for rem calculations */
    font-size: 16px;
}

/* Body Styles */
body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden; /* Prevent horizontal scroll */
}

/* Container for Centering Content */
.container {
    max-width: 75rem; /* 1200px */
    margin: 0 auto;
    padding: 0 1.25rem; /* 20px */
    width: 100%;
}

/* Header Styles */
header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(0.625rem); /* 10px */
    box-shadow: 0 0.125rem 1.25rem var(--shadow-light); /* 2px 20px */
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom-left-radius: var(--border-radius-medium);
    border-bottom-right-radius: var(--border-radius-medium);
}

nav.container {
    margin: 0.0625rem auto; /* 1px */
    padding: 0.625rem 0; /* 10px */
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Allow wrapping for smaller screens */
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.3125rem; /* 5px */
    padding: 0.3125rem 0; /* 5px */
}

.search-container {
    position: relative;
    max-width: 25rem; /* 400px */
    flex-grow: 1;
    margin: 0 1.25rem; /* 20px */
    min-width: 12.5rem; /* 200px */
}

.search-box {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 0.125rem solid var(--border-light); /* 2px */
    border-radius: var(--border-radius-large);
    font-size: 0.95rem;
    outline: none;
    transition: all var(--transition-speed) ease;
    background-color: var(--background-light);
}

.search-box:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.1875rem rgba(102, 126, 234, 0.15); /* 3px */
}

.search-icon {
    position: absolute;
    right: 0.9375rem; /* 15px */
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary-color);
    font-size: 1rem;
    pointer-events: none;
}

/* Main Content Styles */
main {
    flex-grow: 1;
    padding: 1.5rem 0;
}

.hero {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--white);
    padding: 1.5rem 0.75rem;
    border-radius: var(--border-radius-medium);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0.625rem 1.875rem var(--shadow-medium); /* 10px 30px */
}

.hero h1 {
    font-size: 2.8rem;
    margin-bottom: 0.3125rem; /* 5px */
    font-weight: 800;
    letter-spacing: -0.05rem;
}

.hero h2 {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
    opacity: 0.95;
}

.hero p {
    font-size: 1rem;
    opacity: 0.9;
    margin-bottom: 0.625rem; /* 10px */
}

.feedback-btn {
    background: var(--accent-color);
    color: var(--text-dark);
    border: none;
    padding: 0.8rem 1.8rem;
    border-radius: var(--border-radius-large);
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: all var(--transition-speed) ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    box-shadow: 0 0.25rem 0.625rem var(--shadow-medium); /* 4px 10px */
}

.feedback-btn:hover {
    background: #e6c200;
    transform: translateY(-0.1875rem); /* 3px */
    box-shadow: 0 0.375rem 0.9375rem var(--shadow-heavy); /* 6px 15px */
}

.access-note {
    color: #ffeb3b;
    font-weight: bold;
    font-family: 'monospace', sans-serif;
    font-size: 0.95rem;
    margin-top: 1.25rem; /* 20px */
    letter-spacing: 0.05rem;
    line-height: 1.4;
}

/* Content Sections */
.content-section {
    background: var(--white);
    border-radius: var(--border-radius-medium);
    padding: 1.875rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 0.625rem 1.875rem var(--shadow-light); /* 10px 30px */
    transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
    border: 0.0625rem solid var(--border-light); /* 1px */
}

/* Ensure sections are hidden by default and shown with JS */
#homeSection.hidden,
#coursesSection.hidden,
#courseDetailsSection.hidden,
#searchResultsSection.hidden {
    display: none;
}

.content-section:hover {
    transform: translateY(-0.3125rem); /* 5px */
    box-shadow: 0 0.9375rem 2.5rem var(--shadow-medium); /* 15px 40px */
}

.section-title {
    font-size: 1.8rem;
    color: var(--text-dark);
    margin-bottom: 1.25rem;
    text-align: center;
    font-weight: 700;
    position: relative;
    padding-bottom: 0.3125rem; /* 5px */
}

.section-title::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: 3.75rem; /* 60px */
    height: 0.25rem; /* 4px */
    background-color: var(--primary-color);
    border-radius: 0.125rem; /* 2px */
}

/* Semester Grid */
.semester-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13.75rem, 1fr)); /* 220px */
    gap: 1.125rem; /* 18px */
    margin-bottom: 1.5rem; /* 24px */
}

.semester-card {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--white);
    padding: 1.125rem;
    border-radius: var(--border-radius-medium);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    /* Fixed height for consistency, allowing course-list to scroll */
    height: 10rem; /* 160px */
    box-shadow: 0 0.5rem 1.25rem rgba(0, 0, 0, 0.2); /* 8px 20px */
}

.semester-card:hover {
    transform: translateY(-0.4375rem); /* 7px */
    box-shadow: 0 1.125rem 2.5rem rgba(102, 126, 234, 0.5); /* 18px 40px */
    background: linear-gradient(135deg, #5a6fd8, #6d4294);
}

.semester-card h3 {
    margin-bottom: 0.4375rem; /* 7px */
    font-size: 1.2rem;
    font-weight: 700;
}

.semester-card p {
    font-size: 0.85rem;
    opacity: 0.9;
    margin-bottom: 0.4375rem; /* 7px */
}

.semester-card .course-list {
    font-size: 0.8rem;
    opacity: 0.8;
    margin-top: 0.3125rem; /* 5px */
    flex-grow: 1; /* Allow it to take available space */
    overflow-y: auto; /* Enable scrolling for overflow */
    -webkit-overflow-scrolling: touch;
    padding: 0 0.3125rem; /* 5px */
    color: rgba(255, 255, 255, 0.9);
}

/* Custom scrollbar for better aesthetics */
.semester-card .course-list::-webkit-scrollbar {
    width: 0.3125rem; /* 5px */
}

.semester-card .course-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 0.625rem; /* 10px */
}

.semester-card .course-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.5);
    border-radius: 0.625rem; /* 10px */
}

/* Course Grid */
.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); /* 320px */
    gap: 1.125rem; /* 18px */
    margin-top: 1.25rem; /* 20px */
}

.course-card {
    background: var(--white);
    border: 0.0625rem solid var(--border-light); /* 1px */
    border-radius: var(--border-radius-medium);
    padding: 1.125rem;
    transition: all var(--transition-speed) ease;
    cursor: pointer;
    box-shadow: 0 0.25rem 0.9375rem var(--shadow-light); /* 4px 15px */
    display: flex; /* Use flexbox for content alignment */
    flex-direction: column;
    justify-content: space-between; /* Push code to bottom if needed */
}

.course-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-0.3125rem); /* 5px */
    box-shadow: 0 0.625rem 1.875rem rgba(102, 126, 234, 0.3); /* 10px 30px */
    background-color: var(--background-light);
}

.course-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 0.3125rem; /* 5px */
}

.course-code {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.9rem;
}

/* Course Details */
.course-details {
    background: var(--white);
    border-radius: var(--border-radius-medium);
    padding: 1.875rem;
    margin-top: 1.25rem; /* 20px */
    box-shadow: 0 0.625rem 1.875rem var(--shadow-light); /* 10px 30px */
    border: 0.0625rem solid var(--border-light); /* 1px */
}

.course-details h3 {
    color: var(--text-dark);
    font-size: 1.6rem;
    margin-bottom: 0.9375rem; /* 15px */
    font-weight: 700;
    text-align: center;
}

.course-details p {
    font-size: 1rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
    text-align: center;
}

.resource-section {
    margin-bottom: 1.5rem;
    border-top: 0.0625rem dashed var(--border-light); /* 1px */
    padding-top: 1.25rem; /* 20px */
}

.resource-section:first-of-type {
    border-top: none;
    padding-top: 0;
}

.resource-section h4 {
    color: var(--primary-color);
    margin-bottom: 0.9375rem; /* 15px */
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    justify-content: center;
}

.resource-section h4 i {
    font-size: 1.25rem; /* 20px */
    color: var(--secondary-color);
}

.resource-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}

.resource-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem; /* 6px */
    padding: 0.7rem 1.1rem;
    background: var(--background-light);
    border: 0.0625rem solid var(--border-light); /* 1px */
    border-radius: var(--border-radius-small);
    text-decoration: none;
    color: var(--text-dark);
    transition: all var(--transition-speed) ease;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.05); /* 2px 8px */
}

.resource-link:hover {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
    transform: translateY(-0.125rem); /* 2px */
    box-shadow: 0 0.25rem 0.75rem rgba(102, 126, 234, 0.3); /* 4px 12px */
}

/* Specific resource link colors */
.resource-link.prof {
    background: #e8f4f8; border-color: #2196f3; color: #2196f3;
}
.resource-link.prof:hover { background: #2196f3; color: var(--white); }

.resource-link.videos {
    background: #fff3e0; border-color: #ff9800; color: #ff9800;
}
.resource-link.videos:hover { background: #ff9800; color: var(--white); }

.resource-link.notes {
    background: #f3e5f5; border-color: #9c27b0; color: #9c27b0;
}
.resource-link.notes:hover { background: #9c27b0; color: var(--white); }

.resource-link.webpages {
    background: #e3f2fd; border-color: #42a5f5; color: #42a5f5;
}
.resource-link.webpages:hover { background: #42a5f5; color: var(--white); }

.resource-link.tutorials {
    background: #f1f8e9; border-color: #8bc34a; color: #8bc34a;
}
.resource-link.tutorials:hover { background: #8bc34a; color: var(--white); }

.resource-link.others {
    background: #fbe9e7; border-color: #ff7043; color: #ff7043;
}
.resource-link.others:hover { background: #ff7043; color: var(--white); }


.back-btn {
    background: var(--primary-color);
    color: var(--white);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius-small);
    cursor: pointer;
    margin-bottom: 0.9375rem; /* 15px */
    font-size: 0.95rem;
    font-weight: 600;
    transition: all var(--transition-speed) ease;
    display: inline-flex;
    align-items: center;
    gap: 0.3125rem; /* 5px */
    box-shadow: 0 0.25rem 0.625rem rgba(0, 0, 0, 0.1); /* 4px 10px */
}

.back-btn:hover {
    background: var(--secondary-color);
    transform: translateY(-0.125rem); /* 2px */
    box-shadow: 0 0.375rem 0.9375rem rgba(0, 0, 0, 0.2); /* 6px 15px */
}

/* Search Results */
.search-results {
    background: var(--white);
    border-radius: var(--border-radius-medium);
    padding: 1.875rem;
    margin-top: 1.25rem; /* 20px */
    box-shadow: 0 0.625rem 1.875rem var(--shadow-light); /* 10px 30px */
    border: 0.0625rem solid var(--border-light); /* 1px */
}

.search-results > p {
    text-align: center;
    color: var(--text-light);
    font-size: 1rem;
    margin-bottom: 0.9375rem; /* 15px */
    font-weight: 500;
}

.search-result-item {
    padding: 0.75rem;
    border-bottom: 0.0625rem solid var(--border-light); /* 1px */
    cursor: pointer;
    transition: background var(--transition-speed) ease, transform var(--transition-speed) ease;
    border-radius: var(--border-radius-small);
    margin-bottom: 0.3125rem; /* 5px */
}

.search-result-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.search-result-item:hover {
    background: var(--background-light);
    transform: translateX(0.3125rem); /* 5px */
}

.search-result-item .course-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.1875rem; /* 3px */
}

.search-result-item .course-code {
    font-size: 0.85rem;
    color: var(--primary-color);
    font-weight: 500;
}

/* Hidden class - removed from HTML and controlled by JS for smooth transitions */
/* .hidden {
    display: none;
} */

/* Footer Styles */
footer {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(0.625rem); /* 10px */
    color: var(--text-dark);
    text-align: center;
    padding: 1.5rem 0;
    margin-top: 1.875rem; /* 30px */
    border-top-left-radius: var(--border-radius-medium);
    border-top-right-radius: var(--border-radius-medium);
    box-shadow: 0 -0.125rem 1.25rem var(--shadow-light); /* -2px 20px */
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(17.5rem, 1fr)); /* 280px */
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: left;
}

.footer-section {
    padding: 0 0.625rem; /* 10px */
}

.footer-section h4 {
    color: var(--primary-color);
    margin-bottom: 0.75rem; /* 12px */
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
}

.footer-section p, .footer-section a {
    color: var(--text-light);
    text-decoration: none;
    line-height: 1.8;
    font-size: 0.9rem;
    text-align: center;
}

.footer-section a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.footer-section .about {
    color: var(--primary-color);
    font-weight: 600;
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 0.75rem; /* 12px */
    margin-top: 0.9375rem; /* 15px */
}

.social-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem; /* 40px */
    height: 2.5rem; /* 40px */
    border: 0.125rem solid var(--primary-color); /* 2px */
    border-radius: 50%;
    color: var(--primary-color);
    text-decoration: none;
    transition: all var(--transition-speed) ease;
    font-size: 1rem;
    box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.1); /* 2px 8px */
}

.social-btn:hover {
    background: var(--primary-color);
    color: var(--white);
    transform: translateY(-0.1875rem) scale(1.05); /* 3px */
    box-shadow: 0 0.375rem 0.9375rem rgba(0, 0, 0, 0.2); /* 6px 15px */
}

.footer-bottom {
    border-top: 0.0625rem solid var(--border-light); /* 1px */
    padding-top: 0.9375rem; /* 15px */
    color: var(--text-light);
    font-size: 0.85rem;
}

.heart-icon {
    color: #e74c3c;
    display: inline-block; /* Required for transform */
    animation: heartbeat 1.5s infinite ease-in-out; /* Heartbeat animation */
}

/* Heartbeat Animation */
@keyframes heartbeat {
    0% {
        transform: scale(1);
    }
    15% {
        transform: scale(1.2);
    }
    30% {
        transform: scale(1);
    }
    45% {
        transform: scale(1.2);
    }
    60% {
        transform: scale(1);
    }
    100% {
        transform: scale(1);
    }
}


/* Responsive Design */

/* Tablet and larger phones (max-width: 1024px) */
@media (max-width: 64rem) { /* 1024px */
    :root {
        font-size: 15px; /* Slightly smaller base font for tablets */
    }

    .container {
        padding: 0 0.9375rem; /* 15px */
    }

    nav.container {
        padding: 0.5rem 0; /* 8px */
    }

    .hero h1 {
        font-size: 2.5rem;
    }

    .hero h2 {
        font-size: 1.5rem;
    }

    .section-title {
        font-size: 1.6rem;
    }

    .semester-grid {
        grid-template-columns: repeat(auto-fit, minmax(11.25rem, 1fr)); /* 180px */
        gap: 0.9375rem; /* 15px */
    }

    .semester-card {
        padding: 0.9375rem; /* 15px */
        min-height: 8.75rem; /* 140px */
        height: 8.75rem; /* Ensure consistent height */
    }

    .semester-card h3 {
        font-size: 1.1rem;
    }

    .semester-card p {
        font-size: 0.8rem;
    }

    .course-grid {
        grid-template-columns: repeat(auto-fit, minmax(17.5rem, 1fr)); /* 280px */
        gap: 0.9375rem; /* 15px */
    }

    .course-card {
        padding: 0.9375rem; /* 15px */
    }

    .course-name {
        font-size: 1.1rem;
    }

    .course-details {
        padding: 1.25rem; /* 20px */
    }

    .resource-section h4 {
        font-size: 1.1rem;
    }

    .resource-link {
        padding: 0.7rem 1.2rem;
        font-size: 0.85rem;
    }

    .back-btn {
        padding: 0.7rem 1.2rem;
    }

    .search-result-item {
        padding: 0.75rem;
    }

    .footer-content {
        grid-template-columns: 1fr; /* Stack columns on tablets */
        text-align: center;
    }

    .footer-section {
        padding: 0;
    }
}

/* Mobile devices (max-width: 768px) */
@media (max-width: 48rem) { /* 768px */
    :root {
        font-size: 14px; /* Even smaller base font for mobile */
    }

    nav {
        flex-direction: column;
        gap: 0.625rem; /* 10px */
    }

    .logo {
        text-align: center;
        width: 100%;
        justify-content: center;
        font-size: 1.4rem;
    }

    .search-container {
        margin: 0.625rem 0; /* 10px */
        width: 95%; /* Adjust width for better fit on small screens */
    }

    .hero {
        padding: 0.9375rem 0.3125rem; /* 15px 5px */
    }

    .hero h1 {
        font-size: 2.2rem;
    }

    .hero h2 {
        font-size: 1.2rem;
        margin-bottom: 1.25rem; /* 20px */
    }

    .hero p {
        font-size: 0.9rem;
    }

    .feedback-btn {
        padding: 0.7rem 1.2rem;
        font-size: 0.9rem;
    }

    .access-note {
        font-size: 0.9rem;
        margin-top: 0.9375rem; /* 15px */
    }

    .content-section {
        padding: 0.9375rem; /* 15px */
    }

    .section-title {
        font-size: 1.4rem;
        margin-bottom: 0.9375rem; /* 15px */
    }

    .semester-grid {
        grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); /* 128px */
        gap: 0.625rem; /* 10px */
    }

    .semester-card {
        padding: 0.625rem; /* 10px */
        min-height: 7.5rem; /* 120px */
        height: 7.5rem; /* Ensure consistent height */
    }

    .semester-card h3 {
        font-size: 1rem;
    }

    .semester-card p {
        font-size: 0.7rem;
    }

    .semester-card .course-list {
        font-size: 0.65rem;
    }

    .course-grid {
        grid-template-columns: 1fr; /* Single column on mobile */
        gap: 0.625rem; /* 10px */
    }

    .course-card {
        padding: 0.75rem;
    }

    .course-name {
        font-size: 1rem;
    }

    .course-code {
        font-size: 0.8rem;
    }

    .course-details {
        padding: 0.9375rem; /* 15px */
    }

    .course-details h3 {
        font-size: 1.3rem;
    }

    .course-details p {
        font-size: 0.9rem;
    }

    .resource-section {
        padding-top: 0.9375rem; /* 15px */
        margin-bottom: 1.25rem; /* 20px */
    }

    .resource-section h4 {
        font-size: 1.1rem;
        gap: 0.3125rem; /* 5px */
    }

    .resource-section h4 i {
        font-size: 1.1rem;
    }

    .resource-links {
        flex-direction: column; /* Stack links vertically on mobile */
        gap: 0.5rem; /* 8px */
    }

    .resource-link {
        padding: 0.6rem 0.75rem;
        font-size: 0.8rem;
        width: 100%; /* Make links full width */
        justify-content: center; /* Center text in full-width links */
    }

    .back-btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
        width: fit-content; /* Adjust width to content */
        margin: 0 auto 0.625rem auto; /* Center button and add margin */
        display: block; /* Ensure it takes full width for centering */
    }

    .search-results {
        padding: 0.9375rem; /* 15px */
    }

    .search-results > p {
        font-size: 0.9rem;
        margin-bottom: 0.625rem; /* 10px */
    }

    .search-result-item {
        padding: 0.6rem;
    }

    .search-result-item .course-name {
        font-size: 1rem;
    }

    .search-result-item .course-code {
        font-size: 0.75rem;
    }

    footer {
        padding: 1.25rem 0; /* 20px */
    }

    .footer-content {
        gap: 0.9375rem; /* 15px */
        margin-bottom: 0.9375rem; /* 15px */
    }

    .footer-section h4 {
        font-size: 1.1rem;
    }

    .social-btn {
        width: 2.2rem; /* 35px */
        height: 2.2rem; /* 35px */
        font-size: 0.9rem;
    }
}
