:root {
    --color-bg: #FBFBFC;
    --color-surface: #FFFFFF;
    --color-text: #0F1724;
    --color-muted: #464b54;
    --color-border: #E6E7EA;
    --color-shadow: rgba(15, 23, 36, 0.06);

    --color-primary: #FFCC00;
    --color-primary-700: #E6B800;
    --color-primary-hover: #FFB800;
    --color-primary-active: #E6A900;
    --color-primary-contrast: #0B1220;
    --focus-ring: rgba(255, 204, 0, 0.20);
    --color-primary-filter: invert(79%) sepia(37%) saturate(2541%) hue-rotate(359deg) brightness(104%) contrast(105%);

    --color-accent: #0F1724;
    --color-accent-contrast: #FFFFFF;
    --color-accent-filter: invert(7%) sepia(8%) saturate(3793%) hue-rotate(178deg) brightness(95%) contrast(95%);

    --color-success: #16A34A;
    --color-success-contrast: #FFFFFF;
    --color-warning: #F59E0B;
    --color-danger: #EF4444;

    --base-layer: 0;
    --headerFooter-layer: 10;
    --modal-layer: 20;
    --popup-layer: 30;
}

html[data-theme="dark"] {
    --color-bg: #071021;
    --color-surface: #0F1724;
    --color-text: #F8FAFB;
    --color-muted: #9CA3AF;
    --color-border: #1F2937;
    --color-shadow: rgba(2, 6, 23, 0.6);

    --color-primary: #FFD24D;
    --color-primary-700: #E6B800;
    --color-primary-hover: #FFDA6A;
    --color-primary-active: #E6A900;
    --color-primary-contrast: #071021;
    --focus-ring: rgba(255, 204, 0, 0.14);
    --color-primary-filter: invert(90%) sepia(64%) saturate(1053%) hue-rotate(318deg) brightness(104%) contrast(101%);

    --color-accent: #FFFFFF;
    --color-accent-contrast: #0F1724;
    --color-accent-filter: invert(99%) sepia(0%) saturate(1124%) hue-rotate(157deg) brightness(119%) contrast(100%);

    --color-success: #34D399;
    --color-success-contrast: #071021;
    --color-warning: #F59E0B;
    --color-danger: #F87171;
    color-scheme: dark;
}

/* Everything */
* {
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    scroll-behavior: smooth;
    margin: 0;
    padding: 0;
    border-width: 0;
}

/* Body */
body {
    position: absolute;
    width: 100vw;
    height: 100vh;
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
}

body.no-scroll {
    overflow: hidden;
}

/* Header */
header {
    position: fixed;
    background-color: var(--color-surface);
    box-shadow: 0 2px 4px var(--color-shadow);
    padding: 5px 10px;
    top: 0;
    z-index: var(--headerFooter-layer);
    height: 50px;
    width: 100%;
    display: flex;
    flex-direction: row;
    /* border: 2px solid red; */
}

.header-logo-link {
    position: relative;
    height: 100%;
}

.header-logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 50%;
    flex-direction: row;
    justify-content: left;
    align-items: center;
    /* border: 2px solid purple; */
}

.header-logo {
    position: relative;
    height: 100%;
    /* border: 2px solid yellow; */
}

.header-nav {
    display: flex;
    height: 100%;
    width: 50%;
    flex-direction: row;
    justify-content: right;
    align-items: center;
    gap: 10px;
    /* border: 2px solid orange; */
}

.header-nav-link {
    text-decoration: none;
    color: var(--color-text);
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 4px;
    transition: all .2s ease-in-out;
}

.header-nav-link:hover {
    background-color: var(--color-primary);
    color: var(--color-primary-contrast);
}

/* Mobile hamburger & responsive header controls (moved from index.css) */
.header-toggle {
    position: absolute;
    background: transparent;
    border: none;
    width: auto;
    height: auto;
    right: 10px;
    top: 0px;
    min-height: 44px;
    display: none;
    align-items: center;
    justify-content: center;
    /* padding: 6px 10px; */
    gap: 8px;
    cursor: pointer;
    /* border: 2px solid red; */
}

.header-toggle .hamburger {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--color-text);
    position: relative;
}

.header-toggle .hamburger::before,
.header-toggle .hamburger::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--color-text);
}

.header-toggle .hamburger::before {
    top: -7px;
}

.header-toggle .hamburger::after {
    top: 7px;
}

@media (max-width: 880px) {
    .header-toggle {
        display: flex;
    }

    /* Make the Menu label visible next to the hamburger and give spacing */
    .header-toggle .sr-only {
        position: static;
        width: auto;
        height: auto;
        clip: auto;
        overflow: visible;
        white-space: nowrap;
        margin-right: 10px;
        font-weight: 600;
        color: var(--color-text);
        display: inline-block;
    }

    .header-toggle .hamburger {
        margin-left: 4px;
    }

    .header-nav {
        position: absolute;
        top: 64px;
        right: 12px;
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: 8px;
        padding: 8px;
        display: none;
        flex-direction: column;
        gap: 6px;
        z-index: 9999;
        min-width: 200px;
        height: min-content;
        max-height: calc(100vh - 88px);
        overflow: auto;
    }

    .header-nav.open {
        display: flex;
    }

    .header-nav a {
        display: block;
        padding: 10px 12px;
        border-radius: 6px;
        line-height: 1.2;
    }
}

/* Main */
main {
    position: relative;
    padding: 20px;
    min-height: calc(100vh - 50px);
    width: 100%;
    height: min-content;
    display: flex;
    flex-direction: column;
    /* border: 2px solid blue; */
}

.main-section {
    margin-bottom: 40px;
}

/* Footer */
footer {
    position: relative;
    min-height: 50px;
    height: min-content;
    width: 100%;
    background-color: var(--color-surface);
    box-shadow: 0 -2px 4px var(--color-shadow);
    padding: 10px;
    text-align: center;
    z-index: var(--headerFooter-layer);
    /* border: 2px solid green; */
}

/* Popup Container */
.popup-container {
    position: fixed;
    top: 55px;
    right: 20px;
    min-width: 300px;
    width: min-content;
    max-width: 90%;
    height: min-content;
    display: flex;
    color: var(--color-accent-contrast);
    background-color: var(--color-accent);
    padding: 10px;
    border-radius: 8px;
    z-index: var(--popup-layer);
    overflow: hidden;
    flex-direction: column;
}

.popup-progress-bar {
    position: absolute;
    width: 100%;
    height: 5px;
    top: 0;
    left: 0;
    overflow: hidden;
}

.popup-progress-fill {
    width: 100%;
    height: 100%;
    background-color: var(--color-primary);
    animation: progress-bar-empty 3s linear forwards;
}

@keyframes progress-bar-empty {
    from {
        width: 100%;
    }

    to {
        width: 0%;
    }
}

.popup-btn.hidden,
.popup-container.hidden {
    display: none;
}

.popup-action-btn {
    position: relative;
    right: 0px;
    align-self: flex-end;
}

.popup-btn {
    position: relative;
    display: flex;
    flex-direction: row;
    justify-content: end;
}

.popup-close {
    position: absolute;
    right: 8px;
    top: 8px;
    cursor: pointer;
}

.popup-title {
    position: relative;
    max-width: calc(100% - 16px);
    cursor: default;
}

.popup-message {
    position: relative;
    max-width: calc(100% - 16px);
    margin-top: 8px;
    cursor: default;
}

/* Forms */
form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    align-items: flex-start;
    margin-top: 15px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
textarea,
select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background-color: var(--color-surface);
    color: var(--color-text);
    font-size: 1rem;
    transition: all 0.16s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="tel"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px var(--focus-ring);
}

form button {
    align-self: center;
}

/* Buttons/Inputs */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 8px;
    text-decoration: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.16s ease;
    border: 1px solid transparent;
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 6px var(--focus-ring);
}

.btn-primary {
    background: var(--color-primary);
    color: var(--color-primary-contrast);
    box-shadow: 0 6px 18px var(--color-shadow);
}

.btn-primary:hover {
    background: var(--color-primary-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-ghost:hover {
    background: var(--color-surface);
    box-shadow: 0 6px 18px var(--color-shadow);
}

/* Animations */

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-surface);
}

::-webkit-scrollbar-thumb {
    background-color: var(--color-primary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--color-primary-hover);
}

/* Background shapes (lightweight, hardware-accelerated) */
#bg-shapes {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: var(--base-layer);
    overflow: hidden;
}

.bg-shape {
    position: absolute;
    will-change: transform, opacity;
    pointer-events: none;
    opacity: 0.18;
    mix-blend-mode: screen;
    filter: blur(6px);
    border-radius: 50%;
    transform: translate3d(0, 0, 0);
    animation-name: drift;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
    animation-direction: alternate;
    /* duration set per-element via --dur */
    animation-duration: var(--dur, 24s);
}

.bg-shape .shape-inner {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: inherit;
    overflow: hidden;
    transform-origin: 50% 50%;
    animation-name: spin;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
    animation-duration: var(--rot-dur, 90s);
}

.bg-shape img,
.bg-shape svg {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes drift {
    from {
        transform: translate3d(0, 0, 0) scale(1);
    }

    to {
        transform: translate3d(var(--tx, 0), var(--ty, 0), 0) scale(var(--s, 1));
    }
}

@media (prefers-reduced-motion: reduce) {
    .bg-shape {
        animation: none !important;
        opacity: 0.06;
        filter: blur(6px);
    }

    .bg-shape .shape-inner {
        animation: none !important;
    }
}

/* Header: compact styles for small screens */
@media (max-width: 640px) {
    header {
        height: 44px;
        padding: 6px 8px;
    }

    .header-logo {
        max-height: 28px;
        width: auto;
    }

    .header-nav {
        gap: 8px;
    }

    .header-nav-link {
        font-size: 0.9rem;
        padding: 6px 8px;
    }
}

@media (max-width: 420px) {
    .header-nav-link {
        font-size: 0.85rem;
        padding: 4px 6px;
    }
}