/* ============================================================
   RESET
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body, h1, h2, h3, h4, p, figure, blockquote, dl, dd { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img, picture, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }
input, textarea { font: inherit; }

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  /* Backgrounds */
  --bg-base: #0a0a0a;
  --bg-elevated-1: #141414;
  --bg-elevated-2: #1c1c1c;

  /* Accent — acid green */
  --accent: #ccff00;
  --accent-strong: #b4ff39;
  --accent-dark: #8fcc00;
  --accent-glow: rgba(204, 255, 0, 0.35);
  --accent-glow-soft: rgba(204, 255, 0, 0.12);

  /* Text */
  --text-primary: #f5f5f0;
  --text-secondary: #a8a8a0;
  --text-muted: #6b6b65;
  --text-on-accent: #0a0a0a;

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-default: rgba(255, 255, 255, 0.14);
  --border-accent: rgba(204, 255, 0, 0.45);

  /* Header glass background — theme-aware */
  --header-bg: rgba(10, 10, 10, 0.55);

  /* Spacing */
  --space-3xs: 0.25rem;
  --space-2xs: 0.5rem;
  --space-xs: 0.75rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2rem;
  --space-xl: 3rem;
  --space-2xl: 4rem;
  --space-section: clamp(3rem, 8vw, 8rem);

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 999px;

  /* Shadow */
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 40px var(--accent-glow);

  /* Fonts */
  --font-display: "Unbounded", "Arial Black", sans-serif;
  --font-body: "Inter", -apple-system, "Segoe UI", sans-serif;

  /* Fluid type scale */
  --fs-xs: clamp(0.75rem, 0.72rem + 0.15vw, 0.875rem);
  --fs-sm: clamp(0.875rem, 0.83rem + 0.2vw, 1rem);
  --fs-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --fs-md: clamp(1.25rem, 1.1rem + 0.7vw, 1.5rem);
  --fs-lg: clamp(1.75rem, 1.4rem + 1.5vw, 2.5rem);
  --fs-xl: clamp(2.25rem, 1.7rem + 2.5vw, 3.5rem);
  --fs-hero: clamp(2rem, 1.4rem + 2.4vw, 3.25rem);

  --header-height: 84px;
  --ease-smooth: cubic-bezier(.16, 1, .3, 1);
}

/* ============================================================
   BASE
   ============================================================ */
html {
  scroll-behavior: smooth;
}
body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.6;
  overflow-x: hidden;
  transition: background-color 0.3s var(--ease-smooth), color 0.3s var(--ease-smooth);
}
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.01em;
}
section[id], main {
  scroll-margin-top: var(--header-height);
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: var(--text-on-accent);
  padding: var(--space-sm) var(--space-md);
  z-index: 200;
  border-radius: var(--radius-sm);
  font-weight: 600;
}
.skip-link:focus {
  left: var(--space-md);
  top: var(--space-md);
}

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

.container {
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 4vw, 3rem);
}

.accent { color: var(--accent); }

.section {
  padding-block: var(--space-section);
}
.section-eyebrow {
  color: var(--accent);
  font-family: var(--font-display);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: var(--space-sm);
}
.section-title {
  font-size: var(--fs-hero);
  max-width: 24ch;
}
.section-subtitle {
  color: var(--text-secondary);
  font-size: var(--fs-base);
  max-width: 50ch;
  margin-top: var(--space-sm);
}

/* Section header with prev/next controls off to the side (cases section). */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--space-lg);
}

/* ============================================================
   CASE CAROUSEL CONTROLS — prev/next arrows
   ============================================================ */
.case-controls {
  display: flex;
  gap: var(--space-sm);
  flex-shrink: 0;
}
.case-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-default);
  background: var(--bg-elevated-1);
  color: var(--text-primary);
  transition: border-color 0.2s var(--ease-smooth), background-color 0.2s var(--ease-smooth), opacity 0.2s var(--ease-smooth);
}
.case-arrow svg {
  width: 18px;
  height: 18px;
}
.case-arrow:hover {
  border-color: var(--border-accent);
  background: var(--bg-elevated-2);
}
.case-arrow:disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* ============================================================
   ABOUT — tool/skill chips
   ============================================================ */
.about-tools {
  margin-top: var(--space-xl);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}
.tool-chip {
  padding: 0.55rem 1.15rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-default);
  background: var(--bg-elevated-1);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: border-color 0.2s var(--ease-smooth), color 0.2s var(--ease-smooth);
}
.tool-chip:hover {
  border-color: var(--border-accent);
  color: var(--text-primary);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xs);
  padding: 0.9rem 1.75rem;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: var(--fs-sm);
  transition: transform 0.2s var(--ease-smooth), box-shadow 0.2s var(--ease-smooth), background-color 0.2s var(--ease-smooth), color 0.2s var(--ease-smooth);
  white-space: nowrap;
}
.btn--accent {
  background: var(--accent);
  color: var(--text-on-accent);
}
.btn--accent:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
  background: var(--accent-strong);
}
.btn--dark {
  background: var(--bg-base);
  color: var(--text-primary);
}
.btn--dark:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.btn--sm {
  padding: 0.6rem 1.25rem;
}
.btn--block {
  width: 100%;
}

/* ============================================================
   SCROLL-REVEAL ANIMATION
   ============================================================ */
[data-reveal] {
  opacity: 0;
  transition: opacity 0.7s var(--ease-smooth), transform 0.7s var(--ease-smooth);
  transition-delay: calc(var(--i, 0) * 80ms);
  will-change: opacity, transform;
}
[data-reveal="up"] { transform: translateY(28px); }
[data-reveal="scale"] { transform: scale(0.94); }
[data-reveal="fade"] { transform: none; }
[data-reveal="left"] { transform: translateX(-36px); }
[data-reveal="right"] { transform: translateX(36px); }

[data-reveal].is-visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   HEADER / NAV
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border-subtle);
  transition: background-color 0.3s var(--ease-smooth), border-color 0.3s var(--ease-smooth);
}
.header-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-md);
  height: var(--header-height);
}
.logo {
  display: inline-flex;
  grid-column: 1;
  justify-self: start;
  color: var(--text-primary);
  transition: transform 0.2s var(--ease-smooth);
}
.logo:hover {
  transform: translateY(-2px);
}
.logo svg {
  width: 20px;
  height: 20px;
}

.nav-desktop {
  display: flex;
  align-items: center;
  justify-self: center;
  gap: var(--space-lg);
  font-size: var(--fs-sm);
  font-weight: 500;
}
.nav-desktop a {
  position: relative;
  padding-block: 0.25rem;
  color: var(--text-secondary);
  transition: color 0.2s var(--ease-smooth);
}
.nav-desktop a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width 0.25s var(--ease-smooth);
}
.nav-desktop a:hover {
  color: var(--text-primary);
}
.nav-desktop a:hover::after {
  width: 100%;
}

/* Round accent buttons in the header's right slot (CV + Telegram). */
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  grid-column: 3;
  justify-self: end;
}
.header-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--text-on-accent);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  transition: transform 0.2s var(--ease-smooth), box-shadow 0.2s var(--ease-smooth), background-color 0.2s var(--ease-smooth);
}
.header-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
  background: var(--accent-strong);
}
.header-btn svg {
  width: 15px;
  height: 15px;
}


/* ============================================================
   HERO
   ============================================================ */
.hero {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-block: clamp(1.5rem, 3vw, 2.25rem) clamp(3rem, 6vw, 4.5rem);
  min-height: clamp(560px, 88vh, 820px);
}
.hero-grid {
  position: relative;
  z-index: 2;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.hero-copy {
  max-width: 640px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.hero-title {
  font-size: var(--fs-hero);
}
/* Single-line name on desktop only — tablet/mobile keep the natural 2-line wrap. */
@media (min-width: 901px) {
  .hero-copy {
    max-width: 800px;
  }
  .hero-title {
    white-space: nowrap;
    font-size: clamp(2rem, 1.2rem + 2.1vw, 3rem);
  }
}
.hero-role {
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: var(--fs-sm);
  margin-top: var(--space-xs);
}
.hero-subtitle {
  color: var(--text-secondary);
  font-size: var(--fs-base);
  margin-top: var(--space-md);
  max-width: 46ch;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-md);
  margin-top: var(--space-xl);
}
.hero-cta-arrow {
  display: inline-flex;
  margin-left: 0.35rem;
}

/* Animated "scroll down" arrow that replaces the hero CTA button.
   Just the arrow — it gently bobs up and down forever to hint scrolling. */
.hero-scroll {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  filter: drop-shadow(0 0 8px var(--accent-glow));
  animation: hero-scroll-bob 1.8s var(--ease-smooth) infinite;
  transition: transform 0.2s var(--ease-smooth), opacity 0.2s var(--ease-smooth);
}
.hero-scroll svg {
  width: 34px;
  height: 34px;
}
.hero-scroll:hover {
  opacity: 0.7;
}
@keyframes hero-scroll-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(8px); }
}

/* ============ HERO BACKGROUND EFFECT (animated dotted wave, see js/dotted-surface.js) ============ */
.hero-dots {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
.hero-dots canvas {
  display: block;
}

/* ============================================================
   CASE STUDIES — horizontal scroll, square cards
   ============================================================ */
.section--work { overflow: hidden; }

.case-carousel {
  margin-top: var(--space-2xl);
  max-width: 1200px;
  margin-inline: auto;
  cursor: grab;
}
.case-carousel.is-dragging {
  cursor: grabbing;
}
.case-track {
  display: flex;
  gap: var(--space-lg);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-inline: clamp(1.25rem, 4vw, 3rem);
  padding-block: var(--space-2xs) var(--space-lg);
  scrollbar-width: none;
}
.case-track::-webkit-scrollbar { display: none; }

.case-card {
  position: relative;
  flex: 0 0 calc((100% - 2 * var(--space-lg)) / 3);
  aspect-ratio: 5 / 6;
  isolation: isolate;
  user-select: none;
}
/* Clips the photo + text overlay to the rounded card shape. Kept separate
   from .case-card itself so the hover beam (below) can sit just outside the
   card's silhouette instead of being clipped away with everything else. */
.case-card-inner {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-elevated-1);
}
.case-card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}
.case-card-body {
  position: absolute;
  inset: auto 0 0 0;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  background: linear-gradient(to top, rgba(6, 8, 4, 0.95) 0%, rgba(6, 8, 4, 0.68) 55%, transparent 100%);
}
.case-card-body h3 {
  font-size: var(--fs-md);
  color: #f5f5f0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.case-link {
  display: inline-flex;
  align-items: center;
  color: var(--accent);
  font-weight: 600;
  font-size: var(--fs-sm);
}

/* Outline around every card — a thin line tracing a rect just outside the
   card's own silhouette (not clipped by .case-card-inner). Faint grey by
   default; turns accent-green with a soft glow on hover. No animation. */
.case-card-beam {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  overflow: visible;
  pointer-events: none;
}
.case-card-beam-glow {
  fill: none;
  stroke: var(--border-default);
  stroke-width: 1.5;
  filter: none;
  vector-effect: non-scaling-stroke;
  transition: stroke 0.3s var(--ease-smooth), filter 0.3s var(--ease-smooth);
}
.case-card:hover .case-card-beam-glow {
  stroke: var(--accent);
  filter: drop-shadow(0 0 6px var(--accent-glow));
}

/* ============================================================
   EXPERIENCE TIMELINE
   ============================================================ */
.timeline {
  margin-top: var(--space-2xl);
  display: flex;
  flex-direction: column;
}
.timeline-item {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: var(--space-lg);
  padding-block: var(--space-lg);
  border-top: 1px solid var(--border-default);
  transition: border-color 0.25s var(--ease-smooth);
}
.timeline-item:last-child {
  border-bottom: 1px solid var(--border-default);
}
.timeline-item:hover {
  border-color: var(--border-accent);
}
.timeline-date {
  font-family: var(--font-display);
  color: var(--accent);
  font-size: var(--fs-sm);
  letter-spacing: 0.04em;
}
.timeline-body h3 {
  font-size: var(--fs-md);
  margin-bottom: var(--space-3xs);
}
.timeline-role {
  color: var(--accent);
  font-weight: 600;
  font-size: var(--fs-sm);
  margin-bottom: var(--space-xs);
}
.timeline-body p:last-child {
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  max-width: 60ch;
}
.timeline-item--parallel {
  border-top-style: dashed;
}
.timeline-item--parallel:last-child {
  border-bottom-style: dashed;
}
.timeline-item--parallel .timeline-date {
  color: var(--text-muted);
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  position: relative;
  overflow: hidden;
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--space-xl);
}
/* A beam that endlessly sweeps back and forth along the footer's top edge —
   always running, no hover needed. */
.site-footer::before {
  content: "";
  position: absolute;
  top: -1px;
  left: -220px;
  width: 220px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  filter: drop-shadow(0 0 6px var(--accent-glow));
  animation: footer-beam-sweep 8s ease-in-out infinite;
  pointer-events: none;
}
@keyframes footer-beam-sweep {
  0%, 100% { left: -220px; }
  50% { left: 100%; }
}
.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding-bottom: var(--space-lg);
  text-align: center;
}
.footer-tagline {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}
.footer-contacts {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}
.footer-contacts a {
  color: var(--text-secondary);
  transition: color 0.2s var(--ease-smooth);
}
.footer-contacts a:hover {
  color: var(--accent);
}
.footer-contacts span {
  margin-inline: var(--space-2xs);
  color: var(--text-muted);
}
.footer-copyright {
  padding-block: var(--space-lg);
  border-top: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  text-align: center;
}

/* ============================================================
   CASE DETAIL PAGE (cases/*.html)
   ============================================================ */
.case-back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: color 0.2s var(--ease-smooth);
}
.case-back:hover {
  color: var(--accent);
}
.case-back-arrow {
  transition: transform 0.2s var(--ease-smooth);
}
.case-back:hover .case-back-arrow {
  transform: translateX(-3px);
}

.case-hero {
  padding-top: clamp(2.5rem, 6vw, 4rem);
  padding-bottom: clamp(0.5rem, 2vw, 1rem);
}
.case-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-hero);
  color: var(--accent);
  margin-top: var(--space-xl);
}

.case-overview {
  padding-top: clamp(1.5rem, 4vw, 2.5rem);
}
.case-overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2xl);
}
.case-heading {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-lg);
  margin-bottom: var(--space-sm);
}
.case-overview-grid p {
  color: var(--text-secondary);
  font-size: var(--fs-base);
  max-width: 56ch;
}
.case-overview-grid p + p {
  margin-top: var(--space-sm);
}

.case-role {
  margin-top: var(--space-2xl);
  padding-top: var(--space-2xl);
  border-top: 1px solid var(--border-subtle);
}
.case-role > p {
  color: var(--text-secondary);
  font-size: var(--fs-base);
  margin-bottom: var(--space-md);
}
.case-role-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.case-feature {
  display: flex;
  align-items: center;
  gap: var(--space-2xl);
  padding-block: var(--space-2xl);
}
.case-feature:not(:last-child) {
  border-bottom: 1px solid var(--border-subtle);
}
.case-feature--reverse {
  flex-direction: row-reverse;
}
.case-feature-media {
  flex: 0 0 42%;
}
.case-feature-media img {
  width: 100%;
  height: auto;
  display: block;
}
.case-feature-text {
  flex: 1;
  min-width: 0;
}
.case-feature-text h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-lg);
  margin-bottom: var(--space-sm);
}
.case-feature-text p {
  color: var(--text-secondary);
  font-size: var(--fs-base);
  max-width: 46ch;
}
.case-feature-text p + p {
  margin-top: var(--space-sm);
}

.case-results {
  border-top: 1px solid var(--border-subtle);
}
.case-results-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2xl);
}
.case-results-row p {
  color: var(--text-secondary);
  font-size: var(--fs-base);
  max-width: 58ch;
  margin-top: var(--space-sm);
}
.case-next-btn {
  flex-shrink: 0;
}

/* ============================================================
   BREAKPOINT: 900px — tablet
   ============================================================ */
@media (max-width: 900px) {
  .nav-desktop { display: none; }

  .case-card {
    flex-basis: calc((100% - var(--space-lg)) / 2);
  }

  .case-feature,
  .case-feature--reverse {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-lg);
  }
  .case-feature-media {
    flex-basis: auto;
    max-width: 420px;
  }
}

/* ============================================================
   BREAKPOINT: 640px — mobile
   ============================================================ */
@media (max-width: 640px) {
  :root {
    --header-height: 72px;
  }

  .timeline-item {
    grid-template-columns: 1fr;
    gap: var(--space-2xs);
  }

  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .hero-actions .btn {
    width: 100%;
  }

  /* One card per screen, centred with equal gutters on both sides
     (instead of a left-aligned card with a big empty "peek" on the right). */
  .case-track {
    padding-inline: var(--space-md);
    scroll-padding-inline: var(--space-md);
  }
  .case-card {
    flex-basis: calc(100vw - 2 * var(--space-md));
    scroll-snap-align: center;
  }

  .section-head {
    flex-wrap: wrap;
  }
  .case-controls {
    margin-top: var(--space-sm);
  }

  .case-overview-grid {
    grid-template-columns: 1fr;
    gap: var(--space-xl);
  }

  .case-results-row {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-lg);
  }
  .case-next-btn {
    width: 100%;
    justify-content: center;
  }
}
