/**
 * Theme: Apex
 * Direction: A race engineer's timing wall—compressed, urgent and built for glanceability.
 */

[data-theme="apex"] {
    --theme-primary: #edff38;
    --theme-primary-light: #f5ff83;
    --theme-secondary: #ff4d2e;
    --theme-accent: #53d7ff;
    --theme-gradient: linear-gradient(100deg, #edff38 0 66%, #ff4d2e 66% 100%);

    --theme-bg-dark: #0c0e0f;
    --theme-bg-medium: #171a1b;
    --theme-bg-glow-1: rgba(237, 255, 56, 0.05);
    --theme-bg-glow-2: transparent;
    --theme-bg-glow-3: transparent;

    --theme-card-bg: #171a1b;
    --theme-card-border: rgba(237, 255, 56, 0.28);
    --theme-card-border-hover: #edff38;
    --theme-card-glow: rgba(237, 255, 56, 0.12);

    --theme-btn-bg: #242829;
    --theme-btn-border: #4d5455;
    --theme-btn-hover-bg: #edff38;
    --theme-btn-glow: none;
    --theme-btn-glow-hover: 0 0 0 2px #0c0e0f, 0 0 0 4px #edff38;

    --theme-connected-bg: #edff38;
    --theme-connected-border: #edff38;
    --theme-connected-glow: none;

    --theme-text-accent: #edff38;
    --theme-text-secondary-accent: #53d7ff;
    --theme-shadow-glow: none;
    --theme-shadow-card: 0 12px 0 rgba(0, 0, 0, 0.28);
    --theme-progress-bg: repeating-linear-gradient(135deg, #edff38 0 12px, #c7d725 12px 24px);
    --theme-progress-glow: 0 0 16px rgba(237, 255, 56, 0.4);

    --font-primary: "DM Mono", monospace;
    --font-display: "Rajdhani", sans-serif;
    --radius-sm: 0;
    --radius-md: 0;
    --radius-lg: 0;
    --radius-xl: 0;
}

[data-theme="apex"] body {
    background-color: #0c0e0f;
    background-image:
        linear-gradient(125deg, transparent 0 72%, rgba(237, 255, 56, 0.035) 72% 73%, transparent 73%),
        linear-gradient(180deg, #0c0e0f 0%, #171a1b 100%);
}

[data-theme="apex"] body::before {
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
    background-size: 48px 48px;
}

[data-theme="apex"] .container {
    max-width: 1880px;
    padding-top: 34px;
}

[data-theme="apex"] .header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 18px;
    padding: 18px 22px 16px 26px;
    background: #171a1b;
    border-top: 2px solid #edff38;
    border-bottom: 1px solid #4d5455;
    border-left: 8px solid #edff38;
    text-align: left;
    clip-path: polygon(0 0, 97% 0, 100% 50%, 97% 100%, 0 100%);
}

[data-theme="apex"] .header::after {
    content: "LIVE TELEMETRY / SYSTEM ARMED";
    padding: 5px 8px;
    background: #edff38;
    color: #0c0e0f;
    font-size: 0.68rem;
    letter-spacing: 1.4px;
}

[data-theme="apex"] .header__title {
    background: none;
    color: #f1f3ec;
    font-size: clamp(2.3rem, 4vw, 4.4rem);
    font-style: italic;
    line-height: 0.85;
    letter-spacing: -2px;
    text-shadow: none;
    -webkit-text-fill-color: currentColor;
    animation: none;
}

[data-theme="apex"] .header__subtitle {
    display: none;
}

[data-theme="apex"] .connection-panel {
    justify-content: flex-start;
    gap: 8px;
    padding: 10px;
    background: #171a1b;
    backdrop-filter: none;
    border: 1px solid #3a4041;
    border-left: 4px solid #ff4d2e;
    box-shadow: none;
}

[data-theme="apex"] .workout-picker {
    border-left-color: #53d7ff;
}

[data-theme="apex"] .btn {
    padding: 10px 14px;
    border-width: 1px;
    border-radius: 0;
    font-size: 0.68rem;
    letter-spacing: 1px;
    transition: color 100ms linear, background 100ms linear, border-color 100ms linear;
}

[data-theme="apex"] .btn::before {
    display: none;
}

[data-theme="apex"] .btn:hover:not(:disabled) {
    color: #0c0e0f;
    transform: none;
}

[data-theme="apex"] .btn.connected {
    color: #0c0e0f;
}

[data-theme="apex"] .status-message {
    margin-bottom: 14px;
    padding: 7px 12px;
    background: #ff4d2e;
    border: 0;
    border-radius: 0;
    color: #fff;
    font-size: 0.68rem;
    letter-spacing: 1.2px;
    text-align: left;
    text-shadow: none;
}

[data-theme="apex"] .status-message::before {
    content: "COMMS // ";
    color: #0c0e0f;
    font-weight: 700;
}

[data-theme="apex"] .two-column-layout {
    grid-template-columns: minmax(0, 1.16fr) minmax(440px, 0.84fr);
    gap: 12px;
    margin-top: 12px;
}

[data-theme="apex"] .column {
    gap: 12px;
}

[data-theme="apex"] .column--right {
    display: grid;
    grid-template-columns: 1fr;
}

[data-theme="apex"] .workout-section,
[data-theme="apex"] .metric-card {
    background: #171a1b;
    backdrop-filter: none;
    border: 1px solid #3a4041;
    border-radius: 0;
    box-shadow: var(--theme-shadow-card);
}

[data-theme="apex"] .workout-section {
    padding: 18px;
    margin-bottom: 0;
}

[data-theme="apex"] .section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #f1f3ec;
    font-size: 0.72rem;
    letter-spacing: 2px;
}

[data-theme="apex"] .section-title::before {
    content: "";
    width: 22px;
    height: 5px;
    background: #edff38;
}

[data-theme="apex"] .hr-zone-section {
    padding: 18px;
    border-top: 5px solid #edff38;
}

[data-theme="apex"] .hr-zone-header {
    margin: 0;
    padding: 0;
    background: none;
    border: 0;
}

[data-theme="apex"] .hr-zone-title {
    color: #889091;
    font-family: "DM Mono", monospace;
    font-size: 0.68rem;
    letter-spacing: 2px;
}

[data-theme="apex"] .hr-zone-content {
    display: grid;
    grid-template-columns: minmax(230px, 0.72fr) minmax(0, 1.28fr);
    gap: 18px;
    margin-top: 12px;
}

[data-theme="apex"] .hr-display {
    align-self: stretch;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 18px;
    background: #edff38;
    color: #0c0e0f;
    text-align: left;
    clip-path: polygon(0 0, 94% 0, 100% 10%, 100% 100%, 0 100%);
}

[data-theme="apex"] .hr-display__value,
[data-theme="apex"] .metric-card__value,
[data-theme="apex"] .phase-timer {
    background: none;
    text-shadow: none;
    -webkit-text-fill-color: currentColor;
}

[data-theme="apex"] .hr-display__value {
    color: #0c0e0f;
    font-size: clamp(6rem, 10vw, 10rem);
    font-style: italic;
    letter-spacing: -7px;
    filter: none;
}

[data-theme="apex"] .hr-display__unit {
    color: rgba(12, 14, 15, 0.65);
    font-size: 0.7rem;
}

[data-theme="apex"] .hr-display__zone {
    align-self: flex-start;
    margin-top: 10px;
    padding: 4px 7px;
    background: #0c0e0f;
    border: 0;
    color: #edff38;
    font-size: 0.8rem;
}

[data-theme="apex"] .zone-bars__container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
}

[data-theme="apex"] .zone-box {
    min-height: 0;
    flex-direction: row;
    align-items: center;
    padding: 7px 12px;
    background: #222627;
    border: 0;
    border-left: 8px solid currentColor;
    border-radius: 0;
}

[data-theme="apex"] .zone-box__content {
    display: grid;
    grid-template-columns: 76px 1fr auto;
    align-items: center;
    width: 100%;
    padding: 0;
    background: transparent;
    text-align: left;
}

[data-theme="apex"] .zone-box__name {
    font-size: 0.72rem;
}

[data-theme="apex"] .zone-box__desc,
[data-theme="apex"] .zone-box__range {
    margin: 0;
    color: #a5acad;
    font-size: 0.62rem;
}

[data-theme="apex"] .zone-box__number {
    display: none;
}

[data-theme="apex"] .metrics-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    margin-bottom: 0;
    order: 2;
}

[data-theme="apex"] .metric-card {
    padding: 11px 8px;
    border-top: 3px solid #53d7ff;
    box-shadow: none;
}

[data-theme="apex"] .metric-card:first-child {
    border-top-color: #ff4d2e;
}

[data-theme="apex"] .metric-card:nth-child(4) {
    border-top-color: #edff38;
}

[data-theme="apex"] .metric-card::before {
    display: none;
}

[data-theme="apex"] .metric-card:hover {
    transform: none;
    border-color: #edff38;
    box-shadow: none;
}

[data-theme="apex"] .metric-card__label {
    margin-bottom: 6px;
    color: #8f9798;
    font-size: 0.55rem;
    letter-spacing: 0.8px;
}

[data-theme="apex"] .metric-card__value {
    color: #f1f3ec;
    font-size: clamp(1.6rem, 2.6vw, 2.5rem);
}

[data-theme="apex"] .metric-card__value--small {
    font-size: clamp(1.2rem, 2vw, 1.8rem);
}

[data-theme="apex"] .metric-card__unit {
    color: #53d7ff;
    font-size: 0.56rem;
}

[data-theme="apex"] .metric-card__zone,
[data-theme="apex"] .metric-card__status {
    font-size: 0.65rem;
}

[data-theme="apex"] .column--right > .workout-section:nth-of-type(1) {
    order: 1;
    border-top: 5px solid #ff4d2e;
}

[data-theme="apex"] .column--right > .workout-section:nth-of-type(2) {
    order: 3;
}

[data-theme="apex"] .current-phase {
    color: #ff4d2e;
    font-size: 0.75rem;
    letter-spacing: 2px;
    text-align: left;
    text-shadow: none;
}

[data-theme="apex"] .phase-timer {
    color: #f1f3ec;
    font-size: clamp(6rem, 11vw, 11rem);
    font-style: italic;
    line-height: 0.78;
    letter-spacing: -7px;
    text-align: left;
}

[data-theme="apex"] .progress-bar {
    height: 16px;
    background: #0c0e0f;
    border: 1px solid #3a4041;
    border-radius: 0;
}

[data-theme="apex"] .progress-bar__fill::after {
    display: none;
}

[data-theme="apex"] .workout-controls,
[data-theme="apex"] .next-phase {
    margin: 0;
    text-align: left;
}

[data-theme="apex"] .phase-item {
    padding: 8px 10px;
    background: #202425;
    border: 0;
    border-left: 4px solid #4d5455;
    border-radius: 0;
    font-size: 0.74rem;
}

[data-theme="apex"] .phase-item:hover {
    transform: none;
    border-left-color: #edff38;
}

[data-theme="apex"] .phase-item.active {
    background: #edff38;
    border-color: #edff38;
    box-shadow: none;
    color: #0c0e0f;
    animation: apexActive 1s steps(2, end) infinite;
}

[data-theme="apex"] .zone-card {
    padding: 10px 8px;
    background: #202425;
    border-width: 0 0 0 5px;
    border-radius: 0;
    box-shadow: none;
}

[data-theme="apex"] .zone-card:hover {
    transform: none;
    background: #292e2f;
}

[data-theme="apex"] .theme-switcher {
    background: #171a1b;
    border: 1px solid #4d5455;
    border-radius: 0;
}

@keyframes apexActive {
    50% {
        background: #d0df2e;
    }
}

@media (max-width: 1200px) {
    [data-theme="apex"] .two-column-layout {
        grid-template-columns: 1fr;
    }

    [data-theme="apex"] .column--right {
        display: flex;
    }

    [data-theme="apex"] .metrics-grid,
    [data-theme="apex"] .column--right > .workout-section {
        order: initial;
    }
}

@media (max-width: 760px) {
    [data-theme="apex"] .container {
        padding: 22px 4px 64px;
    }

    [data-theme="apex"] .header {
        display: block;
        clip-path: polygon(0 0, 96% 0, 100% 22%, 100% 100%, 0 100%);
    }

    [data-theme="apex"] .header::after {
        display: block;
        margin-top: 8px;
    }

    [data-theme="apex"] .connection-panel {
        padding: 8px;
    }

    [data-theme="apex"] .btn {
        flex: 1 1 130px;
    }

    [data-theme="apex"] .hr-zone-content {
        grid-template-columns: 1fr;
    }

    [data-theme="apex"] .hr-display__value {
        font-size: 7rem;
    }

    [data-theme="apex"] .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    [data-theme="apex"] .metric-card:last-child {
        grid-column: span 2;
    }

    [data-theme="apex"] .phase-timer {
        font-size: 6rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    [data-theme="apex"] .phase-item.active {
        animation: none;
    }
}
