/* OMEGA Compute Network — Cross-platform stylesheet
   Targets: iOS Safari, Android Chrome, Samsung Internet, Firefox, Edge, Desktop Chrome */

/* ── Reset & base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --violet: #7c3aed;
  --cyan: #06b6d4;
  --green: #10b981;
  /* Safe area insets for notch/home-bar (iOS) */
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
}

html {
  scroll-behavior: smooth;
  /* Prevent font size inflation on iOS rotation */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
               Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  /* Remove tap highlight on Android/iOS */
  -webkit-tap-highlight-color: transparent;
  tap-highlight-color: transparent;
  /* Smooth font rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-smoothing: antialiased;
  /* Prevent horizontal overflow */
  overflow-x: hidden;
  /* iOS momentum scrolling */
  -webkit-overflow-scrolling: touch;
}

/* ── Typography ───────────────────────────────────────────────────────── */
.font-mono, code, pre {
  font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Cascadia Code',
               'Consolas', 'Liberation Mono', monospace;
}

/* ── Navigation — iOS safe area ──────────────────────────────────────── */
nav.fixed-nav {
  padding-top: calc(0.75rem + var(--sat));
  padding-left: calc(1.5rem + var(--sal));
  padding-right: calc(1.5rem + var(--sar));
}

/* Footer safe area */
footer {
  padding-bottom: calc(3rem + var(--sab));
}

/* ── Backdrop blur — needs -webkit- prefix for Safari/iOS ────────────── */
.backdrop-blur,
[class*="backdrop-blur"] {
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

/* ── Touch targets — minimum 44×44px (Apple HIG / Google Material) ────── */
a, button, [role="button"], select, input[type="range"],
input[type="checkbox"], input[type="radio"] {
  min-height: 44px;
  min-width: 44px;
}

/* Override for inline links that shouldn't stretch */
p a, .inline-link { min-height: unset; min-width: unset; }

/* ── Inputs — font-size ≥16px prevents iOS auto-zoom ─────────────────── */
input, select, textarea {
  font-size: 16px !important;
  /* iOS inner shadow removal */
  -webkit-appearance: none;
  appearance: none;
  border-radius: 0.75rem;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  min-height: 44px;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--violet);
  cursor: pointer;
  margin-top: -9px;
}
input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--violet);
  cursor: pointer;
  border: none;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: #374151;
  border-radius: 2px;
}
input[type="range"]::-moz-range-track {
  height: 4px;
  background: #374151;
  border-radius: 2px;
}

/* Select arrow on Android Chrome */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px !important;
}

/* ── Scrollbars ───────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #374151; border-radius: 2px; }

/* Hide scrollbar on mobile (still scrollable) */
@media (max-width: 768px) {
  ::-webkit-scrollbar { display: none; }
  * { scrollbar-width: none; }
}

/* ── Cards & interactive elements ────────────────────────────────────── */
.stat-card { transition: transform 0.2s, border-color 0.2s; }
@media (hover: hover) {
  .stat-card:hover { transform: translateY(-2px); border-color: rgba(124,58,237,0.5); }
}

/* Active state for touch (replaces hover on mobile) */
.stat-card:active { transform: scale(0.98); }

/* ── iOS 100vh fix — use dvh where supported ─────────────────────────── */
.min-h-screen {
  min-height: 100vh;
  min-height: 100dvh; /* Dynamic viewport height — collapses browser chrome */
}
.h-screen {
  height: 100vh;
  height: 100dvh;
}

/* ── Dashboard sidebar transition ────────────────────────────────────── */
#sidebar {
  will-change: transform;
  /* Hardware-accelerated slide on iOS */
  -webkit-transform: translateX(-100%);
  transform: translateX(-100%);
  transition: -webkit-transform 0.25s ease-in-out;
  transition: transform 0.25s ease-in-out;
}
#sidebar.open {
  -webkit-transform: translateX(0);
  transform: translateX(0);
}
@media (min-width: 1024px) {
  #sidebar {
    -webkit-transform: translateX(0) !important;
    transform: translateX(0) !important;
  }
}

/* ── Gradient text (WebKit prefix for older Safari) ─────────────────── */
.gradient-text,
[class*="bg-clip-text"] {
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ── Animations — respect reduced motion preference ─────────────────── */
@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;
  }
  .animate-pulse { animation: none !important; }
}

/* ── Line clamp (cross-browser) ───────────────────────────────────────── */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Skeleton loading ─────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #1f2937 25%, #374151 50%, #1f2937 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: 4px;
}
@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Focus ring — accessibility ───────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--violet);
  outline-offset: 2px;
}
:focus:not(:focus-visible) { outline: none; }

/* ── Modal bottom sheet on mobile ────────────────────────────────────── */
@media (max-width: 640px) {
  #detail-modal > div {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    max-height: 90vh;
    padding-bottom: calc(1.5rem + var(--sab));
  }
}

/* ── Prevent text selection on UI elements ───────────────────────────── */
nav, button, .stat-card {
  -webkit-user-select: none;
  user-select: none;
}

/* ── Samsung Internet / older Android fix for flex ───────────────────── */
.flex { display: -webkit-box; display: -ms-flexbox; display: flex; }
.grid { display: grid; }

/* ── Global overflow control ──────────────────────────────────────────── */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

/* ── Text overflow everywhere ─────────────────────────────────────────── */
p, h1, h2, h3, h4, span, div {
  overflow-wrap: break-word;
  word-break: break-word;
}

/* ── Webkit-specific: fix 100% width sections ─────────────────────────── */
section, main, article, header, footer, nav {
  max-width: 100%;
  box-sizing: border-box;
}

/* ── OMEGA Lab Connect pages (2026-09-13) ───────────────────────────────
   The templates toggle visibility with the `hidden` attribute from JS, so a
   Tailwind display class on the same element must not win over it. */
[hidden] { display: none !important; }

/* Notices written by connect.js / reply.js. Defined here, not as Tailwind
   utilities, so they exist whether or not the JS files are scanned when
   tailwind.css is compiled. */
.notice {
  border: 1px solid;
  border-radius: 0.75rem;
  padding: 0.625rem 0.875rem;
  font-size: 0.8125rem;
  line-height: 1.45;
  white-space: pre-wrap;
}
.notice-error { color: #f87171; background: rgba(248, 113, 113, 0.08); border-color: rgba(248, 113, 113, 0.35); }
.notice-ok    { color: #34d399; background: rgba(52, 211, 153, 0.08);  border-color: rgba(52, 211, 153, 0.35); }
.notice-warn  { color: #fbbf24; background: rgba(251, 191, 36, 0.08);  border-color: rgba(251, 191, 36, 0.35); }
.notice-info  { color: #a5b4fc; background: rgba(165, 180, 252, 0.08); border-color: rgba(165, 180, 252, 0.35); }

.violation-row {
  font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', 'Liberation Mono', monospace;
  font-size: 0.75rem;
  color: #fbbf24;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

/* The generic input rule above strips native appearance from every input,
   which leaves a radio button invisible; restore it for the verdict choice. */
input[type="radio"], input[type="checkbox"] {
  -webkit-appearance: auto;
  appearance: auto;
  width: 1rem;
  height: 1rem;
  min-width: unset;
  min-height: unset;
  border-radius: 0;
  accent-color: var(--violet);
  flex-shrink: 0;
}

/* The JSON textarea: the 16px floor exists to stop iOS auto-zoom, which
   does not apply on wider screens where a smaller monospace fits more. */
@media (min-width: 640px) {
  textarea.code-input { font-size: 13px !important; }
}
pre { overflow-wrap: normal; word-break: normal; }
