/* kosareva.cloud — supplemental styles beyond Tailwind */

/* Fix 5 (Григорик): size-adjust fallback — уменьшает CLS при swap с Geist.
   Метрики подобраны под Geist (близок к Inter/Helvetica Neue).
   Браузер резервирует правильный размер блока ещё до загрузки шрифта. */
@font-face {
  font-family: 'Geist-Fallback';
  src: local('ui-sans-serif'), local('system-ui'), local('-apple-system');
  ascent-override: 88%;
  descent-override: 22%;
  line-gap-override: 0%;
  size-adjust: 100%;
}

html {
  scroll-behavior: smooth;
}

body {
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

/* Light theme overrides — Tailwind dark: handles dark mode, these are light fallbacks */
html:not(.dark) body {
  background-color: #FAFAFA;
  color: #0A0A0A;
}

html:not(.dark) header {
  background-color: rgba(250, 250, 250, 0.85);
  border-color: rgba(229, 229, 229, 0.8);
}

html:not(.dark) .bg-ink-900 { background-color: #FAFAFA !important; }
html:not(.dark) .bg-ink-800,
html:not(.dark) .bg-ink-800\/50,
html:not(.dark) .bg-ink-800\/40,
html:not(.dark) .bg-ink-800\/60,
html:not(.dark) .bg-ink-800\/80 {
  background-color: #FFFFFF !important;
}
html:not(.dark) .text-ink-50 { color: #0A0A0A !important; }
html:not(.dark) .text-ink-100 { color: #404040 !important; }
html:not(.dark) .text-ink-200 { color: #737373 !important; }
html:not(.dark) .text-ink-300 { color: #A3A3A3 !important; }
html:not(.dark) .border-ink-700,
html:not(.dark) .border-ink-700\/60,
html:not(.dark) .border-ink-700\/50 {
  border-color: #E5E5E5 !important;
}
html:not(.dark) .bg-white { background-color: #0A0A0A !important; }
html:not(.dark) .hover\:bg-ink-100:hover { background-color: #262626 !important; }

/* Inline-валидация: красная рамка для невалидного поля (перекрывает focus:border-accent) */
input[aria-invalid='true'] {
  border-color: #f87171 !important;
}
input[aria-invalid='true']:focus {
  box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.4) !important;
}

/* Range slider — accent color across browsers */
input[type='range'] {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
  height: 4px;
}
input[type='range']::-webkit-slider-runnable-track {
  height: 4px;
  background: #262626;
  border-radius: 2px;
}
html:not(.dark) input[type='range']::-webkit-slider-runnable-track {
  background: #E5E5E5;
}
input[type='range']::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  margin-top: -8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #14B8A6;
  border: 3px solid #0A0A0A;
  box-shadow: 0 0 0 1px #14B8A6, 0 0 12px #14B8A655;
  transition: transform 0.15s ease;
}
html:not(.dark) input[type='range']::-webkit-slider-thumb {
  border-color: #FAFAFA;
}
input[type='range']::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}
input[type='range']::-moz-range-track {
  height: 4px;
  background: #262626;
  border-radius: 2px;
}
input[type='range']::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #14B8A6;
  border: 3px solid #0A0A0A;
  box-shadow: 0 0 0 1px #14B8A6, 0 0 12px #14B8A655;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: #0A0A0A;
}
html:not(.dark) ::-webkit-scrollbar-track {
  background: #FAFAFA;
}
::-webkit-scrollbar-thumb {
  background: #262626;
  border-radius: 5px;
}
html:not(.dark) ::-webkit-scrollbar-thumb {
  background: #D4D4D4;
}
::-webkit-scrollbar-thumb:hover {
  background: #14B8A6;
}

/* FAQ details — smooth open */
details summary::-webkit-details-marker {
  display: none;
}
details > summary {
  list-style: none;
}

/* Subtle "noise" texture overlay on hero (optional, very faint) */
section:first-of-type::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85'/></filter><rect width='200' height='200' filter='url(%23n)' opacity='0.5'/></svg>");
}

/* Animations */
@keyframes pulse-soft {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.animate-pulse {
  animation: pulse-soft 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Animated mesh gradient blobs (Раух: AI-era hero) */
.mesh-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
  mix-blend-mode: screen;
  will-change: transform;
}
.mesh-blob-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #14B8A6 0%, transparent 70%);
  top: -200px;
  left: -100px;
  animation: mesh-float-1 20s ease-in-out infinite;
}
.mesh-blob-2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, #2BD3C0 0%, transparent 70%);
  top: -100px;
  right: -150px;
  animation: mesh-float-2 25s ease-in-out infinite;
}
.mesh-blob-3 {
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, #14B8A6 0%, transparent 70%);
  bottom: -200px;
  left: 30%;
  animation: mesh-float-3 18s ease-in-out infinite;
  opacity: 0.3;
}
@keyframes mesh-float-1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(120px, 80px) scale(1.1); }
  66%      { transform: translate(-60px, 140px) scale(0.95); }
}
@keyframes mesh-float-2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(-100px, 60px) scale(1.05); }
  66%      { transform: translate(40px, -80px) scale(1.15); }
}
@keyframes mesh-float-3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(-80px, -120px) scale(1.2); }
}
html:not(.dark) .mesh-blob {
  opacity: 0.25;
  mix-blend-mode: multiply;
}
/* Fix 2 (Григорик): filter:blur(80px) на мобильном — paint storm на каждом кадре.
   На Snapdragon 665 это 40–80ms/кадр. На мобильном показываем статичный градиент. */
@media (max-width: 767px) {
  .mesh-blob {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .mesh-blob {
    animation: none !important;
  }
}

/* Copy button on code blocks (Раух: dev-tool chrome) */
.code-copy-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: #A3A3A3;
  background: rgba(20, 20, 20, 0.85);
  border: 1px solid #262626;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: all 0.15s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 5;
}
pre:hover ~ .code-copy-btn,
.code-copy-btn:hover,
.code-copy-btn:focus-visible {
  opacity: 1;
  color: #FAFAFA;
  border-color: #404040;
}
/* Always visible on touch / always visible to make discoverable */
@media (hover: none) {
  .code-copy-btn { opacity: 1; }
}
.code-copy-btn.copied {
  color: #14B8A6;
  border-color: #14B8A6;
  opacity: 1;
}
html:not(.dark) .code-copy-btn {
  color: #525252;
  background: rgba(255, 255, 255, 0.85);
  border-color: #E5E5E5;
}
html:not(.dark) .code-copy-btn:hover {
  color: #0A0A0A;
  border-color: #A3A3A3;
}

/* Show copy button always when parent code container is hovered */
section:has(pre):hover .code-copy-btn,
.rounded-xl:has(pre):hover .code-copy-btn {
  opacity: 1;
}

/* Tab content transition */
.tab-content {
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Focus rings everywhere — accessibility */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 2px solid #14B8A6;
  outline-offset: 2px;
  border-radius: 4px;
}
