/* ==========================================================================
   Straiker product design system — vanilla CSS build for Doppelganger.
   Tokens: tokens.css (verbatim from tooling/tailwind-config/styles.css).
   Primitives below mirror @straiker/ui anatomy (Button, Badge, Card, Tabs,
   Input, Switch, Tooltip, Toast, CornerArrow, Separator, Bolt, noise).
   Square corners. Color only for severity/status/CTA. Inter body, Pressio
   display (ALL CAPS, large), VT323 accent (ALL CAPS, never small).
   ========================================================================== */

@font-face { font-family: 'Inter';   src: url(fonts/inter.woff2)   format('woff2'); font-display: swap; }
@font-face { font-family: 'Pressio'; src: url(fonts/pressio.woff2) format('woff2'); font-style: normal; font-display: swap; }
@font-face { font-family: 'VT323';   src: url(fonts/vt323.woff2)   format('woff2'); font-display: swap; }

:root {
  --font-body: 'Inter', sans-serif;
  --font-display: 'Pressio', sans-serif;
  --font-accent: 'VT323', monospace;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  --text-tiny: 0.6875rem;
  --spacing-page: 2rem; --spacing-card: 1.5rem; --spacing-gap: 1rem;
  --shadow-card: 0 0 30px var(--box-shadow, rgba(0,0,0,.35));
  --footer-height: 24px;
}
html.dark { color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; border-radius: 0; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--background); color: var(--foreground);
  font-family: var(--font-body); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; font-synthesis: none; text-rendering: optimizeLegibility;
}
::selection { background: var(--ring); color: var(--primary); }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
code, pre, .mono { font-family: var(--font-mono); }
.hidden { display: none !important; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }

/* display / accent type — the system's global rules */
.font-display { font-family: var(--font-display); text-transform: uppercase; letter-spacing: .025em; font-weight: 600; }
.font-accent  { font-family: var(--font-accent);  text-transform: uppercase; }
.text-secondary { color: var(--secondary-foreground); }
.text-tiny { font-size: var(--text-tiny); }
.tabular { font-variant-numeric: tabular-nums; }

/* icons — sprite <use> */
.i { width: 1em; height: 1em; display: inline-block; vertical-align: -0.125em; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.i-4 { width: 16px; height: 16px; } .i-5 { width: 20px; height: 20px; } .i-6 { width: 24px; height: 24px; } .i-10 { width: 40px; height: 40px; }
.i.straiker { stroke: currentColor; }  /* straiker glyphs carry explicit fill/stroke attrs */
@keyframes ds-spin { to { transform: rotate(360deg); } }
.spin { animation: ds-spin 1s linear infinite; }

/* --------------------------------------------------------------- Button */
.ds-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  height: 2.25rem; padding: 0 1rem; font-size: .875rem; font-weight: 500; white-space: nowrap;
  border: 1px solid transparent; background: var(--primary); color: var(--primary-foreground);
  cursor: pointer; text-decoration: none; position: relative; transition: background .15s, color .15s, border-color .15s, opacity .15s;
}
.ds-btn:hover { background: color-mix(in hsl, var(--primary) 88%, black); }
.ds-btn:disabled, .ds-btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.ds-btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.ds-btn.secondary { background: var(--secondary); color: var(--foreground); border-color: var(--border); }
.ds-btn.secondary:hover { background: color-mix(in hsl, var(--secondary) 70%, var(--foreground) 8%); }
.ds-btn.ghost { background: transparent; color: var(--secondary-foreground); }
.ds-btn.ghost:hover { background: var(--secondary); color: var(--foreground); }
.ds-btn.ghost.active { background: color-mix(in hsl, var(--secondary) 80%, transparent); color: var(--foreground); }
.ds-btn.link { background: none; color: var(--foreground); text-decoration: underline; padding: 0; height: auto; }
.ds-btn.destructive { background: var(--destructive); color: var(--destructive-foreground); }
.ds-btn.destructive-outline { background: transparent; color: var(--destructive-foreground); border-color: var(--destructive-foreground); }
.ds-btn.sm { height: 2rem; padding: 0 .75rem; font-size: .8125rem; }
.ds-btn.xs { height: 1.75rem; padding: 0 .5rem; font-size: .75rem; }
.ds-btn.lg { height: 2.5rem; padding: 0 1.25rem; }
.ds-btn.icon { width: 2.25rem; padding: 0; } .ds-btn.icon-sm { width: 2rem; height: 2rem; padding: 0; } .ds-btn.icon-xs { width: 1.75rem; height: 1.75rem; padding: 0; }
/* default-variant corner-border hover treatment */
.ds-btn:not(.ghost):not(.link):not(.secondary)::before, .ds-btn:not(.ghost):not(.link):not(.secondary)::after {
  content: ''; position: absolute; width: 6px; height: 6px; border: 2px solid var(--primary-foreground); opacity: 0; transition: opacity .15s;
}
.ds-btn:not(.ghost):not(.link):not(.secondary)::before { top: 2px; left: 2px; border-right: 0; border-bottom: 0; }
.ds-btn:not(.ghost):not(.link):not(.secondary)::after  { bottom: 2px; right: 2px; border-left: 0; border-top: 0; }
.ds-btn:not(.ghost):not(.link):not(.secondary):hover::before, .ds-btn:not(.ghost):not(.link):not(.secondary):hover::after { opacity: .6; }

/* --------------------------------------------------------------- Badge */
.ds-badge {
  display: inline-flex; align-items: center; gap: .375rem; height: 1.375rem; padding: 0 .5rem;
  font-size: .75rem; font-weight: 500; line-height: 1; white-space: nowrap;
  border: 1px solid var(--border); background: var(--background-tier-2); color: var(--foreground);
}
.ds-badge.outline { background: transparent; }
.ds-badge.secondary { background: var(--secondary); color: var(--secondary-foreground); border-color: transparent; }
.ds-badge.success { background: var(--success); color: var(--success-foreground); border-color: color-mix(in hsl, var(--success-foreground) 40%, transparent); }
.ds-badge.warn    { background: var(--warn);    color: var(--warn-foreground);    border-color: color-mix(in hsl, var(--warn-foreground) 40%, transparent); }
.ds-badge.fail    { background: var(--fail);    color: var(--fail-foreground);    border-color: color-mix(in hsl, var(--fail-foreground) 40%, transparent); }
.ds-badge.info    { background: var(--severity-info); color: var(--severity-info-foreground); border-color: color-mix(in hsl, var(--severity-info-foreground) 40%, transparent); }
.ds-badge code { font-size: inherit; }
.ds-badge-group { display: inline-flex; } .ds-badge-group .ds-badge + .ds-badge { margin-left: -1px; }
.ds-badge.clickable { cursor: pointer; } .ds-badge.clickable:hover { border-color: var(--foreground); }

/* --------------------------------------------------------------- Card */
.ds-card { border: 1px solid var(--border); background: var(--background-tier-1); box-shadow: var(--shadow-card); }
.ds-card.t2 { background: var(--background-tier-2); } .ds-card.t3 { background: var(--background-tier-3); }
.ds-card.ghost { border-color: transparent; box-shadow: none; background: transparent; }
.ds-card-header { padding: 1rem 1.25rem .5rem; } .ds-card-content { padding: 1.25rem; } .ds-card-footer { padding: .5rem 1.25rem 1rem; }
.ds-card-title { font-weight: 600; font-size: .9375rem; margin: 0; }
.ds-card-desc { color: var(--secondary-foreground); font-size: .8125rem; margin: .25rem 0 0; }
.ds-card-status { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .5rem .75rem; font-size: .75rem; font-weight: 700; background: var(--card-status); position: relative; }
/* decoration=incident: severity border fading toward bottom-right + top-left triangle */
.ds-card.incident { position: relative; }
.ds-card.incident::before { content: ''; position: absolute; inset: 0; pointer-events: none; border: 1px solid var(--destructive-foreground);
  -webkit-mask-image: linear-gradient(to right, black 50%, transparent 90%), linear-gradient(to bottom, black 50%, transparent 90%); mask-image: linear-gradient(to right, black 50%, transparent 90%), linear-gradient(to bottom, black 50%, transparent 90%); -webkit-mask-composite: source-in; mask-composite: intersect; }
.ds-card.incident::after { content: ''; position: absolute; top: 4px; left: 4px; width: 12px; height: 12px; background: var(--destructive-foreground); clip-path: polygon(0 0, 100% 0, 0 100%); pointer-events: none; }

/* --------------------------------------------------------------- Tabs */
.ds-tabs-list { display: inline-flex; gap: 2px; padding: 0; border-bottom: 1px solid var(--border); width: 100%; }
.ds-tab { background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: .5rem .875rem; font-size: .8125rem; font-weight: 500; color: var(--secondary-foreground); cursor: pointer; }
.ds-tab:hover { color: var(--foreground); }
.ds-tab[aria-selected="true"] { color: var(--foreground); border-bottom-color: var(--foreground); }
.ds-tab:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }

/* --------------------------------------------------------------- Forms */
.ds-field { display: flex; flex-direction: column; gap: .375rem; }
.ds-label { font-size: .8125rem; font-weight: 500; color: var(--foreground); }
.ds-desc  { font-size: .75rem; color: var(--secondary-foreground); }
.ds-input, .ds-select, .ds-textarea {
  width: 100%; min-height: 2.25rem; padding: .5rem .75rem; font-size: .875rem;
  background: var(--input); color: var(--foreground); border: 1px solid var(--border); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.ds-textarea { resize: vertical; line-height: 1.5; }
.ds-input:focus, .ds-select:focus, .ds-textarea:focus { border-color: var(--ring); box-shadow: 0 0 0 2px color-mix(in hsl, var(--ring) 35%, transparent); }
.ds-input::placeholder, .ds-textarea::placeholder { color: var(--secondary-foreground); }
.ds-select { appearance: none; -webkit-appearance: none; padding-right: 2rem;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23858585' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right .5rem center; }
.ds-select option, .ds-select optgroup { background: var(--popover); color: var(--foreground); }
/* Switch */
.ds-switch { position: relative; display: inline-flex; width: 2.25rem; height: 1.25rem; flex-shrink: 0; cursor: pointer; }
.ds-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.ds-switch .track { position: absolute; inset: 0; background: var(--input); border: 1px solid var(--border); transition: background .15s, border-color .15s; }
.ds-switch .track::after { content: ''; position: absolute; top: 2px; left: 2px; width: calc(1.25rem - 6px); height: calc(1.25rem - 6px); background: var(--secondary-foreground); transition: transform .15s, background .15s; }
.ds-switch input:checked + .track { background: var(--primary); border-color: var(--primary); }
.ds-switch input:checked + .track::after { transform: translateX(1rem); background: var(--primary-foreground); }
.ds-switch input:focus-visible + .track { outline: 2px solid var(--ring); outline-offset: 2px; }
/* Collapsible/details */
.ds-details { border: 1px solid var(--border); background: var(--background-tier-1); }
.ds-details > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .5rem; padding: .625rem .875rem; font-size: .8125rem; font-weight: 500; color: var(--secondary-foreground); }
.ds-details > summary::-webkit-details-marker { display: none; }
.ds-details > summary:hover { color: var(--foreground); }
.ds-details > summary .chev { transition: transform .15s; } .ds-details[open] > summary .chev { transform: rotate(90deg); }
.ds-details > *:not(summary) { padding: 0 .875rem .875rem; }
.ds-details[open] > summary { border-bottom: 1px solid var(--border); margin-bottom: .75rem; }

/* --------------------------------------------------------------- Overlays */
.ds-overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.ds-dialog { background: var(--popover); border: 1px solid var(--border); box-shadow: var(--shadow-card); width: 100%; max-width: 640px; max-height: calc(100vh - 3rem); display: flex; flex-direction: column; }
.ds-dialog.lg { max-width: 820px; }
.ds-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.25rem 1.25rem .75rem; }
.ds-dialog-title { font-size: 1.0625rem; font-weight: 600; margin: 0; display: flex; align-items: center; gap: .5rem; }
.ds-dialog-desc { color: var(--secondary-foreground); font-size: .8125rem; margin: .25rem 0 0; }
.ds-dialog-body { padding: 0 1.25rem 1.25rem; overflow-y: auto; display: flex; flex-direction: column; gap: 1rem; }
.ds-dialog-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .75rem 1.25rem 1.25rem; border-top: 1px solid var(--border); }
/* Sheet (right) with the sheet-cut notch */
.ds-sheet-overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 60; }
.ds-sheet { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--sheet); border-left: 1px solid var(--border); z-index: 61; display: flex; flex-direction: column;
  padding-left: 4rem; --cut-width: 40px; clip-path: polygon(0 0, 0 40px, var(--cut-width) 60px, var(--cut-width) 200px, 0 220px, 0 100%, 100% 100%, 100% 0); }
.ds-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: 1.25rem 1.25rem .75rem 0; }
.ds-sheet-body { flex: 1; overflow-y: auto; padding: 0 1.25rem 1.25rem 0; display: flex; flex-direction: column; gap: .75rem; }
/* Tooltip (CSS-only via data-tip) */
[data-tip] { position: relative; }
[data-tip]::after { content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%); white-space: nowrap;
  background: var(--popover); color: var(--foreground); border: 1px solid var(--border); padding: .25rem .5rem; font-size: .75rem; font-weight: 400; pointer-events: none; opacity: 0; transition: opacity .12s; z-index: 70; }
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; }
/* Toast */
.ds-toaster { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 80; }
.ds-toast { display: flex; align-items: center; gap: .625rem; min-width: 260px; max-width: 420px; padding: .75rem 1rem; background: var(--popover); border: 1px solid var(--border); box-shadow: var(--shadow-card); font-size: .8125rem; animation: ds-toast-in .18s ease-out; }
.ds-toast.success { border-left: 3px solid var(--success-foreground); } .ds-toast.error { border-left: 3px solid var(--fail-foreground); } .ds-toast.warning { border-left: 3px solid var(--warn-foreground); }
@keyframes ds-toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* --------------------------------------------------------------- Chrome */
.ds-sep { height: 1px; width: 100%; background: var(--border); flex: 0 0 auto; position: relative; }
.ds-sep.vertical { width: 1px; height: 100%; }
.ds-corner { position: absolute; width: 12px; height: 12px; pointer-events: none; border: 0 solid var(--primary); }
.ds-corner.tl { top: -1px; left: -1px; border-top-width: 3px; border-left-width: 3px; }
.ds-corner.tr { top: -1px; right: -1px; border-top-width: 3px; border-right-width: 3px; }
.ds-corner.bl { bottom: -1px; left: -1px; border-bottom-width: 3px; border-left-width: 3px; }
.ds-corner.br { bottom: -1px; right: -1px; border-bottom-width: 3px; border-right-width: 3px; }
.ds-corner.glow { filter: drop-shadow(0 0 10px var(--primary)); }
.noise { -webkit-mask-image: url(noise.svg); mask-image: url(noise.svg); -webkit-mask-size: cover; mask-size: cover; }
.ds-grain { position: fixed; inset: 0; z-index: 50; pointer-events: none; background: var(--noise); mix-blend-mode: multiply; }
html.dark .ds-grain { mix-blend-mode: lighten; }
@keyframes flicker { 90%{opacity:1} 10%{opacity:.2} 20%{opacity:1} 30%{opacity:.5} 40%{opacity:1} 50%{opacity:.3} 60%{opacity:1} 0%,100%{opacity:1} }
@keyframes flicker-intermittent { 90%{opacity:1} 90.5%{opacity:.2} 91%{opacity:1} 91.5%{opacity:.5} 92%{opacity:1} 92.5%{opacity:.3} 93%{opacity:1} 0%,100%{opacity:1} }
.animate-flicker { animation: flicker .3s linear 2; }
.animate-flicker-intermittent { animation: flicker-intermittent 10s linear infinite; }
@media (prefers-reduced-motion: reduce) { .animate-flicker, .animate-flicker-intermittent, .spin, .ds-toast { animation: none !important; } }

/* Bolt loading glyph — stroke animates along the brand gradient */
.ds-bolt { height: 40px; width: auto; filter: drop-shadow(0 2px 2px rgba(0,0,0,.3)); }
.ds-bolt.loading path { fill: none; stroke: url(#ds-bolt-grad); stroke-width: 1.5; stroke-dasharray: 100; animation: ds-bolt-dash 1.5s linear infinite; }
@keyframes ds-bolt-dash { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }

/* striped meter track (Meter/ScoreBar idiom) */
.ds-meter { height: .5rem; background-image: repeating-linear-gradient(90deg, var(--secondary-foreground) 0, var(--secondary-foreground) 2px, transparent 0, transparent 50%); background-size: 10px 10px; position: relative; }
.ds-meter > i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--primary); box-shadow: 0 0 10px 0 var(--primary); }
