/* ==========================================================================
   ESH Lab — Sovereign Lab Dark Design System & Emil Kowalski Motion Tokens
   ========================================================================== */

:root {
  /* Sovereign Lab Dark Color Tokens */
  --canvas-bg: #090D16;
  --surface-card: #0F172A;
  --surface-card-subtle: #162036;
  --wiki-canvas: #0D1526;
  --wiki-paper: #111C33;
  --wiki-border: #1E2D4A;
  --border-subtle: #1E293B;
  --border-hover: #334155;
  --brand-gold: #F59E0B;
  --brand-gold-hover: #D97706;
  --cyan-accent: #38BDF8;
  --emerald-online: #10B981;
  --text-primary: #F8FAFC;
  --text-muted: #94A3B8;

  /* Emil Kowalski Custom Easing Curves */
  --ease-out-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-strong: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out-strong: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
}

/* Mobile-native baseline (Emil Kowalski / mobile-native skill) */
html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

button, a, [role="button"], .tactile-btn {
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

@media (pointer: coarse) {
  input, textarea, select {
    font-size: 16px;
  }
}

.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Subtle 40px architectural rack-mesh background grid */
.bg-grid-mesh {
  background-size: 40px 40px;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.022) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.022) 1px, transparent 1px);
}

/* Tabular numbers for live telemetry and counters (prevents layout shift) */
.tabular-nums {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "zero" 1;
}

/* ==========================================================================
   Tactile Buttons & Pressables (Emil Kowalski Principle: scale(0.97) on press)
   Never use `transition: all` — specify exact GPU/paint properties under 200ms
   ========================================================================== */
.tactile-btn {
  transform: translateZ(0);
  transition:
    transform 160ms var(--ease-out-spring),
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    box-shadow 160ms var(--ease-out-strong);
  will-change: transform;
}

.tactile-btn:active {
  transform: scale(0.97);
}

/* Gate hover elevations behind pointer:fine to avoid sticky hover on touch */
@media (hover: hover) and (pointer: fine) {
  .tactile-btn-gold:hover {
    background-color: var(--brand-gold-hover);
    box-shadow: 0 0 28px -4px rgba(245, 158, 11, 0.48);
  }

  .tactile-btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.035);
    border-color: var(--border-hover);
  }

  /* Interactive Bento & Manifesto Surface Proximity */
  .sovereign-card {
    transition:
      transform 200ms var(--ease-out-spring),
      border-color 180ms ease,
      box-shadow 180ms ease;
  }

  .sovereign-card:hover {
    border-color: var(--border-hover);
    box-shadow:
      inset 0 1px 0 0 rgba(255, 255, 255, 0.06),
      0 18px 36px -12px rgba(0, 0, 0, 0.55);
  }

  .sovereign-card-gold:hover {
    border-color: rgba(245, 158, 11, 0.5);
    transform: translateY(-2px);
  }

  .sovereign-card-cyan:hover {
    border-color: rgba(56, 189, 248, 0.5);
    transform: translateY(-2px);
  }

  .sovereign-card-emerald:hover {
    border-color: rgba(16, 185, 129, 0.5);
    transform: translateY(-2px);
  }

  .hero-rack-photo {
    transition: transform 260ms var(--ease-out-spring);
  }

  .hero-rack-container:hover .hero-rack-photo {
    transform: scale(1.015);
  }

  .video-play-trigger {
    transition:
      transform 200ms var(--ease-out-spring),
      box-shadow 200ms ease;
  }

  .video-preview-box:hover .video-play-trigger {
    transform: scale(1.08);
    box-shadow: 0 0 42px -4px rgba(56, 189, 248, 0.65);
  }

  .video-preview-box:active .video-play-trigger {
    transform: scale(0.96);
  }
}

/* ==========================================================================
   Staggered Entry Animations (Never animate from scale(0); start at 0.96)
   ========================================================================== */
@keyframes sovereignEnter {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.stagger-item {
  opacity: 0;
  transform: scale(0.96) translateY(8px);
  animation: sovereignEnter 260ms var(--ease-out-spring) forwards;
}

.stagger-1 { animation-delay: 0ms; }
.stagger-2 { animation-delay: 50ms; }
.stagger-3 { animation-delay: 100ms; }
.stagger-4 { animation-delay: 150ms; }
.stagger-5 { animation-delay: 200ms; }

/* Live Ping Radar Dot (GPU-only transform + opacity) */
@keyframes ping-slow {
  75%, 100% {
    transform: scale(2.15);
    opacity: 0;
  }
}

.animate-ping-slow {
  animation: ping-slow 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

/* ESH Verified Lab Seal Pulse (Subtle breathing opacity & scale without harsh flicker) */
@keyframes verified-seal-pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.85;
    transform: scale(0.98);
  }
}

.verified-seal-pulse {
  animation: verified-seal-pulse 3s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  will-change: opacity, transform;
}

/* Zabbix Time-Series Sliding Track (Composite-only transform) */
.zabbix-slide-track {
  will-change: transform;
  transform: translate3d(0, 0, 0);
}

.zabbix-slide-track.is-sliding {
  transition: transform 650ms var(--ease-out-strong);
}

/* Telemetry tiles: subtle border highlight on hover (pointer devices only) */
.telemetry-tile {
  transition: border-color 160ms ease, background-color 160ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .telemetry-tile:hover {
    border-color: rgba(56, 189, 248, 0.35);
  }
}

/* Live dot: soft heartbeat (opacity only) */
.telemetry-live-dot {
  animation: telemetry-live 2s ease-in-out infinite;
}
@keyframes telemetry-live {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
@media (prefers-reduced-motion: reduce) {
  .telemetry-live-dot { animation: none; }
  .telemetry-tile:hover { transform: none !important; }
  .zabbix-slide-track.is-sliding { transition: none !important; }
}

/* APA 7th Edition Hanging Indentation (Sangría francesa de 2rem) */
.apa-reference-item {
  padding-left: 2rem;
  text-indent: -2rem;
  line-height: 1.75;
}

.apa-reference-item em,
.apa-reference-item i {
  color: #E2E8F0;
  font-style: italic;
}

/* ==========================================================================
   Blog RichText Typography & Formatted Paragraph Styles (.blog-richtext)
   Supports text-wrapping around floated left figure & Sovereign Lab tokens
   ========================================================================== */
.blog-richtext p {
  margin-bottom: 1rem;
  line-height: 1.82;
}

.blog-richtext p:last-child {
  margin-bottom: 0;
}

.blog-richtext strong,
.blog-richtext b {
  color: #F8FAFC;
  font-weight: 600;
}

.blog-richtext em,
.blog-richtext i {
  color: #E2E8F0;
  font-style: italic;
}

.blog-richtext code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.86em;
  color: #38BDF8;
  background-color: #090D16;
  border: 1px solid #1E293B;
  border-radius: 0.375rem;
  padding: 0.12rem 0.42rem;
  word-break: break-word;
}

.blog-richtext pre {
  background-color: #090D16;
  border: 1px solid #1E293B;
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin: 1rem 0;
}

.blog-richtext pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: #E2E8F0;
}

.blog-richtext ul,
.blog-richtext ol {
  margin: 0.85rem 0 1.1rem 0;
  padding-left: 1.25rem;
  list-style-position: inside;
}

.blog-richtext ul {
  list-style-type: disc;
}

.blog-richtext ol {
  list-style-type: decimal;
}

.blog-richtext li {
  margin-bottom: 0.45rem;
  line-height: 1.75;
}

.blog-richtext li::marker {
  color: #F59E0B;
}

.blog-richtext blockquote {
  border-left: 3px solid #F59E0B;
  background-color: rgba(9, 13, 22, 0.65);
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  border-radius: 0 0.5rem 0.5rem 0;
  color: #CBD5E1;
  font-style: italic;
}

.blog-richtext a {
  color: #38BDF8;
  text-decoration: underline;
  text-decoration-color: rgba(56, 189, 248, 0.4);
  transition: color 150ms ease, text-decoration-color 150ms ease;
}

.blog-richtext a:hover {
  color: #F59E0B;
  text-decoration-color: #F59E0B;
}

.blog-richtext h3,
.blog-richtext h4 {
  color: #F8FAFC;
  font-weight: 700;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}

.blog-richtext hr {
  border-color: #1E293B;
  margin: 1.5rem 0;
}


/* ==========================================================================
   Tech Strip Horizontal Marquee (Composite-only translate3d + Canvas Fade)
   Moves left continuously and dissolves into #0c1220 well before page edges
   ========================================================================== */
@keyframes tech-marquee-scroll {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(-50%, 0, 0);
  }
}

.tech-marquee-viewport {
  position: relative;
  overflow: hidden;
  max-width: 62rem;
  margin-left: auto;
  margin-right: auto;
  -webkit-mask-image: linear-gradient(
    to right,
    transparent 0%,
    rgba(0, 0, 0, 0.08) 7%,
    rgba(0, 0, 0, 1) 24%,
    rgba(0, 0, 0, 1) 76%,
    rgba(0, 0, 0, 0.08) 93%,
    transparent 100%
  );
  mask-image: linear-gradient(
    to right,
    transparent 0%,
    rgba(0, 0, 0, 0.08) 7%,
    rgba(0, 0, 0, 1) 24%,
    rgba(0, 0, 0, 1) 76%,
    rgba(0, 0, 0, 0.08) 93%,
    transparent 100%
  );
}

.tech-marquee-viewport::before,
.tech-marquee-viewport::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 7.5rem;
  pointer-events: none;
  z-index: 2;
}

.tech-marquee-viewport::before {
  left: 0;
  background: linear-gradient(to right, #0c1220 0%, rgba(12, 18, 32, 0.75) 45%, transparent 100%);
}

.tech-marquee-viewport::after {
  right: 0;
  background: linear-gradient(to left, #0c1220 0%, rgba(12, 18, 32, 0.75) 45%, transparent 100%);
}

.tech-marquee-track {
  display: flex;
  align-items: center;
  width: max-content;
  will-change: transform;
  animation: tech-marquee-scroll 28s linear infinite;
}

.tech-marquee-group {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 3rem;
  padding-right: 3rem;
}

@media (min-width: 640px) {
  .tech-marquee-group {
    gap: 3.75rem;
    padding-right: 3.75rem;
  }
}

@media (hover: hover) and (pointer: fine) {
  .tech-marquee-viewport:hover .tech-marquee-track {
    animation-play-state: paused;
  }
}

/* ==========================================================================
   Accessibility: prefers-reduced-motion
   Remove transform-based movement; keep gentle opacity comprehension
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .stagger-item {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
  }

  .verified-seal-pulse {
    animation: pulse 2.2s cubic-bezier(0.4, 0, 0.6, 1) infinite !important;
    transform: none !important;
  }

  .tactile-btn:active,
  .sovereign-card-gold:hover,
  .sovereign-card-cyan:hover,
  .sovereign-card-emerald:hover,
  .hero-rack-container:hover .hero-rack-photo,
  .video-preview-box:hover .video-play-trigger {
    transform: none !important;
  }
}

/* ==========================================================================
   Network topology (El Taller en Acción)
   ========================================================================== */
.topo-flow {
  stroke-dasharray: 4 10;
  stroke-linecap: round;
  animation: topo-dash 1.4s linear infinite;
}
.topo-api { animation: topo-api-dash 1.2s linear infinite; }
@keyframes topo-dash { to { stroke-dashoffset: -28; } }
@keyframes topo-api-dash { to { stroke-dashoffset: -20; } }

.topo-node { cursor: default; outline: none; }
.topo-node rect:first-of-type,
.topo-node rect:first-of-type + * {
  transition: filter 150ms ease-out;
}
@media (hover: hover) and (pointer: fine) {
  .topo-node:hover rect:first-of-type { filter: brightness(1.5) drop-shadow(0 0 6px rgba(34, 211, 238, 0.35)); }
}
.topo-node:focus-visible rect:first-of-type { stroke-width: 2.5; filter: brightness(1.5); }

@media (prefers-reduced-motion: reduce) {
  .topo-flow, .topo-api { animation: none !important; }
  .wiki-cat-trigger:active,
  .wiki-manual-link:active,
  .wiki-cat-chevron,
  .wiki-cat-panel-inner {
    transition: none !important;
    transform: none !important;
  }
}

/* ==========================================================================
   Wiki Documentation Surface & Collapsible Category Filters (/guias/)
   Emil Kowalski Craft: Specific property transitions, <200ms ease-out,
   tactile press feedback, origin-aware chevron rotation.
   ========================================================================== */
.wiki-center-canvas {
  background-color: var(--wiki-canvas);
  background-image:
    radial-gradient(circle at 50% 0%, rgba(56, 189, 248, 0.06), transparent 55%),
    linear-gradient(to right, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 100% 100%, 32px 32px, 32px 32px;
}

.wiki-doc-paper {
  background-color: var(--wiki-paper);
  border: 1px solid var(--wiki-border);
  box-shadow:
    inset 0 1px 0 0 rgba(255, 255, 255, 0.05),
    0 20px 45px -15px rgba(3, 7, 18, 0.7);
}

.wiki-cat-trigger {
  transform: translateZ(0);
  transition:
    transform 150ms var(--ease-out-spring),
    background-color 150ms ease,
    border-color 150ms ease,
    color 150ms ease;
}

.wiki-cat-trigger:active {
  transform: scale(0.98);
}

.wiki-cat-chevron {
  transform-origin: center;
  transition: transform 180ms var(--ease-out-strong), color 150ms ease;
}

.wiki-cat-trigger[aria-expanded="true"] .wiki-cat-chevron {
  transform: rotate(90deg);
}

.wiki-cat-panel {
  display: grid;
  grid-template-rows: 1fr;
  opacity: 1;
  transition:
    grid-template-rows 180ms var(--ease-out-strong),
    opacity 150ms ease-out;
}

.wiki-cat-panel[data-collapsed="true"] {
  grid-template-rows: 0fr;
  opacity: 0;
  pointer-events: none;
}

.wiki-cat-panel-inner {
  overflow: hidden;
  transform: translateY(0);
  transition: transform 180ms var(--ease-out-strong);
}

.wiki-cat-panel[data-collapsed="true"] .wiki-cat-panel-inner {
  transform: translateY(-4px);
}

.wiki-manual-link {
  transform: translateZ(0);
  transition:
    transform 140ms var(--ease-out-spring),
    background-color 140ms ease,
    border-color 140ms ease,
    color 140ms ease;
}

.wiki-manual-link:active {
  transform: scale(0.98);
}

/* Compact Zabbix-inspired utilization gauges. */
.telemetry-gauge {
  height: 12px;
  overflow: hidden;
  border: 1px solid #334155;
  border-radius: 3px;
  background: repeating-linear-gradient(to right, #111c2d 0, #111c2d calc(10% - 1px), #334155 calc(10% - 1px), #334155 10%);
}
.telemetry-gauge-fill {
  height: 100%;
  background: var(--gauge-color);
  transform-origin: left center;
  transition: transform 250ms ease-out;
}
.telemetry-gauge-scale {
  display: flex;
  justify-content: space-between;
  color: #94a3b8;
  font: 10px ui-monospace, monospace;
}
@media (prefers-reduced-motion: reduce) {
  .telemetry-gauge-fill { transition: none; }
}

/* ==========================================================================
   Blog History Dropdown Responsive Safeguard (iPhone / <640px viewports)
   Prevents right-0 + fixed width from overflowing off the left screen edge
   ========================================================================== */
@media (max-width: 639.98px) {
  #blog-history-dropdown {
    width: 100%;
  }

  #blog-dropdown-trigger {
    width: 100%;
    justify-content: space-between;
  }

  #blog-dropdown-menu {
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
  }
}

/* ==========================================================================
   Popup "Pronto disponible" (YouTube) — native <dialog>, branding Sovereign Lab Dark
   Enter: opacity + scale(0.96) → 1 · Exit: 140ms · only transform/opacity animate
   ========================================================================== */
.esh-dialog {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  max-width: none;
  max-height: none;
  overflow: visible;
}

.esh-dialog::backdrop {
  background: rgba(5, 8, 17, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.esh-dialog[open] {
  animation: eshDialogIn 200ms var(--ease-out-strong, cubic-bezier(0.23, 1, 0.32, 1)) both;
}

.esh-dialog[open]::backdrop {
  animation: eshDialogFade 200ms ease-out both;
}

.esh-dialog.is-closing {
  animation: eshDialogOut 140ms ease-in both;
}

.esh-dialog.is-closing::backdrop {
  animation: eshDialogFadeOut 140ms ease-in both;
}

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

@keyframes eshDialogOut {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(0.97); }
}

@keyframes eshDialogFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes eshDialogFadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .esh-dialog[open],
  .esh-dialog[open]::backdrop,
  .esh-dialog.is-closing,
  .esh-dialog.is-closing::backdrop {
    animation: none !important;
  }
}

/* ==========================================================================
   Cursos (/cursos/) — Tarjetas de portada enlazadas a Udemy
   Solo transform / opacity / color. Hover limitado a punteros finos.
   ========================================================================== */
.course-card {
  transition:
    transform 160ms var(--ease-out-spring),
    border-color 150ms ease;
}

.course-card:active {
  transform: scale(0.98);
}

.course-card-img {
  transition:
    transform 300ms var(--ease-out-strong),
    opacity 200ms ease-out;
}

/* Fade de la portada al cargar (la clase la pone eshlab.js solo si la imagen aún no cargó) */
.course-card-img.is-loading {
  opacity: 0;
}

.course-card-arrow {
  transition: transform 200ms var(--ease-out-strong);
}

@media (hover: hover) and (pointer: fine) {
  .course-card:hover {
    border-color: var(--border-hover);
  }

  .course-card:hover .course-card-img {
    transform: scale(1.03);
  }

  .course-card:hover .course-card-arrow {
    transform: translate(2px, -2px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .course-card,
  .course-card:active,
  .course-card:hover .course-card-img,
  .course-card:hover .course-card-arrow {
    transform: none !important;
  }

  .course-card-img,
  .course-card-arrow {
    transition: opacity 200ms ease-out;
  }
}
