/* ==========================================================================
   SENKAI // BASE RESET + TIPOGRAFÍA + UTILIDADES GLOBALES
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  color-scheme: dark;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
  overflow-x: clip;
  max-width: 100%;
}

/* ── Textura Atmosférica Textil / Grano Analógico (SVG Noise Puro) ─────── */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 99999;
  opacity: 0.055;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

body {
  background-color: var(--bg-main);
  background-image: 
    linear-gradient(to right, var(--grid-color) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-color) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  min-height: 100dvh;
  width: 100%;
  max-width: 100vw;
  overflow-x: clip;
  position: relative;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Jerarquía Tipográfica ─────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  text-transform: uppercase;
  text-wrap: balance;
  overflow-wrap: break-word;
}

h1 { font-size: var(--text-hero); font-weight: 800; }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }

p {
  color: var(--text-secondary);
  text-wrap: pretty;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ── Formularios ───────────────────────────────────────────────────────── */
button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  border: none;
  outline: none;
  background: none;
}

button {
  cursor: pointer;
  user-select: none;
}

/* ── Focus Visible — Ring de marca ─────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ── Scrollbar Minimalista ─────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-dim);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--text-dim) transparent;
}

/* ── Selección de Texto ────────────────────────────────────────────────── */
::selection {
  background: rgba(239, 68, 68, 0.25);
  color: #ffffff;
}

/* ── Imágenes ──────────────────────────────────────────────────────────── */
img, svg, video {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

/* ── Contenedores ──────────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding-inline: var(--content-padding);
}

.container-narrow {
  max-width: 960px;
}

.container-wide {
  max-width: 1600px;
}

@media (max-width: 768px) {
  :root {
    --content-padding: 1.25rem;
  }
}

@media (max-width: 480px) {
  :root {
    --content-padding: 1rem;
  }
}

/* ── Surface Cards — Superficie sólida elevada ─────────────────────────── */
.surface-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition-fast);
}

.surface-card:hover {
  border-color: var(--border-default);
}

.surface-card-elevated {
  background: var(--bg-surface-elevated);
  box-shadow: var(--shadow-card);
}

/* ── Badges / Tags — Ghost Pills Táctiles (DESIGN.md) ──────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.3rem 0.65rem;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-radius: var(--radius-pill);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.badge-accent,
.badge-crimson {
  background: var(--accent-primary-subtle);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--accent-primary);
}

.badge-success,
.badge-lime {
  background: var(--accent-success-subtle);
  border-color: rgba(34, 197, 94, 0.3);
  color: var(--accent-success);
}

.badge-warning,
.badge-amber {
  background: var(--accent-warning-subtle);
  border-color: rgba(245, 158, 11, 0.3);
  color: var(--accent-warning);
}

.badge-admin,
.badge-cyan {
  background: var(--accent-admin-subtle);
  border-color: rgba(56, 189, 248, 0.3);
  color: var(--accent-admin);
}

/* ── Botones — Dark Industrial ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.8rem 1.6rem;
  font-size: var(--text-sm);
  font-weight: 700;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-radius: var(--radius-none);
  position: relative;
  transition:
    background-color var(--transition-fast),
    color var(--transition-fast),
    border-color var(--transition-fast),
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: #ffffff;
  color: #000000;
  border: 1px solid #ffffff;
  border-radius: var(--radius-pill); /* CTA primario Ghost Pill */
}

.btn-primary:hover {
  background: #e4e4e7;
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover {
  border-color: #ffffff;
  background: rgba(255, 255, 255, 0.04);
}

.btn-accent {
  background: var(--accent-primary);
  color: #ffffff;
  border: 1px solid var(--accent-primary);
  border-radius: var(--radius-pill);
}

.btn-accent:hover {
  background: var(--accent-primary-hover);
  border-color: var(--accent-primary-hover);
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.25);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

/* ── Utilidades de Accesibilidad ────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ── Utilidades de Visibilidad Responsiva ───────────────────────────────── */
@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
}

@media (min-width: 769px) {
  .hide-desktop { display: none !important; }
}

/* ── Pulse Indicator ───────────────────────────────────────────────────── */
.pulse-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-success);
  display: inline-block;
  animation: pulse-glow 2s var(--ease-in-out) infinite;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(0.8); }
}

/* ── Technical Drafting & Atelier Utilities ────────────────────────────── */
.corner-brackets {
  position: relative;
}

.corner-brackets::before,
.corner-brackets::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  pointer-events: none;
  z-index: 2;
  transition: border-color var(--transition-fast);
}

/* Esquinas superiores */
.corner-brackets::before {
  top: -1px;
  left: -1px;
  border-top: 2px solid var(--border-technical-hi);
  border-left: 2px solid var(--border-technical-hi);
}

/* Esquinas inferiores */
.corner-brackets::after {
  bottom: -1px;
  right: -1px;
  border-bottom: 2px solid var(--border-technical-hi);
  border-right: 2px solid var(--border-technical-hi);
}

.corner-brackets:hover::before,
.corner-brackets:hover::after {
  border-color: #ffffff;
}

/* Etiquetas de Taller / Care Labels */
.tech-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.25rem 0.65rem;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
  border-radius: var(--radius-pill); /* DESIGN.md: 75px en tags */
}

.tech-tag strong {
  color: var(--text-primary);
  font-weight: 700;
}

/* Mira de Calibración / Crosshair */
.tech-cross {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  user-select: none;
  line-height: 1;
}

/* Estampado de Datos Técnicos (Coordenadas / Batch) */
.tech-spec-line {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.tech-spec-line::before {
  content: "//";
  color: var(--accent-primary);
  font-weight: 700;
}
