/* CounterAegis Demo — Legendary Design with Stellar Performance */

:root {
  --bg: #050913;
  --surface: #0d1423;
  --surface-soft: #111b2e;
  --line: rgba(148, 163, 184, 0.22);
  --text: #f8fafc;
  --text-secondary: #cbd5e1;
  --muted: #94a3b8;
  --dim: #64748b;
  --accent: #06b6d4;
  --accent-hover: #67e8f9;
  --violet: #8b5cf6;
  --good: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --display: "Space Grotesk", "Inter", sans-serif;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: radial-gradient(circle at 20% -10%, rgba(6, 182, 212, 0.12), transparent 45%),
    radial-gradient(circle at 90% 0%, rgba(139, 92, 246, 0.1), transparent 35%), var(--bg);
  background-attachment: fixed;
}

/* App Layout */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 0;
}

/* Sidebar Rail */
.rail {
  border-right: 1px solid var(--line);
  background: rgba(5, 9, 19, 0.95);
  backdrop-filter: blur(8px);
  padding: 1.5rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  transition: var(--transition);
}

.brand:hover {
  transform: scale(1.02);
}

.brand span {
  color: var(--accent);
  background: linear-gradient(135deg, var(--accent), var(--violet));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sub {
  color: var(--muted);
  margin-top: 0.35rem;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  line-height: 1.5;
}

.rail-links {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.rail-link {
  display: block;
  color: var(--text-secondary);
  font-size: 0.84rem;
  font-weight: 600;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  transition: var(--transition);
}

.rail-link:hover {
  color: var(--text);
  border-color: rgba(6, 182, 212, 0.4);
  background: rgba(6, 182, 212, 0.1);
}

/* Navigation */
#screen-nav {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.screen-link {
  width: 100%;
  text-align: left;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
}

.screen-link:hover {
  color: var(--text);
  border-color: rgba(6, 182, 212, 0.3);
  background: rgba(6, 182, 212, 0.08);
}

.screen-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.screen-link.active {
  color: var(--text);
  border-color: rgba(6, 182, 212, 0.5);
  background: rgba(6, 182, 212, 0.12);
  box-shadow: inset 0 0 12px rgba(6, 182, 212, 0.1);
}

/* Main Content */
.main {
  padding: 1.5rem;
  overflow-y: auto;
}

.topbar h1 {
  margin: 0 0 0.5rem;
  font-family: var(--display);
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.topbar p {
  margin: 0.35rem 0 1.5rem;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

/* Grid Layouts */
.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

/* Cards */
.card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--surface), var(--surface-soft));
  padding: 1.25rem;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.05), rgba(139, 92, 246, 0.02));
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.card:hover {
  border-color: rgba(6, 182, 212, 0.35);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3),
              0 0 1px rgba(6, 182, 212, 0.15);
  transform: translateY(-2px);
}

.card:hover::before {
  opacity: 1;
}

.card h3,
.card h4 {
  margin-top: 0;
  margin-bottom: 0.75rem;
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card h3 {
  font-size: 1.1rem;
}

.card h4 {
  font-size: 0.95rem;
}

/* Metrics */
.metric {
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.muted {
  color: var(--muted);
}

/* Badges */
.badge {
  display: inline-block;
  font-size: 0.76rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  border: 1px solid var(--line);
  transition: var(--transition);
}

.badge.good {
  color: var(--good);
  border-color: rgba(34, 197, 94, 0.4);
  background: rgba(34, 197, 94, 0.08);
}

.badge.warn {
  color: var(--warn);
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.08);
}

.badge.bad {
  color: var(--bad);
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.08);
}

/* Key-Value Display */
.kv {
  display: grid;
  gap: 0.5rem;
}

.kv div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 0.4rem;
  font-size: 0.95rem;
}

.kv div:last-child {
  border-bottom: none;
}

/* Timeline */
.timeline {
  display: grid;
  gap: 0.75rem;
}

.event {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 0.75rem 0.85rem;
  background: rgba(6, 182, 212, 0.08);
  transition: var(--transition);
}

.event:hover {
  border-left-color: var(--accent-hover);
  background: rgba(6, 182, 212, 0.12);
  box-shadow: inset 0 0 8px rgba(6, 182, 212, 0.1);
}

.event small {
  color: var(--muted);
  font-size: 0.85rem;
}

/* Actions */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

/* Buttons */
.btn {
  border: 1px solid var(--line);
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.65rem 0.95rem;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font);
}

.btn:hover {
  border-color: rgba(6, 182, 212, 0.3);
  transform: translateY(-1px);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.btn-primary {
  border-color: rgba(6, 182, 212, 0.5);
  background: rgba(6, 182, 212, 0.16);
}

.btn-primary:hover {
  border-color: var(--accent);
  background: rgba(6, 182, 212, 0.24);
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.15);
}

.btn-secondary {
  background: rgba(148, 163, 184, 0.1);
}

.btn-secondary:hover {
  background: rgba(148, 163, 184, 0.15);
}

/* Pills */
.pill {
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 0.2rem 0.65rem;
  font-size: 0.8rem;
  color: var(--muted);
  display: inline-block;
  transition: var(--transition);
}

.pill:hover {
  border-color: rgba(6, 182, 212, 0.3);
  color: var(--text);
}

/* Code Blocks */
pre {
  margin: 0;
  overflow-x: auto;
  background: #091120;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text);
  font-family: 'Monaco', 'Courier New', monospace;
}

pre::-webkit-scrollbar {
  height: 6px;
}

pre::-webkit-scrollbar-track {
  background: transparent;
}

pre::-webkit-scrollbar-thumb {
  background: rgba(6, 182, 212, 0.2);
  border-radius: 3px;
}

pre::-webkit-scrollbar-thumb:hover {
  background: rgba(6, 182, 212, 0.4);
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* High Contrast Mode */
@media (prefers-contrast: more) {
  .card {
    border-width: 2px;
  }
  
  .btn {
    border-width: 2px;
  }
}

/* Reduced Data Mode */
@media (prefers-reduced-data: reduce) {
  body {
    background: var(--bg);
  }
  
  .card::before {
    display: none;
  }
}

/* Responsive Design */
@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }

  .rail {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 1.25rem 1rem;
  }

  .main {
    padding: 1.25rem;
  }

  .topbar h1 {
    font-size: clamp(1.25rem, 2.5vw, 1.75rem);
  }

  .grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }
}

@media (max-width: 600px) {
  .app {
    grid-template-columns: 1fr;
  }

  .rail {
    padding: 1rem;
  }

  .main {
    padding: 1rem;
  }

  .topbar h1 {
    font-size: 1.25rem;
  }

  .topbar p {
    font-size: 0.9rem;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 1rem;
  }

  .metric {
    font-size: 1.75rem;
  }

  .actions {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }
}

/* Print Styles */
@media print {
  .rail {
    display: none;
  }

  body {
    background: white;
    color: black;
  }

  .card {
    page-break-inside: avoid;
  }
}
