/* Soft-factory Dashboard - bespoke styles
 *
 * Tailwind v4 (play CDN) handles utilities. This file is reserved for the
 * small number of things that don't fit Tailwind cleanly: scrollbars,
 * theme-aware tokens, and one-off focus styles.
 */

:root {
  color-scheme: dark;
}

html {
  scrollbar-color: #3f3f46 #09090b;
  scrollbar-width: thin;
}

html::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
html::-webkit-scrollbar-track {
  background: #09090b;
}
html::-webkit-scrollbar-thumb {
  background: #27272a;
  border-radius: 6px;
}
html::-webkit-scrollbar-thumb:hover {
  background: #3f3f46;
}

/* Light-mode overrides when user toggles the theme. */
html:not(.dark) {
  color-scheme: light;
}
html:not(.dark) body {
  background: #fafafa;
  color: #18181b;
}
html:not(.dark) .border-zinc-800 {
  border-color: #e4e4e7;
}
html:not(.dark) .border-zinc-900 {
  border-color: #f4f4f5;
}
html:not(.dark) .bg-zinc-950 {
  background: #ffffff;
}
html:not(.dark) .bg-zinc-950\/80 {
  background: rgba(255, 255, 255, 0.85);
}
html:not(.dark) .bg-zinc-950\/40 {
  background: rgba(250, 250, 250, 0.6);
}
html:not(.dark) .bg-zinc-900\/40 {
  background: rgba(244, 244, 245, 0.7);
}
html:not(.dark) .bg-zinc-900\/60 {
  background: rgba(244, 244, 245, 0.85);
}
html:not(.dark) .text-zinc-50 {
  color: #18181b;
}
html:not(.dark) .text-zinc-100 {
  color: #18181b;
}
html:not(.dark) .text-zinc-200 {
  color: #27272a;
}
html:not(.dark) .text-zinc-300 {
  color: #3f3f46;
}
html:not(.dark) .text-zinc-400 {
  color: #52525b;
}
html:not(.dark) .text-zinc-500 {
  color: #71717a;
}
html:not(.dark) .text-zinc-600 {
  color: #71717a;
}
html:not(.dark) .hover\:bg-zinc-900:hover {
  background: #f4f4f5;
}

/* Smooth focus ring across both themes. */
:focus-visible {
  outline: 2px solid rgba(245, 158, 11, 0.45);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Subtle entrance for the dashboard cards. Respect reduced motion. */
@media (prefers-reduced-motion: no-preference) {
  main section,
  main article {
    animation: fadeUp 0.35s ease-out both;
  }
  main section:nth-child(2) { animation-delay: 0.04s; }
  main section:nth-child(3) { animation-delay: 0.08s; }
  main section:nth-child(4) { animation-delay: 0.12s; }
  main section:nth-child(5) { animation-delay: 0.16s; }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* JSON properties cell on project detail. */
.props-cell {
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 11.5px;
  color: #a1a1aa;
  max-width: 320px;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ─────────────────────────────────────────────────────────────────────
 * Project detail page v2 — editorial-telematic aesthetic
 * (used by `/projects/:id` and `/projects/:id/admin/*`)
 * ───────────────────────────────────────────────────────────────────── */

/* Hero shell — deep zinc panel with subtle column grid background */
.hero-shell {
  position: relative;
}
.hero-grid {
  background-image:
    linear-gradient(to right, rgba(245, 158, 11, 0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(245, 158, 11, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at top, black 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at top, black 30%, transparent 75%);
}

/* Noise overlay via SVG data-uri (extremely faint, editorial feel) */
.noise {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.55 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/></svg>");
  opacity: 0.04;
  pointer-events: none;
}

/* KPI cell — oversized editorial numbers */
.kpi-cell {
  position: relative;
  border-radius: 0.75rem;
  background: linear-gradient(180deg, rgba(39, 39, 42, 0.6) 0%, rgba(24, 24, 27, 0.6) 100%);
  border: 1px solid #27272a;
  padding: 1.25rem 1rem;
  overflow: hidden;
  transition: border-color 200ms ease, transform 200ms ease;
}
.kpi-cell::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 2px;
  background: currentColor;
}
.kpi-cell[data-tone="amber"]   { color: #fbbf24; }
.kpi-cell[data-tone="sky"]     { color: #38bdf8; }
.kpi-cell[data-tone="violet"]  { color: #a78bfa; }
.kpi-cell[data-tone="emerald"] { color: #34d399; }
.kpi-cell:hover {
  border-color: rgba(245, 158, 11, 0.35);
}
.kpi-label {
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #71717a;
  margin-bottom: 0.5rem;
}
.kpi-value {
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 2rem;
  line-height: 1;
  color: #fafafa;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.kpi-sub {
  margin-top: 0.5rem;
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 11px;
  color: #71717a;
}

/* KPI value flash on SSE update (R3: state observable) */
.kpi-value.is-flashing {
  animation: kpiFlash 700ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes kpiFlash {
  0%   { color: #fafafa; transform: translateY(0); }
  20%  { color: #fbbf24; transform: translateY(-2px); text-shadow: 0 0 12px rgba(245,158,11,0.55); }
  100% { color: #fafafa; transform: translateY(0); }
}

/* Bulk action bar */
.bulk-action-bar.is-open { opacity: 1; }
.bulk-action-bar.is-open .pointer-events-auto { transform: translateY(0); }
.pointer-events-auto { transition: transform 240ms cubic-bezier(0.16, 1, 0.3, 1); }
.bulk-action-bar:not(.is-open) .pointer-events-auto { transform: translateY(8px); }

/* Tab styles — built on top of existing CSS tone, no contrast issues */
.tab-btn { color: #a1a1aa; }
.tab-btn.is-active {
  background: rgba(245, 158, 11, 0.10);
  color: #fde68a;
  box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.30);
}
.tab-btn:not(.is-active):hover { background: rgba(39, 39, 42, 0.6); color: #e4e4e7; }

/* Heat strip cells */
.heat-cell {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  transition: transform 120ms ease;
}
.heat-cell:hover {
  transform: scale(1.25);
  outline: 1px solid rgba(251, 191, 36, 0.6);
}

/* Trend chart — crosshair */
[data-trend-chart] { cursor: crosshair; }
[data-trend-chart] svg { display: block; }
#detail-trend-cross.is-visible { opacity: 1 !important; }

/* CMS editor slide-in */
.cms-editor.is-open {
  opacity: 1;
  pointer-events: auto;
}
.cms-editor.is-open > div {
  transform: translateY(0);
}
.cms-editor > div {
  transform: translateY(8px);
  transition: transform 260ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Print stylesheet — PDF export friendly (hide chrome, sidebar, buttons) */
@media print {
  body { background: #ffffff !important; color: #18181b !important; }
  header, aside, .bulk-action-bar, [data-export-fmt], [data-cms-new],
  [data-users-new], [data-intf-test], [data-intf-save], [data-intf-sync] {
    display: none !important;
  }
  .hero-grid, .noise { display: none !important; }
  article, section {
    border: 1px solid #d4d4d8 !important;
    background: #ffffff !important;
    color: #18181b !important;
    page-break-inside: avoid;
  }
  .kpi-value { color: #18181b !important; }
  [role="tabpanel"].hidden { display: block !important; }
}

/* Light-mode overrides for new components */
html:not(.dark) .hero-shell { background: rgba(244, 244, 245, 0.7) !important; }
html:not(.dark) .hero-grid { background-image:
    linear-gradient(to right, rgba(245, 158, 11, 0.10) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(245, 158, 11, 0.10) 1px, transparent 1px);
}
html:not(.dark) .kpi-cell {
  background: linear-gradient(180deg, rgba(244, 244, 245, 0.8) 0%, rgba(228, 228, 231, 0.6) 100%);
  border-color: #e4e4e7;
}
html:not(.dark) .kpi-value { color: #18181b; }
html:not(.dark) .kpi-label,
html:not(.dark) .kpi-sub   { color: #52525b; }

/* Responsive — table → card list below 640 */
@media (max-width: 640px) {
  .kpi-cell .kpi-value { font-size: 1.5rem; }
  /* hero collapses padding on small screens */
  .hero-shell > .grid { padding: 1rem 1.25rem !important; }
  .bulk-action-bar { left: 0.5rem !important; right: 0.5rem !important; }
  .bulk-action-bar > div { flex-direction: column !important; align-items: stretch !important; }
}