/* secify exact cascading order */
@layer base, components, animations, utilities, interaction, custom;

:root {
    --color-bg: #f9f9f9;
    --color-text: #111827;
    --color-marlowblue: #3a5bb4;
    --color-marlowblue-alpha: #3a5bb475;
    --color-marlowred: #b12323;
    --color-marlowred-alpha: #b1232367;
    --color-white: #ffffff;
    --color-light-gray: #eee;
    --color-dark-gray: #333;
    --color-border: #ddd;
    --color-green: #09971c;
    --color-amber: #d97706;
    --color-red: #af0909;
}

@layer base {

    /* Reset */
    *,
    *::before,
    *::after {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
    }

    html {
        font-size: 16px;
        scroll-behavior: smooth;
    }

    body {
        font-size: 1rem;
        font-family: 'Segoe UI', sans-serif;
        line-height: 1.6;
        background-color: var(--color-bg);
        color: var(--color-text);
    }

    h1,
    h2 {
        margin-bottom: 0.75rem;
        font-weight: 600;
    }

    p {
        margin-bottom: 1rem;
    }

    .container {
        max-width: 1200px;
        margin: 0 auto;
        padding: 1.5rem;
    }

    header {
        background-color: var(--color-bg);
        border-bottom: 1px solid var(--color-border);
    }

    nav ul {
        list-style: none;
        display: flex;
        gap: 1.5rem;
        align-items: center;
        margin-top: 0.5rem;
    }

    nav a {
        text-decoration: none;
        color: var(--color-marlowblue);
        font-weight: 500;
    }

    nav a:hover {
        color: var(--color-marlowred);
    }

    section {
        padding: 4rem 1.5rem;
        border-radius: 0.5rem;
        background-color: var(--color-light-gray);
        border-bottom: 1px solid var(--color-light-gray);
    }

    .section-title {
        text-align: center;
        font-size: 2rem;
        color: var(--color-text);
        margin-bottom: 2rem;
    }

    .loginForm,
    .not-found {
        border: var(--color-marlowblue) 4px solid;
        border-radius: 1em;
        width: min(90%, 600px);
        margin: 5rem auto;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
        background-color: var(--color-light-gray);
        text-align: center;
        padding: 6rem 2rem;
    }

    .not-found h1 {
        font-size: 4rem;
        color: var(--color-marlowred);
    }

    .loginForm p,
    .not-found p {
        margin-top: 1rem;
        font-size: 1.25rem;
        color: var(--color-text);
    }

    .not-found a.btn {
        margin-top: 2rem;
        display: inline-block;
    }

    /* Footer */
    .site-footer {
        background-color: var(--color-marlowblue);
        color: var(--color-white);
        text-align: center;
        padding: 2rem 1.5rem;
        font-size: 0.9rem;
        border-top: 1px solid #ddd;
    }

    .footer-links {
        margin-bottom: 0.5rem;
    }

    .footer-links a {
        color: var(--color-light-gray);
        text-decoration: none;
        margin: 0 0.5rem;
    }

    .footer-links a:hover {
        text-decoration: underline;
    }

    .footer-copy {
        color: var(--color-white);
    }
}

@layer components {

    /* Buttons */
    .btn {
        padding: 0.75rem 1.5rem;
        border-radius: 0.375rem;
        font-size: 1rem;
        cursor: pointer;
        text-decoration: none;
        display: inline-block;
        border: none;
    }

    .btn.primary {
        background-color: var(--color-marlowred);
        color: var(--color-white);
    }

    .btn.primary:hover {
        background-color: #f3f4f6;
        color: var(--color-marlowblue);
    }

    /* Override when loading */
    .btn.primary.loading,
    .btn.primary.loading:hover {
        background-color: var(--color-dark-gray);
        cursor: wait;
        pointer-events: none;
        opacity: 0.6;
        transition: opacity 0.2s;
    }

    .btn.secondary {
        background-color: var(--color-white);
        color: var(--color-marlowblue);
        border: 2px solid var(--color-white);
    }

    .btn.secondary:hover {
        background-color: #f3f4f6;
        color: var(--color-marlowblue);
    }

}

@layer animations {

    /* Body Load Animations */
    body {
        filter: blur(0);
        transition: filter 0.15s ease-in-out;
    }

    body.blur-in {
        filter: blur(4px);
    }

    /* Hero Section Animations */
    @keyframes fadeInUp {
        0% {
            opacity: 0;
            transform: translateY(3em);
        }

        100% {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* General Animations */

    .fade-in-up {
        opacity: 0;
        transform: translateY(40px);
        transition: opacity 0.8s ease-out, transform 0.8s ease-out;
    }

    .fade-in-up.visible {
        opacity: 1;
        transform: translateY(0);
    }

    .fade-in {
        animation: fadeIn 0.5s ease-in-out;
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
        }

        to {
            opacity: 1;
        }
    }

    .slide-in {
        animation: slideIn 0.5s ease-in-out;
    }

    @keyframes slideIn {
        from {
            transform: translateY(20px);
            opacity: 0;
        }

        to {
            transform: translateY(0);
            opacity: 1;
        }
    }



}

@layer utilities {

    /* Spacing Helpers */
    .m-0 {
        margin: 0 !important;
    }

    .mt-1 {
        margin-top: 0.25rem !important;
    }

    .mb-1 {
        margin-bottom: 0.25rem !important;
    }

    .mt-2 {
        margin-top: 0.5rem !important;
    }

    .mb-2 {
        margin-bottom: 0.5rem !important;
    }

    .p-1 {
        padding: 0.25rem !important;
    }

    .p-2 {
        padding: 0.5rem !important;
    }

    /* Text Adjustments */
    .text-center {
        text-align: center !important;
    }

    .text-left {
        text-align: left !important;
    }

    .text-right {
        text-align: right !important;
    }

    .text-uppercase {
        text-transform: uppercase !important;
    }

    .text-lowercase {
        text-transform: lowercase !important;
    }

    .text-capitalize {
        text-transform: capitalize !important;
    }

    .text-disabled {
        text-decoration: line-through !important;
        color: var(--color-marlowblue-alpha) !important;
        padding-left: 1em;

    }

    .text-green {
        color: var(--color-green) !important;
    }

    .text-red {
        color: var(--color-red) !important;
    }

    /* Display Helpers */
    .d-block {
        display: block !important;
    }

    .d-inline-block {
        display: inline-block !important;
    }

    .d-flex {
        display: flex !important;
    }

    .justify-center {
        justify-content: center !important;
    }

    .justify-between {
        justify-content: space-between !important;
    }

    .align-center {
        align-items: center !important;
    }

    .sticky-top-right {
        position: sticky;
        top: 1rem;
        left: 90%;
        z-index: 1000;
    }
}

@layer interaction {

    /* Cookie Banner */
    .cookie-banner {
        position: sticky !important;
        bottom: 5%;
        left: 5%;
        width: 90%;
        background: var(--color-amber);
        color: var(--color-text);
        padding: 3rem;
        box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.1);
        border-radius: 1em;
        z-index: 1000;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .cookie-banner p {
        margin: 0;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 1rem;
    }

    .cookie-banner .btn.small {
        font-size: 0.8rem;
        padding: 0.3rem 0.75rem;
    }

    .cookie-banner .btn.small:hover {
        background-color: var(--color-marlowred-alpha);
        color: var(--color-white);
        transform: scale(1.25);
    }

    /* Login/user menu */
    .user-menu {
        position: relative;
        display: inline-block;
        transition-delay: 0.1s;
    }

    .user-icon {
        background: none;
        border: none;
        border-radius: 0.25em;
        padding: 0.5rem;
        font-size: 1.25rem;
        line-height: 1;
        vertical-align: middle;
        color: inherit;
        cursor: pointer;
    }

    .user-info {
        display: inline-block;
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
        color: var(--color-marlowred);
    }

    .user-icon:focus {
        outline: 0.1em solid var(--color-marlowblue);
    }

    .user-dropdown .divider {
        height: 1px;
        margin: 9px 0;
        overflow: hidden;
        background-color: #e5e5e5;
    }

    .user-dropdown>.disabled>a,
    .user-dropdown>.disabled>a:focus,
    .user-dropdown>.disabled>a:hover {
        color: var(--color-marlowblue);
        cursor: not-allowed !important;
        pointer-events: none;
    }

    .user-dropdown {
        position: absolute;
        display: block;
        top: 100%;
        right: 0;
        list-style: none;
        background: var(--color-light-gray);
        border: 1px solid var(--color-border);
        border-radius: 0.25em;
        margin: 0;
        padding: 0;
        max-height: 0;
        opacity: 0;
        width: auto;
        min-width: 0;
        z-index: 100;
        overflow: hidden;
        transform: translateY(-2em);
        transition:
            max-height 0.5s ease,
            padding 0.3s ease,
            opacity 0.3s ease,
            min-width 0.3s ease,
            transform 0.3s ease;
    }

    .user-dropdown li a {
        display: block;
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
        text-decoration: none;
        color: var(--color-text);
    }

    .user-dropdown li a:hover {
        background-color: var(--color-marlowred-alpha);
    }

    /* Show dropdown on hover */
    .user-menu:hover .user-dropdown,
    .user-menu:focus-within .user-dropdown {
        transform: translateY(0);
        max-height: 500px;
        padding: 0.5rem 0;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
        opacity: 1;
        min-width: 15ch;
    }

    /* Contact Form */
    .contact-section {
        padding: 4rem 1.5rem;
        max-width: 700px;
        margin: 2rem auto;
        border: var(--color-border) 1px solid;
        border-radius: 0.5rem;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    }

    .userForm {
        display: flex;
        flex-direction: column;
        gap: 1.25rem;
    }

    .userForm label {
        font-weight: 600;
        margin-bottom: 0.25rem;
        display: block;
    }

    .userForm input,
    .userForm textarea {
        width: 100%;
        padding: 0.75rem;
        border: 1px solid var(--color-border);
        border-radius: 0.375rem;
        font-size: 1rem;
    }

    .userForm textarea {
        resize: vertical;
        min-height: 150px;
    }

    .honeypot {
        display: none;
    }
}


@layer base {

    /* Dark Mode CSS for Marlow Digital */
    .toggle-container,
    .toggle-container button {
        position: fixed;
        top: 0.25rem;
        right: 0.25rem;
        color: var(--color-marlowblue);
        z-index: 1000;
        border: none;
        background-color: transparent;
    }

    body.dark-mode,
    body.dark-mode .container,
    body.dark-mode .faq-section {
        --color-marlowblue: #8ab4f8;
        --color-marlowred: #ff6666;
        --color-white: #1a1a1a;
        --color-light-gray: #2a2a2a;
        --color-dark-gray: #aaa;
        --color-text: #ddd;
        --color-text-light: #999;
        --color-border: #444;

        background-color: var(--color-white);
        color: var(--color-text);
        transition: background-color 0.3s, color 0.3s;
    }

    body.dark-mode .service-block:nth-of-type(even) {
        background-color: var(--color-light-gray);
    }

    body.dark-mode .faq-item summary {
        color: var(--color-text);
    }

    body.dark-mode .faq-item p,
    body.dark-mode .cta,
    body.dark-mode .cta h2,
    body.dark-mode .cta p,
    body.dark-mode .hero,
    body.dark-mode .hero h1 {
        color: var(--color-text) !important;
    }

    body.dark-mode .hero .btn,
    body.dark-mode .cta .btn,
    body.dark-mode .btn.primary,
    body.dark-mode footer .container {
        background-color: var(--color-marlowblue);
        color: var(--color-white);
    }

    body.dark-mode .hero .btn:hover,
    body.dark-mode .cta .btn:hover,
    body.dark-mode .btn.primary:hover {
        background-color: var(--color-marlowred);
    }

    body.dark-mode .icon-service {
        stroke: var(--color-marlowred);
    }

    body.dark-mode .service-card:hover h3,
    body.dark-mode .service-card:hover p {
        color: var(--color-marlowblue);
    }

    body.dark-mode .logo,
    body.dark-mode .faq-item summary {
        color: var(--color-marlowblue) !important;
    }

    body.dark-mode .section,
    body.dark-mode .faq-section,
    body.dark-mode .service-card {
        background-color: var(--color-light-gray) !important;
        border: 1px solid var(--color-border);
    }

    body.dark-mode .faq-item {
        border-top: 1px solid var(--color-border);
    }

    body.dark-mode input,
    body.dark-mode textarea,
    body.dark-mode select {
        background-color: #2a2a2a;
        color: #ddd;
        border: 1px solid var(--color-border);
    }

    body.dark-mode input::placeholder,
    body.dark-mode textarea::placeholder {
        color: #888;
    }

    body.dark-mode input:focus,
    body.dark-mode textarea:focus,
    body.dark-mode select:focus {
        outline: 2px solid var(--color-marlowblue);
        background-color: #1f1f1f;
    }

    /* Accessibility for Marlow Digital */
    .sr-only {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        padding: 0;
        border: 0;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    @media (prefers-reduced-motion: reduce) {
        * {
            animation: none !important;
            transition: none !important;
        }
    }
}