/* CSS Variables for Theming */
:root {
    /* Dark Mode (Default) */
    --bg-color: #121212;
    --text-color: #e6e6e6;
    --sidebar-bg: #1c2526;
    --section-bg: #212121;
    --highlight-color: #14e849;
    --highlight-bg: #14e84933;
    --code-bg: #1a1a1a;
    --link-color: #14e849;
    --link-hover-color: #ffffff;
    --button-bg: #14e849;
    --button-text: #121212;
    --border-color: #444;
}

/* Light Mode */
[data-theme="light"] {
    --bg-color: #f5f5f5;
    --text-color: #333;
    --sidebar-bg: #e0e0e0;
    --section-bg: #ffffff;
    --highlight-color: #0066cc;
    --highlight-bg: #0066cc33;
    --code-bg: #f0f0f0;
    --link-color: #0066cc;
    --link-hover-color: #003366;
    --button-bg: #0066cc;
    --button-text: #ffffff;
    --border-color: #999;
}

/* General Reset and Typography */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 100%;
}

body {
    font-family: 'Inter', 'Roboto', Arial, sans-serif;
    line-height: 1.8;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    min-height: 100vh;
    font-size: 1rem;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Skip Link */
.skip-link {
    position: absolute;
    top: -100px;
    left: 10px;
    background: var(--highlight-color);
    color: var(--button-text);
    padding: 10px 15px;
    border-radius: 4px;
    z-index: 1000;
    transition: top 0.3s ease;
}

.skip-link:focus {
    top: 10px;
}

/* Sidebar Toggle Button (Mobile) */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 14px;
    left: 70%;
    background: var(--highlight-color);
    color: var(--button-text);
    border: none;
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 1.4rem;
    cursor: pointer;
    z-index: 1001;
    transition: background 0.3s ease, transform 0.2s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* Hamburger Icon Using Unicode */
.sidebar-toggle::before {
    content: '☰';
    font-weight: bold;
}

.sidebar-toggle:hover,
.sidebar-toggle.hovered {
    background: var(--highlight-bg);
    transform: scale(1.05);
}

.sidebar-toggle:active {
    transform: scale(0.95);
}

/* Sidebar (Left Column) */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    padding: 40px 25px;
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    overflow-y: auto;
    border-right: 2px solid var(--highlight-bg);
    z-index: 100;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Logo Styling */
.logo {
    display: block;
    height: 50px; /* Fixed height, width auto-adjusts to maintain aspect ratio */
    width: auto;
    margin: 0 auto 20px auto; /* Center the logo with bottom margin */
    border: 1px solid var(--border-color); /* Subtle border */
    border-radius: 6px; /* Rounded corners */
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); /* Subtle shadow for depth */
    transition: transform 0.3s ease, filter 0.3s ease; /* Smooth hover effects */
}

.logo:hover {
    transform: scale(1.05); /* Slight scale on hover */
    filter: brightness(1.1); /* Slight brightness increase */
}

.logo:focus {
    outline: 2px solid var(--highlight-color); /* Accessibility focus outline */
    outline-offset: 2px;
}

.sidebar h2 {
    font-size: 1.75rem;
    color: var(--highlight-color);
    margin-bottom: 20px;
    border-bottom: 2px solid var(--highlight-bg);
    padding-bottom: 15px;
    font-weight: 600;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    text-align: center; /* Center the heading for better alignment with logo */
}

/* Theme Toggle Button */
#theme-toggle {
    width: 100%;
    padding: 12px;
    margin-bottom: 20px;
    background: var(--button-bg);
    color: var(--button-text);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background 0.3s ease, transform 0.2s ease;
    position: relative;
    overflow: hidden;
}

#theme-toggle:hover {
    background: var(--highlight-bg);
    transform: translateY(-2px);
}

#theme-toggle:focus {
    outline: 2px solid var(--link-hover-color);
    outline-offset: 2px;
}

/* Search Bar in Sidebar */
#search-bar {
    width: 100%;
    padding: 12px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--code-bg);
    color: var(--text-color);
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

#search-bar:focus {
    border-color: var(--highlight-color);
    outline: none;
}

.sidebar ul {
    list-style: none;
}

.sidebar ul li {
    margin-bottom: 12px;
}

.sidebar ul li a {
    color: var(--text-color);
    text-decoration: none;
    font-size: 1.05rem;
    font-weight: 400;
    transition: color 0.3s ease, padding-left 0.3s ease, background 0.3s ease;
    display: block;
    padding: 12px 15px;
    border-radius: 6px;
}

.sidebar ul li a:hover {
    color: var(--highlight-color);
    background: var(--code-bg);
    padding-left: 20px;
}

.sidebar ul li a:focus {
    outline: 2px solid var(--highlight-color);
    outline-offset: 2px;
}

/* Main Content (Right Column) */
.content {
    margin-left: 280px;
    padding: 60px 50px 120px 50px;
    flex: 1;
    background: var(--bg-color);
    overflow-y: auto;
    min-height: 100vh;
    overflow-x: hidden;
}

section {
    margin-bottom: 60px;
    background: var(--section-bg);
    padding: 35px;
    border-radius: 12px;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4);
    border-left: 5px solid var(--highlight-color);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease, box-shadow 0.3s ease;
    overflow-x: hidden;
}

section.visible {
    opacity: 1;
    transform: translateY(0);
}

section:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
}

/* Pulse Animation for Sections After Scrolling */
section.pulse {
    animation: pulse 0.6s ease-in-out;
}

@keyframes pulse {
    0% {
        box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4);
    }
    50% {
        box-shadow: 0 6px 15px rgba(255, 255, 255, 0.3);
    }
    100% {
        box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4);
    }
}

/* Headings */
h1 {
    font-size: 3.5rem;
    color: var(--text-color);
    margin-bottom: 30px;
    font-weight: 800;
    letter-spacing: 1.2px;
    text-align: center;
    text-transform: uppercase;
}

h2 {
    font-size: 2.25rem;
    color: var(--highlight-color);
    border-bottom: 3px solid var(--highlight-bg);
    padding-bottom: 15px;
    margin-bottom: 30px;
    font-weight: 700;
    letter-spacing: 0.6px;
}

h3 {
    font-size: 1.75rem;
    color: var(--text-color);
    margin-top: 30px;
    margin-bottom: 20px;
    font-weight: 600;
}

h4 {
    font-size: 1.25rem;
    color: var(--highlight-color);
    margin-bottom: 15px;
    font-weight: 500;
}

/* Text Elements */
p, li {
    font-size: 1.1rem;
    color: var(--text-color);
    margin-bottom: 20px;
    letter-spacing: 0.3px;
}

ul, ol {
    margin: 20px 0;
    padding-left: 40px;
}

ul li, ol li {
    margin-bottom: 12px;
    position: relative;
}

ul li::before {
    content: '•';
    color: var(--highlight-color);
    font-size: 1.5rem;
    position: absolute;
    left: -25px;
    top: 0;
}

dl dt {
    font-weight: 600;
    color: var(--highlight-color);
    font-size: 1.15rem;
    margin-top: 15px;
}

dl dd {
    margin-bottom: 15px;
    margin-left: 30px;
    color: var(--text-color);
}

/* Styling for Raw HTML Code Examples in Content */
pre {
    background: var(--code-bg);
    color: var(--text-color);
    padding: 25px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow-x: auto;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.95rem;
    margin: 20px 0;
    line-height: 1.6;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    white-space: pre-wrap;
    word-wrap: break-word;
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
    position: relative;
}

/* Glow Animation on Hover for <pre> Tags */
pre:hover {
    border-color: var(--highlight-color);
    box-shadow: 0 0 10px var(--highlight-bg);
}

/* Copy to Clipboard Button */
.copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--button-bg);
    color: var(--button-text);
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease;
    z-index: 10;
}

.copy-btn:hover {
    background: var(--highlight-bg);
    transform: scale(1.05);
}

.copy-btn:active {
    transform: scale(0.95);
}

.copy-btn.copied {
    background: var(--highlight-color);
    transform: scale(1.05);
}

/* Show Output Button with Ripple Effect */
.show-output {
    display: block;
    margin: 10px 0;
    padding: 10px 20px;
    background: var(--button-bg);
    color: var(--button-text);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: background 0.3s ease, transform 0.2s ease;
    position: relative;
    overflow: hidden;
}

.show-output:hover {
    background: var(--highlight-bg);
    transform: translateY(-2px);
}

.show-output:focus {
    outline: 2px solid var(--link-hover-color);
    outline-offset: 2px;
}

/* Ripple Effect on Click */
.show-output::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
}

.show-output:active::after {
    width: 300px;
    height: 300px;
    opacity: 0;
}

/* Output Container with Fade Animation */
.output-container {
    margin: 20px 0;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-color);
    min-height: 50px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.output-container.visible {
    opacity: 1;
}

/* Inline Code */
code {
    background: var(--code-bg);
    padding: 4px 8px;
    border-radius: 4px;
    color: var(--highlight-color);
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.95rem;
}

/* Links */
a {
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.3s ease;
    position: relative;
}

a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -2px;
    left: 0;
    background: var(--link-hover-color);
    transition: width 0.3s ease;
}

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

a:hover::after {
    width: 100%;
}

a:focus {
    outline: 2px solid var(--highlight-color);
    outline-offset: 2px;
}

/* Blockquote */
blockquote {
    border-left: 6px solid var(--highlight-color);
    padding-left: 25px;
    margin: 25px 0;
    color: var(--text-color);
    font-style: italic;
    background: var(--code-bg);
    border-radius: 0 8px 8px 0;
}

/* Images and Multimedia */
img {
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 15px 0;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    display: block;
}

video, audio {
    width: 100%;
    max-width: 100%;
    margin: 15px 0;
    border-radius: 8px;
}

figure {
    margin: 20px 0;
    text-align: center;
}

figcaption {
    font-size: 0.9rem;
    color: var(--text-color);
    margin-top: 10px;
}

/* Tables */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 25px 0;
    background: var(--code-bg);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

th, td {
    border: 1px solid var(--border-color);
    padding: 16px;
    text-align: left;
    transition: background 0.3s ease;
}

th {
    background: var(--highlight-bg);
    color: var(--text-color);
    font-weight: 600;
    font-size: 1.1rem;
}

td {
    background: var(--code-bg);
    color: var(--text-color);
}

tr:hover td {
    background: var(--highlight-bg);
}

/* Table Caption */
caption {
    padding: 10px;
    background: var(--highlight-bg);
    color: var(--text-color);
    font-weight: 600;
    font-size: 1.1rem;
    border-radius: 8px 8px 0 0;
}

/* Form Styling */
form {
    margin: 25px 0;
    max-width: 100%;
}

fieldset {
    border: 1px solid var(--border-color);
    padding: 25px;
    border-radius: 8px;
    background: var(--code-bg);
}

legend {
    color: var(--highlight-color);
    font-weight: 600;
    font-size: 1.15rem;
    padding: 0 15px;
}

label {
    display: block;
    margin-bottom: 10px;
    color: var(--text-color);
    font-weight: 500;
}

input[type="text"],
input[type="email"],
input[type="file"],
input[type="checkbox"],
input[type="radio"],
textarea,
select {
    padding: 12px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--code-bg);
    color: var(--text-color);
    font-size: 1rem;
    width: 100%;
    transition: border-color 0.3s ease;
}

input[type="checkbox"],
input[type="radio"] {
    width: auto;
    margin-right: 10px;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="file"]:focus,
textarea:focus,
select:focus {
    border-color: var(--highlight-color);
    outline: none;
}

input[type="submit"],
button {
    background: var(--button-bg);
    color: var(--button-text);
    padding: 12px 25px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease;
    font-weight: 600;
    font-size: 1rem;
}

input[type="submit"]:hover,
button:hover {
    background: var(--highlight-bg);
    transform: translateY(-2px);
}

input[type="submit"]:focus,
button:focus {
    outline: 2px solid var(--link-hover-color);
    outline-offset: 2px;
}

/* Code Playground */
#code-input {
    width: 100%;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--code-bg);
    color: var(--text-color);
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.95rem;
    resize: vertical;
    min-height: 150px;
    transition: border-color 0.3s ease;
}

#code-input:focus {
    border-color: var(--highlight-color);
    outline: none;
}

#code-output {
    width: 100%;
    height: 300px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 20px;
    background: #ffffff;
}

/* IFrames */
iframe {
    width: 100%;
    max-width: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    aspect-ratio: 16 / 9;
    display: block;
}

/* Canvas and SVG */
canvas, svg {
    width: 100%;
    max-width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin: 15px 0;
    display: block;
}

/* Details and Summary */
details {
    margin: 15px 0;
    padding: 15px;
    background: var(--code-bg);
    border-radius: 8px;
}

summary {
    cursor: pointer;
    color: var(--highlight-color);
    font-weight: 500;
}

summary:hover {
    color: var(--link-hover-color);
}

/* Dialog */
dialog {
    background: var(--section-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
}

/* Output */
output {
    display: inline-block;
    padding: 5px 10px;
    background: var(--code-bg);
    border-radius: 4px;
    color: var(--highlight-color);
}

/* Footer */
footer {
    background: var(--sidebar-bg);
    text-align: center;
    padding: 15px;
    border-top: 2px solid var(--highlight-bg);
    color: var(--text-color);
    font-size: 0.95rem;
    font-weight: 400;
    position: fixed;
    bottom: 0;
    left: 280px;
    width: calc(100% - 280px);
    z-index: 50;
}

footer a {
    color: var(--link-color);
    font-weight: 500;
}

footer a:hover {
    color: var(--link-hover-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar-toggle {
        display: block;
    }

    .sidebar {
        width: 100%;
        max-width: 100%;
        transform: translateX(-100%);
        opacity: 0;
    }

    .sidebar.active {
        transform: translateX(0);
        opacity: 1;
    }

    .content {
        margin-left: 0;
        padding: 70px 15px 100px 15px;
    }

    footer {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        padding: 12px;
    }

    h1 {
        font-size: 2.5rem;
    }

    h2 {
        font-size: 1.75rem;
    }

    h3 {
        font-size: 1.5rem;
    }

    section {
        padding: 20px;
        border-left-width: 3px;
    }

    #code-output {
        height: 200px;
    }

    .output-container {
        display: block;
        visibility: visible;
        min-height: 40px;
    }

    iframe,
    img,
    video,
    audio,
    canvas,
    svg {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    section,
    .content {
        overflow-x: hidden;
    }

    /* Adjust Logo for Mobile */
    .logo {
        height: 40px; /* Slightly smaller for mobile */
        margin-bottom: 15px;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--code-bg);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: var(--highlight-bg);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--highlight-color);
}

/* Accessibility */
@media (prefers-contrast: high) {
    body {
        background: #000000;
        color: #ffffff;
    }

    a, button, input[type="submit"] {
        color: #ffffff;
        background: var(--highlight-color);
    }

    section {
        background: #1a1a1a;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* Scroll to Top Button */
#scroll-to-top {
    position: fixed;
    bottom: 40px;
    right: 40px;
    background: linear-gradient(145deg, var(--button-bg), var(--highlight-bg));
    border: none;
    border-radius: 10px;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease, background 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1000;
}

#scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
}

#scroll-to-top:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

#scroll-to-top:active {
    transform: translateY(0);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

#scroll-to-top:focus {
    outline: 2px solid var(--highlight-color);
    outline-offset: 2px;
}

/* Up Arrow Image Styling */
#scroll-to-top img {
    width: 28px;
    height: 28px;
    transition: transform 0.3s ease;
}

/* Bounce Animation on Hover */
#scroll-to-top:hover img {
    animation: bounce 0.5s ease-in-out;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

/* Tooltip Styling */
#scroll-to-top::after {
    content: "Back to Top";
    position: absolute;
    bottom: 100%;
    right: 0;
    background: var(--code-bg);
    color: var(--text-color);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.85rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

#scroll-to-top:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Adjust for Mobile */
@media (max-width: 768px) {
    #scroll-to-top {
        bottom: 147px;
        right: 25px;
        width: 42px;
        height: 42px;
        border-radius: 8px;
    }

    #scroll-to-top img {
        width: 22px;
        height: 22px;
    }

    #scroll-to-top::after {
        font-size: 0.75rem;
        padding: 4px 8px;
    }
}