/**
 * Sprint DS-2.1 — Pixel-perfect visual layer (mobile-first authority).
 *
 * Design authority hierarchy:
 *   1. Mobile reference  — PRIMARY (canonical product language)
 *   2. Tablet reference  — SECONDARY (reflow)
 *   3. Desktop reference — EXTENDED executive workspace (layout expansion only)
 *
 * Desktop must NOT be redesigned independently. It expands the mobile experience.
 * Card radius, glass, glow, typography, and spacing inherit from mobile base rules.
 *
 * Requires: executive-tokens.css, brief-pwa.css, ds-2-identity.css (load this file last).
 */

/* ── Today dashboard shell ── */
body[data-design-system="ds-2-1"] .exec-content,
body[data-design-system="ds-2-1"] .eos-content {
    max-width: none;
    width: 100%;
    margin-inline: 0;
    padding: clamp(16px, 2.5vw, 28px) clamp(16px, 2.8vw, 32px) calc(var(--eos-bottom-nav-height) + 24px);
}

/* P0 — studio-shell 2-col grid conflicts with fixed executive sidebar */
body[data-design-system="ds-2-1"].studio-shell {
    display: block;
}

body[data-design-system="ds-2-1"] .exec-shell,
body[data-design-system="ds-2-1"] .eos-shell {
    width: calc(100% - var(--eos-rail-width));
    margin-left: var(--eos-rail-width);
    min-width: 0;
    box-sizing: border-box;
}

@media (min-width: 1024px) {
    body[data-design-system="ds-2-1"] .exec-shell,
    body[data-design-system="ds-2-1"] .eos-shell {
        width: calc(100% - var(--eos-rail-width-expanded));
        margin-left: var(--eos-rail-width-expanded);
    }
}

@media (max-width: 767px) {
    body[data-design-system="ds-2-1"] .exec-shell,
    body[data-design-system="ds-2-1"] .eos-shell {
        width: 100%;
        margin-left: 0;
    }
}

/* P0 — override legacy page width caps (executive-components + studio.css) */
body[data-design-system="ds-2-1"] .exec-brief-page,
body[data-design-system="ds-2-1"] .brief-homepage {
    max-width: none;
    width: 100%;
    margin-inline: 0;
}

/* P0 — neutralize legacy 12-column brief grid; DS-2.1 rows own layout */
body[data-design-system="ds-2-1"] .eos-brief-grid.ds21-dashboard-grid {
    grid-template-columns: 1fr;
    grid-template-areas: none;
}

body[data-design-system="ds-2-1"] .eos-brief-grid.ds21-dashboard-grid .eos-card-priority,
body[data-design-system="ds-2-1"] .eos-brief-grid.ds21-dashboard-grid .eos-card-why,
body[data-design-system="ds-2-1"] .eos-brief-grid.ds21-dashboard-grid .eos-card-confidence,
body[data-design-system="ds-2-1"] .eos-brief-grid.ds21-dashboard-grid .eos-card-risk,
body[data-design-system="ds-2-1"] .eos-brief-grid.ds21-dashboard-grid .eos-card-opportunity,
body[data-design-system="ds-2-1"] .eos-brief-grid.ds21-dashboard-grid .eos-card-focus,
body[data-design-system="ds-2-1"] .eos-brief-grid.ds21-dashboard-grid .eos-card-notifications,
body[data-design-system="ds-2-1"] .eos-brief-grid.ds21-dashboard-grid .eos-card-change {
    grid-area: auto;
}

body[data-design-system="ds-2-1"] .ds21-today-dashboard {
    position: relative;
    z-index: var(--tds-z-content);
    width: 100%;
    max-width: none;
    margin: 0;
}

body[data-design-system="ds-2-1"] .ds21-hidden-legacy-context {
    display: none !important;
}

/* ── Dashboard header (mobile authority = stacked) ── */
body[data-design-system="ds-2-1"] .ds21-dashboard-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--tds-space-9);
    margin-bottom: var(--tds-section-gap);
    padding: var(--tds-space-7) var(--tds-space-9);
    border-radius: var(--tds-radius-card);
    background: color-mix(in srgb, var(--tds-glass-fill) 90%, rgba(168, 85, 247, 0.05));
    border: 1px solid color-mix(in srgb, var(--tds-border) 70%, rgba(168, 85, 247, 0.22));
    box-shadow: var(--tds-glow-card);
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
}

body[data-design-system="ds-2-1"] .ds21-greeting {
    margin: 0;
    font-size: var(--tds-type-greeting);
    font-weight: 800;
    line-height: 1.25;
}

body[data-design-system="ds-2-1"] .ds21-date {
    display: block;
    margin-top: 4px;
    color: var(--tds-muted);
    font-size: 0.82rem;
    font-weight: 600;
}

body[data-design-system="ds-2-1"] .ds21-header-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--tds-space-7);
    flex-shrink: 0;
}

body[data-design-system="ds-2-1"] .ds21-notification-btn {
    position: relative;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid color-mix(in srgb, var(--tds-border) 80%, rgba(168, 85, 247, 0.25));
    background: rgba(255, 255, 255, 0.04);
    color: var(--tds-text);
    font-size: 1.1rem;
    cursor: pointer;
}

body[data-design-system="ds-2-1"] .ds21-notification-badge {
    position: absolute;
    top: -4px;
    inset-inline-end: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--tds-purple), var(--tds-cyan));
    color: #fff;
    font-size: 0.62rem;
    font-weight: 800;
    line-height: 18px;
    text-align: center;
}

body[data-design-system="ds-2-1"] .ds21-start-day-form {
    margin: 0;
}

body[data-design-system="ds-2-1"] .ds21-start-day-btn {
    width: auto;
    flex: 1;
    min-width: 148px;
    padding: 12px 22px;
    white-space: nowrap;
}

/* ── Dashboard grid (mobile authority = single column) ── */
body[data-design-system="ds-2-1"] .ds21-dashboard-grid {
    display: grid;
    row-gap: var(--tds-section-gap, var(--tds-dashboard-gap));
    column-gap: var(--tds-dashboard-gap);
    grid-template-columns: 1fr;
    grid-template-areas: unset;
}

body[data-design-system="ds-2-1"] .ds21-dashboard-grid > *,
body[data-design-system="ds-2-1"] .ds21-dashboard-grid .eos-card {
    grid-area: auto;
}

body[data-design-system="ds-2-1"] .ds21-hero-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--tds-dashboard-gap);
    align-items: stretch;
}

body[data-design-system="ds-2-1"] .ds21-hero-priority {
    position: relative;
    overflow: hidden;
    min-height: 180px;
    padding: clamp(16px, 4vw, 20px);
    border-radius: var(--tds-radius-card);
}

body[data-design-system="ds-2-1"] .ds21-hero-priority-inner {
    position: relative;
    z-index: 2;
    max-width: min(100%, 100%);
}

body[data-design-system="ds-2-1"] .ds21-hero-artwork {
    position: absolute;
    inset-block: 0;
    inset-inline-end: -10%;
    width: 58%;
    background:
        url('/assets/images/brain-artwork.svg') center / contain no-repeat;
    opacity: 0.22;
    filter: drop-shadow(0 0 32px rgba(34, 211, 238, 0.22));
    pointer-events: none;
    animation: ds21-brain-drift var(--tds-motion-drift) infinite alternate;
}

@keyframes ds21-brain-drift {
    from { transform: translateY(0) scale(1); }
    to { transform: translateY(-6px) scale(1.02); }
}

body[data-design-system="ds-2-1"] .ds21-icon-brain {
    color: var(--tds-cyan);
    filter: drop-shadow(0 0 8px rgba(34, 211, 238, 0.45));
}

body[data-design-system="ds-2-1"] .ds21-priority-why {
    margin-top: 14px;
}

body[data-design-system="ds-2-1"] .ds21-hero-confidence {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding-top: 18px;
    padding-bottom: 18px;
}

body[data-design-system="ds-2-1"] .ds21-hero-confidence .eos-confidence-ring {
    width: min(132px, 28vw);
    margin: 8px 0;
}

/* ── Status row (mobile = stacked) ── */
body[data-design-system="ds-2-1"] .ds21-status-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--tds-dashboard-gap);
}

body[data-design-system="ds-2-1"] .ds21-status-card .eos-widget-list li,
body[data-design-system="ds-2-1"] .ds21-status-card .eos-outcomes-list li {
    font-size: 0.84rem;
}

body[data-design-system="ds-2-1"] .ds21-status-card .eos-outcomes-list {
    margin: 0;
    padding-inline-start: 18px;
    display: grid;
    gap: 6px;
}

/* ── Bottom row (mobile = stacked) ── */
body[data-design-system="ds-2-1"] .ds21-bottom-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--tds-dashboard-gap);
}

body[data-design-system="ds-2-1"] .ds21-schedule-timeline {
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 10px;
}

body[data-design-system="ds-2-1"] .ds21-streak-ring {
    position: relative;
    width: 108px;
    height: 108px;
    margin: 10px auto 8px;
}

body[data-design-system="ds-2-1"] .ds21-streak-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

body[data-design-system="ds-2-1"] .ds21-streak-track {
    fill: none;
    stroke: rgba(255, 255, 255, 0.08);
    stroke-width: 8;
}

body[data-design-system="ds-2-1"] .ds21-streak-progress {
    fill: none;
    stroke: var(--tds-cyan);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 301;
    stroke-dashoffset: calc(301 - (301 * var(--streak-percent, 50) / 100));
    filter: drop-shadow(0 0 8px rgba(34, 211, 238, 0.45));
}

body[data-design-system="ds-2-1"] .ds21-streak-value {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.65rem;
    font-weight: 800;
}

body[data-design-system="ds-2-1"] .ds21-streak-caption,
body[data-design-system="ds-2-1"] .ds21-remaining-caption {
    margin: 0;
    text-align: center;
    color: var(--tds-muted);
    font-size: 0.78rem;
}

body[data-design-system="ds-2-1"] .ds21-remaining-value {
    margin: 12px 0 6px;
    text-align: center;
    font-size: clamp(2rem, 4vw, 2.6rem);
    font-weight: 800;
    background: linear-gradient(135deg, var(--tds-cyan), var(--tds-purple));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

body[data-design-system="ds-2-1"] .ds21-status-checklist {
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 8px;
}

body[data-design-system="ds-2-1"] .ds21-status-item {
    display: grid;
    grid-template-columns: 18px 20px 1fr;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.78rem;
}

body[data-design-system="ds-2-1"] .ds21-status-item[data-status="complete"] .ds21-status-check {
    color: var(--tds-lime);
}

body[data-design-system="ds-2-1"] .ds21-status-item[data-status="partial"] .ds21-status-check {
    color: var(--tds-gold);
}

/* ── Footer row (mobile = stacked) ── */
body[data-design-system="ds-2-1"] .ds21-footer-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--tds-dashboard-gap);
}

body[data-design-system="ds-2-1"] .ds21-quote-card {
    margin: 0;
    display: flex;
    align-items: center;
}

body[data-design-system="ds-2-1"] .ds21-quote-text {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.65;
    color: var(--tds-muted);
    font-style: italic;
}

body[data-design-system="ds-2-1"] .ds21-learning-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

body[data-design-system="ds-2-1"] .ds21-learning-percent {
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--tds-cyan);
}

body[data-design-system="ds-2-1"] .ds21-learning-label {
    margin: 0 0 10px;
    font-size: 0.84rem;
    line-height: 1.45;
}

body[data-design-system="ds-2-1"] .ds21-learning-track {
    height: 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

body[data-design-system="ds-2-1"] .ds21-learning-fill {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--tds-gradient-progress);
    box-shadow: 0 0 12px rgba(34, 211, 238, 0.35);
}

body[data-design-system="ds-2-1"] .ds21-mobile-notifications {
    grid-column: 1 / -1;
    display: none;
}

body[data-design-system="ds-2-1"] .ds21-re-evaluate-card {
    grid-column: 1 / -1;
}

body[data-design-system="ds-2-1"] [data-morning-experience] .ds21-re-evaluate-card {
    display: none;
}

/* ── Desktop extended workspace (layout expansion — same product language) ── */
@media (min-width: 1024px) {
    body[data-design-system="ds-2-1"] .exec-content,
    body[data-design-system="ds-2-1"] .eos-content {
        max-width: none;
        width: 100%;
        padding-inline: clamp(24px, 2.4vw, 44px);
    }

    body[data-design-system="ds-2-1"] .ds21-today-dashboard {
        max-width: none;
        width: 100%;
    }

    body[data-design-system="ds-2-1"] .ds21-dashboard-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: var(--tds-space-11);
    }

    body[data-design-system="ds-2-1"] .ds21-header-actions {
        justify-content: flex-end;
        flex: 0 0 auto;
    }

    body[data-design-system="ds-2-1"] .ds21-start-day-btn {
        flex: 0 0 auto;
    }

    body[data-design-system="ds-2-1"] .ds21-dashboard-grid {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: unset;
    }

    body[data-design-system="ds-2-1"] .ds21-hero-row {
        grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
    }

    body[data-design-system="ds-2-1"] .ds21-hero-priority-inner {
        max-width: min(100%, 620px);
    }

    body[data-design-system="ds-2-1"] .ds21-hero-artwork {
        inset-inline-end: -4%;
        width: min(52%, 480px);
        opacity: 0.28;
    }

    body[data-design-system="ds-2-1"] .ds21-status-row {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    body[data-design-system="ds-2-1"] .ds21-bottom-row {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    body[data-design-system="ds-2-1"] .ds21-footer-row {
        grid-template-columns: 1.2fr 1fr;
    }

    body[data-design-system="ds-2-1"] .ds21-mobile-notifications {
        display: none;
    }

    body[data-design-system="ds-2-1"] .eos-rail-link.is-active,
    body[data-design-system="ds-2-1"] .exec-rail-link.is-active {
        background: linear-gradient(90deg, rgba(124, 58, 237, 0.32), rgba(34, 211, 238, 0.14));
        border-radius: var(--tds-radius-pill);
        box-shadow: var(--tds-glow-nav-pill), inset 0 0 0 1px rgba(168, 85, 247, 0.35);
    }

    body[data-design-system="ds-2-1"] .eos-leadership-level,
    body[data-design-system="ds-2-1"] .exec-leadership-level {
        margin-top: 12px;
        padding-top: 10px;
        border-top: 1px solid color-mix(in srgb, var(--eos-border) 75%, transparent);
    }

    body[data-design-system="ds-2-1"] .eos-leadership-head,
    body[data-design-system="ds-2-1"] .exec-leadership-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        margin-bottom: 6px;
    }

    body[data-design-system="ds-2-1"] .eos-leadership-label,
    body[data-design-system="ds-2-1"] .exec-leadership-label {
        font-size: 0.62rem;
        color: var(--eos-muted);
        font-weight: 600;
    }

    body[data-design-system="ds-2-1"] .eos-leadership-percent,
    body[data-design-system="ds-2-1"] .exec-leadership-percent {
        font-size: 0.62rem;
        font-weight: 800;
        color: var(--eos-cyan);
    }

    body[data-design-system="ds-2-1"] .eos-leadership-track,
    body[data-design-system="ds-2-1"] .exec-leadership-track {
        height: var(--tds-leadership-bar-height);
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.08);
        overflow: hidden;
    }

    body[data-design-system="ds-2-1"] .eos-leadership-fill,
    body[data-design-system="ds-2-1"] .exec-leadership-fill {
        display: block;
        height: 100%;
        width: var(--leadership-percent, 0%);
        border-radius: inherit;
        background: var(--tds-gradient-progress);
        box-shadow: 0 0 10px rgba(34, 211, 238, 0.35);
    }

    body[data-design-system="ds-2-1"] .eos-sidebar-utilities,
    body[data-design-system="ds-2-1"] .exec-sidebar-utilities {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 6px;
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid color-mix(in srgb, var(--eos-border) 75%, transparent);
    }

    body[data-design-system="ds-2-1"] .eos-sidebar-utility,
    body[data-design-system="ds-2-1"] .exec-sidebar-utility {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 34px;
        height: 34px;
        border-radius: 10px;
        border: 1px solid color-mix(in srgb, var(--eos-border) 80%, rgba(168, 85, 247, 0.2));
        background: rgba(255, 255, 255, 0.03);
        color: var(--eos-muted);
        text-decoration: none;
        font-size: 0.95rem;
        cursor: pointer;
        transition: color var(--tds-motion-fast), box-shadow var(--tds-motion-fast);
    }

    body[data-design-system="ds-2-1"] .eos-sidebar-utility:hover,
    body[data-design-system="ds-2-1"] .exec-sidebar-utility:hover {
        color: var(--eos-text);
        box-shadow: 0 0 12px rgba(168, 85, 247, 0.2);
    }
}

/* ── Tablet secondary authority (reflow — inherits mobile language) ── */
@media (min-width: 768px) and (max-width: 1023px) {
    body[data-design-system="ds-2-1"] .ds21-dashboard-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    body[data-design-system="ds-2-1"] .ds21-header-actions {
        justify-content: flex-end;
        flex: 0 0 auto;
    }

    body[data-design-system="ds-2-1"] .ds21-start-day-btn {
        flex: 0 0 auto;
    }

    body[data-design-system="ds-2-1"] .ds21-hero-confidence {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 16px;
        text-align: start;
    }

    body[data-design-system="ds-2-1"] .ds21-status-row,
    body[data-design-system="ds-2-1"] .ds21-bottom-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

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

/* ── Mobile-specific chrome (bottom nav, safe areas) ── */
@media (max-width: 767px) {
    body[data-design-system="ds-2-1"] .ds21-mobile-notifications {
        display: block;
    }

    body[data-design-system="ds-2-1"] .ds21-bottom-nav {
        height: calc(var(--eos-bottom-nav-height) + env(safe-area-inset-bottom));
        padding-inline: 8px;
        align-items: flex-end;
    }

    body[data-design-system="ds-2-1"] .ds21-bottom-nav .eos-bottom-link,
    body[data-design-system="ds-2-1"] .ds21-bottom-nav .exec-bottom-link {
        position: relative;
        padding-bottom: 6px;
    }

    body[data-design-system="ds-2-1"] .ds21-bottom-nav .eos-bottom-link.is-center-brand,
    body[data-design-system="ds-2-1"] .ds21-bottom-nav .exec-bottom-link.is-center-brand {
        align-self: flex-start;
        margin-top: -18px;
    }

    body[data-design-system="ds-2-1"] .ds21-bottom-nav .eos-bottom-brand-wrap,
    body[data-design-system="ds-2-1"] .ds21-bottom-nav .exec-bottom-brand-wrap {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 56px;
        height: 56px;
        border-radius: 999px;
        background: linear-gradient(135deg, rgba(124, 58, 237, 0.35), rgba(34, 211, 238, 0.18));
        border: 1px solid color-mix(in srgb, var(--tds-purple) 45%, rgba(34, 211, 238, 0.35));
        box-shadow: var(--tds-glow-brain-center);
    }

    body[data-design-system="ds-2-1"] .ds21-bottom-nav .eos-bottom-logo,
    body[data-design-system="ds-2-1"] .ds21-bottom-nav .exec-bottom-logo {
        width: 32px;
        height: 32px;
    }
}

[dir="rtl"] body[data-design-system="ds-2-1"] .ds21-hero-artwork {
    inset-inline-end: auto;
    inset-inline-start: -4%;
    transform: scaleX(-1);
}
