/* ====== CSS Reset & Variables ====== */
:root {
    /* Logo Colors */
    --logo-grey: #2c3e50;
    /* Main Hex */
    --logo-blue: #3498db;
    /* Secondary Blue */

    /* Layout & Theme */
    --bg-color: #ffffff;
    /* Lots of white space requested */
    --text-primary: #1a1a1a;
    --text-secondary: #5a5a5a;
    --accent-blue: #3e9ce3;

    /* Footer */
    --footer-bg: #f9f9fb;
    --footer-border: #eaeaea;

    /* Typography */
    --font-family: 'Inter', sans-serif;

    /* Spacing */
    --whitespace: 6rem;
    --transition: all 0.3s ease-in-out;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}



/* ====== Typography Classes ====== */
.text-subtle {
    color: var(--text-secondary);
}

.text-bold {
    font-weight: 600;
    color: var(--logo-grey);
}

/* ====== Header & Navigation ====== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    background: #f4f6f8;
    /* Really light grey header */
    padding: 1rem 4rem;
    /* Considerably shrunk vertical padding */
    transition: var(--transition);
}

.navbar.scrolled {
    background: rgba(244, 246, 248, 0.98);
    backdrop-filter: blur(10px);
    padding: 0.6rem 4rem;
    /* Trimmer scroll padding */
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.05);
}



.nav-container {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Recreating the Logo accurately */
.logo {
    font-family: 'Inter', sans-serif;
    font-size: 2.2rem;
    font-weight: 500;
    letter-spacing: -1px;
    color: var(--logo-grey);
    line-height: 1;
}

.logo-img {
    max-height: 28px;
    /* Considerably smaller logo */
    width: auto;
    display: block;
}

/* Tabs */
.nav-links {
    display: flex;
    gap: 3rem;
    align-items: center;
}

.nav-item {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    position: relative;
    padding: 0.5rem 0;
}

.nav-item::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0%;
    height: 1px;
    background-color: var(--logo-blue);
    transition: var(--transition);
}

.nav-item:hover {
    color: var(--logo-grey);
}

.nav-item:hover::after {
    width: 100%;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--logo-grey);
    cursor: pointer;
}

/* ====== Search System ====== */
.search-container {
    position: relative;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--logo-grey);
    padding: 0.4rem 0;
    margin-left: 1rem;
    width: 150px;
}

.search-container .search-input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.95rem;
    color: var(--logo-grey);
    font-family: inherit;
    width: 100%;
}

.search-container .search-input::placeholder {
    color: #b0b0b0;
    font-weight: 300;
}

.search-container .search-btn {
    background: none;
    border: none;
    color: var(--logo-grey);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0;
    margin-left: 0.5rem;
    transition: var(--transition);
}

.search-container .search-btn:hover {
    color: var(--logo-blue);
}

.search-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 15px);
    right: 0;
    width: 250px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid #eaeaea;
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.03);
    z-index: 2000;
}

.search-result-item {
    display: block;
    padding: 0.8rem 0;
    margin: 0 1rem;
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--footer-border);
    transition: color 0.2s ease;
}

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

.search-result-item:hover:not(.no-results) {
    color: var(--logo-grey);
    background: transparent;
}

.search-result-item.no-results {
    color: #999;
    font-weight: 300;
}

/* ====== Hero Section ====== */
.hero-section {
    position: relative;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    text-align: left;
    padding: 0 4rem;
    overflow: hidden;
}

/* Ambient Fluid Mesh Gradient */
.waves {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -2;

    /* Deeply subtle "almost white" base moving gradient */
    background: linear-gradient(135deg, #ffffff, #fafcfd, #f5f8fb, #ffffff);
    background-size: 200% 200%;
    animation: liquidFlow 6s ease-in-out infinite alternate;
}

@keyframes liquidFlow {
    0% {
        background-position: 0% 0%;
    }

    100% {
        background-position: 100% 100%;
    }
}

/* The blurs soften the color into an organic gradient */
.wave {
    position: absolute;
    filter: blur(80px);
    /* Lower blur for slightly more visible distinct liquid shapes */
    border-radius: 50%;
    opacity: 0.95;
}

/* Super light ethereal 'almost white' flowing shapes */
.wave1 {
    width: 70vw;
    height: 70vw;
    top: -15%;
    left: -10%;
    background: #f8fbfe;
    animation: float1 15s ease-in-out infinite alternate;
}

.wave2 {
    width: 80vw;
    height: 80vw;
    bottom: -20%;
    right: -15%;
    background: #f4f7fa;
    animation: float2 18s ease-in-out infinite alternate;
}

.wave3 {
    width: 60vw;
    height: 60vw;
    top: 30%;
    left: 20%;
    background: #fafbfc;
    animation: float3 21s ease-in-out infinite alternate;
}

/* Organic, subtly floating keyframes */
@keyframes float1 {
    0% {
        transform: translate(0, 0) scale(1) rotate(0deg);
    }

    100% {
        transform: translate(5vw, 6vh) scale(1.05) rotate(5deg);
    }
}

@keyframes float2 {
    0% {
        transform: translate(0, 0) scale(1) rotate(0deg);
    }

    100% {
        transform: translate(-6vw, -4vh) scale(1.08) rotate(-5deg);
    }
}

@keyframes float3 {
    0% {
        transform: translate(0, 0) scale(1.1) rotate(0deg);
    }

    100% {
        transform: translate(-5vw, 6vh) scale(0.95) rotate(8deg);
    }
}

/* 3D WebGL Living Mesh Container */
.webgl-mesh {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}

.hero-container {
    max-width: 1100px;
    margin: 0;
    padding-top: var(--whitespace);
    padding-bottom: var(--whitespace);
    position: relative;
    z-index: 1;
    /* Keeping it cleanly above any glows */
}



.hero-title {
    font-size: 3rem;
    font-weight: 500;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin-bottom: 2.5rem;
    min-height: 8rem;
    /* Prevents layout jump while typing */

    background: linear-gradient(135deg, var(--logo-grey) 0%, var(--logo-blue) 40%, var(--logo-grey) 60%, var(--logo-blue) 100%);
    background-size: 300% 300%;
    animation: textLiquidFlow 12s ease infinite alternate;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--logo-grey);
    /* Fallback */
}

@keyframes textLiquidFlow {
    0% {
        background-position: 0% 0%;
    }

    25% {
        background-position: 100% 50%;
    }

    50% {
        background-position: 100% 100%;
    }

    75% {
        background-position: 50% 0%;
    }

    100% {
        background-position: 0% 0%;
    }
}

.cursor {
    display: inline-block;
    width: 3px;
    background-color: var(--logo-blue);
    animation: blink 1s step-end infinite;
    color: transparent;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

.hero-text {
    font-size: 1.4rem;
    font-weight: 300;
    color: var(--logo-grey);
    max-width: 800px;
    margin: 0 0 4rem 0;
    line-height: 1.7;
}



/* ====== Fat Footer ====== */
.fat-footer {
    background-color: var(--footer-bg);
    border-top: 1px solid var(--footer-border);
    padding: 6rem 4rem 2rem;
}

.footer-grid {
    width: 100%;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 4rem;
    margin-bottom: 5rem;
}

.footer-logo {
    display: inline-block;
    margin-bottom: 1.5rem;
    font-size: 2.8rem;
}

.footer-info {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.8;
}

.footer-heading {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.footer-links {
    list-style: none;
}

.footer-links li {
    margin-bottom: 1rem;
}

.footer-links a {
    color: var(--text-secondary);
    font-size: 0.95rem;
    transition: var(--transition);
}

.footer-links a:hover {
    color: var(--logo-blue);
    padding-left: 5px;
}

/* Footer Bottom (Legal Links) */
.footer-bottom {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--footer-border);
    padding-top: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.legal-links {
    display: flex;
    gap: 2rem;
}

.legal-links a {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.legal-links a:hover {
    color: var(--logo-grey);
}

.btn-physics {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid rgba(44, 62, 80, 0.25);
    padding: 0.25rem 0.65rem;
    border-radius: 40px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.25s ease;
}

.btn-physics:hover {
    color: var(--logo-blue);
    border-color: var(--logo-blue);
    background: transparent;
}

.copyright {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ====== Responsive Design ====== */
@media (max-width: 1024px) {
    .desktop-break {
        display: none;
    }

    .footer-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .navbar {
        padding: 1.5rem 2rem;
    }

    .nav-links {
        display: none;
    }

    .nav-links.active {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: #f4f6f8;
        padding: 1rem 0;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
        align-items: center;
        gap: 1.5rem;
    }

    .navbar.scrolled .nav-links.active {
        background: rgba(244, 246, 248, 0.98);
        backdrop-filter: blur(10px);
    }

    .search-container {
        width: 85%;
        margin: 0.5rem auto 1.5rem;
        padding-bottom: 0.5rem;
        margin-left: auto;
        margin-right: auto;
    }

    .search-container .search-dropdown {
        width: 100%;
        right: auto;
        left: 0;
        position: static;
        box-shadow: none;
        border: none;
        border-top: 1px solid var(--footer-border);
        margin-top: 0;
        border-radius: 0;
        background: transparent;
    }

    .nav-item {
        font-size: 1.4rem;
        padding: 0.8rem 1rem;
    }

    .menu-toggle {
        display: block;
        font-size: 1.8rem;
    }

    .hero-section {
        padding: 8rem 2rem 0; /* Moved down to avoid header */
        justify-content: flex-start; /* Align to top with padding instead of centering */
    }

    .hero-title {
        font-size: 1.8rem;
        margin-bottom: 1.5rem;
        min-height: auto;
        transform: scale(0.95); /* Scaled down slightly */
        transform-origin: left center;
    }

    .hero-text {
        font-size: 1rem;
        margin-bottom: 2rem;
        transform: scale(0.95); /* Scaled down slightly */
        transform-origin: left center;
    }

    .footer-grid {
        grid-template-columns: 1fr;
        gap: 3rem;
    }

    .footer-bottom {
        flex-direction: column;
        text-align: center;
    }

    .legal-links {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
    }
}

/* ====== Accessibility Tools ====== */

.page-content {
    max-width: 800px;
    margin: 120px auto 100px;
    padding: 0 2rem;
    color: var(--text-secondary);
    animation: fadeIn 0.5s ease-out forwards;
    transition: font-size 0.3s, background 0.3s, filter 0.3s;
}

.page-title {
    color: var(--logo-grey);
    font-size: 2.5rem;
    font-weight: 500;
    margin-bottom: 2rem;
    letter-spacing: -1px;
}

.page-content p,
.page-content li {
    margin-bottom: 2rem;
    line-height: 2;
    font-size: 1em;
}

.page-content ul {
    padding-left: 2rem;
    margin-bottom: 2rem;
}

h2 {
    color: var(--logo-grey);
    margin-top: 3.5rem;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    font-weight: 500;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Reading Tools Sidebar */
.reading-sidebar {
    position: fixed;
    top: 50%;
    right: 0;
    left: auto;
    transform: translateY(-50%) translateX(0);
    background: #ffffff;
    border: 1px solid #eaeaea;
    border-right: none;
    border-radius: 8px 0 0 8px;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    z-index: 9999;
    transition: transform 0.3s ease;
}

.reading-sidebar.closed {
    transform: translateY(-50%) translateX(100%);
}

.sidebar-toggle {
    position: absolute;
    left: -32px;
    right: auto;
    top: 50%;
    transform: translateY(-50%);
    background: #ffffff;
    border: 1px solid #eaeaea;
    border-right: none;
    width: 32px;
    height: 48px;
    border-radius: 8px 0 0 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: -2px 0 5px rgba(0, 0, 0, 0.02);
    color: var(--logo-grey);
    font-size: 1.2rem;
}

.sidebar-tools {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
}

.tool-btn {
    background: #f4f6f8;
    border: 1px solid #eaeaea;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--logo-grey);
    transition: all 0.2s;
    position: relative;
}

.tool-btn:hover,
.tool-btn.active {
    background: var(--logo-blue);
    color: #ffffff;
    border-color: var(--logo-blue);
}

/* Tooltips */
.tool-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    right: 120%;
    left: auto;
    top: 50%;
    transform: translateY(-50%);
    background: #1a1a1a;
    color: #ffffff;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 10000;
}

.tool-btn:hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(-5px);
}

/* Font Size Slider Bar */
.font-size-bar {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: #ffffff;
    border: 1px solid #eaeaea;
    border-radius: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.5rem 1.5rem;
    z-index: 9999;
    transition: opacity 0.3s;
}

.font-size-bar.hidden {
    display: none;
}

.font-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--logo-grey);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    transition: background 0.2s;
}

.font-btn:hover {
    background: #f4f6f8;
}

.font-slider-input {
    width: 150px;
    cursor: pointer;
}

/* Line Reader Overlay */
#lineReaderOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    display: none;
}

#lineReaderHole {
    position: absolute;
    left: 0;
    width: 100%;
    height: 100px;
    background: rgba(255, 255, 255, 0.15);
    border-top: 1px solid #ffffff;
    border-bottom: 1px solid #ffffff;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.7);
}

/* Reading Modes (Fonts) */
body.theme-opendyslexic .page-content * {
    font-family: 'OpenDyslexic', sans-serif !important;
    letter-spacing: 0.5px;
}

body.theme-lexend .page-content * {
    font-family: 'Lexend', sans-serif !important;
}

.sub-title {
    color: var(--logo-grey);
    margin-top: 2.5rem !important;
    margin-bottom: 0.5rem !important;
    font-size: 1.1em;
}