/* ==========================================================================
   My Work — animated walkthrough of DCU validation responsibilities.
   Builds on editorial.css tokens (loaded first).
   ========================================================================== */

html.js .reveal {
    opacity: 0;
    transform: translateY(28px);
    transition: opacity 0.8s cubic-bezier(.2, .7, .2, 1), transform 0.8s cubic-bezier(.2, .7, .2, 1);
    transition-delay: var(--d, 0ms);
}
html.js .reveal.is-visible { opacity: 1; transform: none; }

*, *::before, *::after { box-sizing: border-box; }

.mw-top {
    position: fixed; inset: 0 0 auto 0; z-index: 50;
    background: var(--navbar-bg);
    backdrop-filter: saturate(140%) blur(10px);
    -webkit-backdrop-filter: saturate(140%) blur(10px);
    border-bottom: 1px solid var(--border-primary);
}
.mw-top-inner {
    max-width: var(--wrap); margin: 0 auto; padding: 14px var(--gutter);
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.mw-back { color: var(--text-secondary); text-decoration: none; font-size: 14px; font-weight: 600; }
.mw-back:hover { color: var(--accent-primary); }
.mw-progress {
    position: absolute; left: 0; bottom: -1px; height: 2px; width: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    transform-origin: 0 50%; transform: scaleX(0);
}
.mw-chapters {
    display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; max-width: 62vw;
}
.mw-chapters::-webkit-scrollbar { display: none; }
.mw-chapters a {
    font-family: var(--font-mono); font-size: 12px; color: var(--text-tertiary);
    text-decoration: none; padding: 4px 8px; border-radius: 999px; white-space: nowrap;
    border: 1px solid transparent;
}
.mw-theme-toggle {
    flex: none; width: 36px; height: 36px; border-radius: 999px; cursor: pointer;
    display: grid; place-items: center; font-size: 15px;
    background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border-accent);
}
.mw-theme-toggle:hover { border-color: var(--accent-primary); color: var(--accent-primary); }
.mw-chapters a.active { color: var(--accent-primary); border-color: var(--border-accent); }

main.mw { padding-top: 72px; }

/* ---------- Hero ---------- */
.mw-hero { padding: 120px 0 88px; position: relative; overflow: hidden; }
.mw-hero::before {
    content: ''; position: absolute; inset: -20% -10% auto auto; width: 60vw; height: 60vw; max-width: 720px; max-height: 720px;
    background: radial-gradient(circle, color-mix(in srgb, var(--accent-secondary) 18%, transparent) 0%, transparent 60%);
    animation: mw-drift 14s ease-in-out infinite alternate; pointer-events: none;
}
@keyframes mw-drift { from { transform: translate(0,0); } to { transform: translate(-40px, 30px); } }
.mw-title {
    font-size: clamp(44px, 8vw, 96px); line-height: 0.98; margin: 0 0 22px; letter-spacing: -0.03em;
}
.mw-title .word { display: inline-block; opacity: 0; transform: translateY(40px); animation: mw-rise 0.9s cubic-bezier(.2,.7,.2,1) forwards; }
@keyframes mw-rise { to { opacity: 1; transform: none; } }
.mw-sub { font-size: 20px; max-width: 58ch; color: var(--text-secondary); margin: 0 0 32px; }
.mw-cta-row { display: flex; gap: 12px; flex-wrap: wrap; }
.mw-scroll-hint {
    margin-top: 56px; font-family: var(--font-mono); font-size: 12px; color: var(--text-tertiary);
    display: flex; align-items: center; gap: 10px;
}
.mw-scroll-hint::after {
    content: ''; width: 1px; height: 36px; background: var(--border-accent);
    animation: mw-line 1.8s ease-in-out infinite;
}
@keyframes mw-line { 0%,100% { transform: scaleY(0.3); transform-origin: top; } 50% { transform: scaleY(1); transform-origin: top; } }

/* ---------- Chapters ---------- */
.mw-chapter { padding: 112px 0; border-top: 1px solid var(--border-primary); }
.mw-chapter-head { margin-bottom: 48px; max-width: 760px; }
.mw-chapter-head h2 { font-size: clamp(30px, 4.6vw, 52px); margin: 6px 0 14px; letter-spacing: -0.02em; }
.mw-chapter-head p { font-size: 18px; color: var(--text-tertiary); margin: 0; }

.mw-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.mw-card {
    background: var(--bg-card); border: 1px solid var(--border-primary); border-radius: 16px;
    padding: 26px; display: flex; flex-direction: column; gap: 10px;
    transition: border-color .25s ease, transform .25s ease, background-color .25s ease;
}
.mw-card:hover { border-color: var(--border-accent); transform: translateY(-3px); background: var(--bg-card-hover); }
.mw-card .mw-icon {
    width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
    background: color-mix(in srgb, var(--accent-primary) 14%, transparent); color: var(--accent-primary); font-size: 18px;
}
.mw-card h3 { font-size: 20px; margin: 4px 0 0; }
.mw-card p, .mw-card li { font-size: 16px; color: var(--text-secondary); margin: 0; }
.mw-card ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.mw-tag {
    font-family: var(--font-mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase;
    color: var(--accent-secondary);
}
.mw-num {
    font-family: var(--font-heading); font-size: 44px; line-height: 1; color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

/* Embedded interactive diagram */
.mw-embed {
    background: var(--bg-card); border: 1px solid var(--border-primary); border-radius: 18px; overflow: hidden;
}
.mw-embed-frame { display: block; width: 100%; height: 420px; border: 0; background: transparent; }
.mw-embed-caption {
    display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 14px 20px; border-top: 1px solid var(--border-primary); font-size: 14px; color: var(--text-tertiary);
}
.mw-embed-caption a { color: var(--accent-primary); font-weight: 600; text-decoration: none; }
.mw-embed-frame--strip { height: 230px; }
.mw-embed-frame--medium { height: 480px; }
.mw-embed-frame--tall { height: 940px; }
.mw-embed-frame--compact { height: 330px; }
@media (max-width: 640px) { .mw-embed-frame { height: 560px; } .mw-embed-frame--strip { height: 200px; } }

/* Intro profile cards */
.mw-intro-stat { font-size: 15px; color: var(--text-tertiary); }

/* Input files list */
.mw-files { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mw-file {
    display: flex; align-items: center; gap: 14px; padding: 18px 20px; border-radius: 14px;
    background: var(--bg-card); border: 1px solid var(--border-primary); font-size: 17px; color: var(--text-primary);
}
.mw-file i { color: var(--accent-secondary); width: 22px; text-align: center; }

/* Hardware checklist: six-segment ring built from CSS */
.mw-hw { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.mw-hw-item {
    border-left: 2px solid var(--accent-primary); padding: 4px 0 4px 18px;
}
.mw-hw-item h3 { font-size: 19px; margin: 0 0 6px; font-family: var(--font-body); font-weight: 700; color: var(--accent-secondary); letter-spacing: .01em; }
.mw-hw-item p { margin: 0; font-size: 16px; color: var(--text-secondary); }

/* Bench diagram */
.mw-bench {
    background: var(--bg-card); border: 1px solid var(--border-primary); border-radius: 18px; padding: 18px;
}
.mw-bench svg { width: 100%; height: auto; display: block; }
.mw-bench .node-box { fill: var(--bg-secondary); stroke: var(--border-accent); stroke-width: 1.4; }
.mw-bench .node-label { fill: var(--text-primary); font-family: var(--font-body); font-size: 15px; font-weight: 600; }
.mw-bench .node-sub { fill: var(--text-tertiary); font-family: var(--font-mono); font-size: 11px; }
.mw-bench .wire { fill: none; stroke: var(--text-tertiary); stroke-width: 2; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; }
.mw-bench.is-visible .wire { animation: mw-draw 1.6s ease forwards; }
.mw-bench .wire:nth-of-type(2) { animation-delay: .25s !important; }
.mw-bench .wire:nth-of-type(3) { animation-delay: .5s !important; }
.mw-bench .wire:nth-of-type(4) { animation-delay: .75s !important; }
.mw-bench .wire:nth-of-type(5) { animation-delay: 1s !important; }
@keyframes mw-draw { to { stroke-dashoffset: 0; } }
.mw-bench .pulse { fill: var(--accent-primary); opacity: 0; }
.mw-bench.is-visible .pulse { animation: mw-pulse 2.6s ease-in-out 1.8s infinite; }
@keyframes mw-pulse {
    0% { opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { opacity: 0; }
}
.mw-bench-legend { display: flex; flex-wrap: wrap; gap: 14px 24px; margin-top: 14px; font-size: 14px; color: var(--text-tertiary); }

/* Environment: horizontal stepper */
.mw-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; position: relative; }
.mw-step { padding: 22px 22px 26px; border-top: 2px solid var(--border-primary); position: relative; }
.mw-step::before {
    content: attr(data-n); font-family: var(--font-mono); font-size: 13px; color: var(--accent-primary);
    display: block; margin-bottom: 10px;
}
.mw-step h3 { font-size: 19px; margin: 0 0 8px; }
.mw-step p { margin: 0; font-size: 16px; color: var(--text-secondary); }
.mw-step.is-visible { border-top-color: var(--accent-primary); transition: border-color .6s ease .15s; }

/* Smoke testing: numbered timeline */
.mw-timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.mw-timeline::before {
    content: ''; position: absolute; left: 15px; top: 6px; bottom: 6px; width: 2px;
    background: linear-gradient(var(--accent-primary), var(--accent-secondary));
    transform-origin: top; transform: scaleY(0);
    transition: transform 1.6s ease;
}
.mw-timeline.is-visible::before { transform: scaleY(1); }
.mw-timeline li { position: relative; padding: 0 0 26px 52px; }
.mw-timeline li::before {
    content: ''; position: absolute; left: 8px; top: 6px; width: 16px; height: 16px; border-radius: 50%;
    background: var(--bg-primary); border: 2px solid var(--accent-primary);
}
.mw-timeline h3 { font-size: 19px; margin: 0 0 4px; }
.mw-timeline p { margin: 0; font-size: 16px; color: var(--text-secondary); }

/* Zero DTC: two-column ordered steps */
.mw-ordered { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 32px; counter-reset: zd; list-style: none; padding: 0; margin: 0; }
.mw-ordered li { counter-increment: zd; display: flex; gap: 14px; align-items: baseline; font-size: 17px; color: var(--text-secondary); }
.mw-ordered li::before {
    content: counter(zd, decimal-leading-zero); font-family: var(--font-mono); font-size: 13px; color: var(--accent-primary); flex-shrink: 0;
}
.mw-ordered strong { color: var(--text-primary); font-weight: 600; }

/* Failsafe example: DTC status walk */
.mw-flow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; align-items: stretch; }
.mw-flow-card { background: var(--bg-card); border: 1px solid var(--border-primary); border-radius: 14px; padding: 22px; display: flex; flex-direction: column; gap: 8px; }
.mw-flow-card h3 { font-size: 17px; margin: 0; }
.mw-flow-card p { margin: 0; font-size: 15px; color: var(--text-secondary); }
.mw-status {
    margin-top: 40px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
    padding: 24px; border: 1px solid var(--border-accent); border-radius: 16px; background: var(--bg-card);
}
.mw-status-code {
    font-family: var(--font-mono); font-size: 32px; padding: 10px 18px; border-radius: 12px; min-width: 110px; text-align: center;
    border: 1px solid var(--border-primary); color: var(--text-primary); transition: background-color .6s ease, color .6s ease;
}
.mw-status-code.active { background: color-mix(in srgb, #ef4444 22%, transparent); border-color: #ef4444; color: var(--text-primary); }
.mw-status-code.history { background: color-mix(in srgb, var(--accent-secondary) 20%, transparent); border-color: var(--accent-secondary); }
.mw-status-arrow { font-family: var(--font-mono); color: var(--text-tertiary); font-size: 14px; }
.mw-status-note { font-size: 15px; color: var(--text-secondary); flex: 1; min-width: 220px; margin: 0; }

/* Report flow */
.mw-report { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }

/* Challenges */
.mw-challenges { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mw-challenge { border-top: 3px solid var(--accent-primary); }

/* Closing */
.mw-close { padding: 120px 0; border-top: 1px solid var(--border-primary); text-align: left; }
.mw-close h2 { font-size: clamp(44px, 7vw, 84px); margin: 0 0 16px; letter-spacing: -0.03em; }
.mw-close p { font-size: 19px; color: var(--text-tertiary); margin: 0 0 32px; }

/* Buttons + links (reuse editorial look, scoped to this page) */
.mw-btn {
    display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 600; font-size: 15px;
    padding: 12px 22px; border-radius: 999px; border: 1px solid var(--accent-primary);
    background: var(--accent-primary); color: #0b0d10;
}
[data-theme="light"] .mw-btn { color: #ffffff; }
.mw-btn.ghost { background: transparent; color: var(--text-primary); border-color: var(--border-accent); }
.mw-btn:hover { filter: brightness(1.08); }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
    .mw-grid, .mw-challenges { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .mw-flow, .mw-report { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .mw-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .mw-chapter { padding: 80px 0; }
    .mw-hero { padding: 96px 0 64px; }
    .mw-grid, .mw-challenges, .mw-files, .mw-hw, .mw-ordered, .mw-steps, .mw-flow, .mw-report { grid-template-columns: 1fr; }
    .mw-chapters { max-width: 100%; }
    .mw-top-inner { flex-wrap: wrap; }
    .mw-chapter-head { margin-bottom: 32px; }
    .mw-sub { font-size: 17px; }
}

/* ---------- Reduced motion: show everything at once ---------- */
@media (prefers-reduced-motion: reduce) {
    html.js .reveal { opacity: 1; transform: none; transition: none; }
    .mw-title .word { opacity: 1; transform: none; animation: none; }
    .mw-hero::before, .mw-scroll-hint::after { animation: none; }
    .mw-bench .wire { stroke-dashoffset: 0; animation: none !important; }
    .mw-bench .pulse { display: none; }
    .mw-timeline::before { transform: none; transition: none; }
}
