/* Data widgets + /pulse/ + /security/ pages.
   Loaded AFTER ../styles.css, so it reuses the homepage tokens (--bg, --yellow, --paper, --display ...),
   .site-nav, .sec-h, .kicker, .fact tiles and .site-footer. Only data-specific rules live here. */

.dw-page { padding: clamp(40px, 6vw, 88px) var(--pad) clamp(64px, 8vw, 120px); }
.dw-page .kicker { margin-bottom: 18px; font-family: var(--body); font-size: 1rem; font-weight: 700; letter-spacing: 0; text-transform: none; color: var(--yellow); }
.dw-title { font-size: clamp(3.25rem, 2rem + 6.5vw, 8rem); max-width: 14ch; }
.dw-lede { font-size: var(--t-lede); line-height: 1.25; font-stretch: 85%; font-weight: 700; max-width: 34ch; margin-top: 28px; }
.dw-note { color: var(--muted); max-width: 66ch; font-size: 1rem; line-height: 1.6; margin-top: 14px; }
.dw-note strong, .dw-copy strong { color: var(--ink); }
.dw-copy { max-width: 66ch; margin-top: 14px; color: var(--ink-soft); }
.dw-h2 {
    font-family: var(--display); font-stretch: 62%; font-weight: 900; text-transform: uppercase;
    font-size: clamp(2.25rem, 1.5rem + 3vw, 4.5rem); line-height: .86; letter-spacing: -.01em;
    margin: clamp(48px, 6vw, 96px) 0 24px;
}
.dw-status {
    margin: 28px 0 0; padding: 14px 20px; border-radius: var(--r-md); max-width: 70ch;
    background: var(--mint); color: var(--on-light); font-weight: 700;
}
.dw-status.is-warn { background: var(--orange); }
.dw-status.is-err { background: var(--red); color: var(--ink); }
.dw-status a { color: inherit; }
[hidden] { display: none !important; }

/* Story-style tiles */
.dw-cards { display: grid; gap: clamp(12px, 1.5vw, 20px); grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); margin-top: 32px; }
.dw-card {
    display: flex; flex-direction: column; gap: 14px; min-width: 0;
    padding: 24px; border-radius: var(--r-lg);
    background: var(--surface); color: var(--ink);
}
.dw-card h3 { font-weight: 800; font-size: 1.25rem; line-height: 1.2; overflow-wrap: anywhere; font-stretch: 90%; }
.dw-card p { font-size: 1.0625rem; line-height: 1.45; overflow-wrap: anywhere; }
.dw-card a { font-weight: 700; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 5px; transition: text-underline-offset .25s var(--ease); }
.dw-card a:hover { text-underline-offset: 9px; }
.dw-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; font-size: .9375rem; color: var(--muted); margin-top: auto; }
.dw-card:has(.dw-meta) > p + .dw-meta { margin-top: auto; }
.dw-cve .id { font-family: var(--display); font-stretch: 62%; font-weight: 900; font-size: 2.25rem; line-height: .9; color: var(--ink); letter-spacing: .01em; }
.dw-badge {
    display: inline-block; padding: 4px 12px; border-radius: 999px;
    font-weight: 800; font-size: .875rem; background: var(--red); color: var(--ink); font-variant-numeric: tabular-nums;
}
.dw-badge.is-high { background: var(--orange); color: var(--on-light); }

/* Stat tiles reuse .fact / .fact-num / .fact-say */
.dw-stats { display: grid; gap: clamp(12px, 1.5vw, 20px); grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); margin-top: 40px; }
.dw-stats .fact { min-height: 220px; }
.dw-stats .fact:hover { transform: none; }

/* Table */
.dw-tablewrap { overflow-x: auto; border-radius: var(--r-md); background: var(--surface); }
.dw-tablewrap table { border-collapse: collapse; width: 100%; }
@media (max-width: 600px) { .dw-tablewrap th, .dw-tablewrap td { padding: 12px 10px; font-size: .9375rem; } }
.dw-tablewrap table { }
.dw-tablewrap caption { text-align: left; caption-side: bottom; padding: 14px 20px; color: var(--muted); font-size: .875rem; }
.dw-tablewrap th, .dw-tablewrap td { text-align: left; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.dw-tablewrap th { font-size: .875rem; font-weight: 700; color: var(--muted); }
.dw-tablewrap td { font-weight: 600; }
.dw-tablewrap td.n { font-variant-numeric: tabular-nums; }
.dw-vis { display: inline-block; padding: 4px 12px; border-radius: 999px; font-weight: 800; font-size: .875rem; }
.dw-vis.on { background: var(--mint); color: var(--on-light); }
.dw-vis.off { background: var(--red); color: var(--ink); }

/* Chart */
.dw-chart { background: var(--surface); border-radius: var(--r-md); padding: clamp(14px, 2vw, 28px); }
.dw-chart svg { display: block; width: 100%; height: auto; }
.dw-chart .grid { stroke: var(--line); stroke-width: 1; }
.dw-chart .line { fill: none; stroke: var(--yellow); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.dw-chart .area { fill: rgba(255, 214, 10, .1); }
.dw-chart text { fill: var(--muted); font: 600 11px var(--body); }

/* Timeline */
.dw-time { max-width: 70ch; border-left: 4px solid var(--yellow); margin-left: 6px; }
.dw-time li { position: relative; padding: 0 0 32px 28px; }
.dw-time li::before { content: ""; position: absolute; left: -12px; top: 4px; width: 20px; height: 20px; border-radius: 50%; background: var(--bg); border: 4px solid var(--yellow); }
.dw-time time { font-size: 1rem; font-weight: 700; color: var(--yellow); }
.dw-time h3 { font-family: var(--display); font-stretch: 75%; font-weight: 800; font-size: 1.75rem; line-height: 1.05; margin: 6px 0 8px; }
.dw-time p { color: var(--ink-soft); margin-bottom: 8px; }
.dw-time a { font-weight: 700; text-underline-offset: 5px; text-decoration-thickness: 2px; }

/* Homepage widgets */
.dw-hn { padding: clamp(32px, 4vw, 56px) var(--pad) clamp(48px, 6vw, 96px); }
.dw-hn .dw-h { font-family: var(--display); font-stretch: 62%; font-weight: 900; text-transform: uppercase; font-size: clamp(2.5rem, 1.6rem + 4vw, 5.5rem); line-height: .86; }
.dw-hn .dw-card { background: var(--paper); color: var(--on-light); }
.dw-hn .dw-card .dw-meta { color: #4a4a4a; }
.dw-hn .score { font-weight: 800; color: var(--on-light); background: var(--orange); border-radius: 999px; padding: 2px 10px; }
.dw-hn .dw-note { color: #a6a6a6; }
.dw-hn .dw-cards { margin-top: 24px; }
.dw-hn .dw-cards li:nth-child(n+7) { display: none; }
.dw-hn .dw-card { padding: 18px; gap: 10px; }
.dw-hn .dw-card h3 { font-size: 1.125rem; }
.dw-now { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; padding: 12px var(--pad); background: var(--yellow); color: var(--on-light); font-weight: 700; }
.dw-now .tag { font-family: var(--display); font-stretch: 62%; font-weight: 900; text-transform: uppercase; font-size: 1.25rem; letter-spacing: .02em; }
.dw-now .when { font-weight: 500; font-size: .875rem; opacity: .7; }

@media (prefers-reduced-motion: reduce) { .dw-card a, .dw-card { transition: none; } }

/* ===== v4 polish: motion, states, hierarchy (transform/opacity only; reduced-motion safe) ===== */
.dw-polish .dw-page { max-width: 1500px; margin: 0 auto; }
.dw-page .kicker { display: inline-flex; align-items: center; gap: 10px; }
.dw-page .kicker::before { /* live dot */
    content: ""; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--mint);
    box-shadow: 0 0 0 0 rgba(111, 242, 200, .6); animation: dw-live 2s var(--ease) infinite;
}
@keyframes dw-live { 70%, 100% { box-shadow: 0 0 0 10px rgba(111, 242, 200, 0); } }
.dw-title { animation: dw-rise .7s var(--ease) backwards; }
.dw-lede { animation: dw-rise .7s var(--ease) .08s backwards; }
.dw-polish .dw-h2 { padding-top: 14px; border-top: 1px solid var(--line); }
@keyframes dw-rise { from { opacity: 0; transform: translateY(18px); } }

/* staggered entry: cards, tiles, outage rows, table rows */
.dw-card, .dw-stats .fact, .dw-time li, .dw-tablewrap tbody tr { animation: dw-rise .55s var(--ease) backwards; }
.dw-cards > :nth-child(2), .dw-stats > :nth-child(2), .dw-time > :nth-child(2), tbody tr:nth-child(2) { animation-delay: 60ms; }
.dw-cards > :nth-child(3), .dw-stats > :nth-child(3), .dw-time > :nth-child(3), tbody tr:nth-child(3) { animation-delay: 120ms; }
.dw-cards > :nth-child(4), .dw-time > :nth-child(4), tbody tr:nth-child(4) { animation-delay: 180ms; }
.dw-cards > :nth-child(5), .dw-time > :nth-child(5), tbody tr:nth-child(5) { animation-delay: 240ms; }
.dw-cards > :nth-child(n+6), .dw-time > :nth-child(n+6) { animation-delay: 300ms; }

/* hover and focus states */
.dw-polish .dw-card { border: 1px solid transparent; transition: transform .35s var(--ease), border-color .25s, background-color .25s; }
.dw-polish .dw-card:hover { transform: translateY(-4px); border-color: var(--yellow); background: var(--surface-2); }
.dw-card:focus-within { border-color: var(--yellow); }
.dw-polish .dw-card a { min-height: 44px; display: inline-flex; align-items: center; align-self: flex-start; }
.dw-cve.is-crit { border-left: 4px solid var(--red); }
.dw-tablewrap tbody tr { transition: background-color .2s; }
.dw-tablewrap tbody tr:hover { background: var(--surface-2); }
.dw-tablewrap tbody tr:last-child td { border-bottom: 0; }
.dw-tablewrap td.dw-vis, .dw-tablewrap td:last-child { white-space: nowrap; }
.dw-time li { transition: transform .3s var(--ease); }
.dw-time li:hover { transform: translateX(4px); }
.dw-time li::before { transition: background-color .25s; }
.dw-time li:hover::before { background: var(--yellow); }
.dw-stats .fact-num { font-variant-numeric: tabular-nums; }

/* chart: line draws in, area fades after */
.dw-chart .dot-end { fill: var(--yellow); }
.dw-chart.is-drawn .line { stroke-dasharray: 1; stroke-dashoffset: 0; animation: dw-draw 1.4s cubic-bezier(.3, .6, .2, 1) backwards; }
.dw-chart.is-drawn .area { animation: dw-fade .9s ease-out .7s backwards; }
@keyframes dw-draw { from { stroke-dashoffset: 1; } }
@keyframes dw-fade { from { opacity: 0; } }

/* skeletons (inserted by motion.js while data is pending) */
.dw-skel { display: grid; gap: clamp(12px, 1.5vw, 20px); grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); margin-top: 32px; }
.dw-skel-cards { grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.dw-skel-block {
    min-height: 168px; border-radius: var(--r-lg); background: var(--surface);
    position: relative; overflow: hidden;
}
.dw-skel-tile { min-height: 220px; }
.dw-skel-wide { grid-column: 1 / -1; min-height: 260px; border-radius: var(--r-md); }
.dw-skel-block::after {
    content: ""; position: absolute; inset: 0; transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .06), transparent);
    animation: dw-shimmer 1.6s ease-in-out infinite;
}
@keyframes dw-shimmer { to { transform: translateX(100%); } }

/* status banners */
.dw-status { animation: dw-rise .4s var(--ease) backwards; }


/* homepage widgets */

@media (max-width: 600px) { .dw-stats .fact { min-height: 150px; } .dw-title { max-width: none; } }
@media (prefers-reduced-motion: reduce) {
    .dw-title, .dw-lede, .dw-card, .dw-stats .fact, .dw-time li, .dw-tablewrap tbody tr, .dw-status,
    .dw-page .kicker::before, .dw-skel-block::after, .dw-chart.is-drawn .line, .dw-chart.is-drawn .area { animation: none; }
    .dw-polish .dw-card:hover, .dw-time li:hover { transform: none; }
}

/* visibility cell: text + dot instead of a pill that broke the row rhythm */
.dw-polish .dw-tablewrap td.dw-vis { display: table-cell; background: none; border-radius: 0; padding: 16px 20px; font-size: .9375rem; }
.dw-polish .dw-tablewrap td.dw-vis::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 10px; background: currentColor; }
.dw-polish .dw-tablewrap td.dw-vis.on { color: var(--mint); }
.dw-polish .dw-tablewrap td.dw-vis.off { color: #ff7b80; }

/* ===== CVE detail view (security) ===== */
.dw-cve { position: relative; }
.dw-cve .id a.dw-cardlink { font-weight: inherit; text-decoration: none; min-height: 0; display: inline; color: inherit; }
.dw-cve .id a.dw-cardlink::after { content: ""; position: absolute; inset: 0; border-radius: var(--r-lg); }
.dw-cve .id a.dw-cardlink:focus-visible { outline: none; }
.dw-cve:has(a.dw-cardlink:focus-visible) { outline: 3px solid var(--yellow); outline-offset: 3px; }
.dw-more { margin-left: auto; font-weight: 700; color: var(--yellow); }
.dw-detail { max-width: 78ch; margin-top: 8px; }
.dw-detail.is-in { animation: dw-detail-in .4s var(--ease) both; }
@keyframes dw-detail-in { from { opacity: 0; transform: translateY(14px); } }
.dw-back, .dw-nav-link { color: var(--ink); font-weight: 700; text-decoration: none; }
.dw-back { display: inline-flex; align-items: center; min-height: 44px; padding-right: 12px; border-bottom: 2px solid var(--yellow); margin-bottom: clamp(20px, 3vw, 36px); }
.dw-back:hover { color: var(--yellow); }
.dw-detail-kicker { font-weight: 700; color: var(--yellow); margin-bottom: 10px; }
.dw-detail-h {
    font-family: var(--display); font-stretch: 62%; font-weight: 900; text-transform: uppercase;
    font-size: clamp(3rem, 1.5rem + 7vw, 7rem); line-height: .88; letter-spacing: .005em; overflow-wrap: anywhere;
}
.dw-detail-h:focus { outline: none; }
.dw-detail-h:focus-visible { outline: 3px solid var(--yellow); outline-offset: 6px; }
.dw-detail-meta { margin-top: 22px; gap: 10px 18px; }
.dw-detail-sum { font-size: clamp(1.125rem, 1.05rem + .4vw, 1.375rem); line-height: 1.55; margin-top: 28px; overflow-wrap: anywhere; color: var(--ink); }
.dw-detail-note { margin-top: 28px; }
.dw-detail-nav { display: flex; flex-wrap: wrap; gap: 12px; margin-top: clamp(32px, 5vw, 56px); padding-top: 20px; border-top: 1px solid var(--line); }
.dw-nav-link { flex: 1 1 150px; min-width: 0; display: flex; flex-direction: column; gap: 4px; padding: 16px 20px; border-radius: var(--r-md); background: var(--surface); border: 1px solid transparent; transition: transform .3s var(--ease), border-color .25s; }
.dw-nav-link:hover, .dw-nav-link:focus-visible { border-color: var(--yellow); transform: translateY(-2px); }
.dw-nav-link.is-next { text-align: right; }
.dw-nav-dir { font-size: .875rem; color: var(--muted); }
.dw-nav-id { font-family: var(--display); font-stretch: 62%; font-weight: 900; font-size: 1.5rem; overflow-wrap: anywhere; }
@media (max-width: 480px) { .dw-nav-link.is-next { text-align: left; } }
@media (prefers-reduced-motion: reduce) {
    .dw-detail.is-in { animation: none; }
    .dw-nav-link:hover, .dw-nav-link:focus-visible { transform: none; }
}
