/* ============================================================
   SayDev – saydev.se
   Dark circuit-world extended from the hero video.
   ============================================================ */

/* ---------- Fonts (self-hosted, variable) ---------- */
@font-face {
  font-family: "Instrument Sans";
  src: url("../fonts/InstrumentSans-var.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("../fonts/JetBrainsMono-var.woff2") format("woff2");
  font-weight: 400 500;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --bg: #0a0f1e;
  --navy: #0b1220;
  --navy-raise: #0e1628;
  --cyan: #06b6d4;
  --cyan-bright: #22d3ee;
  --white: #f8fafc;
  --text: #dbe3ee;
  --text-dim: #94a3b8;
  --line: rgba(148, 163, 184, 0.14);
  --line-faint: rgba(148, 163, 184, 0.08);

  --font-sans: "Instrument Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Mono", ui-monospace, monospace;

  --space-2xs: 0.5rem;
  --space-xs: 0.75rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2.5rem;
  --space-xl: 4rem;
  --space-section: clamp(5rem, 12vw, 9rem);

  --radius: 10px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --glow: 0 0 0 1px rgba(34, 211, 238, 0.35), 0 0 28px rgba(34, 211, 238, 0.22);
}

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

html {
  color-scheme: dark;
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.65;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

a {
  color: var(--cyan-bright);
  text-decoration: none;
}

::selection {
  background: rgba(6, 182, 212, 0.35);
  color: var(--white);
}

:focus-visible {
  outline: 2px solid var(--cyan-bright);
  outline-offset: 3px;
  border-radius: 2px;
}

.container {
  width: min(100% - clamp(2rem, 6vw, 5rem), 72rem);
  margin-inline: auto;
}

/* ---------- Typography ---------- */
h1,
h2,
h3 {
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.12;
  color: var(--white);
  text-wrap: balance;
}

h2 {
  font-size: clamp(1.875rem, 1.3rem + 2.6vw, 2.75rem);
}

h3 {
  font-size: 1.25rem;
  line-height: 1.3;
}

p {
  max-width: 65ch;
  text-wrap: pretty;
}

.section-kicker {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cyan-bright);
  margin-bottom: var(--space-xs);
}

.section-lead {
  margin-top: var(--space-sm);
  font-size: 1.125rem;
  color: var(--text-dim);
}

.section {
  padding-block: var(--space-section);
}

.section-head {
  margin-bottom: clamp(2.5rem, 6vw, 4rem);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Scroll progress ---------- */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 60;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan), var(--cyan-bright));
  transform: scaleX(0);
  transform-origin: 0 50%;
}

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 100;
  padding: 0.75rem 1.25rem;
  background: var(--cyan);
  color: #04141b;
  font-weight: 600;
  border-radius: 0 0 var(--radius) var(--radius);
}

.skip-link:focus {
  top: 0;
}

/* ---------- Header ---------- */
.site-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 50;
  padding-block: 0.875rem;
  transition: background-color 300ms ease, border-color 300ms ease;
  border-bottom: 1px solid transparent;
}

.site-header.scrolled {
  background: rgba(10, 15, 30, 0.92);
  border-bottom-color: var(--line-faint);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
}

.brand-glyph {
  display: inline-block;
  text-align: center;
}

.brand-caret {
  display: inline-block;
  width: 0.5em;
  height: 0.14em;
  margin-left: 0.12em;
  background: var(--cyan-bright);
  vertical-align: baseline;
  animation: caret-blink 1.2s steps(1) infinite;
}

@keyframes caret-blink {
  50% {
    opacity: 0;
  }
}

.brand-word {
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  line-height: 1;
}

.brand-say {
  color: var(--white);
}

.brand-dev {
  color: var(--cyan-bright);
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: clamp(1.25rem, 3vw, 2.25rem);
  list-style: none;
  padding: 0;
}

.nav-menu a {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text);
  padding-block: 0.5rem;
  transition: color 150ms ease;
}

.nav-menu a:hover {
  color: var(--cyan-bright);
}

.nav-cta {
  border: 1px solid rgba(34, 211, 238, 0.5);
  border-radius: var(--radius);
  padding: 0.5rem 1rem !important;
  color: var(--cyan-bright) !important;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.nav-cta:hover {
  border-color: var(--cyan-bright);
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.25);
}

/* Mobile toggle */
.nav-toggle {
  display: none;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  padding: 0.5rem 0.875rem;
  cursor: pointer;
}

.nav-toggle-box {
  position: relative;
  width: 16px;
  height: 10px;
}

.nav-toggle-line,
.nav-toggle-box::before,
.nav-toggle-box::after {
  content: "";
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
  transition: transform 200ms var(--ease-out), opacity 150ms ease;
}

.nav-toggle-box::before {
  top: 0;
}

.nav-toggle-line {
  top: 4px;
}

.nav-toggle-box::after {
  top: 8px;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-box::before {
  transform: translateY(4px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle-line {
  opacity: 0;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-box::after {
  transform: translateY(-4px) rotate(-45deg);
}

@media (max-width: 47.99em) {
  .nav-toggle {
    display: inline-flex;
  }

  .nav-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: rgba(10, 15, 30, 0.98);
    border-bottom: 1px solid var(--line-faint);
    padding: 0.5rem clamp(1rem, 3vw, 2.5rem) 1.25rem;
    opacity: 0;
    transform: translateY(-8px);
    visibility: hidden;
    transition: opacity 250ms ease, transform 250ms var(--ease-out), visibility 0s 250ms;
  }

  .site-header.menu-open .nav-menu {
    opacity: 1;
    transform: none;
    visibility: visible;
    transition-delay: 0s;
  }

  .site-header.menu-open {
    background: rgba(10, 15, 30, 0.98);
  }

  .nav-menu a {
    display: block;
    padding: 0.875rem 0.25rem;
    border-bottom: 1px solid var(--line-faint);
  }

  .nav-menu li:last-child a {
    border-bottom: 0;
  }

  .nav-cta {
    border: 0;
    margin-top: 0.5rem;
    padding: 0.875rem 0.25rem !important;
  }
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  background:
    radial-gradient(90rem 55rem at 68% 30%, #101a33, transparent 65%),
    radial-gradient(50rem 35rem at 15% 85%, rgba(6, 182, 212, 0.07), transparent 60%),
    var(--bg);
}

.hero-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: pan-y;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(42rem 26rem at 18% 78%, rgba(10, 15, 30, 0.5), transparent 65%),
    linear-gradient(
      180deg,
      rgba(10, 15, 30, 0.5) 0%,
      rgba(10, 15, 30, 0.04) 26%,
      rgba(10, 15, 30, 0.04) 58%,
      rgba(10, 15, 30, 0.3) 82%,
      rgba(10, 15, 30, 0.72) 93%,
      var(--bg) 100%
    );
}

@media (max-width: 47.99em) {
  .hero-overlay {
    background:
      linear-gradient(
        180deg,
        rgba(10, 15, 30, 0.62) 0%,
        rgba(10, 15, 30, 0.42) 30%,
        rgba(10, 15, 30, 0.58) 55%,
        rgba(10, 15, 30, 0.9) 82%,
        var(--bg) 100%
      );
  }

  /* The HTML overlay already carries the name; the in-scene wordmark
     collides with the CTAs on narrow crops */
  .hero-scene .wordmark {
    display: none;
  }
}

.hero-content {
  position: relative;
  z-index: 1;
  padding-block: clamp(6rem, 16vh, 9rem) clamp(5.5rem, 14vh, 8rem);
}

/* emblem: isometric wireframe cube, cyan -> blue -> violet */
.emblem {
  display: block;
  width: clamp(84px, 9vw, 124px);
  height: auto;
}

.emblem-sm {
  width: 27px;
  height: 27px;
}

/* big logotype that arrives on load and stays */
.hero-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: clamp(0.875rem, 2.5vh, 1.5rem);
  margin-bottom: clamp(1rem, 3vh, 2rem);
}

.hero-brand .brand-word {
  font-size: clamp(3.25rem, 2rem + 7vw, 6.5rem);
  letter-spacing: -0.03em;
}

.hero-brand .brand-caret {
  width: 0.45em;
  height: 0.13em;
  margin-left: 0.14em;
}

/* header logo appears once the hero is scrolled past */
.site-header .brand {
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 300ms ease, transform 300ms var(--ease-out);
}

.site-header.scrolled .brand {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.hero-kicker {
  font-family: var(--font-mono);
  font-size: clamp(0.875rem, 0.8rem + 0.4vw, 1.0625rem);
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text);
  margin-bottom: var(--space-sm);
  min-height: 1.65em;
}

.hero-kicker .prompt {
  color: var(--cyan-bright);
  margin-right: 0.75ch;
}

.type-caret {
  display: inline-block;
  width: 0.55ch;
  height: 1.05em;
  margin-left: 0.15ch;
  background: var(--cyan-bright);
  vertical-align: text-bottom;
  animation: caret-blink 1s steps(1) infinite;
}

.hero-title {
  font-size: clamp(2.5rem, 1.6rem + 5.4vw, 4.75rem);
  margin-bottom: var(--space-sm);
  text-shadow: 0 2px 24px rgba(10, 15, 30, 0.65);
}

.hero-lead {
  max-width: 46ch;
  font-size: clamp(1.0625rem, 1rem + 0.4vw, 1.25rem);
  color: var(--text);
  margin-bottom: var(--space-lg);
  text-shadow: 0 1px 14px rgba(10, 15, 30, 0.8);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

/* Scroll cue */
.scroll-cue {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: 1.5rem;
  translate: -50% 0;
  padding: 0.5rem;
}

.scroll-cue-track {
  display: block;
  width: 22px;
  height: 36px;
  border: 1.5px solid rgba(248, 250, 252, 0.45);
  border-radius: 11px;
  position: relative;
  transition: border-color 150ms ease;
}

.scroll-cue:hover .scroll-cue-track {
  border-color: var(--cyan-bright);
}

.scroll-cue-dot {
  position: absolute;
  left: 50%;
  top: 6px;
  width: 4px;
  height: 8px;
  margin-left: -2px;
  border-radius: 2px;
  background: var(--cyan-bright);
  animation: cue-fall 2.2s var(--ease-out) infinite;
}

@keyframes cue-fall {
  0% {
    transform: translateY(0);
    opacity: 0;
  }
  25% {
    opacity: 1;
  }
  65% {
    transform: translateY(12px);
    opacity: 0;
  }
  100% {
    transform: translateY(12px);
    opacity: 0;
  }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0.75rem 1.75rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0;
  transition: background-color 150ms ease, color 150ms ease,
    border-color 150ms ease, box-shadow 200ms ease, transform 150ms var(--ease-out);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--cyan);
  color: #04141b;
  border: 1px solid transparent;
}

.btn-primary:hover {
  background: var(--cyan-bright);
  box-shadow: var(--glow);
}

.btn-ghost {
  border: 1px solid rgba(248, 250, 252, 0.28);
  color: var(--white);
}

.btn-ghost:hover {
  border-color: var(--cyan-bright);
  color: var(--cyan-bright);
}

/* ---------- Tjänster ---------- */
.services {
  position: relative;
}

.service-grid {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17.5rem), 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  overflow: hidden;
}

.service {
  position: relative;
  overflow: hidden;
  background: var(--navy);
  padding: clamp(1.75rem, 4vw, 2.5rem);
  transition: background-color 250ms ease;
}

.service:hover {
  background: var(--navy-raise);
}

/* pointer/finger-tracked glow */
.service::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    220px circle at var(--px, 50%) var(--py, 50%),
    rgba(34, 211, 238, 0.14),
    transparent 65%
  );
  opacity: 0;
  transition: opacity 350ms ease;
}

.service.lit::after,
.service:hover::after {
  opacity: 1;
}

.service-icon {
  color: var(--cyan);
  margin-bottom: var(--space-md);
  transition: color 250ms ease, filter 250ms ease;
}

.service:hover .service-icon {
  color: var(--cyan-bright);
  filter: drop-shadow(0 0 10px rgba(34, 211, 238, 0.45));
}

.service h3 {
  margin-bottom: var(--space-2xs);
}

.service p {
  color: var(--text-dim);
  font-size: 0.9688rem;
}

/* ---------- Så jobbar vi ---------- */
.process {
  background:
    radial-gradient(60rem 30rem at 70% 0%, rgba(6, 182, 212, 0.05), transparent 60%),
    var(--navy);
  border-block: 1px solid var(--line-faint);
}

.steps {
  list-style: none;
  counter-reset: step;
  padding: 0;
  display: grid;
  gap: clamp(2.5rem, 5vw, 2rem);
}

@media (min-width: 48em) {
  .steps {
    grid-template-columns: repeat(3, 1fr);
  }
}

.step {
  position: relative;
  padding-top: 4.25rem;
}

.step-node {
  position: absolute;
  top: 0;
  left: 0;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  border: 1px solid rgba(34, 211, 238, 0.4);
  background: var(--bg);
  display: grid;
  place-items: center;
  box-shadow: 0 0 16px rgba(34, 211, 238, 0.12);
}

.step-num {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 1rem;
  color: var(--cyan-bright);
}

/* connecting trace */
.step::before {
  content: "";
  position: absolute;
  background: linear-gradient(90deg, rgba(34, 211, 238, 0.35), rgba(34, 211, 238, 0.08));
}

@media (min-width: 48em) {
  .step::before {
    top: 1.5rem;
    left: 3.75rem;
    right: 0.75rem;
    height: 1px;
  }

  .step:last-child::before {
    display: none;
  }
}

@media (max-width: 47.99em) {
  .step::before {
    left: 1.5rem;
    top: 3.75rem;
    bottom: -2rem;
    width: 1px;
    background: linear-gradient(180deg, rgba(34, 211, 238, 0.35), rgba(34, 211, 238, 0.08));
  }

  .step:last-child::before {
    display: none;
  }
}

.step h3 {
  margin-bottom: var(--space-2xs);
}

.step p {
  color: var(--text-dim);
  font-size: 0.9688rem;
  max-width: 38ch;
}

/* ---------- Om ---------- */
.about-grid {
  display: grid;
  gap: clamp(2rem, 5vw, 5rem);
}

@media (min-width: 48em) {
  .about-grid {
    grid-template-columns: 5fr 6fr;
    align-items: start;
  }
}

.about-big {
  margin-top: var(--space-sm);
  font-size: clamp(1.5rem, 1.1rem + 2vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--white);
  max-width: 18ch;
}

.about-copy p + p {
  margin-top: var(--space-sm);
}

.about-sign {
  margin-top: var(--space-md) !important;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--cyan-bright);
}

/* ---------- Kontakt ---------- */
.contact {
  background:
    radial-gradient(50rem 26rem at 20% 100%, rgba(6, 182, 212, 0.06), transparent 60%),
    var(--bg);
  border-top: 1px solid var(--line-faint);
}

.contact-grid {
  display: grid;
  gap: clamp(2.5rem, 6vw, 5rem);
}

@media (min-width: 48em) {
  .contact-grid {
    grid-template-columns: 7fr 4fr;
  }
}

.field {
  margin-bottom: var(--space-md);
}

.field label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin-bottom: 0.375rem;
}

.field input,
.field textarea {
  width: 100%;
  background: var(--navy);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--white);
  font: inherit;
  padding: 0.75rem 1rem;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.field textarea {
  resize: vertical;
  min-height: 8rem;
}

.field input:focus-visible,
.field textarea:focus-visible {
  outline: none;
  border-color: var(--cyan-bright);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.18);
}

.field input[aria-invalid="true"],
.field textarea[aria-invalid="true"] {
  border-color: #f87171;
}

.field-error {
  margin-top: 0.375rem;
  font-size: 0.875rem;
  color: #fca5a5;
}

.form-note {
  margin-top: var(--space-sm);
  font-size: 0.875rem;
  color: var(--text-dim);
}

.form-status {
  margin-top: var(--space-sm);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9375rem;
}

.form-status.ok {
  background: rgba(74, 222, 128, 0.1);
  border: 1px solid rgba(74, 222, 128, 0.35);
  color: #86efac;
}

.form-status.err {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #fca5a5;
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.contact-label {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.25rem;
}

.contact-label + p,
.contact-mail {
  margin-bottom: var(--space-md);
}

.contact-mail a {
  font-size: clamp(1.25rem, 1rem + 1.2vw, 1.625rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--white);
  transition: color 150ms ease;
}

.contact-mail a:hover {
  color: var(--cyan-bright);
}

.contact-link {
  color: var(--text);
  border-bottom: 1px solid rgba(34, 211, 238, 0.4);
  transition: color 150ms ease, border-color 150ms ease;
}

.contact-link:hover {
  color: var(--cyan-bright);
  border-color: var(--cyan-bright);
}

.contact-blurb {
  color: var(--text-dim);
  font-size: 0.9375rem;
  max-width: 28ch;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line-faint);
  padding-block: var(--space-lg);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.site-footer .brand-word {
  font-size: 1.0625rem;
}

.footer-legal {
  font-size: 0.875rem;
  color: var(--text-dim);
}

.footer-legal a {
  color: var(--text-dim);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 150ms ease;
}

.footer-legal a:hover {
  color: var(--cyan-bright);
}

/* ---------- Scroll reveals (JS adds .js on <html>) ---------- */
.js .reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 700ms ease, transform 700ms var(--ease-out);
  transition-delay: calc(var(--i, 0) * 90ms);
}

.js .reveal.in {
  opacity: 1;
  transform: none;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .brand-caret,
  .type-caret {
    animation: none;
  }

  [data-magnetic] {
    transform: none !important;
  }

  .js .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .scroll-cue-dot {
    animation: none;
    opacity: 0.8;
    transform: translateY(4px);
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
