/* ==========================================================================
   Oleksandr Fishchuk — Portfolio
   Design tokens
   ========================================================================== */

:root {
  /* Color */
  --bg-void: #040705;          /* base background, near-black with a green cast */
  --bg-panel: #0a120d;         /* slightly raised surface (cards, gallery tiles) */
  --code-dim: #0e3d20;         /* dim matrix rain glyphs */
  --code-bright: #3cff7a;      /* bright matrix rain glyphs / accents */
  --ink: #eafff0;              /* base text */
  --ink-hi: #f4fff7;           /* headline text */
  --ink-lo: #8fada0;           /* secondary / supporting text */
  --pill-red: #ff3b46;
  --pill-red-glow: rgba(255, 59, 70, 0.55);
  --pill-blue: #3b8bff;
  --pill-blue-glow: rgba(59, 139, 255, 0.55);

  /* Type */
  --font-display: 'Share Tech Mono', 'IBM Plex Mono', 'Consolas', monospace;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'EB Garamond', 'Georgia', 'Times New Roman', serif;

  /* Layout */
  --max-width: 1280px;
  --gutter: clamp(20px, 5vw, 64px);

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg-void);
  color: var(--ink);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  cursor: url('../assets/img/cursor-retro.png') 2 2, auto;
}

a, button, [role="button"] {
  cursor: url('../assets/img/cursor-retro.png') 2 2, pointer;
}

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

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

button { font-family: inherit; }

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

/* Visible keyboard focus */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--code-bright);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ==========================================================================
   Site nav — CONTACT link, top right, Matrix-styled with a color glitch
   ========================================================================== */

.site-nav {
  position: fixed;
  top: clamp(14px, 3vh, 26px);
  right: clamp(14px, 3vw, 32px);
  z-index: 50;
}

.site-nav__link {
  display: inline-block;
  font-family: var(--font-display);
  font-size: clamp(0.95rem, 2.4vw, 1.2rem);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--code-bright);
  text-decoration: none;
  padding: 0.75em 1.4em;
  border: 1px solid rgba(60, 255, 122, 0.4);
  border-radius: 6px;
  background: rgba(4, 7, 5, 0.55);
  backdrop-filter: blur(6px);
  transition: border-color 0.25s var(--ease-out), background 0.25s var(--ease-out), color 0.25s var(--ease-out);
}

.site-nav__link:hover,
.site-nav__link:focus-visible {
  border-color: #d9ffe6;
  background: rgba(14, 61, 32, 0.55);
  color: #eafff0;
  animation: nav-glitch 0.45s steps(2) infinite;
}

@keyframes nav-glitch {
  0%, 100% { text-shadow: -2px 0 rgba(255, 59, 70, 0.85), 2px 0 rgba(59, 139, 255, 0.85); }
  50% { text-shadow: 2px 0 rgba(255, 59, 70, 0.85), -2px 0 rgba(59, 139, 255, 0.85); }
}

@media (prefers-reduced-motion: reduce) {
  .site-nav__link:hover,
  .site-nav__link:focus-visible {
    animation: none;
  }
}

/* Shared terminal "decoding text" effect — used by the homepage headline
   and the AI-portfolio lightbox title/description (see headline-decode.js) */
.cursor-caret {
  display: inline-block;
  width: 0.55ch;
  margin-left: 2px;
  background: var(--code-bright);
  animation: caret-blink 1s steps(1) infinite;
}

@keyframes caret-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.decode-noise {
  color: rgba(143, 230, 160, 0.55);
  text-shadow: none;
}

/* Constant gentle RGB-split glitch flicker for text — mostly calm with a
   brief flicker every few seconds. Used on the Contact page title and
   available anywhere else via this keyframe. */
/* Same hard jump-cut mechanic as the Contact button's nav-glitch, wrapped
   in a periodic burst. Must be used with `steps(1)` as the animation's
   timing function (see usages) — that's what makes it a sharp glitch
   instead of a smooth fade. */
@keyframes text-glitch-flicker {
  0%, 84% { text-shadow: 0 0 18px rgba(60, 255, 122, 0.35); }
  85% { text-shadow: -4px 0 rgba(255, 59, 70, 1), 4px 0 rgba(59, 139, 255, 1); }
  87% { text-shadow: 4px 0 rgba(255, 59, 70, 1), -4px 0 rgba(59, 139, 255, 1); }
  89% { text-shadow: -4px 0 rgba(255, 59, 70, 1), 4px 0 rgba(59, 139, 255, 1); }
  91% { text-shadow: 4px 0 rgba(255, 59, 70, 1), -4px 0 rgba(59, 139, 255, 1); }
  93% { text-shadow: -3px 0 rgba(255, 59, 70, 0.9), 3px 0 rgba(59, 139, 255, 0.9); }
  95%, 100% { text-shadow: 0 0 18px rgba(60, 255, 122, 0.35); }
}

@media (prefers-reduced-motion: reduce) {
  .contact-title, .headline__name { animation: none; }
}

/* ==========================================================================
   Background — fixed, full-bleed photo, adapts to any screen via `cover`
   ========================================================================== */

#bg-image {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  background-image: url('../assets/img/background-matrix.jpg');
  background-size: cover;
  background-position: center 30%;
  background-repeat: no-repeat;
}

/* subtle vignette so foreground content stays readable over the photo */
.vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 25%, rgba(4,7,5,0) 0%, rgba(4,7,5,0.25) 62%, rgba(4,7,5,0.6) 100%);
}

/* ==========================================================================
   Page transition overlay (glitch / fade between pages)
   ========================================================================== */

#page-transition {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: var(--bg-void);
  pointer-events: none;
  opacity: 0;
}

#page-transition.is-active {
  pointer-events: all;
}

#page-transition.is-active::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(60, 255, 122, 0.06) 0px,
    rgba(60, 255, 122, 0.06) 2px,
    transparent 2px,
    transparent 4px
  );
  animation: glitch-scan 0.18s steps(2) infinite;
}

@keyframes glitch-scan {
  0% { transform: translateY(0); }
  100% { transform: translateY(4px); }
}

/* "Stepping into the booth" — the whole page rushes toward the screen
   before landing on the contact page. Applied to <body> so it carries the
   fixed-position background layers along with it (a CSS transform on an
   ancestor becomes the containing block for its fixed descendants). */
body.is-entering-booth {
  animation: booth-zoom-in 0.6s cubic-bezier(0.55, 0, 0.85, 0.35) forwards;
  overflow: hidden;
}

@keyframes booth-zoom-in {
  0% { transform: scale(1); filter: brightness(1); }
  70% { transform: scale(1.9); filter: brightness(1.3); }
  100% { transform: scale(2.6); filter: brightness(2.2); }
}

@media (prefers-reduced-motion: reduce) {
  body.is-entering-booth { animation: none; }
}

@media (prefers-reduced-motion: reduce) {
  #page-transition.is-active::before { animation: none; }
}

/* ==========================================================================
   Cursor trail (desktop only, injected by JS)
   ========================================================================== */

.cursor-glyph {
  position: fixed;
  z-index: 500;
  pointer-events: none;
  font-family: var(--font-display);
  color: #8fe6a0;
  text-shadow: 0 0 6px rgba(90, 200, 120, 0.8);
  will-change: transform, opacity;
  user-select: none;
}
