/* =========================================================
   Thorgathis — dark editorial portfolio
   Brand accent: blue (#4a9eff), client-mandated.
   Executed as a single locked accent over cool neutrals
   harmonised to the same hue. No second accent, no glow.
   ========================================================= */

:root {
  /* --- surfaces: one cool gray family, tinted toward the brand hue --- */
  --bg:        #0a0c10;
  --bg-2:      #0e1116;
  --surface:   #12161d;
  --line:      #222834;
  --line-soft: #171c24;

  /* --- text --- */
  --text:    #e6eaf2;
  --muted:   #8d95a6;
  --muted-2: #798195;

  /* --- brand accent, locked for the whole page --- */
  --accent:        #4a9eff;
  --accent-strong: #6fb2ff;   /* hover lift only */
  --accent-deep:   #2f6fd0;   /* borders, dim states */
  --accent-ink:    #06101f;   /* text on accent fill, 6.9:1 */
  --accent-rgb:    74, 158, 255;

  /* --- type ---
     Space Grotesk has no Cyrillic coverage, so it is scoped to the Latin
     wordmark and project names, with Geist as the deliberate fallback
     instead of whatever system-ui happens to be. Russian headings use
     Geist at 600 — one family, hierarchy carried by weight. */
  --display: "Space Grotesk", "Geist", system-ui, sans-serif;
  --heading: "Geist", "Space Grotesk", system-ui, sans-serif;
  --body:    "Geist", "Space Grotesk", system-ui, sans-serif;
  --mono:    "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;

  /* --- radius system, documented and applied everywhere ---
     interactive -> pill · containers -> 16px · micro tags -> 8px */
  --r-pill: 999px;
  --r-lg:   16px;
  --r-sm:   8px;
  --bezel:  6px;   /* outer shell padding; inner radius = --r-lg - --bezel */

  /* --- metrics --- */
  --max: 1140px;
  --pad: clamp(20px, 5vw, 64px);

  --ease: cubic-bezier(.32, .72, 0, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  /* --- z-index scale --- */
  --z-nav:   50;
  --z-noise: 90;
  --z-skip:  120;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 104px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-weight: 400;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }

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

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

.skip {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: var(--z-skip);
  transform: translateY(-180%);
  padding: 10px 18px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--mono);
  font-size: 13px;
  border-radius: var(--r-pill);
  transition: transform .3s var(--ease);
}
.skip:focus-visible { transform: none; }

#nav-sentinel {
  position: absolute;
  top: 0;
  height: 1px;
  width: 100%;
  pointer-events: none;
}

/* =========================================================
   ATMOSPHERE — ambient depth + film grain
   ========================================================= */
.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(90% 55% at 18% -8%, rgba(var(--accent-rgb), .11), transparent 62%),
    radial-gradient(70% 45% at 92% 6%,  rgba(var(--accent-rgb), .05), transparent 60%),
    radial-gradient(120% 85% at 50% 108%, rgba(3, 6, 12, .62), transparent 58%);
}

.noise {
  position: fixed;
  inset: 0;
  z-index: var(--z-noise);
  pointer-events: none;
  opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* =========================================================
   NAV — floating pill, detached from the top edge
   ========================================================= */
.nav {
  position: sticky;
  top: 16px;
  z-index: var(--z-nav);
  display: flex;
  justify-content: center;
  padding: 16px var(--pad) 0;
  pointer-events: none;
}

.nav__pill {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 26px;
  height: 52px;
  padding: 0 5px 0 22px;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  transition: background .45s var(--ease), border-color .45s var(--ease),
              box-shadow .45s var(--ease), backdrop-filter .45s var(--ease);
}
.nav.is-stuck .nav__pill {
  background: rgba(12, 15, 21, .72);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border-color: rgba(255, 255, 255, .07);
  /* tinted to the page hue, never flat black */
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .07),
    0 16px 40px -18px rgba(4, 10, 22, .9);
}

.nav__mark {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--text);
  transition: color .3s var(--ease);
}
.nav__mark:hover { color: var(--accent); }
.nav__caret {
  color: var(--accent);
  animation: blink 1.25s steps(2, start) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.nav__links {
  display: flex;
  gap: 24px;
  font-size: 12.5px;
  color: var(--muted-2);
}
.nav__links a {
  position: relative;
  padding: 4px 0;
  transition: color .3s var(--ease);
}
.nav__links a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .45s var(--ease-out);
}
.nav__links a:hover { color: var(--text); }
.nav__links a.is-active { color: var(--text); }
.nav__links a.is-active::after { transform: scaleX(1); }

.nav__cta {
  font-size: 12.5px;
  padding: 9px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  color: var(--muted);
  transition: border-color .3s var(--ease), color .3s var(--ease),
              background .3s var(--ease), transform .15s var(--ease);
}
.nav__cta:hover { border-color: var(--accent-deep); color: var(--text); background: rgba(var(--accent-rgb), .08); }
.nav__cta:active { transform: scale(.97); }
.nav__cta.is-active { border-color: var(--accent-deep); color: var(--accent); background: rgba(var(--accent-rgb), .1); }

@media (max-width: 760px) {
  .nav__links { display: none; }
  .nav__pill { gap: 18px; }
}

/* =========================================================
   HERO — 4 elements: eyebrow, wordmark, subtext, CTAs
   ========================================================= */
.hero {
  position: relative;
  z-index: 1;
  max-width: var(--max);
  margin: 0 auto;
  /* top padding capped so the hero never floats down the viewport */
  padding: clamp(44px, 8vh, 96px) var(--pad) clamp(48px, 8vh, 88px);
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--accent);
  font-size: 12.5px;
  letter-spacing: .16em;
  text-transform: lowercase;
  margin-bottom: 24px;
  opacity: 0;
  animation: fadeUp .8s var(--ease-out) .1s forwards;
}
.eyebrow__rule {
  width: 34px;
  height: 1px;
  background: currentColor;
  opacity: .55;
}

.hero__name {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(46px, 11.6vw, 138px);
  line-height: .9;
  letter-spacing: -0.04em;
  color: var(--text);
  /* `text-wrap` and `white-space` are both shorthands over text-wrap-mode —
     declaring balance here would silently undo nowrap. */
  white-space: nowrap;
}
@media (max-width: 480px) { .hero__name { white-space: normal; } }
.hero__name .ch { display: inline-block; }
.hero__name .ch.scrambling { color: var(--accent); }

.hero__tag {
  max-width: 42ch;
  margin-top: 34px;
  font-size: clamp(17px, 2.2vw, 21px);
  font-weight: 300;
  line-height: 1.5;
  color: var(--muted);
  text-wrap: pretty;
  opacity: 0;
  animation: fadeUp .8s var(--ease-out) .5s forwards;
}

.hero__cta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 44px;
  opacity: 0;
  animation: fadeUp .8s var(--ease-out) .68s forwards;
}

/* =========================================================
   BUTTONS — pill, with a nested icon well on the primary CTA
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  font-family: var(--mono);
  font-size: 13px;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  transition: transform .25s var(--ease), border-color .3s var(--ease),
              background .3s var(--ease), color .3s var(--ease),
              box-shadow .35s var(--ease);
}
.btn__label { display: block; }

.btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 500;
  padding: 14px 26px;
}
.btn--primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  transform: translateY(-2px);
  box-shadow: 0 14px 34px -12px rgba(var(--accent-rgb), .5);
}
.btn--primary:active { transform: translateY(0) scale(.98); box-shadow: none; }

.btn--ghost {
  color: var(--text);
  padding: 14px 26px;
}
.btn--ghost:hover {
  border-color: var(--accent-deep);
  color: var(--accent);
  background: rgba(var(--accent-rgb), .07);
  transform: translateY(-2px);
}
.btn--ghost:active { transform: translateY(0) scale(.98); }

/* =========================================================
   SECTIONS
   ========================================================= */
.section {
  position: relative;
  z-index: 1;
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(44px, 6vh, 72px) var(--pad) clamp(48px, 7vh, 80px);
}

.section__head {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-bottom: clamp(44px, 7vh, 68px);
}
.section__title {
  font-family: var(--heading);
  font-weight: 600;
  font-size: clamp(26px, 4vw, 42px);
  letter-spacing: -0.03em;
  line-height: 1.1;
  text-wrap: balance;
}
.section__rule {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line), transparent);
}

/* =========================================================
   ABOUT
   ========================================================= */
.about {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: clamp(32px, 6vw, 88px);
}
.about__text p {
  color: var(--muted);
  font-size: 17px;
  font-weight: 300;
  line-height: 1.72;
  margin-bottom: 20px;
  max-width: 62ch;
  text-wrap: pretty;
}
.about__text p:last-child { margin-bottom: 0; }
.about__text strong { color: var(--text); font-weight: 500; }

.about__facts {
  display: flex;
  flex-direction: column;
  font-size: 12.5px;
  align-self: start;
}
.about__facts div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 0;
  border-bottom: 1px solid var(--line-soft);
}
.about__facts div:last-child { border-bottom: 0; }
.about__facts dt { color: var(--muted-2); }
.about__facts dd { color: var(--text); text-align: right; }

@media (max-width: 780px) {
  .about { grid-template-columns: 1fr; }
}
@media (max-width: 440px) {
  /* side-by-side dt/dd cannot shrink past their min-content on small phones */
  .about__facts div { flex-direction: column; gap: 6px; }
  .about__facts dd { text-align: left; }
}

/* =========================================================
   WORK — editorial index list
   ========================================================= */
.work { border-top: 1px solid var(--line-soft); }

.row { border-bottom: 1px solid var(--line-soft); }
.row > a,
.row > .row__inner {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(16px, 3vw, 40px);
  padding: 32px 0;
  transition: padding .5s var(--ease);
}
.row > .row__inner { cursor: default; }
/* accent wash bleeding past the container edges on hover */
.row > a::before {
  content: "";
  position: absolute;
  inset: 0 -24px;
  background: linear-gradient(90deg, rgba(var(--accent-rgb), .08), transparent 72%);
  opacity: 0;
  transition: opacity .5s var(--ease);
  pointer-events: none;
}
.row > a:hover::before { opacity: 1; }
.row > a:hover { padding-left: 20px; }

.row__name {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(22px, 3vw, 30px);
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 9px;
  transition: color .4s var(--ease);
}
.row > a:hover .row__name { color: var(--accent); }

.row__desc {
  color: var(--muted);
  font-size: 14.5px;
  font-weight: 300;
  line-height: 1.6;
  max-width: 56ch;
  text-wrap: pretty;
}

.row__tech { display: flex; flex-wrap: wrap; gap: 7px; justify-content: flex-end; }
.row__tech span {
  font-size: 10.5px;
  color: var(--muted-2);
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  white-space: nowrap;
  transition: border-color .4s var(--ease), color .4s var(--ease);
}
.row > a:hover .row__tech span { border-color: var(--accent-deep); color: var(--muted); }

@media (max-width: 820px) {
  .row > a,
  .row > .row__inner {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 16px;
    align-items: start;
  }
  .row__tech { grid-column: 1 / -1; justify-content: flex-start; }
}

/* Phones: tighten the vertical rhythm between blocks */
@media (max-width: 600px) {
  .nav { display: none; }
  .section { padding: 32px var(--pad) 36px; }
  .hero { padding: 40px var(--pad) 32px; }
  .section__head { margin-bottom: 28px; }
}

/* =========================================================
   STACK — proficiency bars + directions
   ========================================================= */
.stack { display: flex; flex-direction: column; gap: 40px; }
.stack__row { display: grid; grid-template-columns: 150px 1fr; gap: 28px; }
.stack__label {
  font-size: 12px;
  color: var(--muted-2);
  padding-top: 4px;
}

.bars { display: flex; flex-direction: column; gap: 14px; }
.bar { display: grid; grid-template-columns: 120px 1fr 42px; align-items: center; gap: 16px; }
.bar__k { font-size: 13px; color: var(--text); }
.bar__t {
  position: relative; height: 3px;
  background: var(--line); border-radius: 2px; overflow: hidden;
}
.bar__t::after {
  content: ""; position: absolute; inset: 0;
  width: var(--v);
  background: linear-gradient(90deg, var(--accent-strong), var(--accent));
  transform: scaleX(0); transform-origin: left;
  transition: transform 1s var(--ease-out);
}
.reveal.in .bar__t::after { transform: scaleX(1); }
.bar__v { font-size: 12px; color: var(--muted-2); text-align: right; }
.bar__v::after { content: "%"; }

.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tags li {
  font-size: 12.5px;
  color: var(--muted);
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  transition: border-color .3s var(--ease), color .3s var(--ease),
              background .3s var(--ease), transform .25s var(--ease);
}
.tags li:hover {
  border-color: var(--accent-deep);
  color: var(--text);
  background: rgba(var(--accent-rgb), .06);
  transform: translateY(-1px);
}

@media (max-width: 820px) {
  .stack__row { grid-template-columns: 1fr; gap: 14px; }
  .bar { grid-template-columns: 100px 1fr 38px; }
}

/* =========================================================
   CONTACT
   ========================================================= */
.contact__lead {
  font-family: var(--heading);
  font-weight: 500;
  font-size: clamp(23px, 4vw, 36px);
  letter-spacing: -0.03em;
  line-height: 1.25;
  max-width: 36ch;
  margin-bottom: 52px;
  text-wrap: balance;
}

.links {
  /* every row reserves the same trailing slot, so link values line up in
     one column whether the row ends in an arrow or a copy button */
  --action-w: 128px;
  border-top: 1px solid var(--line-soft);
}
.links__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--action-w);
  align-items: center;
  border-bottom: 1px solid var(--line-soft);
}

.links__main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 22px 4px;
  font-size: 14.5px;
  transition: padding .45s var(--ease);
}
/* external rows span the action slot too, keeping the value column identical;
   the 16px column gap eats into the slot, so subtract it */
.links__main--wide {
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1fr) auto calc(var(--action-w) - 16px);
}
.links__main:hover { padding-left: 16px; }

.links__k { color: var(--muted-2); font-size: 12px; letter-spacing: .06em; }
.links__v { color: var(--text); transition: color .3s var(--ease); }
.links__main:hover .links__v { color: var(--accent); }

.links__go {
  justify-self: end;
  color: var(--muted-2);
  font-size: 14px;
  transition: transform .45s var(--ease-out), color .3s var(--ease);
}
.links__main:hover .links__go { transform: translate(3px, -3px); color: var(--accent); }

.links__action { justify-self: end; padding-right: 4px; }

@media (max-width: 620px) {
  .links { --action-w: 104px; }
  .links__k { font-size: 11px; }
  .links__main { font-size: 13px; }
}

.copy {
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .06em;
  color: var(--muted-2);
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 7px 14px;
  cursor: pointer;
  transition: border-color .3s var(--ease), color .3s var(--ease),
              background .3s var(--ease), transform .15s var(--ease);
}
.copy:hover { border-color: var(--accent-deep); color: var(--text); }
.copy:active { transform: scale(.95); }
.copy.is-done { border-color: var(--accent-deep); color: var(--accent); background: rgba(var(--accent-rgb), .1); }
.copy.is-failed { border-color: #7d4638; color: #e0917c; }

.copy__status {
  min-height: 20px;
  margin-top: 16px;
  font-size: 11.5px;
  color: var(--muted-2);
}

/* =========================================================
   FOOTER
   ========================================================= */
.footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--line-soft);
}
.footer__inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 32px var(--pad) 48px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 28px;
  font-size: 11.5px;
  color: var(--muted-2);
}
.footer__nav { display: flex; flex-wrap: wrap; gap: 20px; }
.footer__nav a,
.footer__top { transition: color .3s var(--ease); }
.footer__nav a:hover,
.footer__top:hover { color: var(--accent); }
.footer__top { margin-left: auto; }

@media (max-width: 620px) {
  .footer__top { margin-left: 0; }
}

/* =========================================================
   REVEAL — sections resolve out of a soft blur, children cascade
   ========================================================= */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  filter: blur(6px);
  transition: opacity .9s var(--ease-out), transform .9s var(--ease-out),
              filter .9s var(--ease-out);
}
.reveal.in { opacity: 1; transform: none; filter: blur(0); }

.stagger > * {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .7s var(--ease-out), transform .7s var(--ease-out);
}
.reveal.in .stagger > * { opacity: 1; transform: none; }
.reveal.in .stagger > *:nth-child(1) { transition-delay: .12s; }
.reveal.in .stagger > *:nth-child(2) { transition-delay: .19s; }
.reveal.in .stagger > *:nth-child(3) { transition-delay: .26s; }
.reveal.in .stagger > *:nth-child(4) { transition-delay: .33s; }
.reveal.in .stagger > *:nth-child(5) { transition-delay: .40s; }

@keyframes fadeUp { to { opacity: 1; transform: none; } }
.eyebrow, .hero__tag, .hero__cta { transform: translateY(16px); }

/* =========================================================
   REDUCED MOTION
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    transition-delay: 0ms !important;
  }
  .reveal, .stagger > * { opacity: 1; transform: none; filter: none; }
  .eyebrow, .hero__tag, .hero__cta { opacity: 1; transform: none; }
}

/* Frosted nav needs a solid fallback when transparency is reduced */
@media (prefers-reduced-transparency: reduce) {
  .nav.is-stuck .nav__pill {
    background: var(--bg-2);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}
