/* ═══════════════════════════════════════════════════════════════
   EROZ.IO — Brutalist / Web3 Resume
   Relative Color Syntax · @layer · @property · CSS Grid
   ═══════════════════════════════════════════════════════════════ */

/* ─── LAYERS ─── */
@layer reset, tokens, base, layout, components, utilities, print;

/* ─── ANIMATED CUSTOM PROPERTIES ─── */
@property --accent-h {
  syntax: "<number>";
  inherits: true;
  initial-value: 142;
}

@property --glitch-offset {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}

@property --bar-width {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 0%;
}

@property --marquee-x {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 0%;
}

@property --grain-opacity {
  syntax: "<number>";
  inherits: true;
  initial-value: 0.04;
}

/* ─── RESET ─── */
@layer reset {
  *, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }

  ul, ol { list-style: none; }

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

  button {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    cursor: pointer;
  }

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

/* ─── TOKENS ─── */
@layer tokens {

  :root {
    /* ── Base palette ── */
    --black: #000000;
    --white: #ffffff;
    --raw-white: #f0f0e8;

    /* ── Accent: acid green (dark) / electric blue (light) ── */
    --accent-hsl: var(--accent-h) 90% 50%;
    --accent: hsl(var(--accent-hsl));

    /* ── Font stacks ── */
    --font-mono: "JetBrains Mono", "Fira Code", "SF Mono", monospace;
    --font-display: "Space Grotesk", "JetBrains Mono", sans-serif;

    /* ── Spacing scale ── */
    --space-xs: clamp(0.25rem, 0.5vw, 0.5rem);
    --space-s: clamp(0.5rem, 1vw, 1rem);
    --space-m: clamp(1rem, 2vw, 2rem);
    --space-l: clamp(1.5rem, 3vw, 3rem);
    --space-xl: clamp(2rem, 5vw, 5rem);
    --space-2xl: clamp(3rem, 7vw, 7rem);

    /* ── Border ── */
    --border-w: 3px;
    --border-w-thick: 5px;

    /* ── Timing ── */
    --ease-brutal: cubic-bezier(0.22, 1, 0.36, 1);
    --dur: 0.25s;
  }

  /* ═══ DARK THEME ═══ */
  [data-theme="dark"] {
    --accent-h: 142;                          /* acid green */
    --bg: var(--black);
    --fg: var(--raw-white);
    --fg-muted: hsl(from var(--fg) h s l / 0.45);
    --surface: hsl(from var(--fg) h s 8%);
    --border-color: hsl(from var(--fg) h s l / 0.12);
    --border-loud: hsl(from var(--fg) h s l / 0.25);
    --accent-dim: hsl(from var(--accent) h s calc(l - 15%) / 0.6);
    --accent-glow: hsl(from var(--accent) h s l / 0.15);
    --stat-bg: hsl(from var(--accent) h 60% 8%);
    --grain-opacity: 0.04;
  }

  /* ═══ LIGHT THEME ═══ */
  [data-theme="light"] {
    --accent-h: 235;                          /* electric indigo */
    --bg: var(--raw-white);
    --fg: #0a0a0a;
    --fg-muted: hsl(from var(--fg) h s l / 0.5);
    --surface: hsl(from var(--fg) h s 96%);
    --border-color: hsl(from var(--fg) h s l / 0.15);
    --border-loud: hsl(from var(--fg) h s l / 0.35);
    --accent-dim: hsl(from var(--accent) h s calc(l + 15%) / 0.5);
    --accent-glow: hsl(from var(--accent) h s l / 0.08);
    --stat-bg: hsl(from var(--accent) h 50% 95%);
    --grain-opacity: 0.025;
  }
}

/* ─── BASE ─── */
@layer base {
  html {
    scroll-behavior: smooth;
    scroll-padding-top: var(--space-l);
    scrollbar-color: var(--accent) var(--bg);
    scrollbar-width: thin;
  }

  body {
    font-family: var(--font-mono);
    font-size: clamp(0.8125rem, 0.75rem + 0.25vw, 0.9375rem);
    line-height: 1.6;
    color: var(--fg);
    background-color: var(--bg);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
  }

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

  /* ── Film grain texture ── */
  body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    opacity: var(--grain-opacity);
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 200px;
  }

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

/* ─── LAYOUT ─── */
@layer layout {

  .brutalist-wrapper {
    width: 100%;
    max-width: 1400px;
    margin-inline: auto;
    padding-inline: var(--space-m);
    position: relative;
  }

  /* Grid overlay (decorative scanlines) */
  .grid-overlay {
    position: fixed;
    inset: 0;
    z-index: 9998;
    pointer-events: none;
    background: repeating-linear-gradient(
      to bottom,
      transparent,
      transparent 3px,
      hsl(from var(--fg) h s l / 0.015) 3px,
      hsl(from var(--fg) h s l / 0.015) 4px
    );
  }

  .skip-link {
    position: fixed;
    top: -100%;
    left: var(--space-m);
    z-index: 10000;
    padding: var(--space-xs) var(--space-s);
    background: var(--accent);
    color: var(--bg);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    border: var(--border-w) solid var(--fg);
  }

  .skip-link:focus {
    top: var(--space-s);
    outline: 3px solid var(--accent);
    outline-offset: 2px;
  }
}

/* ─── COMPONENTS ─── */
@layer components {

  /* ════════════════════════════════════════
     HEADER
     ════════════════════════════════════════ */
  .header {
    padding-block: var(--space-xl) var(--space-l);
    border-bottom: var(--border-w-thick) solid var(--fg);
    position: relative;
  }

  .header__brand {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
  }

  .header__name-block {
    position: relative;
  }

  .header__name {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 5vw + 1rem, 6rem);
    font-weight: 700;
    line-height: 0.9;
    letter-spacing: -0.03em;
    text-transform: uppercase;
    position: relative;
  }

  /* Glitch pseudo-element */
  .header__name::after {
    content: attr(data-text);
    position: absolute;
    inset: 0;
    color: var(--accent);
    clip-path: inset(0 0 65% 0);
    transform: translate(var(--glitch-offset), 0);
    opacity: 0;
    transition: opacity var(--dur) var(--ease-brutal);
    pointer-events: none;
    aria-hidden: true;
  }

  .header__name:hover::after,
  .header:hover .header__name::after {
    opacity: 0.7;
    animation: glitch-clip 0.6s steps(3) infinite alternate;
  }

  @keyframes glitch-clip {
    0%   { clip-path: inset(10% 0 60% 0); transform: translate(3px, 0); }
    33%  { clip-path: inset(40% 0 20% 0); transform: translate(-2px, 0); }
    66%  { clip-path: inset(70% 0 5% 0);  transform: translate(4px, 0); }
    100% { clip-path: inset(20% 0 50% 0); transform: translate(-3px, 0); }
  }

  .header__stripe {
    height: var(--border-w-thick);
    background: var(--accent);
    margin-top: var(--space-xs);
    width: clamp(80px, 20vw, 200px);
  }

  .header__meta {
    margin-top: var(--space-s);
  }

  .header__title {
    font-size: clamp(0.875rem, 1vw + 0.25rem, 1.125rem);
    font-weight: 500;
    letter-spacing: 0.02em;
  }

  .header__sep {
    color: var(--accent);
    font-weight: 700;
  }

  .header__location {
    font-size: 0.8125rem;
    color: var(--fg-muted);
    margin-top: 0.25em;
  }

  .header__coords {
    display: inline-block;
    font-size: 0.6875rem;
    letter-spacing: 0.08em;
    color: var(--accent-dim);
    margin-right: var(--space-xs);
    font-variant-numeric: tabular-nums;
  }

  /* ── Theme Toggle ── */
  .header__controls {
    position: absolute;
    top: var(--space-xl);
    right: 0;
  }

  .theme-toggle {
    border: var(--border-w) solid var(--border-loud);
    padding: var(--space-xs) var(--space-s);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    transition: all var(--dur) var(--ease-brutal);
    position: relative;
    overflow: hidden;
  }

  .theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
  }

  .theme-toggle:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
  }

  .theme-toggle__track {
    display: flex;
    gap: var(--space-xs);
    pointer-events: none;
  }

  [data-theme="dark"] .theme-toggle__label--dark { color: var(--accent); }
  [data-theme="dark"] .theme-toggle__label--light { color: var(--fg-muted); }
  [data-theme="light"] .theme-toggle__label--dark { color: var(--fg-muted); }
  [data-theme="light"] .theme-toggle__label--light { color: var(--accent); }


  /* ════════════════════════════════════════
     NAVIGATION
     ════════════════════════════════════════ */
  .nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    margin-top: var(--space-m);
    border-top: 1px solid var(--border-color);
  }

  .nav__link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-s) var(--space-m);
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    transition: all var(--dur) var(--ease-brutal);
    position: relative;
  }

  .nav__link:first-child {
    border-left: 1px solid var(--border-color);
  }

  .nav__link::before {
    content: attr(data-idx);
    font-size: 0.625rem;
    color: var(--fg-muted);
    font-variant-numeric: tabular-nums;
    margin-right: var(--space-xs);
  }

  .nav__link:hover,
  .nav__link:focus-visible {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
  }

  .nav__link:hover::before,
  .nav__link:focus-visible::before {
    color: hsl(from var(--bg) h s l / 0.6);
  }

  .nav__link:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: -3px;
  }


  /* ════════════════════════════════════════
     MARQUEE
     ════════════════════════════════════════ */
  .marquee-section {
    border-bottom: var(--border-w) solid var(--border-color);
    overflow: hidden;
    padding-block: var(--space-s);
  }

  .marquee {
    overflow: hidden;
    white-space: nowrap;
  }

  .marquee__inner {
    display: inline-flex;
    animation: marquee-scroll 25s linear infinite;
    font-family: var(--font-display);
    font-size: clamp(0.875rem, 1.2vw, 1.125rem);
    font-weight: 300;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--fg-muted);
  }

  .marquee__inner span {
    flex-shrink: 0;
    padding-right: 0;
  }

  @keyframes marquee-scroll {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
  }

  @media (prefers-reduced-motion: reduce) {
    .marquee__inner { animation: none; }
  }


  /* ════════════════════════════════════════
     SECTIONS (shared)
     ════════════════════════════════════════ */
  .section {
    padding-block: var(--space-xl);
    border-bottom: var(--border-w) solid var(--border-color);
    animation: fade-up 0.6s var(--ease-brutal) both;
  }

  .section__label {
    display: flex;
    align-items: baseline;
    gap: var(--space-s);
    margin-bottom: var(--space-l);
  }

  .section__title {
    font-family: var(--font-display);
    font-size: clamp(1.75rem, 3vw + 0.5rem, 3.5rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    text-transform: uppercase;
    line-height: 1;
  }

  .section__tag {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    color: var(--accent);
    border: 1px solid var(--accent-dim);
    padding: 0.15em 0.6em;
    vertical-align: super;
    text-transform: uppercase;
  }


  /* ════════════════════════════════════════
     STATS GRID
     ════════════════════════════════════════ */
  .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
    gap: 0;
  }

  .stat {
    border: 1px solid var(--border-color);
    padding: var(--space-m);
    position: relative;
    overflow: hidden;
    transition: all var(--dur) var(--ease-brutal);
    container-type: inline-size;
  }

  .stat:hover {
    background: var(--stat-bg);
    border-color: var(--accent-dim);
  }

  .stat__value {
    font-family: var(--font-display);
    font-size: clamp(1.75rem, 3cqi, 2.75rem);
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.02em;
  }

  .stat__plus {
    color: var(--accent);
    font-weight: 300;
  }

  .stat__label {
    margin-top: var(--space-xs);
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    color: var(--fg-muted);
    text-transform: uppercase;
  }

  .stat__label small {
    display: block;
    font-size: 0.6875rem;
    margin-top: 0.2em;
    color: hsl(from var(--fg-muted) h s l / 0.7);
    text-transform: none;
    letter-spacing: 0;
  }

  .stat__bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: var(--accent);
    transition: width 0.6s var(--ease-brutal);
  }

  .stat:hover .stat__bar {
    width: 100%;
  }

  /* Hero stat */
  .stat--hero {
    border-width: var(--border-w);
    border-color: var(--accent-dim);
  }

  .stat--hero .stat__value {
    color: var(--accent);
  }

  /* Accent stat */
  .stat--accent .stat__value {
    color: var(--accent);
  }


  /* ════════════════════════════════════════
     TIMELINE
     ════════════════════════════════════════ */
  .timeline {
    counter-reset: timeline-counter;
    position: relative;
  }

  /* Vertical line */
  .timeline::before {
    content: "";
    position: absolute;
    top: 0;
    left: clamp(90px, 12vw, 145px);
    bottom: 0;
    width: 1px;
    background: var(--border-color);
  }

  .timeline__item {
    display: grid;
    grid-template-columns: clamp(90px, 12vw, 145px) 1fr;
    gap: 0;
    border-bottom: 1px solid var(--border-color);
    counter-increment: timeline-counter;
    position: relative;
    transition: background var(--dur) var(--ease-brutal);
  }

  .timeline__item:first-child {
    border-top: 1px solid var(--border-color);
  }

  .timeline__item:hover {
    background: var(--accent-glow);
  }

  /* Dot on the vertical line */
  .timeline__item::after {
    content: "";
    position: absolute;
    left: clamp(90px, 12vw, 145px);
    top: 50%;
    width: 9px;
    height: 9px;
    background: var(--bg);
    border: 2px solid var(--fg-muted);
    transform: translate(-50%, -50%) rotate(45deg);
    z-index: 1;
    transition: all var(--dur) var(--ease-brutal);
  }

  .timeline__item:hover::after {
    border-color: var(--accent);
    background: var(--accent);
  }

  .timeline__item--current::after {
    border-color: var(--accent);
    background: var(--accent);
    box-shadow: 0 0 8px hsl(from var(--accent) h s l / 0.5);
  }

  .timeline__date {
    padding: var(--space-m) var(--space-s);
    display: flex;
    align-items: center;
    gap: 0.3em;
    font-variant-numeric: tabular-nums;
    font-size: 0.8125rem;
    color: var(--fg-muted);
  }

  .timeline__year {
    font-weight: 700;
    color: var(--fg);
  }

  .timeline__year--now {
    color: var(--accent);
    font-size: 0.6875rem;
    letter-spacing: 0.1em;
  }

  .timeline__dash {
    color: var(--border-loud);
  }

  .timeline__content {
    padding: var(--space-m);
    border-left: 1px solid var(--border-color);
    padding-left: calc(var(--space-m) + 12px);
  }

  .timeline__role {
    font-family: var(--font-display);
    font-size: clamp(0.9375rem, 1.2vw, 1.125rem);
    font-weight: 600;
    line-height: 1.3;
  }

  .timeline__company {
    font-size: 0.8125rem;
    color: var(--fg-muted);
    margin-top: 0.25em;
  }

  .timeline__impact {
    font-size: 0.8125rem;
    margin-top: var(--space-xs);
    color: hsl(from var(--accent) h s calc(l + 5%));
    letter-spacing: 0.01em;
  }

  .timeline__delta {
    color: hsl(142 70% 50%);
    font-weight: 700;
  }

  .timeline__item--origin .timeline__role {
    font-style: italic;
  }


  /* ════════════════════════════════════════
     STACK / EXPERTISE
     ════════════════════════════════════════ */
  .stack-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
    gap: 0;
  }

  .stack-group {
    border: 1px solid var(--border-color);
    padding: var(--space-m);
    position: relative;
    transition: all var(--dur) var(--ease-brutal);
  }

  .stack-group:hover {
    background: var(--accent-glow);
    border-color: var(--accent-dim);
  }

  .stack-group__title {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: var(--space-s);
    display: flex;
    align-items: baseline;
    gap: var(--space-xs);
  }

  .stack-group__idx {
    font-size: 0.625rem;
    font-weight: 400;
    color: var(--accent);
    letter-spacing: 0.1em;
    font-family: var(--font-mono);
  }

  .stack-group__list li {
    font-size: 0.8125rem;
    padding-block: 0.35em;
    color: var(--fg-muted);
    border-bottom: 1px solid hsl(from var(--border-color) h s l / 0.5);
    transition: color var(--dur) var(--ease-brutal);
  }

  .stack-group__list li:last-child {
    border-bottom: none;
  }

  .stack-group:hover .stack-group__list li {
    color: var(--fg);
  }


  /* ════════════════════════════════════════
     CONTACT
     ════════════════════════════════════════ */
  .contact-block {
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .contact__link {
    display: flex;
    align-items: center;
    gap: var(--space-s);
    padding: var(--space-m);
    border: var(--border-w) solid var(--border-color);
    font-size: clamp(1rem, 1.5vw + 0.25rem, 1.5rem);
    font-weight: 500;
    transition: all var(--dur) var(--ease-brutal);
    position: relative;
    overflow: hidden;
  }

  .contact__link + .contact__link {
    border-top: none;
  }

  .contact__prefix {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--accent);
    flex-shrink: 0;
  }

  .contact__link::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--accent);
    transform: translateX(-101%);
    transition: transform 0.35s var(--ease-brutal);
    z-index: 0;
  }

  .contact__link:hover::after {
    transform: translateX(0);
  }

  .contact__link:hover {
    border-color: var(--accent);
    color: var(--bg);
  }

  .contact__link > * {
    position: relative;
    z-index: 1;
  }

  .contact__link:hover .contact__prefix {
    color: hsl(from var(--bg) h s l / 0.7);
  }

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


  /* ════════════════════════════════════════
     FOOTER
     ════════════════════════════════════════ */
  .footer {
    padding-block: var(--space-l);
    border-top: var(--border-w-thick) solid var(--fg);
  }

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

  .footer__copy {
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    font-weight: 700;
  }

  .footer__status {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 0.625rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--fg-muted);
  }

  .footer__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: hsl(142 80% 50%);
    animation: pulse-dot 2s ease-in-out infinite;
  }

  @keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.3; }
  }


  /* ════════════════════════════════════════
     SCROLL-DRIVEN ANIMATIONS
     ════════════════════════════════════════ */
  @keyframes fade-up {
    from {
      opacity: 0;
      transform: translateY(30px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .section {
    animation: fade-up linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 25%;
  }

  @media (prefers-reduced-motion: reduce) {
    .section {
      animation: none;
      opacity: 1;
      transform: none;
    }
  }


  /* ════════════════════════════════════════
     FOCUS STYLES
     ════════════════════════════════════════ */
  :is(a, button, input, textarea, select):focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
  }


  /* ════════════════════════════════════════
     RESPONSIVE
     ════════════════════════════════════════ */
  @media (max-width: 640px) {
    .header__controls {
      position: static;
      margin-top: var(--space-s);
    }

    .timeline::before {
      display: none;
    }

    .timeline__item {
      grid-template-columns: 1fr;
    }

    .timeline__item::after {
      display: none;
    }

    .timeline__content {
      border-left: 3px solid var(--accent-dim);
      padding-left: var(--space-m);
    }

    .timeline__date {
      padding-bottom: 0;
    }

    .nav__link {
      padding: var(--space-xs) var(--space-s);
      font-size: 0.75rem;
    }

    .stats-grid {
      grid-template-columns: repeat(2, 1fr);
    }

    .contact__link {
      flex-direction: column;
      align-items: flex-start;
      gap: var(--space-xs);
    }
  }

  @media (max-width: 400px) {
    .stats-grid {
      grid-template-columns: 1fr;
    }
  }
}

/* ─── PRINT ─── */
@layer print {
  @media print {
    *,
    *::before,
    *::after {
      background: transparent !important;
      color: #000 !important;
      box-shadow: none !important;
    }

    body::after,
    .grid-overlay,
    .marquee-section,
    .theme-toggle,
    .footer__status,
    .skip-link {
      display: none !important;
    }

    body {
      font-size: 10pt;
      line-height: 1.4;
    }

    .brutalist-wrapper {
      max-width: 100%;
      padding: 0;
    }

    .header {
      padding-block: 0.5cm;
    }

    .header__name {
      font-size: 24pt;
    }

    .section {
      padding-block: 0.5cm;
      page-break-inside: avoid;
    }

    .stats-grid {
      grid-template-columns: repeat(3, 1fr);
    }

    .nav {
      display: none;
    }

    .contact__link::after {
      display: none;
    }

    a[href^="http"]::after {
      content: " (" attr(href) ")";
      font-size: 8pt;
      color: #555 !important;
    }
  }
}
