/* ============================================================
   ARTEFICIALISMO BASE — shared across all pages
   v20260614
   ============================================================ */

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

html, body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

body {
  font-family: "Courier New", Courier, monospace;
  color: var(--fg, #f2f2f2);
  background: var(--bg, #050505);
}

a { color: inherit; }
button { font: inherit; }

/* --- Cursor --- */
body { cursor: crosshair; }
a, button, [role="button"], label[for], summary, [tabindex]:not([tabindex="-1"]) {
  cursor: pointer;
}

/* --- Fixed overlay layers (aria-hidden decorative) --- */
.noise,
.scanlines,
.cosmic-field,
.spectrum-breach,
.pixel-fluid,
.glitch-wipe,
.ambient-glow,
.argo-geometry,
.cursor-dot {
  pointer-events: none;
}

.noise {
  position: fixed;
  inset: 0;
  opacity: .08;
  mix-blend-mode: screen;
  background-image:
    repeating-radial-gradient(circle at 17% 32%, rgba(255,255,255,.25) 0 1px, transparent 1px 3px),
    repeating-radial-gradient(circle at 73% 61%, rgba(255,255,255,.18) 0 1px, transparent 1px 4px);
  animation: noiseMove 1.4s steps(2) infinite;
  z-index: 1;
}

.scanlines {
  position: fixed;
  inset: 0;
  opacity: .2;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,.04),
    rgba(255,255,255,.04) 1px,
    transparent 1px,
    transparent 4px
  );
  z-index: 2;
}

.cursor-dot {
  position: fixed;
  width: 8px;
  height: 8px;
  border: 1px solid var(--accent, #ff3b3b);
  border-radius: 50%;
  z-index: 10;
  transform: translate(-50%, -50%);
  mix-blend-mode: difference;
  opacity: .9;
}

/* --- Language switcher --- */
.lang-switcher {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  display: flex;
  gap: 6px;
  padding: 6px;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(5,5,5,.48);
  backdrop-filter: blur(8px);
}

.lang-switcher button {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted, #8f8f8f);
  font: inherit;
  font-size: 11px;
  letter-spacing: .12em;
  padding: 7px 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.lang-switcher button:hover,
.lang-switcher button.active {
  color: var(--fg, #f2f2f2);
  border-color: rgba(255,255,255,.2);
  background: rgba(255,255,255,.04);
}

/* --- Flag icons (CSS-drawn, no image deps) --- */
.flag {
  position: relative;
  display: inline-block;
  width: 16px;
  height: 11px;
  overflow: hidden;
  border-radius: 1px;
  box-shadow: 0 0 0 1px rgba(255,255,255,.18);
  flex-shrink: 0;
}

.flag-us {
  background: repeating-linear-gradient(to bottom, #b22234 0 1px, #fff 1px 2px);
}
.flag-us::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 7px; height: 6px;
  background: #3c3b6e;
}

.flag-br { background: #009b3a; }
.flag-br::before {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 8px; height: 8px;
  background: #ffdf00;
  transform: translate(-50%,-50%) rotate(45deg);
}
.flag-br::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: #002776;
  transform: translate(-50%,-50%);
}

.flag-es {
  background: linear-gradient(to bottom, #aa151b 0 27%, #f1bf00 27% 73%, #aa151b 73% 100%);
}

/* --- Glitch-wipe transition overlay --- */
.glitch-wipe {
  position: fixed;
  inset: 0;
  z-index: 70;
  opacity: 0;
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0 8px,
      rgba(255,255,255,.16) 8px 9px,
      transparent 9px 14px
    ),
    linear-gradient(90deg, transparent, rgba(255,255,255,.14), transparent);
  mix-blend-mode: screen;
}

body.is-glitching .glitch-wipe {
  animation: glitchWipe .38s steps(2) both;
}

/* --- Shared animations --- */
@keyframes noiseMove {
  0%   { transform: translate(0,0); }
  25%  { transform: translate(-2%,1%); }
  50%  { transform: translate(1%,-2%); }
  75%  { transform: translate(2%,2%); }
  100% { transform: translate(0,0); }
}

@keyframes glitchWipe {
  0%   { opacity: 0; transform: translateX(-8%); }
  20%  { opacity: .9; transform: translateX(4%); }
  38%  { opacity: .35; transform: translateX(-2%); }
  58%  { opacity: 1; transform: translateX(6%); }
  100% { opacity: 0; transform: translateX(0); }
}

@keyframes blink {
  0%,70% { opacity: 1; }
  71%,100% { opacity: .25; }
}

@keyframes cursorBlink {
  0%,50% { opacity: 1; }
  51%,100% { opacity: 0; }
}

/* --- System log common styles --- */
.system-log-line {
  display: block;
  min-height: 1.65em;
  opacity: 0;
  transform: translateY(4px);
  white-space: nowrap;
  transition: opacity .24s ease, transform .24s ease;
}

.system-log-line.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.system-log-line.is-typing::after {
  content: "_";
  color: var(--accent, #ff3b3b);
  animation: cursorBlink .7s steps(2) infinite;
}

/* --- Mobile overrides --- */
@media (max-width: 600px) {
  .lang-switcher {
    left: 50%;
    right: auto;
    top: 10px;
    bottom: auto;
    transform: translateX(-50%);
  }

  .noise {
    animation: none;
    opacity: .045;
  }

  .cursor-dot { display: none; }
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }

  .noise { animation: none; opacity: .035; }
  .cursor-dot { display: none; }

  .pixel-fluid,
  .cosmic-field,
  .spectrum-breach,
  .argo-geometry,
  .argo-geometry::before,
  .argo-geometry::after {
    animation: none !important;
    opacity: .1;
  }
}
