/* Global Variables */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #e74c3c;
    /* Red Highlight */
    --accent-color: #3498db;
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --text-color: #333333;
    --text-muted: #666666;
    --shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 25px rgba(0, 0, 0, 0.15);
    --radius-md: 12px;
    --font-heading: 'Roboto Slab', serif;
    --font-body: 'Raleway', sans-serif;
    --nav-height: 70px;
}

/* Smooth Scroll */
html {
    scroll-behavior: smooth;
}

/* Reset & Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    color: var(--text-color);
    background-color: var(--bg-color);
    line-height: 1.6;
    padding-top: var(--nav-height);
    /* Prevent content hiding behind fixed nav */
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.3s;
}

a:hover {
    color: var(--secondary-color);
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    color: var(--primary-color);
    margin-bottom: 1rem;
}

h1 {
    font-size: 1.6em;
}

/* Navbar */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--nav-height);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    transition: all 0.3s ease;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--primary-color);
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    list-style: none;
}

.nav-link {
    font-weight: 500;
    color: var(--text-color);
    font-size: 0.95rem;
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -4px;
    left: 0;
    background-color: var(--secondary-color);
    transition: width 0.3s;
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

.btn-contact {
    padding: 0.5rem 1.2rem;
    background-color: var(--secondary-color);
    color: white;
    border-radius: 20px;
    font-weight: 600;
    transition: transform 0.2s, background-color 0.2s;
}

.btn-contact:hover {
    color: white;
    background-color: #c0392b;
    transform: translateY(-2px);
}

/* Mobile Menu Toggle */
.menu-toggle {
    display: none;
    font-size: 1.5rem;
    cursor: pointer;
}

/* Hero Section */
.hero {
    height: calc(100vh + var(--nav-height));
    margin-top: calc(-1 * var(--nav-height));
    /* Counteract body padding */
    display: flex;
    align-items: flex-start;
    justify-content: center;
    background: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url('https://cdn.jsdelivr.net/gh/needleworm/needleworm.github.io@main/src/images/bookcovers.jpg') center/cover no-repeat;
    color: white;
    text-align: center;
    padding: calc(17.5vh + var(--nav-height)) 1rem 0;
    position: relative;
}

.hero-content {
    max-width: 800px;
    width: 100%;
    animation: fadeInUp 1s ease-out;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.profile-img {
    width: 25vh;
    height: auto;
    max-width: 50vw;
    aspect-ratio: 1;
    border-radius: 50%;
    border: 4px solid white;
    margin-bottom: 2rem;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
    object-fit: cover;
}

.hero-title {
    font-size: 3.5rem;
    margin-bottom: 0.5rem;
    color: white;
}

.hero-subtitle {
    font-size: 1.2rem;
    font-weight: 300;
    margin-bottom: 2rem;
    opacity: 0.9;
}

.hero-socials {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.social-icon {
    font-size: 1.8rem;
    color: white;
    transition: transform 0.3s;
}

.social-icon:hover {
    transform: translateY(-5px);
    color: var(--secondary-color);
}

/* Hero Buttons */
.hero-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.btn-hero {
    padding: 0.8rem 2rem;
    border-radius: 50px;
    font-weight: 700;
    font-size: 1rem;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background-color: var(--secondary-color);
    color: white;
    border: 2px solid var(--secondary-color);
}

.btn-primary:hover {
    background-color: #c0392b;
    border-color: #c0392b;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(231, 76, 60, 0.4);
}

.btn-secondary {
    background-color: white;
    color: var(--text-color);
    border: 2px solid white;
}

.btn-secondary:hover {
    background-color: #f0f0f0;
    border-color: #f0f0f0;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(255, 255, 255, 0.3);
}

/* Hero Stats Banner (Glassmorphism) */
.hero-stats-banner {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 12px 10px;
    margin-top: 1rem;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
}

.stat-item {
    display: flex;
    align-items: center;
    padding: 0 24px;
    text-decoration: none;
    color: white;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    border-radius: 8px;
}

.stat-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    color: white;
    /* Ensure text stays white */
}

.stat-icon {
    font-size: 1.8rem;
    margin-right: 14px;
    opacity: 0.9;
    color: rgba(255, 255, 255, 0.8);
}

.stat-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.8rem;
    opacity: 0.7;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
}

.stat-divider {
    width: 1px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
}

/* Responsive adjustments for banner */
@media (max-width: 576px) {
    .hero-stats-banner {
        padding: 10px 5px;
        width: 100%;
        justify-content: space-around;
        border-radius: 12px;
    }

    .stat-item {
        padding: 0 8px;
        /* Reduce padding */
        border-radius: 6px;
    }

    .stat-icon {
        font-size: 1.2rem;
        /* Smaller icon */
        margin-right: 8px;
    }

    .stat-label {
        font-size: 0.65rem;
    }

    .stat-value {
        font-size: 1rem;
        /* Smaller number */
    }

    .stat-divider {
        height: 24px;
    }
}

/* Scroll Arrow */
.scroll-down-arrow {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 1.5rem;
    animation: bounce 2s infinite;
    cursor: pointer;
    opacity: 0.8;
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translate(-50%, 0);
    }

    40% {
        transform: translate(-50%, -10px);
    }

    60% {
        transform: translate(-50%, -5px);
    }
}

/* Section Common Styles */
section {
    padding: 5rem 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.section-title {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 1rem;
    position: relative;
    display: inline-block;
    left: 50%;
    transform: translateX(-50%);
}

.section-title::after {
    content: '';
    display: block;
    width: 60px;
    height: 4px;
    background-color: var(--secondary-color);
    margin: 10px auto 0;
    border-radius: 2px;
}

.section-description {
    text-align: center;
    max-width: 700px;
    margin: 0 auto 3rem;
    color: var(--text-muted);
}

/* Sub-tabs for sections (e.g. Media/News) */
.sub-tabs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.sub-tab-btn {
    padding: 0.5rem 1.5rem;
    border: 2px solid #e0e0e0;
    background: transparent;
    border-radius: 30px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.3s;
}

.sub-tab-btn.active,
.sub-tab-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Grid Layouts */
/* Grid Layouts - Desktop Default (3 Columns) */
.grid-container,
.bookContainer,
.websitesContainer,
.lecturesContainer,
.codesContainer,
.projectContainer {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s, box-shadow 0.3s;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
}

.card-img-top {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-bottom: 1px solid #eee;
}

.card-body {
    padding: 1.5rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.card-text {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: auto;
    /* Push footer down */
}

.card-footer {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
}

.btn-sm {
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 4px;
    background: #f1f1f1;
    color: #555;
    transition: 0.2s;
}

.btn-sm:hover {
    background: var(--secondary-color);
    color: white;
}

/* Book Specifics using existing classes to minimize HTML rewrite if possible, but cleaner to use new ones */
/* We will map old classes to these new visual styles in the implementation */

/* Contact Section */
/* ----------------------------------------------------- */
/* Contact Section - White Card Design */
/* ----------------------------------------------------- */
#contact {
    background: #f8f9fa;
    padding: 4rem 0;
}

#contact .section-title {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

#contact .section-description {
    color: var(--text-color);
    margin-bottom: 3rem;
}

.contact-form-container {
    max-width: 600px;
    margin: 0 auto;
    background: #ffffff;
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #333;
    font-weight: 500;
    font-size: 0.95rem;
}

.form-control {
    width: 100%;
    padding: 0.85rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    background: #f8f9fa;
    transition: border-color 0.3s, background 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: #e74c3c;
    background: #ffffff;
}

textarea.form-control {
    resize: vertical;
    min-height: 120px;
}

.btn-submit {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.3s, transform 0.2s, box-shadow 0.3s;
}

.btn-submit:hover {
    background: linear-gradient(135deg, #c0392b 0%, #a93226 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
}

.btn-submit:active {
    transform: translateY(0);
}

/* Progressive Reveal Styling */
.hidden-field {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.4s ease, margin 0.4s ease;
    margin-bottom: 0;
}

.hidden-field.visible {
    max-height: 200px;
    opacity: 1;
    margin-bottom: 1.5rem;
}

/* Form Animation */
@keyframes formReveal {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.contact-form-container {
    animation: formReveal 0.6s ease;
}

/* Footer */
footer {
    background: #222;
    color: #888;
    padding: 3rem 0;
    text-align: center;
    font-size: 0.9rem;
}

.btn-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: var(--secondary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    z-index: 900;
    transition: transform 0.3s;
}

.btn-to-top:hover {
    transform: translateY(-5px);
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        padding: 0 1rem;
    }

    .hero {
        height: auto !important;
        min-height: calc(100vh + var(--nav-height));
        padding-top: calc(10vh + var(--nav-height)) !important;
        padding-bottom: 2rem;
    }

    @media (max-height: 800px) {
        .hero {
            padding-top: calc(15vh + var(--nav-height)) !important;
        }

        .profile-img {
            width: 20vh;
            margin-bottom: 1rem;
        }

        .hero-title {
            font-size: 2rem;
            margin-bottom: 0.2rem;
        }

        .hero-subtitle {
            margin-bottom: 1rem;
        }

        .hero-socials {
            margin-bottom: 1rem;
        }
    }

    .nav-links {
        display: none;
        position: fixed;
        top: var(--nav-height);
        left: 0;
        width: 100%;
        height: calc(100vh - var(--nav-height));
        background: white;
        flex-direction: column;
        padding: 1rem;
        box-shadow: var(--shadow-md);
        overflow-y: auto;
    }

    .nav-links.active {
        display: flex;
        align-items: center;
        /* Center children horizontally */
        text-align: center;
    }

    .nav-links li {
        width: 100%;
        /* Ensure li takes full width */
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        margin-bottom: 1rem;
        /* Spacing between items */
    }

    .menu-toggle {
        display: block;
    }

    .contact-layout {
        grid-template-columns: 1fr;
    }

    .profile-img {
        /* Inherit global settings */
    }

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

    .hero-buttons {
        gap: 0.5rem;
    }

    .btn-hero {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
    }

    /* 2-column grid for mobile */
    /* 2-column grid for mobile */
    /* 2-column grid for mobile - Enforced */
    .grid-container,
    .bookContainer,
    .websitesContainer,
    .lecturesContainer,
    .codesContainer,
    .projectContainer {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem;
    }

    /* Override for Websites: 1 Column on Mobile */
    #tab-websites .websitesContainer {
        grid-template-columns: 1fr !important;
    }

    /* Reduce font size for mobile cards */
    .singleBookContainer h5,
    .singleWebsiteCard h5,
    .singleNewsCard h5,
    .projectText h5 {
        font-size: 0.95rem !important;
        min-height: 2.5rem;
        /* Adjust per font size */
    }

    .bookDescription,
    .projectText,
    .codeBody {
        font-size: 0.8rem !important;
        padding: 1rem !important;
        /* Reduce padding slightly */
    }
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Utility for hidden elements (tabs) */
.hidden-content {
    display: none;
}

/* ----------------------------------------------------- */
/* Mapped Styles for Legacy HTML Classes */
/* ----------------------------------------------------- */

/* Legacy Class Mappings */
/* Legacy Class Mappings - Removed to prevent conflicts */

/* Ensure images don't overflow */
img {
    max-width: 100%;
    height: auto;
}

/* Book Card */
.singleBookContainer {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.singleBookContainer:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

/* Wrappers for other cards */
.singleLectureContainer,
.singleProjectContainer {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* The General Card (used inside wrappers) */
.singleWebsiteCard {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.singleLectureContainer:hover .singleWebsiteCard,
.singleProjectContainer:hover .singleWebsiteCard {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

/* Images */
.bookCoverImage,
.websiteImage {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-bottom: 1px solid #eee;
}

/* Text in Cards */
.bookDescription,
.projectText,
.codeBody {
    padding: 1.5rem;
    flex-grow: 1;
    font-size: 0.9rem;
    color: var(--text-color);
}

/* Fix for double padding when nested */
.projectText .bookDescription,
.projectText .codeBody {
    padding: 0 !important;
}

.projectText h5 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

/* Link Resets in Cards */
.singleWebsiteCard a {
    text-decoration: none;
    color: var(--text-color);
}

.singleWebsiteCard a:hover {
    color: var(--secondary-color);
}

/* Icons/Links */
.list-inline,
.lectureIcons,

.gitIcons {
    padding: 1rem;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    justify-content: flex-start;
    list-style: none;
    margin-top: auto;
    /* Push to bottom */
}

/* Section Headings */
.subpageHeading {
    color: var(--primary-color);
    margin-top: 4rem;
    margin-bottom: 2rem;
    text-align: center;
    font-family: var(--font-heading);
}

.subpageHeading::after {
    content: '';
    display: block;
    width: 60px;
    height: 4px;
    background-color: var(--secondary-color);
    margin: 10px auto 0;
    border-radius: 2px;
}

/* Animation Overrides */
.animated {
    animation: none !important;
    visibility: visible !important;
}

/* Hide original section backgrounds/styles if any conflicting */
section .row {
    margin: 0;
    /* Reset bootstrap row margins if present in inherited css or just safe reset */
}

/* Layout Refinement Styles */
.section-group {
    padding-top: 5rem;
    padding-bottom: 5rem;
    border-bottom: 1px solid #f0f0f0;
}

.group-header {
    margin-bottom: 3rem;
    text-align: center;
}

.group-title {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.group-desc {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.sub-nav-pills {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.pill-btn {
    padding: 0.5rem 1.5rem;
    border: 2px solid #eee;
    background: white;
    border-radius: 50px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.pill-btn:hover {
    background: var(--bg-color);
    border-color: var(--secondary-color);
    color: var(--secondary-color);
}

/* Hidden Items & Load More */
.hidden-item {
    display: none !important;
}

.btn-load-more {
    display: block;
    margin: 2rem auto 0;
    padding: 0.8rem 2.5rem;
    background: white;
    border: 2px solid var(--secondary-color);
    color: var(--secondary-color);
    border-radius: 50px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-load-more:hover {
    background: var(--secondary-color);
    color: white;
}

/* ----------------------------------------------------- */
/* Tab Switching Animations */
/* ----------------------------------------------------- */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.active-tab-content {
    animation: fadeIn 0.5s ease-out;
}

/* Ensure hidden items are truly hidden */
.tab-content-item {
    width: 100%;
}


/* ----------------------------------------------------- */
/* Book Card Design Update (Refinement) */
/* ----------------------------------------------------- */

/* 1. Square Images */
.bookCoverImage {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    object-position: center;
    border-bottom: 1px solid #eee;
}

/* 2. Typography Updates */
.singleBookContainer h5 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 1.2rem 1rem 0.5rem 1rem;
    color: var(--primary-color);
    line-height: 1.4;
    min-height: 3rem;
    /* Align titles */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bookDescription {
    font-size: 0.9rem;
    color: #95a5a6;
    /* Softer text for publisher/date */
    margin: 0 1rem 1rem 1rem;
    padding: 0;
    /* Remove old padding if any */
    font-weight: 500;
}

/* 3. Store Icon Limit */
.bookStoreIcon {
    max-width: 50px;
    max-height: 50px;
    width: auto;
    height: auto;
    object-fit: contain;
    transition: transform 0.2s;
}

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

.list-inline {
    padding: 1rem;
    justify-content: center;
    /* Center icons */
    gap: 15px;
    /* Better spacing */
}

.list-inline li {
    display: inline-block;
}


/* ----------------------------------------------------- */
/* Hotfix: Force Square Images & Smaller Icons */
/* ----------------------------------------------------- */

.bookCoverImage {
    height: auto !important;
    /* Override fixed height */
    aspect-ratio: 1 / 1 !important;
}

.bookStoreIcon {
    max-width: 30px !important;
    max-height: 30px !important;
}


/* ----------------------------------------------------- */
/* Store Icons: Rounded & Shadow */
/* ----------------------------------------------------- */

.bookStoreIcon {
    border-radius: 8px !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15) !important;
    /* Optional: Ensure they show as tiles if transparent */
    background-color: #fff;
}

/* ----------------------------------------------------- */
/* Global Icon Alignment */
/* ----------------------------------------------------- */

.gitIcons {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 15px;
}

/* ----------------------------------------------------- */
/* Papers Section Refinement */
/* ----------------------------------------------------- */

/* 1. Image Aspect Ratio (1:1.4) */
#tab-papers .singleWebsiteCard .websiteImage {
    aspect-ratio: 1 / 1.4 !important;
    object-fit: cover;
    object-position: top center;
    height: auto !important;
    /* Override potential fixed heights */
}

/* Patent Image Aspect Ratio (4:3) */
#tab-patents .singleWebsiteCard .websiteImage {
    aspect-ratio: 4 / 3 !important;
    object-fit: cover;
    object-position: top center;
    height: auto !important;
}

/* Collections Image Aspect Ratio (1:1) */
#tab-collections .singleWebsiteCard .websiteImage {
    aspect-ratio: 1 / 1 !important;
    object-fit: cover !important;
    height: 100% !important;
    /* Ensure it fills the container */
    width: 100% !important;
}

/* Social Image Aspect Ratio (1:1.4) */
#tab-social .singleWebsiteCard .websiteImage {
    aspect-ratio: 1 / 1.4 !important;
    object-fit: cover !important;
    height: auto !important;
    object-position: top center;
}



#tab-papers .gitIcons,
#tab-patents .gitIcons {
    padding-top: 1rem;
    /* Space for border */
    border-top: 1px solid #eee !important;
    /* Restore border */
    margin-top: 1rem;
    width: 100%;
    display: flex;
    justify-content: flex-end;
    /* Right align */
    gap: 15px;
}

/* 2. Text Truncation */
.paper-description-truncated,
.description-truncated {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    /* Changed to 4 lines as requested */
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 3. Show More Button */
.paper-show-more-btn,
.show-more-btn {
    display: block;
    margin: 0.5rem auto 0;
    /* Center block */
    color: var(--primary-color);
    font-size: 0.85rem;
    font-weight: 400;
    /* Remove bold */
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    text-align: right;
    /* Text aligns to right */
    width: 90%;
    /* Match abstract width */
}

.paper-show-more-btn:hover,
.show-more-btn:hover {
    text-decoration: underline;
}

/* 5. Title Width Refinement */
#tab-papers .projectText h5 {
    width: 90% !important;
    margin: 0 auto 0.5rem auto !important;
}

/* 4. Abstract Layout Refinement */
#tab-papers .projectText,
#tab-papers .codeBody {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
}

#tab-papers .bookDescription {
    margin: 0 auto !important;
    /* Center with auto margins */
    text-align: justify !important;
    width: 90% !important;
    /* Set to 90% width as requested */
}

/* ----------------------------------------------------- */
/* Media Section Aspect Ratio (16:9) */
/* ----------------------------------------------------- */
#media-section .singleWebsiteCard .YoutubePreview,
#media-section .singleWebsiteCard .websiteImage {
    aspect-ratio: 16 / 9 !important;
    width: 100%;
    object-fit: cover;
    height: auto !important;
}

/* ----------------------------------------------------- */
/* News Section Refinement */
/* ----------------------------------------------------- */

/* News Card Style */
.singleNewsCard {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s, box-shadow 0.3s;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    height: 100%;
}

.singleNewsCard:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

/* Force Hidden Thumbnail to Show */
.singleNewsCard .hideOnDesktop {
    display: block !important;
}

/* Thumbnail Area */
.singleNewsCard .newsThumnail {
    width: 100%;
    margin: 0;
    padding: 0;
    position: relative;
    height: 200px;
    overflow: hidden;
}

/* Image Style */
.singleNewsCard .newsImage {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block !important;
}

/* Hide the small text label inside thumbnail (e.g. '??????') as it's often redundant or overlays poorly */
.singleNewsCard .newsThumnail h5 {
    position: absolute;
    bottom: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.6);
    color: white !important;
    font-size: 0.8rem !important;
    padding: 4px 10px;
    margin: 0;
    border-top-left-radius: 8px;
}

/* Text Area */
.singleNewsCard .projectText {
    padding: 1.5rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* Title Link */
.singleNewsCard .projectText a {
    text-decoration: none;
}

.singleNewsCard .projectText h5 {
    color: var(--primary-color);
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.8rem;
    line-height: 1.4;
    transition: color 0.3s;
}

.singleNewsCard .projectText a:hover h5 {
    color: var(--secondary-color);
}

/* Meta/Date */
.singleNewsCard .codeBody {
    margin-top: auto;
}

.firstCommitDate {
    display: block;
    color: var(--primary-color);
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}


/* ----------------------------------------------------- */
/* Custom Select Dropdown for Contact Form */
/* ----------------------------------------------------- */
.custom-select-wrapper {
    position: relative;
    user-select: none;
}

.custom-select {
    position: relative;
    width: 100%;
}

.select-selected {
    background-color: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 0.85rem;
    cursor: pointer;
    transition: border-color 0.3s;
}

.select-selected:hover {
    border-color: #ffc107;
}

.select-selected::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 0.85rem;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border: 5px solid transparent;
    border-color: #333 transparent transparent transparent;
}

.select-selected.select-arrow-active::after {
    border-color: transparent transparent #333 transparent;
    top: 40%;
}

.select-items {
    position: absolute;
    background-color: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 99;
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
    margin-top: 4px;
}

.select-items div {
    padding: 0.7rem 0.85rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.select-items div:hover {
    background-color: #f8f9fa;
}

.select-items div.same-as-selected {
    background-color: #ffc107;
    color: white;
}

.select-hide {
    display: none;
}

.phone-input-group {
    display: flex;
    gap: 0.5rem;
}

.phone-input-group .custom-select-wrapper {
    flex: 0 0 140px;
}

.phone-input-group input[type="tel"] {
    flex: 1;
}

/* Fix for dropdown being clipped by parent overflow */
#div-phone,
#div-institution,
#div-email {
    overflow: visible !important;
}

/* ----------------------------------------------------- */
/* Toast Notification */
/* ----------------------------------------------------- */
.toast-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 40px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    font-size: 18px;
    font-weight: 600;
    animation: scaleIn 0.3s ease-out, fadeOut 0.4s ease-in 2.6s;
    pointer-events: none;
    min-width: 300px;
    text-align: center;
}

.toast-notification.success {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

.toast-notification.error {
    background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%);
}

@keyframes scaleIn {
    from {
        transform: translate(-50%, -50%) scale(0.7);
        opacity: 0;
    }

    to {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    to {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.95);
    }
}

@media (max-width: 768px) {
    .toast-notification {
        top: 50%;
        left: 50%;
        right: auto;
        transform: translate(-50%, -50%);
        min-width: 280px;
        max-width: 90vw;
    }
}

/* ----------------------------------------------------- */
/* Logo Styling */
/* ----------------------------------------------------- */
.navbar-brand a {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.navbar-brand .logo-img {
    height: 40px;
    width: auto;
    max-width: 200px;
    object-fit: contain;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.navbar-brand .logo-img:hover {
    transform: scale(1.05);
}

@media (max-width: 768px) {
    .navbar-brand .logo-img {
        height: 32px;
        max-width: 150px;
    }
}

/* Footer Container Override */
footer .container {
    text-align: center;
}

footer p {
    margin: 0.5rem 0;
    text-align: center;
}

/* Force overflow hidden to prevent horizontal scroll issues */
html,
body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0;
    padding: 0;
    position: relative;
}

/* Ultra-narrow screens adjustments */
@media (max-width: 350px) {
    .hero {
        padding: 0 0.5rem;
    }

    .hero-title {
        font-size: 1.5rem !important;
    }

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

    .btn-hero {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }

    .stat-badge {
        font-size: 0.75rem;
        padding: 0.4rem 0.8rem;
    }

    .social-icon {
        font-size: 1.4rem;
    }

    /* Ensure profile image stays circular and small enough */
    .profile-img {
        width: 50vw !important;
        height: auto !important;
        max-width: 150px !important;
    }
}

/* Consolidate overrides */
.hero-content {
    min-width: 0 !important;
    width: 100% !important;
    max-width: 800px !important;
    padding: 0 1rem;
}

.profile-img {
    width: 30vh;
    max-width: 60vw;
    height: auto !important;
    aspect-ratio: 1 / 1 !important;
    object-fit: cover;
}

/* ----------------------------------------------------- */
/* Text Truncation Logic */
/* ----------------------------------------------------- */
/* Hide abstracts completely by default in Papers section */
.abstract {
    display: none;
    margin-top: 15px;
    text-align: justify;
}

.abstract.expanded {
    display: block !important;
    margin-top: 15px;
    text-align: justify;
}

/* Truncate other content to 3 lines */
.projectText.description-truncated,
.codeBody.description-truncated {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.show-more-btn {
    background: none;
    border: none;
    color: var(--secondary-color, #e74c3c);
    padding: 0;
    font-size: 0.9rem;
    cursor: pointer;
    margin-top: 0.5rem;
    font-weight: 500;
    display: inline-block;
}

.show-more-btn:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    .description-truncated {
        /* Hide entire description on mobile by default */
        display: block !important;
        height: 0 !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        -webkit-line-clamp: unset !important;
        overflow: hidden !important;
    }
}

/* Mobile Small Screens (< 450px) */
@media (max-width: 450px) {

    .grid-container,
    .bookContainer,
    .websitesContainer,
    .lecturesContainer,
    .codesContainer,
    .projectContainer {
        grid-template-columns: 1fr !important;
    }


}


.language-chart-container {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    position: relative;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

.language-chart-container canvas {
    width: 100% !important;
    height: auto !important;
    display: block;
    max-width: 100%;
}

@media (max-width: 550px) {
    .language-chart-container {
        width: 90vw;
    }
}

@media (max-width: 768px) {
    .bookDescription.description-truncated {
        height: auto !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        margin-bottom: 1rem !important;
        overflow: hidden !important;
    }
}

/* Submenu Styles */
.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    height: 100%;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    box-shadow: var(--shadow-md);
    padding: 0.5rem 0;
    border-radius: 8px;
    z-index: 1001;
    min-width: 150px;
    list-style: none;
    flex-direction: column;
}

.dropdown-menu.show-dropdown {
    display: flex;
    animation: fadeInUpDropdown 0.3s ease-out;
}

@keyframes fadeInUpDropdown {
    from {
        opacity: 0;
        transform: translate(-50%, 10px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

.dropdown-menu li {
    width: 100%;
}

.dropdown-menu a {
    display: block;
    padding: 0.8rem 1.5rem;
    color: var(--text-color);
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
    text-align: left;
}

/* Hover effect handled by JS, but style for items */
.dropdown-menu a:hover {
    background: #f8f9fa;
    color: var(--secondary-color);
}

/* Mobile specific overrides */
@media (max-width: 768px) {
    .nav-item {
        flex-direction: column;
        align-items: center;
        height: auto;
        width: 100%;
    }

    .dropdown-menu {
        display: block !important;
        position: static;
        box-shadow: none;
        transform: none;
        padding-left: 0;
        background: transparent;
        width: 100%;
        border-radius: 0;
        text-align: center;
    }

    .dropdown-menu a {
        padding: 0.5rem 0;
        font-size: 0.85rem;
        color: var(--text-muted);
        text-align: center;
    }
}

.firstCommitDate {
    color: var(--secondary-color);
}