/* ═══════════════════════════════════════════════════════════════
   BASE — Reset + tipografía + helpers globales
═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ─── Reset moderno ─────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: var(--t-base);
  font-weight: var(--w-regular);
  line-height: var(--lh-normal);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
  transition: background-color var(--d-slow) var(--ease-standard),
              color var(--d-slow) var(--ease-standard);
}

img, svg, video, canvas {
  display: block;
  max-width: 100%;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: none;
  cursor: pointer;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--d-fast) var(--ease-standard);
}
a:hover { color: var(--accent-hover); }

ul, ol { list-style: none; }

/* ─── Tipografía editorial ──────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: var(--w-semibold);
  line-height: var(--lh-tight);
  letter-spacing: -0.02em;
  color: var(--text);
}

h1 { font-size: var(--t-xl); letter-spacing: -0.025em; }
h2 { font-size: var(--t-lg); }
h3 { font-size: var(--t-md); }
h4 { font-size: var(--t-base); }

p { line-height: var(--lh-normal); }

/* Tabular nums para datos */
.num,
.mono,
code,
kbd,
.t-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum', 'cv11';
}

code {
  font-size: 0.875em;
  padding: 1px 6px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  font-size: var(--t-xs);
  font-weight: var(--w-medium);
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: var(--r-sm);
  line-height: 1;
}

/* ─── Selección ─────────────────────────────────────────── */
::selection {
  background: var(--accent-soft);
  color: var(--text);
}

/* ─── Scrollbar minimalista ─────────────────────────────── */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--text-3);
  background-clip: padding-box;
  border: 2px solid transparent;
}

/* ─── Focus visible (accesible) ─────────────────────────── */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ─── Utility classes ───────────────────────────────────── */
.muted    { color: var(--text-2); }
.dim      { color: var(--text-3); }
.hidden   { display: none !important; }
.sr-only  {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.t-xs   { font-size: var(--t-xs); }
.t-sm   { font-size: var(--t-sm); }
.t-md   { font-size: var(--t-md); }
.t-lg   { font-size: var(--t-lg); }
.t-xl   { font-size: var(--t-xl); }
.t-2xl  { font-size: var(--t-2xl); }
.t-3xl  { font-size: var(--t-3xl); }

.w-regular  { font-weight: var(--w-regular); }
.w-medium   { font-weight: var(--w-medium); }
.w-semibold { font-weight: var(--w-semibold); }
.w-bold     { font-weight: var(--w-bold); }

.text-uppercase {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: var(--t-xs);
  font-weight: var(--w-medium);
  color: var(--text-2);
}

/* Stack & cluster (utility primitives) */
.stack > * + *      { margin-top: var(--s-3); }
.stack-sm > * + *   { margin-top: var(--s-2); }
.stack-lg > * + *   { margin-top: var(--s-5); }
.stack-xl > * + *   { margin-top: var(--s-7); }

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3);
}
.cluster-sm { gap: var(--s-2); }
.cluster-lg { gap: var(--s-5); }

.row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex-wrap: wrap;
}
.between { justify-content: space-between; }
.row-end { justify-content: flex-end; }

.grid {
  display: grid;
  gap: var(--s-4);
}
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 980px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
}

/* ─── Animaciones globales ──────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

/* ─── Visibility toggles ────────────────────────────────── */
body.is-not-admin .admin-only { display: none !important; }
body.is-not-admin .admin-only-flex { display: none !important; }
body.is-not-master .master-only { display: none !important; }
body.is-not-master .master-only-flex { display: none !important; }

/* Loading state */
.is-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.6;
}
.is-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--surface-2) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}
