/* ============ base ============ */
:root {
  --bg: #06080d;
  --surface: rgba(255, 255, 255, 0.03);
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8ecf1;
  --muted: #8b94a3;
  --accent: #5eead4;
  --accent-dim: rgba(94, 234, 212, 0.12);
  --font-sans: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-weight: 300;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

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

/* ============ three.js canvas ============ */
#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
}

/* everything else floats above the canvas */
.nav,
main,
.footer {
  position: relative;
  z-index: 1;
}

/* ============ nav ============ */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem clamp(1.25rem, 5vw, 4rem);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: rgba(6, 8, 13, 0.55);
  border-bottom: 1px solid var(--border);
}

.nav__logo {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.02em;
}

.nav__links {
  display: flex;
  gap: clamp(1rem, 3vw, 2.25rem);
  align-items: center;
}

.nav__links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 400;
  transition: color 0.25s ease;
}

.nav__links a:hover {
  color: var(--text);
}

.nav__gh {
  color: var(--accent) !important;
  font-family: var(--font-mono);
  font-size: 0.85rem !important;
}

/* ============ hero ============ */
.hero {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 clamp(1.25rem, 8vw, 8rem);
  position: relative;
}

.hero__eyebrow {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
}

.hero__title {
  font-size: clamp(2.4rem, 6.5vw, 5rem);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -0.025em;
  max-width: 18ch;
}

/* decrypt effect scaffolding: words never break mid-word, and each
   character box is width-locked so scramble glyphs can't reflow lines */
.dc-word {
  display: inline-block;
  white-space: nowrap;
}

.dc-char {
  display: inline-block;
  text-align: center;
  overflow: hidden;
  vertical-align: bottom;
}

.hero__sub {
  margin-top: 1.75rem;
  max-width: 58ch;
  font-size: clamp(1rem, 1.4vw, 1.15rem);
  color: var(--muted);
}

.hero__cta {
  margin-top: 2.75rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.hero__scroll {
  position: absolute;
  bottom: 2.5rem;
  left: 50%;
  transform: translateX(-50%);
  width: 1px;
  height: 56px;
  overflow: hidden;
}

.hero__scroll span {
  display: block;
  width: 1px;
  height: 100%;
  background: linear-gradient(to bottom, transparent, var(--accent));
  animation: scrollhint 2.2s ease-in-out infinite;
}

@keyframes scrollhint {
  0% { transform: translateY(-100%); }
  60%, 100% { transform: translateY(100%); }
}

/* ============ buttons (terminal bracket style) ============ */
.btn {
  display: inline-block;
  padding: 0.55rem 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.25s ease, letter-spacing 0.25s ease;
}

.btn::before {
  content: "[ ";
  opacity: 0.5;
  transition: opacity 0.25s ease;
}

.btn::after {
  content: " ]";
  opacity: 0.5;
  transition: opacity 0.25s ease;
}

.btn:hover::before,
.btn:hover::after {
  opacity: 1;
}

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

.btn--primary:hover {
  letter-spacing: 0.04em;
  text-shadow: 0 0 24px rgba(94, 234, 212, 0.5);
}

.btn--ghost {
  color: var(--muted);
}

.btn--ghost:hover {
  color: var(--text);
  letter-spacing: 0.04em;
}

/* ============ sections ============ */
.section {
  padding: clamp(5rem, 11vw, 9rem) clamp(1.25rem, 8vw, 8rem);
  max-width: 1240px;
  margin: 0 auto;
}

.section__title {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  margin-bottom: 3rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.section__path {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 400;
  letter-spacing: 0.05em;
}

.section__more {
  margin-top: 2.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.section__more a {
  color: var(--accent);
  text-decoration: none;
}

.section__more a:hover {
  text-decoration: underline;
}

/* ============ work layout: index list + 3D preview ============ */
.work__layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: clamp(2rem, 4vw, 4rem);
  align-items: start;
}

.work__preview {
  position: sticky;
  top: 110px;
  height: 300px;
}

.work__preview canvas {
  width: 100%;
  height: 100%;
  display: block;
}

@media (max-width: 900px) {
  .work__layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .work__preview {
    display: none;
  }
}

/* ============ focus line items (rolling carousel) ============ */
.focus-list {
  /* perspective makes the scroll-driven rotateX read as a rolodex roll */
  perspective: 900px;
  perspective-origin: 50% 50%;
}

.focus-item {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1.1fr) minmax(0, 1.4fr);
  gap: clamp(1rem, 3vw, 2.5rem);
  align-items: baseline;
  padding: clamp(1.6rem, 3.5vw, 2.4rem) 0.25rem;
  border-top: 1px solid var(--border);
  transform-origin: 50% 50%;
  will-change: transform, opacity;
  transition: background 0.3s ease;
}

.focus-item:last-child {
  border-bottom: 1px solid var(--border);
}

.focus-item:hover {
  background: linear-gradient(90deg, var(--accent-dim), transparent 65%);
}

.focus-item__num {
  color: var(--accent);
  font-size: 1.15rem;
  line-height: 1;
}

.focus-item__title {
  font-size: clamp(1.2rem, 2.4vw, 1.7rem);
  font-weight: 500;
  letter-spacing: -0.015em;
}

.focus-item__desc {
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 52ch;
}

@media (max-width: 720px) {
  .focus-item {
    grid-template-columns: 2.25rem minmax(0, 1fr);
  }
  .focus-item__desc {
    grid-column: 2;
  }
}

@media (prefers-reduced-motion: reduce) {
  .focus-item {
    transform: none !important;
    opacity: 1 !important;
  }
}

/* ============ companies (editorial rows) ============ */
.company {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
  gap: clamp(1.5rem, 4vw, 4rem);
  padding: clamp(2.2rem, 4vw, 3.2rem) 0.25rem;
  border-top: 1px solid var(--border);
}

.company:last-child {
  border-bottom: 1px solid var(--border);
}

.company__name {
  font-size: clamp(1.7rem, 3.4vw, 2.6rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.company__role {
  display: block;
  margin-top: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
  letter-spacing: 0.08em;
}

.company__tagline {
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 400;
  margin-bottom: 0.9rem;
}

.company__desc {
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 58ch;
}

.company__platforms {
  margin-top: 1.3rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.company__links {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-top: 0.9rem;
}

@media (max-width: 720px) {
  .company {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.25rem;
  }
}

/* ============ projects (index list) ============ */
.project {
  display: block;
  padding: 1.6rem 0.25rem;
  border-top: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: background 0.3s ease, padding-left 0.3s ease;
}

.work__list .project:last-child {
  border-bottom: 1px solid var(--border);
}

.project:hover {
  background: linear-gradient(90deg, var(--accent-dim), transparent 65%);
  padding-left: 0.9rem;
}

.project__row {
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.project__name {
  font-family: var(--font-mono);
  font-size: clamp(1.05rem, 1.8vw, 1.3rem);
  font-weight: 500;
  transition: color 0.25s ease;
}

.project:hover .project__name {
  color: var(--accent);
}

.project__lang {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  margin-left: auto;
}

.project__lang[data-lang="c"] { color: #93b4f0; }
.project__lang[data-lang="ts"] { color: #7cc7ff; }
.project__lang[data-lang="sol"] { color: #c9b3f5; }

.project__arrow {
  color: var(--muted);
  transition: color 0.25s ease, transform 0.25s ease;
}

.project:hover .project__arrow {
  color: var(--accent);
  transform: translate(2px, -2px);
}

.project__desc {
  margin-top: 0.55rem;
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 62ch;
}

.project__tags {
  margin-top: 1.2rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent);
  opacity: 0.75;
}

.project__stars {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #f5d76e;
  opacity: 0.85;
}

/* ============ writings ============ */
.writing {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr) auto;
  gap: clamp(1rem, 3vw, 2.5rem);
  align-items: baseline;
  padding: 1.35rem 0.25rem;
  border-top: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: background 0.3s ease, padding-left 0.3s ease;
}

.writing:last-of-type {
  border-bottom: 1px solid var(--border);
}

.writing:hover {
  background: linear-gradient(90deg, var(--accent-dim), transparent 65%);
  padding-left: 0.9rem;
}

.writing__date {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

.writing__title {
  font-size: clamp(1rem, 1.6vw, 1.15rem);
  font-weight: 400;
  letter-spacing: -0.01em;
  transition: color 0.25s ease;
}

.writing:hover .writing__title {
  color: var(--accent);
}

.writing__arrow {
  color: var(--muted);
  transition: color 0.25s ease, transform 0.25s ease;
}

.writing:hover .writing__arrow {
  color: var(--accent);
  transform: translate(2px, -2px);
}

@media (max-width: 600px) {
  .writing {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: 0.3rem;
  }
  .writing__date {
    order: 2;
    grid-column: 1;
  }
  .writing__title {
    grid-column: 1;
  }
  .writing__arrow {
    grid-row: 1;
    grid-column: 2;
  }
}

/* ============ contact ============ */
.contact p {
  max-width: 56ch;
  color: var(--muted);
  font-size: 1.05rem;
}

.contact__links {
  margin-top: 2.25rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ============ footer ============ */
.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 2rem clamp(1.25rem, 5vw, 4rem);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

.footer__mono {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
  opacity: 0.7;
}

.footer__mono kbd {
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
}

/* ============ mini terminal ============ */
.terminal {
  position: fixed;
  top: 14%;
  left: 50%;
  transform: translateX(-50%);
  width: min(640px, 92vw);
  z-index: 30;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(8, 11, 18, 0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  animation: term-in 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes term-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.terminal__bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.02);
}

.terminal__close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0 0.2rem;
}

.terminal__close:hover {
  color: var(--text);
}

.terminal__body {
  padding: 0.9rem;
  max-height: 320px;
  overflow-y: auto;
}

.terminal__body pre {
  font-family: inherit;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  margin-bottom: 0.55rem;
  line-height: 1.55;
}

.terminal__body pre.terminal__echo {
  color: var(--accent);
}

.terminal__line {
  display: flex;
  gap: 0.55rem;
  align-items: center;
}

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

.terminal__line input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: inherit;
  caret-color: var(--accent);
}

/* ============ scroll reveal ============ */
.reveal {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .hero__scroll {
    display: none;
  }
}