/* =========================================================
   CDL — HEADER COMPONENT (v4 — clean frosted header)
   Cambiador Letras
   Same class names, same HTML, same JS hooks.
   Only this CSS file changes. Palette: Indigo.
   ---------------------------------------------------------
   Look: sticky frosted-glass bar, hairline gradient edge,
   underline-style navigation, quiet round theme button.
   ========================================================= */


/* =========================================================
   HEADER
   ========================================================= */

.cdl-topbar {
    --cdl-hd-a: #4F46E5;
    --cdl-hd-b: #818CF8;
    --cdl-hd-c: #38BDF8;
    --cdl-hd-fill: linear-gradient(135deg, #4338CA 0%, #6366F1 100%);
    --cdl-hd-on-fill: #ffffff;
    --cdl-hd-tint: rgba(79, 70, 229, 0.07);
    --cdl-hd-tint-strong: rgba(79, 70, 229, 0.15);
    --cdl-hd-fill-shadow: 0 8px 16px -8px rgba(79, 70, 229, 0.65);
    --cdl-hd-glow: rgba(79, 70, 229, 0.30);
    --cdl-hd-glass: rgba(255, 255, 255, 0.82);

    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;

    background: var(--cdl-hd-glass);
    -webkit-backdrop-filter: saturate(1.5) blur(14px);
    backdrop-filter: saturate(1.5) blur(14px);

    border-bottom: 1px solid var(--cdl-clr-border, #e2e8f0);
}


/* Hairline brand gradient along the bottom edge */
.cdl-topbar::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;

    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--cdl-hd-a) 25%,
        var(--cdl-hd-b) 60%,
        var(--cdl-hd-c) 85%,
        transparent 100%
    );
    opacity: 0.55;
    pointer-events: none;
}


/* =========================================================
   HEADER INNER
   ========================================================= */

.cdl-topbar__inner {
    width: 100%;
    max-width: var(--cdl-container-max-width, 1200px);
    min-height: 68px;
    margin: 0 auto;
    padding: 0 var(--cdl-space-page, 20px);

    display: flex;
    align-items: center;
    gap: var(--cdl-space-md, 16px);
}


/* =========================================================
   BRAND
   ========================================================= */

.cdl-topbar__brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;

    min-width: 0;
    flex: 0 0 auto;

    color: var(--cdl-clr-text, #0f172a);
    text-decoration: none;
}


.cdl-topbar__brand:focus-visible {
    outline: 2px solid var(--cdl-hd-a);
    outline-offset: 4px;
    border-radius: 14px;
}


/* =========================================================
   LOGO — simple rounded tile
   ========================================================= */

.cdl-topbar__logo {
    display: block;
    box-sizing: border-box;

    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    padding: 5px;

    object-fit: contain;
    object-position: center;

    background: var(--cdl-clr-surface, #ffffff);
    border: 1px solid var(--cdl-hd-tint-strong);
    border-radius: 13px;

    box-shadow: 0 6px 14px -8px var(--cdl-hd-glow);

    transition:
        transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.25s ease,
        border-color 0.2s ease;
}


.cdl-topbar__brand:hover .cdl-topbar__logo {
    transform: scale(1.06);
    border-color: var(--cdl-hd-b);
    box-shadow: 0 10px 18px -8px var(--cdl-hd-glow);
}


/* =========================================================
   BRAND TEXT — gradient wordmark
   ========================================================= */

.cdl-topbar__brand-text {
    display: block;

    color: var(--cdl-hd-a);

    font-family: var(--cdl-font-family-heading, inherit);
    font-size: 19px;
    line-height: 1.2;
    font-weight: 800;
    letter-spacing: -0.025em;

    white-space: nowrap;
}


@supports (-webkit-background-clip: text) or (background-clip: text) {

    .cdl-topbar__brand-text {
        background: linear-gradient(
            90deg,
            var(--cdl-hd-a) 0%,
            var(--cdl-hd-b) 100%
        );
        -webkit-background-clip: text;
        background-clip: text;
        -webkit-text-fill-color: transparent;
        color: transparent;
    }

}


/* =========================================================
   MOBILE NAVIGATION BUTTON
   ========================================================= */

.cdl-nav-burger {
    display: none;

    align-items: center;
    justify-content: center;

    width: 44px;
    height: 44px;

    margin-left: auto;
    padding: 0;

    border: 1px solid var(--cdl-hd-tint-strong);
    border-radius: 12px;

    background: var(--cdl-clr-surface, #ffffff);
    color: var(--cdl-hd-a);

    font: inherit;
    font-size: 20px;
    line-height: 1;

    cursor: pointer;

    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        box-shadow 0.15s ease,
        transform 0.15s ease;
}


.cdl-nav-burger:hover {
    background: var(--cdl-hd-tint);
    border-color: var(--cdl-hd-a);
}


.cdl-nav-burger:active {
    transform: scale(0.94);
}


.cdl-nav-burger[aria-expanded="true"] {
    background: var(--cdl-hd-fill);
    border-color: transparent;
    color: var(--cdl-hd-on-fill);
    box-shadow: var(--cdl-hd-fill-shadow);
}


.cdl-nav-burger:focus-visible {
    outline: 2px solid var(--cdl-hd-a);
    outline-offset: 2px;
}


/* =========================================================
   PRIMARY NAVIGATION — plain row, underline on hover
   ========================================================= */

.cdl-menu {
    display: flex;
    align-items: center;

    gap: 2px;
    margin-left: auto;
}


/* =========================================================
   NAVIGATION LINK
   ========================================================= */

.cdl-menu__link {
    position: relative;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 40px;
    padding: 0 14px;

    border-radius: 10px;

    color: var(--cdl-clr-text-muted, #64748b);
    text-decoration: none;

    font-size: 14px;
    line-height: 1.2;
    font-weight: 600;

    white-space: nowrap;

    transition:
        color 0.15s ease,
        background-color 0.15s ease;
}


/* Underline marker — grows from the centre */
.cdl-menu__link::after {
    content: "";

    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 3px;

    height: 2px;

    border-radius: 2px;
    background: linear-gradient(
        90deg,
        var(--cdl-hd-a),
        var(--cdl-hd-b)
    );

    opacity: 0;
    transform: scaleX(0);
    transform-origin: center;

    transition: transform 0.22s ease, opacity 0.22s ease;
}


.cdl-menu__link:hover {
    color: var(--cdl-hd-a);
    background: var(--cdl-hd-tint);
}


.cdl-menu__link:hover::after {
    opacity: 1;
    transform: scaleX(1);
}


/* Active page — soft tint + permanent underline */
.cdl-menu__link[aria-current="page"] {
    color: var(--cdl-hd-a);
    background: var(--cdl-hd-tint);
    font-weight: 700;
}


.cdl-menu__link[aria-current="page"]::after {
    opacity: 1;
    transform: scaleX(1);
}


.cdl-menu__link:focus-visible {
    outline: 2px solid var(--cdl-hd-a);
    outline-offset: 2px;
}


/* =========================================================
   THEME TOGGLE
   ========================================================= */

.cdl-theme-switch {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    gap: 7px;

    min-height: 42px;
    padding: 0 15px 0 11px;
    margin-left: 8px;

    border: 1px solid var(--cdl-hd-tint-strong);
    border-radius: 999px;

    background: var(--cdl-clr-surface, #ffffff);
    color: var(--cdl-hd-a);

    font: inherit;
    font-size: 14px;
    font-weight: 700;

    cursor: pointer;
    white-space: nowrap;

    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        color 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.15s ease;
}


.cdl-theme-switch:hover {
    background: var(--cdl-hd-tint);
    border-color: var(--cdl-hd-a);
    box-shadow: 0 8px 16px -10px var(--cdl-hd-glow);
}


.cdl-theme-switch:active {
    transform: scale(0.96);
}


.cdl-theme-switch:focus-visible {
    outline: 2px solid var(--cdl-hd-a);
    outline-offset: 3px;
}


.cdl-theme-switch__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 22px;
    height: 22px;

    line-height: 1;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}


.cdl-theme-switch:hover .cdl-theme-switch__icon {
    transform: rotate(25deg) scale(1.12);
}


.cdl-theme-switch__text {
    display: inline-block;
}


/* =========================================================
   MATERIAL SYMBOLS ICONS (CSS only — HTML unchanged)
   Needs the Material Symbols Rounded stylesheet in <head>
   with these icon_names: close, dark_mode, emoji_symbols,
   home, info, light_mode, menu, mood (plus apps, auto_awesome)
   ========================================================= */

.cdl-menu__link::before,
.cdl-theme-switch__icon::before,
.cdl-nav-burger > span::before {
    font-family: "Material Symbols Rounded";
    font-weight: 500;
    font-style: normal;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    white-space: nowrap;
    direction: ltr;

    -webkit-font-smoothing: antialiased;
    -webkit-font-feature-settings: "liga";
    font-feature-settings: "liga";
}


/* Nav link icons — desktop shows them only when there is room */

.cdl-menu__link::before {
    display: none;
    margin-right: 7px;
    font-size: 18px;
}

#cdl-nav-home::before        { content: "home"; content: "home" / ""; }
#cdl-nav-tools::before       { content: "apps"; content: "apps" / ""; }
#cdl-nav-fancy-text::before  { content: "auto_awesome"; content: "auto_awesome" / ""; }
#cdl-nav-emoji::before       { content: "mood"; content: "mood" / ""; }
#cdl-nav-symbols::before     { content: "emoji_symbols"; content: "emoji_symbols" / ""; }
#cdl-nav-about::before       { content: "info"; content: "info" / ""; }

@media (min-width: 1400px) {

    .cdl-menu__link::before {
        display: inline-block;
    }

}


/* Theme toggle icon — moon in light mode, sun in dark mode */

.cdl-theme-switch__icon {
    font-size: 0; /* hides the emoji text set by theme.js */
}

.cdl-theme-switch__icon::before {
    content: "dark_mode"; content: "dark_mode" / "";
    font-size: 22px;
}

[data-theme="dark"] .cdl-theme-switch__icon::before,
.dark .cdl-theme-switch__icon::before {
    content: "light_mode"; content: "light_mode" / "";
}


/* Mobile menu button — menu / close */

.cdl-nav-burger > span {
    display: inline-flex;
    font-size: 0; /* hides the ☰ character */
}

.cdl-nav-burger > span::before {
    content: "menu"; content: "menu" / "";
    font-size: 26px;
}

.cdl-nav-burger[aria-expanded="true"] > span::before {
    content: "close"; content: "close" / "";
}


/* =========================================================
   LARGE TABLET — tighter nav so 6 links still fit
   ========================================================= */

@media (max-width: 1100px) {

    .cdl-menu__link {
        padding: 0 10px;
        font-size: 13px;
    }

    .cdl-menu__link::after {
        left: 10px;
        right: 10px;
    }

    .cdl-theme-switch {
        padding: 0 12px 0 10px;
    }

}


/* =========================================================
   MOBILE (mobile menu starts here)
   ========================================================= */

@media (max-width: 980px) {

    .cdl-topbar__inner {
        position: relative;

        min-height: 64px;

        flex-wrap: wrap;
    }


    .cdl-nav-burger {
        display: inline-flex;
    }


    /* Navigation panel — floating card */

    .cdl-menu {
        display: none;

        width: 100%;

        flex-direction: column;
        align-items: stretch;

        order: 10;

        gap: 4px;
        margin: 2px 0 14px;
        padding: 10px;

        background: var(--cdl-clr-surface, #ffffff);
        border: 1px solid var(--cdl-hd-tint-strong);
        border-radius: 18px;
        box-shadow: 0 18px 40px -18px var(--cdl-hd-glow);
    }


    .cdl-menu.on-open {
        display: flex;
        animation: cdl-hd-drop 0.2s ease-out;
    }


    .cdl-menu__link {
        width: 100%;
        min-height: 50px;

        justify-content: flex-start;

        padding: 0 16px 0 14px;

        border-radius: 14px;

        font-size: 15px;
    }


    /* Material icon tile (decorative) */

    .cdl-menu__link::before {
        display: inline-flex;
        align-items: center;
        justify-content: center;

        width: 36px;
        height: 36px;
        margin-right: 12px;

        border-radius: 12px;
        background: var(--cdl-hd-tint);
        color: var(--cdl-hd-a);

        font-size: 21px;
    }


    .cdl-menu__link[aria-current="page"]::before {
        background: var(--cdl-hd-fill);
        color: var(--cdl-hd-on-fill);
    }


    /* Underline marker becomes a left bar */

    .cdl-menu__link::after {
        left: 6px;
        right: auto;
        bottom: auto;
        top: 50%;

        width: 4px;
        height: 24px;

        transform: translateY(-50%) scaleY(0);
        transform-origin: center;
    }


    .cdl-menu__link:hover::after,
    .cdl-menu__link[aria-current="page"]::after {
        opacity: 1;
        transform: translateY(-50%) scaleY(1);
    }


    /* Theme button becomes a round icon button */

    .cdl-theme-switch {
        margin-left: 0;

        width: 44px;
        height: 44px;
        min-height: 44px;

        padding: 0;
    }


    .cdl-theme-switch__text {
        position: absolute;

        width: 1px;
        height: 1px;

        padding: 0;
        margin: -1px;

        overflow: hidden;

        clip: rect(0, 0, 0, 0);

        white-space: nowrap;

        border: 0;
    }

}


@keyframes cdl-hd-drop {

    from {
        opacity: 0;
        transform: translateY(-8px);
    }

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

}


/* =========================================================
   SMALL MOBILE
   ========================================================= */

@media (max-width: 420px) {

    .cdl-topbar__inner {
        padding: 0 var(--cdl-space-sm, 12px);
        gap: 8px;
    }


    .cdl-topbar__logo {
        width: 38px;
        height: 38px;

        flex-basis: 38px;
    }


    .cdl-topbar__brand {
        gap: 8px;
    }


    .cdl-topbar__brand-text {
        font-size: 15px;
    }


    .cdl-nav-burger,
    .cdl-theme-switch {
        width: 42px;
        height: 42px;
        min-height: 42px;
    }

}


/* =========================================================
   REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

    .cdl-topbar *,
    .cdl-topbar *::before,
    .cdl-topbar *::after {
        transition: none !important;
        animation: none !important;
    }

}


/* =========================================================
   DARK THEME
   ========================================================= */

[data-theme="dark"] .cdl-topbar,
.dark .cdl-topbar {
    --cdl-hd-a: #A5B4FC;
    --cdl-hd-b: #C7D2FE;
    --cdl-hd-c: #7DD3FC;
    --cdl-hd-fill: linear-gradient(135deg, #A5B4FC 0%, #C7D2FE 100%);
    --cdl-hd-on-fill: #0B0E1F;
    --cdl-hd-tint: rgba(165, 180, 252, 0.10);
    --cdl-hd-tint-strong: rgba(165, 180, 252, 0.22);
    --cdl-hd-fill-shadow: 0 8px 18px -8px rgba(129, 140, 248, 0.55);
    --cdl-hd-glow: rgba(0, 0, 0, 0.6);
    --cdl-hd-glass: rgba(12, 15, 26, 0.80);

    border-bottom-color: var(--cdl-clr-border, #272e45);
}


[data-theme="dark"] .cdl-topbar__logo,
.dark .cdl-topbar__logo,
[data-theme="dark"] .cdl-nav-burger,
.dark .cdl-nav-burger,
[data-theme="dark"] .cdl-theme-switch,
.dark .cdl-theme-switch {
    background: var(--cdl-clr-surface, #141826);
}


[data-theme="dark"] .cdl-nav-burger[aria-expanded="true"],
.dark .cdl-nav-burger[aria-expanded="true"] {
    background: var(--cdl-hd-fill);
}


[data-theme="dark"] .cdl-menu__link,
.dark .cdl-menu__link {
    color: var(--cdl-clr-text-muted, #a3abc2);
}


[data-theme="dark"] .cdl-menu__link:hover,
.dark .cdl-menu__link:hover,
[data-theme="dark"] .cdl-menu__link[aria-current="page"],
.dark .cdl-menu__link[aria-current="page"] {
    color: var(--cdl-hd-a);
}


@media (max-width: 980px) {

    [data-theme="dark"] .cdl-menu,
    .dark .cdl-menu {
        background: var(--cdl-clr-surface, #141826);
    }

}


[data-theme="dark"] .cdl-topbar__brand,
.dark .cdl-topbar__brand {
    color: var(--cdl-clr-text, #e5e7f0);
}