/* ============================================================
   MossIV.github.io — theme: "Monolyth"
   Palette and type are derived from the Unicorn Studio hero scene
   (near-black ground, teal beacon light, thin circuit line-work).
   ============================================================ */

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Design Tokens ── */
:root {
  /* ground */
  --bg:         #05090b;
  --bg-2:       #080e11;
  --bg-card:    #0b1215;
  --bg-card-2:  #0e171a;

  /* structure */
  --border:     #17262a;
  --border-lit: #24444a;

  /* ink */
  --text:       #e7f3f1;
  --muted:      #8ba2a6;

  /* beacon */
  --accent:     #4fe3cf;
  --accent-dim: #35b9a8;
  --accent-ink: #04201d;
  --accent-soft: rgba(79, 227, 207, 0.10);
  --accent-line: rgba(79, 227, 207, 0.28);
  --glow:       rgba(79, 227, 207, 0.35);

  --radius:     12px;
  --radius-sm:  8px;
  --max-w:      1080px;
  --gap:        1.5rem;
  --nav-h:      64px;

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

html { scroll-behavior: smooth; overflow-x: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.65;
  font-size: 1rem;
  -webkit-font-smoothing: antialiased;
  /* No overflow property here on purpose: overflow on <body> makes it a scroll
     container, which breaks position: sticky for everything inside it. Clipping
     the horizontal axis is <html>'s job, where it propagates to the viewport. */
}

a { color: var(--accent); text-decoration: none; }
/* Buttons own their hover colour; the generic link hover must not override it
   (it is light-on-light for a filled button, which hid the label). */
a:not(.btn):hover { text-decoration: none; color: #7ff0e0; }
a:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ── Layout ── */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ── Nav (floats over the hero, solidifies on scroll) ── */
nav {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 100;
  border-bottom: 1px solid transparent;
  transition: background 0.35s ease, border-color 0.35s ease, backdrop-filter 0.35s ease;
}
nav.is-scrolled {
  background: rgba(5, 9, 11, 0.78);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom-color: var(--border);
}
nav .nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 1.05rem 1.5rem;
}
nav .logo {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 0.98rem;
  letter-spacing: -0.01em;
  color: var(--text);
}
nav .logo span { color: var(--accent); }
nav ul { display: flex; gap: 1.6rem; list-style: none; }
nav ul a {
  position: relative;
  font-size: 0.87rem;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.01em;
  padding-bottom: 2px;
}
nav ul a::after {
  content: '';
  position: absolute; left: 0; bottom: -2px;
  height: 1px; width: 0;
  background: var(--accent);
  transition: width 0.25s ease;
}
nav ul a:hover, nav ul a.is-active { color: var(--text); }
nav ul a:hover::after, nav ul a.is-active::after { width: 100%; }

/* ── Hero ── */
#hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  align-items: center;
  padding-top: var(--nav-h);
  overflow: hidden;
  background: var(--bg);
}

/* Ground. The circuit geometry itself is drawn on the canvas above this. */
.hero-poster {
  position: absolute; inset: 0;
  background:
    radial-gradient(58% 44% at 50% 62%, rgba(79, 227, 207, 0.10) 0%, transparent 70%),
    linear-gradient(180deg, #04070a 0%, #061013 58%, #05090b 100%);
}

.hero-canvas {
  position: absolute; inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
}

/* Readability scrim: darkens the left column where the copy sits and fades
   the bottom of the hero into the page. */
.hero-scrim {
  position: absolute; inset: 0; z-index: 2;
  background:
    linear-gradient(90deg, rgba(5, 9, 11, 0.74) 0%, rgba(5, 9, 11, 0.34) 45%, rgba(5, 9, 11, 0) 70%),
    linear-gradient(180deg, rgba(5, 9, 11, 0.55) 0%, rgba(5, 9, 11, 0) 20%, rgba(5, 9, 11, 0) 62%, rgba(5, 9, 11, 0.7) 92%, var(--bg) 100%);
  pointer-events: none;
}

.hero-inner {
  position: relative; z-index: 3;
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.5rem 4.5rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2rem;
}

.hero-identity { max-width: 34rem; }

.hero-kicker {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.6rem;
}
.hero-fallback h1 {
  font-size: clamp(2.4rem, 6vw, 4rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-weight: 600;
}
.hero-lines {
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--muted);
  margin-top: 1rem;
  line-height: 1.9;
}

.hero-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }

.btn {
  display: inline-block;
  padding: 0.7rem 1.35rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  box-shadow: 0 0 0 rgba(79, 227, 207, 0);
}
.btn-primary:hover {
  background: #6ff0de;
  color: var(--accent-ink);          /* keep the label dark on the lighter fill */
  box-shadow: 0 6px 28px rgba(79, 227, 207, 0.28);
  transform: translateY(-1px);
}
.btn-ghost {
  background: rgba(11, 18, 21, 0.55);
  color: var(--text);
  border-color: var(--border-lit);
  backdrop-filter: blur(6px);
}
.btn-ghost:hover { border-color: var(--accent-line); color: var(--accent); }

/* Scroll cue */
.hero-cue {
  position: absolute; z-index: 3;
  left: 50%; bottom: 1.1rem;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
  color: var(--muted);
}
.hero-cue-label {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}
.hero-cue-line {
  width: 1px; height: 34px;
  background: linear-gradient(180deg, var(--accent-line), transparent);
}
.hero-cue:hover { color: var(--accent); }

/* ── Sections ── */
main { position: relative; z-index: 4; background: var(--bg); }
section { padding: 4.5rem 0; scroll-margin-top: var(--nav-h); }
section + section { border-top: 1px solid var(--border); }

.section-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 2rem;
  display: flex; align-items: center; gap: 0.85rem;
  letter-spacing: 0.01em;
}
/* Section index — the numbering mirrors the order of the sections. */
main { counter-reset: sec; }
section { counter-increment: sec; }
.section-title::before,
.projects-kicker::before {
  content: counter(sec, decimal-leading-zero);
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--accent);
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  line-height: 1.4;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border), transparent);
}

.lede { color: var(--muted); max-width: 68ch; }
.lede + .lede { margin-top: 1rem; }

/* ── About ── */
#about .meta { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.6rem; }
#about .meta span {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
}

/* ── Grids (projects + experience) ── */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--gap);
}
.project-card {
  position: relative;
  background: linear-gradient(180deg, var(--bg-card-2), var(--bg-card));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.55rem;
  display: flex; flex-direction: column;
  gap: 0.6rem;
  overflow: hidden;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.5s ease, transform 0.5s ease, border-color 0.2s ease;
}
.project-card.is-visible { opacity: 1; transform: none; }
/* circuit tick on the top edge, lit on hover */
.project-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-line), transparent);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.project-card:hover {
  border-color: var(--border-lit);
  transform: translateY(-3px);
}
.project-card:hover::before { opacity: 1; }

.project-card h3 {
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.project-card p { font-size: 0.9rem; color: var(--muted); flex: 1; }
.project-card p strong { color: var(--text); font-weight: 500; }

.project-card .tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.project-card .tags span {
  font-size: 0.7rem;
  font-family: var(--mono);
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
}
.project-card a {
  font-size: 0.85rem;
  font-family: var(--mono);
  margin-top: 0.65rem;
  align-self: flex-start;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}
.project-card a:hover { border-bottom-color: var(--accent); }
.project-card .company {
  font-size: 0.76rem;
  color: var(--accent);
  font-family: var(--mono);
  letter-spacing: 0.02em;
  margin-top: -0.15rem;
}

/* ── Projects layout ──
   Header on the left, cards scrolling on the right, inside a pinned track. */
.projects-pin {
  /* One viewport, plus the travel the cards need. The JS sets --pin-extra to
     the panel's overflow, so page scroll is spent on the cards and the section
     is released once they reach the bottom. */
  position: relative;
  height: calc(100svh + var(--pin-extra, 0px));
}
#projects {
  position: sticky;                       /* holds still while the track passes */
  top: 0;
  height: 100svh;
  display: flex;
  align-items: stretch;
  padding-top: calc(var(--nav-h) + 1.5rem);
  padding-bottom: 1.5rem;
}
#projects .container { width: 100%; }

.projects-layout {
  display: grid;
  grid-template-columns: minmax(240px, 330px) minmax(0, 1fr);
  gap: clamp(2rem, 4vw, 3.5rem);
  align-items: stretch;
  height: 100%;
}
.projects-side {
  position: sticky;                       /* rides alongside the panel */
  top: calc(var(--nav-h) + 3rem);
}
.projects-kicker {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1.1rem;
}
.projects-display {
  font-size: clamp(2.2rem, 4.4vw, 3.6rem);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.03em;
  text-transform: uppercase;
}
.projects-sub {
  margin-top: 1.1rem;
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--muted);
  max-width: 32ch;
}
.projects-sub strong { color: var(--text); font-weight: 500; }
.projects-meta {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 1.4rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
}
.projects-skip { margin-top: 1.4rem; }

/* ── Projects panel ──
   Driven by the page scroll (see the pin above): the panel is not
   user-scrollable itself, it just shows the slice of the grid that the current
   page position asks for. */
.projects-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.projects-scroller {
  /* takes whatever height the layout gives it, and no wheel input of its own */
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  padding-right: 0.75rem;
  border-radius: var(--radius);
}

/* Progress rail: the panel no longer has a scrollbar, so this shows how far
   through the cards the page has travelled. */
.projects-progress {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 2px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.projects-progress-fill {
  display: block;
  width: 100%;
  height: 0;
  background: var(--accent);
  box-shadow: 0 0 8px var(--glow);
}

/* Two columns inside the panel: a real run of content to scroll through. */
.projects-scroller .projects-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  padding-bottom: 1.5rem;
}

.projects-fade {
  position: absolute;
  left: 0; right: 0.75rem; bottom: 0;
  height: 110px;
  background: linear-gradient(180deg, rgba(5, 9, 11, 0), var(--bg) 90%);
  pointer-events: none;
}
.projects-hint {
  position: absolute;
  right: 1.75rem; bottom: 0.85rem;
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(5, 9, 11, 0.78);
  border: 1px solid var(--border-lit);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.projects-hint::after { content: ' ▾'; color: var(--accent); }
.projects-hint.is-hidden { opacity: 0; }

/* ── Skills ── */
.skills-list { display: flex; flex-wrap: wrap; gap: 0.55rem; }
.skill-pill {
  font-size: 0.83rem;
  font-family: var(--mono);
  color: var(--muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.42rem 0.9rem;
  border-radius: var(--radius-sm);
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.skill-pill:hover {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

/* ── Contact ── */
#contact .links { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.6rem; }
#contact .links a {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.55rem 1.05rem;
  border-radius: 999px;
  transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}
#contact .links a:hover {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}
#contact .links .icon { flex-shrink: 0; }

/* ── Footer ── */
footer {
  border-top: 1px solid var(--border);
  padding: 2.25rem 0;
  text-align: center;
  font-size: 0.8rem;
  font-family: var(--mono);
  color: var(--muted);
}

/* ── Mobile ── */
@media (max-width: 820px) {
  #hero { min-height: 72svh; }
  .hero-inner { padding-bottom: 3rem; }
  /* The scroll cue would collide with the stacked action buttons. */
  .hero-cue { display: none; }
  nav .nav-inner { padding: 0.9rem 1.25rem; gap: 0.75rem; }
  /* Links stay reachable but shrink into a swipeable row instead of
     forcing the page wider than the viewport. */
  nav ul {
    flex: 1 1 auto;
    min-width: 0;
    justify-content: flex-end;
    gap: 0.9rem;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  nav ul::-webkit-scrollbar { display: none; }
  nav ul li { flex-shrink: 0; }
  nav ul a { font-size: 0.82rem; }
  section { padding: 3.5rem 0; }
  /* Side header stacks above the panel on narrow screens. */
  .projects-layout { grid-template-columns: 1fr; gap: 1.75rem; }
  .projects-side { position: static; }
  .projects-display { font-size: clamp(1.8rem, 8vw, 2.4rem); }
  .projects-sub { max-width: 46ch; }
  /* Stacked: the header takes its own height, the panel takes the rest, so a
     full-height panel can never push the section past the screen. */
  #projects { padding-top: 1.5rem; padding-bottom: 1.5rem; }
  .projects-layout { grid-template-rows: auto minmax(0, 1fr); }
}
@media (max-width: 560px) {
  /* Two-row nav: the logo and all five links fit instead of the links
     scrolling out of reach behind the logo. */
  nav .nav-inner { flex-direction: column; align-items: flex-start; gap: 0.45rem; padding: 0.7rem 1rem 0.75rem; }
  nav ul { flex: 0 1 auto; flex-wrap: wrap; justify-content: flex-start; gap: 0.9rem; overflow: visible; width: 100%; }
  nav ul a { font-size: 0.76rem; }
  .logo { font-size: 0.85rem; white-space: nowrap; }
  .hero-actions { width: 100%; gap: 0.6rem; }
  /* min-width:0 lets the buttons shrink below their content width, which is
     what was pushing the whole page past the right edge. */
  .hero-actions .btn { flex: 1 1 0; min-width: 0; text-align: center; padding-inline: 0.75rem; }
  .projects-grid { grid-template-columns: 1fr; }
  /* The nav is two rows tall here, so anchor targets need more clearance. */
  section { scroll-margin-top: 104px; }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .project-card { opacity: 1; transform: none; transition: none; }
  .btn:hover, .project-card:hover { transform: none; }
}
