:root {
  --bg: #1a1a1a;
  --text: #e6e6e6;
  --muted: #a8a8a8;
  --accent: #ff4d6d;
  --accent-soft: #ff7a93;
  --pad: clamp(1.5rem, 5vw, 3rem);
  --robot: min(130vw, max(1024px, 100vh));
  --robot-opacity: 1;
}

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

body {
  margin: 0;
  background: var(--bg) url("img/bg-repeat.jpg") repeat;
  color: var(--text);
  font-family: "Saira", sans-serif;
  font-size: 1rem;
  line-height: 1.6;
}

/* Scanlines for a CRT feel: they crawl down, with a rolling band. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.03) 0,
    rgba(255, 255, 255, 0.03) 1px,
    transparent 1px,
    transparent 3px
  ) 0 0 / 100% 3px repeat;
  animation: scan-crawl 0.5s linear infinite;
}

/* VHS tape grain that flickers by jumping the noise tile around. */
html::after {
  content: "";
  position: fixed;
  inset: -50%;
  z-index: 99;
  pointer-events: none;
  opacity: 0.08;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: vhs-grain 0.5s steps(1) infinite;
}

/* Two soft bands sweeping down at the same speed; negative delay offsets the second by half a cycle. */
body::before,
html::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: 140px;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent, rgba(162, 192, 207, 0.06), transparent);
  animation: scan-roll 9s linear infinite;
}

html::before {
  animation-delay: -4.5s;
}

a {
  color: inherit;
  text-decoration: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

/* Hero */
.hero {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: flex-end;
  min-height: 100vh;
  min-height: 100svh;
  overflow: hidden;
  padding: var(--pad);
  animation: vhs-jitter 7s steps(1) infinite;
}

/* Robot sits 25% off the right edge; the mask fades its edges into the background. */
.hero::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: calc(var(--robot) * 0.07);
  right: calc(var(--robot) / -4);
  width: var(--robot);
  height: var(--robot);
  background: url("img/soulbot2.jpeg") center / cover no-repeat;
  -webkit-mask-image: radial-gradient(closest-side, #000 80%, transparent 100%);
  mask-image: radial-gradient(closest-side, #000 80%, transparent 100%);
  pointer-events: none;
  animation: fade-in 1.5s ease-out both, drift 6s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Darkens the bottom so the text stays legible over the tiles and robot. */
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(to top, rgba(10, 10, 10, 0.75), transparent 55%);
}

.title-block {
  position: relative;
  z-index: 2;
  max-width: 100%;
  text-shadow: -2px 0 rgba(255, 40, 80, 0.5), 2px 0 rgba(0, 220, 255, 0.5), 0 0 8px rgba(162, 192, 207, 0.5);
  animation: vhs-split 7s ease-in-out infinite;
}

.accent-rule {
  width: 64px;
  height: 3px;
  margin-bottom: 1.25rem;
  background: #a8d4ee;
  box-shadow: 0 0 10px rgba(168, 212, 238, 0.6);
  animation: fade-down 0.9s ease-out both;
}

h1 {
  margin: 0 0 0.75rem;
  color: #fff;
  font-weight: 600;
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  line-height: 1.1;
  letter-spacing: 0.02em;
  animation: fade-down 0.9s ease-out 0.1s both;
}

.subtitle {
  animation: fade-down 0.9s ease-out 0.3s both;
}

.subtitle p {
  /* Width is 35 monospace chars (the subtitle length) so the border cursor tracks the typed text. */
  --typed-width: calc(35 * (1ch + 0.04em));
  display: inline-block;
  box-sizing: content-box;
  width: var(--typed-width);
  margin: 0;
  overflow: hidden;
  white-space: nowrap;
  border-right: 0.35em solid #fff;
  color: #ddd;
  font-family: "VT323", monospace;
  font-size: min(clamp(1.5rem, 3.2vw, 2.25rem), calc((100vw - 2 * var(--pad)) / 16));
  line-height: 1.2;
  letter-spacing: 0.04em;
  animation: type 1.6s steps(35, end) 0.8s both, blink 1s steps(1) infinite;
}

.contact {
  display: inline-block;
  margin-top: 1.25rem;
  padding: 0.15rem 1.1rem 0.25rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-family: "VT323", monospace;
  font-size: 1.5rem;
  letter-spacing: 0.05em;
  text-shadow: 0 0 8px rgba(255, 77, 109, 0.5);
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
  animation: fade-down 0.9s ease-out 2.2s both;
}

.contact:hover {
  border-color: var(--accent-soft);
  background: rgba(255, 77, 109, 0.12);
  color: var(--accent-soft);
  text-shadow: 0 0 8px rgba(255, 122, 147, 0.5);
}

/* Services */
.services {
  padding: clamp(3rem, 8vw, 6rem) var(--pad);
  background: linear-gradient(to bottom, rgba(10, 10, 10, 0.75), rgba(10, 10, 10, 0.9));
}

.eyebrow {
  margin: 0 0 2rem;
  color: var(--muted);
  font-family: "VT323", monospace;
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  max-width: 1100px;
}

.card {
  padding: 1.75rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.card:hover {
  border-color: rgba(255, 77, 109, 0.5);
  box-shadow: 0 0 20px rgba(255, 77, 109, 0.12);
}

.card-index {
  color: var(--accent);
  font-family: "VT323", monospace;
  font-size: 1.5rem;
  letter-spacing: 0.1em;
}

.card h3 {
  margin: 0.25rem 0 0.75rem;
  color: #fff;
  font-size: 1.25rem;
  font-weight: 600;
}

.card p {
  margin: 0;
  color: var(--muted);
}

/* Footer */
footer {
  padding: 1.5rem var(--pad);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(10, 10, 10, 0.9);
  color: #888;
  font-family: "VT323", monospace;
  font-size: 1.25rem;
  letter-spacing: 0.05em;
}

footer a:hover {
  color: var(--accent);
}

@media (max-width: 700px) {
  :root {
    --robot-opacity: 0.5;
  }
}

@keyframes scan-crawl {
  to { background-position-y: 3px; }
}

@keyframes scan-roll {
  from { transform: translateY(-140px); }
  to { transform: translateY(100vh); }
}

@keyframes vhs-grain {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-5%, -10%); }
  40% { transform: translate(7%, 4%); }
  60% { transform: translate(-9%, 8%); }
  80% { transform: translate(4%, -6%); }
}

@keyframes vhs-split {
  0%, 100% { text-shadow: -1px 0 rgba(255, 40, 80, 0.45), 1px 0 rgba(0, 220, 255, 0.45), 0 0 8px rgba(162, 192, 207, 0.5); }
  50% { text-shadow: -2px 0 rgba(255, 40, 80, 0.55), 2px 0 rgba(0, 220, 255, 0.55), 0 0 8px rgba(162, 192, 207, 0.5); }
  95% { text-shadow: -6px 0 rgba(255, 40, 80, 0.7), 6px 0 rgba(0, 220, 255, 0.7), 0 0 8px rgba(162, 192, 207, 0.5); }
  97% { text-shadow: -1px 0 rgba(255, 40, 80, 0.45), 1px 0 rgba(0, 220, 255, 0.45), 0 0 8px rgba(162, 192, 207, 0.5); }
}

/* Brief tracking error; times with the RGB split spike above. */
@keyframes vhs-jitter {
  0%, 96.5%, 100% { transform: none; }
  95% { transform: translateX(-4px); }
  95.7% { transform: translateX(3px) skewX(1deg); }
  96% { transform: translateX(-2px); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: var(--robot-opacity); }
}

@keyframes drift {
  from { transform: translate(calc(var(--robot) * 0.06), calc(var(--robot) * 0.06)); }
  to { transform: translate(0, 0); }
}

@keyframes fade-down {
  from { opacity: 0; transform: translateY(-16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes type {
  from { width: 0; }
  to { width: var(--typed-width); }
}

@keyframes blink {
  50% { border-color: transparent; }
}

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