/**
 * Sprint DS-2 — Visual Identity authority layer.
 * Applies Official ThinkTwin design on top of brief-pwa + executive tokens.
 * Requires: executive-tokens.css, brief-pwa.css (load this file last).
 */

/* ── DS-2 marker scope ── */
body[data-design-system="ds-2"],
body[data-design-system="ds-2-1"] {
    color: var(--tds-text);
    font-family: 'Cairo', system-ui, sans-serif;
}

body[data-design-system="ds-2"].executive-os,
body[data-design-system="ds-2-1"].executive-os,
body[data-design-system="ds-2"].auth-executive-shell,
body[data-design-system="ds-2-1"].auth-executive-shell {
    background: var(--tds-bg-primary);
}

body[data-design-system="ds-2"]::before,
body[data-design-system="ds-2-1"]::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse 80% 55% at 18% 12%, var(--tds-nebula-purple), transparent 58%),
        radial-gradient(ellipse 70% 50% at 82% 18%, var(--tds-nebula-cyan), transparent 52%),
        radial-gradient(circle at 50% 88%, rgba(10, 11, 30, 0.85), transparent 45%),
        radial-gradient(1px 1px at 12% 22%, var(--tds-star-color), transparent),
        radial-gradient(1px 1px at 28% 68%, var(--tds-star-color), transparent),
        radial-gradient(1.5px 1.5px at 44% 38%, var(--tds-star-glow), transparent),
        radial-gradient(1px 1px at 58% 14%, var(--tds-star-color), transparent),
        radial-gradient(1px 1px at 72% 52%, var(--tds-star-color), transparent),
        radial-gradient(1.5px 1.5px at 86% 78%, var(--tds-star-glow), transparent),
        radial-gradient(1px 1px at 92% 32%, var(--tds-star-color), transparent),
        linear-gradient(180deg, var(--tds-bg-deep) 0%, var(--tds-bg-primary) 100%);
    opacity: 0.92;
}

/* ── Enhanced glass surfaces ── */
body[data-design-system="ds-2"] .exec-glass-panel,
body[data-design-system="ds-2-1"] .exec-glass-panel,
body[data-design-system="ds-2"] .eos-card,
body[data-design-system="ds-2-1"] .eos-card,
body[data-design-system="ds-2"] .exec-card,
body[data-design-system="ds-2-1"] .exec-card {
    background: color-mix(in srgb, var(--tds-glass-fill) 88%, rgba(168, 85, 247, 0.04));
    border-color: color-mix(in srgb, var(--tds-border) 70%, rgba(168, 85, 247, 0.22));
    box-shadow: var(--tds-glow-card), var(--tds-shadow-panel);
    backdrop-filter: blur(22px) saturate(140%);
    -webkit-backdrop-filter: blur(22px) saturate(140%);
}

/* ── CTA buttons — purple gradient authority ── */
body[data-design-system="ds-2"] .button.primary,
body[data-design-system="ds-2-1"] .button.primary,
body[data-design-system="ds-2"] .eos-cta-gradient,
body[data-design-system="ds-2-1"] .eos-cta-gradient,
body[data-design-system="ds-2"] .exec-btn-primary,
body[data-design-system="ds-2-1"] .exec-btn-primary {
    background: var(--tds-gradient-cta);
    border: 1px solid color-mix(in srgb, var(--tds-purple) 45%, transparent);
    box-shadow: var(--tds-shadow-button);
    color: #fff;
    font-weight: 700;
}

body[data-design-system="ds-2"] .button.primary:hover,
body[data-design-system="ds-2-1"] .button.primary:hover,
body[data-design-system="ds-2"] .eos-cta-gradient:hover,
body[data-design-system="ds-2-1"] .eos-cta-gradient:hover,
body[data-design-system="ds-2"] .exec-btn-primary:hover,
body[data-design-system="ds-2-1"] .exec-btn-primary:hover {
    box-shadow: var(--tds-shadow-button-hover);
    filter: brightness(1.06);
}

/* ── Desktop expanded sidebar (1024+) ── */
@media (min-width: 1024px) {
    body[data-design-system="ds-2"] .eos-icon-rail,
    body[data-design-system="ds-2-1"] .eos-icon-rail,
    body[data-design-system="ds-2"] .exec-sidebar,
    body[data-design-system="ds-2-1"] .exec-sidebar {
        width: var(--eos-rail-width-expanded);
        align-items: stretch;
        padding: 18px 14px;
        background: color-mix(in srgb, rgba(6, 7, 18, 0.92) 85%, rgba(168, 85, 247, 0.06));
        border-right-color: color-mix(in srgb, var(--eos-border) 60%, rgba(168, 85, 247, 0.25));
        box-shadow: inset -1px 0 0 rgba(168, 85, 247, 0.08), 4px 0 32px rgba(0, 0, 0, 0.18);
    }

    body[data-design-system="ds-2"] .eos-brand,
    body[data-design-system="ds-2-1"] .eos-brand {
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto;
        justify-items: start;
        align-items: center;
        column-gap: 10px;
        row-gap: 2px;
        margin-bottom: 20px;
        padding-bottom: 16px;
        border-bottom: 1px solid color-mix(in srgb, var(--eos-border) 80%, transparent);
    }

    body[data-design-system="ds-2"] .eos-brand img,
    body[data-design-system="ds-2-1"] .eos-brand img {
        grid-row: 1 / span 2;
        width: 36px;
        height: 36px;
    }

    body[data-design-system="ds-2"] .eos-brand-text,
    body[data-design-system="ds-2-1"] .eos-brand-text {
        display: block;
        font-size: 0.88rem;
        font-weight: 800;
        letter-spacing: 0.02em;
        justify-self: start;
    }

    body[data-design-system="ds-2"] .eos-brand-tagline,
    body[data-design-system="ds-2-1"] .eos-brand-tagline {
        display: block;
        font-size: 0.62rem;
        color: var(--eos-muted);
        line-height: 1.3;
        justify-self: start;
    }

    body[data-design-system="ds-2"] .eos-rail-link,
    body[data-design-system="ds-2-1"] .eos-rail-link {
        grid-template-columns: 28px 1fr;
        grid-template-rows: auto;
        justify-items: start;
        align-items: center;
        column-gap: 10px;
        padding: 10px 12px;
        width: 100%;
    }

    body[data-design-system="ds-2"] .eos-rail-label,
    body[data-design-system="ds-2-1"] .eos-rail-label,
    body[data-design-system="ds-2"] .exec-rail-label,
    body[data-design-system="ds-2-1"] .exec-rail-label {
        display: block;
        font-size: 0.78rem;
        font-weight: 600;
        line-height: 1.2;
        text-align: start;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    body[data-design-system="ds-2"] .eos-rail-link.is-active,
    body[data-design-system="ds-2-1"] .eos-rail-link.is-active {
        background: linear-gradient(90deg, rgba(168, 85, 247, 0.18), rgba(34, 211, 238, 0.08));
        box-shadow: inset 0 0 0 1px rgba(168, 85, 247, 0.32), 0 0 16px rgba(168, 85, 247, 0.12);
    }

    body[data-design-system="ds-2"] .eos-rail-footer,
    body[data-design-system="ds-2-1"] .eos-rail-footer {
        justify-items: stretch;
        margin-top: auto;
        padding-top: 12px;
        border-top: 1px solid color-mix(in srgb, var(--eos-border) 80%, transparent);
    }

    body[data-design-system="ds-2"] .eos-profile-card,
    body[data-design-system="ds-2-1"] .eos-profile-card,
    body[data-design-system="ds-2"] .exec-profile-card,
    body[data-design-system="ds-2-1"] .exec-profile-card {
        display: block;
        padding: 10px 12px;
        border-radius: var(--tds-radius-rail);
        background: var(--eos-profile-card-bg);
        border: 1px solid var(--eos-profile-card-border);
        box-shadow: var(--eos-profile-card-glow);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }

    body[data-design-system="ds-2"] .eos-profile-link,
    body[data-design-system="ds-2-1"] .eos-profile-link,
    body[data-design-system="ds-2"] .exec-profile-link,
    body[data-design-system="ds-2-1"] .exec-profile-link {
        display: grid;
        grid-template-columns: 36px 1fr;
        align-items: center;
        gap: 10px;
        text-decoration: none;
        color: inherit;
    }

    body[data-design-system="ds-2"] .eos-profile-meta,
    body[data-design-system="ds-2-1"] .eos-profile-meta,
    body[data-design-system="ds-2"] .exec-profile-meta,
    body[data-design-system="ds-2-1"] .exec-profile-meta {
        display: grid;
        gap: 2px;
        min-width: 0;
    }

    body[data-design-system="ds-2"] .eos-profile-name,
    body[data-design-system="ds-2-1"] .eos-profile-name,
    body[data-design-system="ds-2"] .exec-profile-name,
    body[data-design-system="ds-2-1"] .exec-profile-name {
        font-size: var(--tds-profile-name-size);
        font-weight: 700;
        line-height: 1.25;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    body[data-design-system="ds-2"] .eos-profile-role,
    body[data-design-system="ds-2-1"] .eos-profile-role,
    body[data-design-system="ds-2"] .exec-profile-role,
    body[data-design-system="ds-2-1"] .exec-profile-role {
        font-size: var(--tds-profile-role-size);
        color: var(--eos-muted);
        line-height: 1.2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    body[data-design-system="ds-2"] .eos-logout-form,
    body[data-design-system="ds-2-1"] .eos-logout-form {
        display: flex;
        justify-content: flex-end;
        margin-top: 8px;
    }

    body[data-design-system="ds-2"] .eos-shell,
    body[data-design-system="ds-2-1"] .eos-shell,
    body[data-design-system="ds-2"] .exec-shell,
    body[data-design-system="ds-2-1"] .exec-shell {
        margin-left: var(--eos-rail-width-expanded);
    }

    [dir="rtl"] body[data-design-system="ds-2"] .eos-shell,
    [dir="rtl"] body[data-design-system="ds-2-1"] .eos-shell,
    [dir="rtl"] body[data-design-system="ds-2"] .exec-shell,
    [dir="rtl"] body[data-design-system="ds-2-1"] .exec-shell {
        margin-left: 0;
        margin-right: var(--eos-rail-width-expanded);
    }

    [dir="rtl"] body[data-design-system="ds-2"] .eos-icon-rail,
    [dir="rtl"] body[data-design-system="ds-2-1"] .eos-icon-rail,
    [dir="rtl"] body[data-design-system="ds-2"] .exec-sidebar,
    [dir="rtl"] body[data-design-system="ds-2-1"] .exec-sidebar {
        left: auto;
        right: 0;
        border-right: 0;
        border-left: 1px solid color-mix(in srgb, var(--eos-border) 60%, rgba(168, 85, 247, 0.25));
        box-shadow: inset 1px 0 0 rgba(168, 85, 247, 0.08), -4px 0 32px rgba(0, 0, 0, 0.18);
    }
}

/* ── Tablet icon rail (768–1023) — labels hidden, avatar-only profile ── */
@media (min-width: 768px) and (max-width: 1023px) {
    body[data-design-system="ds-2"] .eos-profile-card,
    body[data-design-system="ds-2-1"] .eos-profile-card,
    body[data-design-system="ds-2"] .exec-profile-card,
    body[data-design-system="ds-2-1"] .exec-profile-card {
        display: block;
        padding: 0;
        background: transparent;
        border: 0;
        box-shadow: none;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    body[data-design-system="ds-2"] .eos-profile-meta,
    body[data-design-system="ds-2-1"] .eos-profile-meta,
    body[data-design-system="ds-2"] .exec-profile-meta,
    body[data-design-system="ds-2-1"] .exec-profile-meta {
        display: none;
    }

    body[data-design-system="ds-2"] .eos-profile-link,
    body[data-design-system="ds-2-1"] .eos-profile-link,
    body[data-design-system="ds-2"] .exec-profile-link,
    body[data-design-system="ds-2-1"] .exec-profile-link {
        display: flex;
        justify-content: center;
    }

    body[data-design-system="ds-2"] .eos-rail-label,
    body[data-design-system="ds-2-1"] .eos-rail-label,
    body[data-design-system="ds-2"] .exec-rail-label,
    body[data-design-system="ds-2-1"] .exec-rail-label {
        display: none;
    }
}

/* ── Mobile bottom nav glow ── */
@media (max-width: 767px) {
    body[data-design-system="ds-2"] .eos-bottom-nav,
    body[data-design-system="ds-2-1"] .eos-bottom-nav,
    body[data-design-system="ds-2"] .exec-bottom-nav,
    body[data-design-system="ds-2-1"] .exec-bottom-nav {
        background: color-mix(in srgb, rgba(6, 7, 18, 0.96) 90%, rgba(168, 85, 247, 0.08));
        border-top-color: color-mix(in srgb, var(--eos-border) 70%, rgba(168, 85, 247, 0.3));
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.35);
    }

    body[data-design-system="ds-2"] .eos-bottom-link.is-active,
    body[data-design-system="ds-2-1"] .eos-bottom-link.is-active,
    body[data-design-system="ds-2"] .exec-bottom-link.is-active,
    body[data-design-system="ds-2-1"] .exec-bottom-link.is-active {
        color: var(--eos-cyan);
        text-shadow: 0 0 12px rgba(34, 211, 238, 0.45);
    }

    body[data-design-system="ds-2"] .eos-bottom-link.is-active .eos-bottom-icon,
    body[data-design-system="ds-2-1"] .eos-bottom-link.is-active .eos-bottom-icon,
    body[data-design-system="ds-2"] .exec-bottom-link.is-active .exec-bottom-icon,
    body[data-design-system="ds-2-1"] .exec-bottom-link.is-active .exec-bottom-icon,
    body[data-design-system="ds-2"] .eos-bottom-link.is-active .eos-bottom-logo,
    body[data-design-system="ds-2-1"] .eos-bottom-link.is-active .eos-bottom-logo,
    body[data-design-system="ds-2"] .exec-bottom-link.is-active .exec-bottom-logo,
    body[data-design-system="ds-2-1"] .exec-bottom-link.is-active .exec-bottom-logo {
        filter: drop-shadow(0 0 8px rgba(34, 211, 238, 0.55));
    }

    body[data-design-system="ds-2"] .eos-bottom-link.is-active::after,
    body[data-design-system="ds-2-1"] .eos-bottom-link.is-active::after {
        content: '';
        display: block;
        width: 20px;
        height: 3px;
        border-radius: 999px;
        background: linear-gradient(90deg, var(--eos-cyan), var(--eos-purple));
        box-shadow: 0 0 10px rgba(168, 85, 247, 0.55);
        margin-top: 2px;
    }
}

/* ── Auth executive shell ── */
body[data-design-system="ds-2"].auth-executive-shell,
body[data-design-system="ds-2-1"].auth-executive-shell {
    position: relative;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: clamp(16px, 4vw, 32px);
    overflow-x: hidden;
}

body[data-design-system="ds-2"].auth-executive-shell .eos-brain-layer,
body[data-design-system="ds-2-1"].auth-executive-shell .eos-brain-layer,
body[data-design-system="ds-2"].auth-executive-shell .exec-brain-layer,
body[data-design-system="ds-2-1"].auth-executive-shell .exec-brain-layer {
    z-index: 0;
}

body[data-design-system="ds-2"] .ds2-auth-card,
body[data-design-system="ds-2-1"] .ds2-auth-card,
body[data-design-system="ds-2"].auth-executive-shell .entry-card,
body[data-design-system="ds-2-1"].auth-executive-shell .entry-card {
    position: relative;
    z-index: 1;
    width: min(460px, 100%);
    border: 1px solid color-mix(in srgb, var(--tds-border) 75%, rgba(168, 85, 247, 0.28));
    border-radius: var(--tds-radius-card);
    background: color-mix(in srgb, var(--tds-surface) 92%, rgba(168, 85, 247, 0.04));
    backdrop-filter: blur(24px) saturate(150%);
    -webkit-backdrop-filter: blur(24px) saturate(150%);
    box-shadow: var(--tds-glow-card), var(--tds-shadow-panel);
    padding: clamp(20px, 4vw, 28px);
}

body[data-design-system="ds-2"] .ds2-auth-logo,
body[data-design-system="ds-2-1"] .ds2-auth-logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}

body[data-design-system="ds-2"] .ds2-auth-logo img,
body[data-design-system="ds-2-1"] .ds2-auth-logo img {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

body[data-design-system="ds-2"] .ds2-auth-logo-text,
body[data-design-system="ds-2-1"] .ds2-auth-logo-text {
    display: grid;
    gap: 2px;
    text-align: start;
}

body[data-design-system="ds-2"] .ds2-auth-logo-text strong,
body[data-design-system="ds-2-1"] .ds2-auth-logo-text strong {
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.02em;
}

body[data-design-system="ds-2"] .ds2-auth-logo-text span,
body[data-design-system="ds-2-1"] .ds2-auth-logo-text span {
    font-size: 0.68rem;
    color: var(--tds-muted);
}

body[data-design-system="ds-2"].auth-executive-shell .entry-top,
body[data-design-system="ds-2-1"].auth-executive-shell .entry-top {
    align-items: flex-start;
}

body[data-design-system="ds-2"].auth-executive-shell .language-pill,
body[data-design-system="ds-2-1"].auth-executive-shell .language-pill {
    border-color: color-mix(in srgb, var(--tds-border) 80%, rgba(168, 85, 247, 0.25));
    background: rgba(255, 255, 255, 0.04);
}
