:root {
  --bg: #07070a;
  --fg: #e8ecf1;
  --dim: #6b7280;
  --accent: #b8f3ff;
  --accent-2: #c4a1ff;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  overflow: hidden;
  display: grid;
  place-items: center;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent); color: var(--bg); }

/* --- Bakgrundslager --- */

.aura {
  position: fixed;
  inset: -30%;
  background:
    radial-gradient(40% 35% at 30% 40%, rgba(184, 243, 255, .14), transparent 70%),
    radial-gradient(35% 40% at 70% 60%, rgba(196, 161, 255, .14), transparent 70%);
  filter: blur(40px);
  animation: drift 22s ease-in-out infinite alternate;
}

.grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse at center, #000 20%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse at center, #000 20%, transparent 70%);
}

.grain {
  position: fixed;
  inset: 0;
  opacity: .07;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* --- Innehåll --- */

main {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  padding: 0 16px;
  text-align: center;
  animation: rise 1.4s cubic-bezier(.2, .8, .2, 1) both;
}

.sigil {
  position: relative;
  width: 120px;
  height: 120px;
}

.ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(184, 243, 255, .35);
}

.r1 { border-top-color: var(--accent); animation: spin 9s linear infinite; }
.r2 { inset: 16px; border-color: rgba(196, 161, 255, .3); border-right-color: var(--accent-2); animation: spin 6s linear infinite reverse; }
.r3 { inset: 32px; border-style: dashed; border-color: rgba(255, 255, 255, .15); animation: spin 14s linear infinite; }

.core {
  position: absolute;
  inset: 52px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 20px var(--accent), 0 0 60px rgba(184, 243, 255, .5);
  animation: pulse 3s ease-in-out infinite;
}

.name {
  position: relative;
  font-size: clamp(2.6rem, 11vw, 6rem);
  font-weight: 200;
  letter-spacing: .18em;
  margin-right: -.18em; /* kompensera för letter-spacing så texten centreras */
  background: linear-gradient(100deg, var(--fg) 30%, var(--accent) 50%, var(--accent-2) 60%, var(--fg) 80%);
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 8s linear infinite;
}

/* Kort glitch då och då */
.name::before,
.name::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  opacity: 0;
  -webkit-text-fill-color: currentColor;
}
.name::before { color: var(--accent);   animation: glitch 7s steps(1) infinite; }
.name::after  { color: var(--accent-2); animation: glitch 7s steps(1) infinite .08s; }

/* --- Terminal --- */

.term {
  width: min(520px, calc(100vw - 32px));
  text-align: left;
  font-family: var(--mono);
  font-size: .8rem;
  background: rgba(10, 12, 16, .72);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5), 0 0 0 1px rgba(184, 243, 255, .04) inset;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  overflow: hidden;
  transition: border-color .6s, box-shadow .6s;
}

.term-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.term-bar span { width: 9px; height: 9px; border-radius: 50%; background: rgba(255, 255, 255, .12); }
.term-bar em { margin-left: auto; font-style: normal; font-size: .7rem; color: var(--dim); letter-spacing: .08em; }

.term-body {
  height: calc(1.6em * 7 + 24px); /* exakt 7 rader, så ingen rad klipps halvvägs */
  padding: 12px 14px;
  overflow: hidden;
  line-height: 1.6;
  color: var(--fg);
  white-space: pre-wrap;
}

.term-body .dim  { color: var(--dim); }
.term-body .ok   { color: #4ade80; }
.term-body .warn { color: var(--accent); }

.cursor-line::after {
  content: "";
  display: inline-block;
  width: .6ch;
  height: 1.1em;
  vertical-align: text-bottom;
  background: var(--accent);
  animation: blink 1.1s steps(1) infinite;
}

.progress { padding: 0 14px 14px; }
.progress[hidden] { display: none; }

.progress-meta {
  display: flex;
  justify-content: space-between;
  margin: 6px 0;
  color: var(--fg);
}
.progress-meta.dim { color: var(--dim); font-size: .7rem; }

.bar {
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, .07);
  overflow: hidden;
}
.fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  box-shadow: 0 0 12px var(--accent);
  transition: width .15s linear;
}

/* --- Infektionsläge: allt går över i rött --- */

.scan {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .25) 0 1px, transparent 1px 3px);
  transition: opacity .6s;
}

body { transition: background-color 1s; }
.aura, .core, .ring { transition: all .8s; }

body.infect {
  --accent: #ff3b5c;
  --accent-2: #ff8a3d;
  background-color: #0c0507;
}
body.infect .scan { opacity: 1; }
body.infect .term {
  border-color: rgba(255, 59, 92, .35);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5), 0 0 40px rgba(255, 59, 92, .15);
}
body.infect .ring { border-color: rgba(255, 59, 92, .35); }
body.infect .r1 { border-top-color: var(--accent); animation-duration: 1.2s; }
body.infect .r2 { border-right-color: var(--accent-2); animation-duration: .9s; }
body.infect .r3 { animation-duration: 2s; }
body.infect .aura {
  background:
    radial-gradient(40% 35% at 30% 40%, rgba(255, 59, 92, .18), transparent 70%),
    radial-gradient(35% 40% at 70% 60%, rgba(255, 138, 61, .12), transparent 70%);
}
body.infect .name::before,
body.infect .name::after { animation-duration: 1.4s; }
body.infect .dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); animation-duration: .6s; }
body.infect main { animation: shake .25s steps(2) infinite; }

@keyframes shake {
  0%   { transform: translate(0, 0); }
  50%  { transform: translate(.6px, -.4px); }
}

footer {
  position: fixed;
  bottom: 24px;
  left: 0;
  right: 0;
  z-index: 1;
  text-align: center;
  font-family: var(--mono);
  font-size: .7rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: rgba(107, 114, 128, .7);
}

.dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: .6em;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 8px #4ade80;
  vertical-align: middle;
  animation: pulse 2.4s ease-in-out infinite;
}

/* --- Animationer --- */

@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes blink   { 50% { opacity: 0; } }
@keyframes shimmer { to { background-position: -250% 0; } }
@keyframes pulse   { 50% { opacity: .45; transform: scale(.85); } }
@keyframes rise    { from { opacity: 0; transform: translateY(16px); filter: blur(6px); } }
@keyframes drift   { to { transform: translate(6%, -4%) rotate(8deg); } }

@keyframes glitch {
  0%, 93%, 100% { opacity: 0; transform: none; clip-path: none; }
  94% { opacity: .8; transform: translate(-3px, 1px); clip-path: inset(10% 0 55% 0); }
  95% { opacity: .8; transform: translate(3px, -1px);  clip-path: inset(60% 0 8% 0); }
  96% { opacity: .6; transform: translate(-2px, 0);    clip-path: inset(35% 0 40% 0); }
  97% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; }
}
