/*
  Die Stack — portfolio of Shubham Draveriya
  The page is a cross-section of a chip: each section is one layer,
  and the WebGL scene behind it (assets/js/scene.js) takes the chip apart as you scroll.
*/

:root {
  /* Layer colours. site.js blends --bg between them on scroll. */
  --oxide: #15172b;
  --package: #1b1c36;
  --film: #0d2733;
  --copper-oxide: #2a1811;
  --silicon: #1d1235;
  --gold: #e9b949;

  --bg: var(--oxide);
  --paper: #eceaf5;
  --muted: rgba(236, 234, 245, 0.7);
  --faint: rgba(236, 234, 245, 0.42);
  --line: rgba(236, 234, 245, 0.16);
  --focus: #6fe3e1;

  --display: "Anybody", "Arial Narrow", system-ui, sans-serif;
  --body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --code: "IBM Plex Mono", ui-monospace, monospace;

  /* Type scale: 1.333 ratio from a 17px base */
  --t-small: 0.875rem;
  --t-body: 1.0625rem;
  --t-h3: 1.25rem;
  --t-h2: clamp(2.25rem, 4.6vw, 4.25rem);
  --t-h1: clamp(3.4rem, 11vw, 10.5rem);

  --gutter: clamp(1rem, 4vw, 3.5rem);
  --notch: 9px;
  color-scheme: dark;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--paper);
  font-family: var(--body);
  font-size: var(--t-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: color 0.4s ease;
}

h1,
h2,
h3,
p,
ul,
dl,
dd,
figure {
  margin: 0;
}

ul {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
}

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

.skip {
  position: fixed;
  left: var(--gutter);
  top: -4rem;
  z-index: 50;
  padding: 0.6rem 1rem;
  background: var(--paper);
  color: var(--oxide);
  font-weight: 600;
}

.skip:focus {
  top: 1rem;
}

/* ---------- WebGL stage ---------- */

#stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  display: block;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.2s ease;
}

.is-ready #stage {
  opacity: 1;
}

/* Keeps the copy column readable over the chip on wide screens. */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(
    90deg,
    var(--bg) 0%,
    color-mix(in srgb, var(--bg) 82%, transparent) 34%,
    color-mix(in srgb, var(--bg) 0%, transparent) 56%
  );
}

.boot {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1rem;
  background: var(--oxide);
  color: var(--muted);
  font-family: var(--display);
  font-variation-settings: "wdth" 120;
  font-size: var(--t-small);
  letter-spacing: 0.02em;
  transition: opacity 0.7s ease, visibility 0.7s;
  /* Fallback: never block the page for long, even if the scene fails. */
  animation: boot-out 0.7s ease 4s forwards;
}

.boot-line {
  width: 9rem;
  height: 1px;
  background: linear-gradient(90deg, transparent, #6fe3e1, #9b8cff, transparent);
  background-size: 200% 100%;
  animation: boot-scan 1.1s linear infinite;
}

.is-ready .boot,
html:not(.js) .boot {
  opacity: 0;
  visibility: hidden;
}

@keyframes boot-scan {
  to {
    background-position: -200% 0;
  }
}

@keyframes boot-out {
  to {
    opacity: 0;
    visibility: hidden;
  }
}

/* ---------- Header ---------- */

.bar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 1rem var(--gutter);
  transition: background-color 0.3s ease;
}

.is-scrolled .bar {
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.mark {
  font-family: var(--display);
  font-weight: 800;
  font-variation-settings: "wdth" 130;
  font-size: 1.05rem;
  text-decoration: none;
  white-space: nowrap;
}

.nav {
  display: flex;
  gap: 1.5rem;
  margin-left: auto;
  font-size: var(--t-small);
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.25rem 0;
  border-bottom: 1px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

.nav a:hover,
.nav a[aria-current="true"] {
  color: var(--paper);
  border-color: currentColor;
}

.bar-progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: calc(var(--progress, 0) * 100%);
  background: linear-gradient(90deg, #6fe3e1, #9b8cff, #ff7ab6, #f2c14e);
}

/* ---------- Buttons: square with a pin-1 notch, like a package corner ---------- */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 2.9rem;
  padding: 0.7rem 1.35rem;
  background: var(--paper);
  color: var(--oxide);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  border: 1px solid var(--paper);
  transition: transform 0.2s ease, background-color 0.2s, color 0.2s;
}

.btn::before {
  content: "";
  position: absolute;
  left: -1px;
  top: -1px;
  border-style: solid;
  border-width: var(--notch) var(--notch) 0 0;
  border-color: var(--bg) transparent transparent transparent;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn-ghost {
  background: transparent;
  color: var(--paper);
  border-color: var(--line);
}

.btn-ghost:hover {
  border-color: var(--paper);
}

.btn-small {
  min-height: 2.3rem;
  padding: 0.4rem 1rem;
  font-size: var(--t-small);
}

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

/* ---------- Depth gauge ---------- */

.gauge {
  position: fixed;
  right: var(--gutter);
  top: 50%;
  z-index: 10;
  transform: translateY(-50%);
  display: flex;
  gap: 0.9rem;
  flex-direction: row-reverse;
}

.gauge-track {
  position: relative;
  width: 1px;
  background: var(--line);
}

.gauge-dot {
  position: absolute;
  left: -4px;
  top: calc(var(--gp, 0) * (100% - 9px));
  width: 9px;
  height: 9px;
  background: var(--paper);
  box-shadow: 0 0 14px var(--accent, #6fe3e1);
}

.gauge ol {
  display: grid;
  gap: 1.1rem;
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: right;
  font-size: 0.78rem;
}

.gauge a {
  color: var(--faint);
  text-shadow: 0 0 6px var(--bg), 0 0 14px var(--bg);
  text-decoration: none;
  transition: color 0.25s;
}

.gauge a:hover,
.gauge a[aria-current="true"] {
  color: var(--paper);
}

/* ---------- Layers (sections) ---------- */

main {
  position: relative;
  z-index: 1;
}

.layer {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 7rem var(--gutter);
}

html:not(.js) .layer {
  background: var(--sec);
}

.content {
  width: min(34rem, 100%);
}

.content.wide {
  width: min(40rem, 100%);
}

.stretch {
  font-family: var(--display);
  font-size: var(--t-h2);
  font-weight: 750;
  line-height: 0.98;
  letter-spacing: -0.01em;
  font-variation-settings: "wdth" var(--w, 100);
  margin-bottom: 1.75rem;
  text-wrap: balance;
}

.content p + p {
  margin-top: 1rem;
}

.content > p,
.intro {
  color: var(--muted);
  max-width: 62ch;
}

h3 {
  font-family: var(--display);
  font-size: var(--t-h3);
  font-weight: 650;
  font-variation-settings: "wdth" 110;
  line-height: 1.2;
}

/* Hero */

.hero .content {
  width: min(64rem, 100%);
}

.name {
  font-family: var(--display);
  font-size: var(--t-h1);
  font-weight: 820;
  line-height: 0.84;
  letter-spacing: -0.025em;
  font-variation-settings: "wdth" var(--hw, 120);
  margin-bottom: 1.75rem;
}

.name span {
  display: block;
}

.name span + span {
  /* the surname steps in, like a second metal layer offset over the first */
  padding-left: 0.6em;
  color: transparent;
  -webkit-text-stroke: 1.5px var(--paper);
}

.role {
  font-family: var(--display);
  font-variation-settings: "wdth" 125;
  font-weight: 500;
  font-size: 1.15rem;
  margin-bottom: 0.75rem;
}

.hero .lede {
  color: var(--muted);
  max-width: 34rem;
  margin-bottom: 2rem;
}

.cue {
  position: absolute;
  left: var(--gutter);
  bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--faint);
  font-size: var(--t-small);
}

.cue span {
  position: relative;
  width: 1px;
  height: 2.5rem;
  background: var(--line);
  overflow: hidden;
}

.cue span::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--paper);
  animation: cue 1.8s ease-in-out infinite;
}

@keyframes cue {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(100%);
  }
}

/* About */

.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem 2rem;
  margin-top: 2.25rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.facts dt {
  color: var(--faint);
  font-size: var(--t-small);
}

.facts dd {
  font-weight: 500;
  line-height: 1.4;
}

/* RV32I */

.intro {
  margin-bottom: 2rem;
}

.pipe {
  margin-bottom: 2.25rem;
}

.pipe figcaption {
  color: var(--faint);
  font-size: var(--t-small);
  margin-bottom: 0.75rem;
}

.pipe-stages {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
}

.stage {
  position: relative;
  padding: 0.85rem 0.25rem 1rem;
  border: 0;
  background: rgba(236, 234, 245, 0.05);
  color: var(--muted);
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 650;
  font-variation-settings: "wdth" 90;
  cursor: pointer;
  transition: background-color 0.3s, color 0.3s, font-variation-settings 0.4s;
}

.stage::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--c);
  transform: scaleX(0.18);
  transform-origin: left;
  transition: transform 0.45s ease;
}

.stage:hover,
.stage.is-active {
  color: var(--paper);
  background: color-mix(in srgb, var(--c) 20%, transparent);
  font-variation-settings: "wdth" 125;
}

.stage.is-active::after {
  transform: scaleX(1);
}

.pipe-note {
  min-height: 3.2em;
  margin-top: 0.9rem;
  color: var(--paper);
  font-size: 0.95rem;
}

.cols {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.75rem;
  margin-bottom: 2.25rem;
}

.cols h3,
.kit h3 {
  margin-bottom: 0.6rem;
}

.cols li,
.kit li {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
  padding: 0.4rem 0;
  border-top: 1px solid var(--line);
}

/* On the bench */

.bench li {
  padding: 1.5rem 0;
  border-top: 1px solid rgba(227, 153, 91, 0.35);
}

.bench li:last-child {
  border-bottom: 1px solid rgba(227, 153, 91, 0.35);
}

.bench-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.5rem;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--t-small);
  color: var(--s);
}

.status::before {
  content: "";
  width: 7px;
  height: 7px;
  background: var(--s);
  box-shadow: 0 0 10px var(--s);
  animation: blink 1.6s steps(2, jump-none) infinite;
}

@keyframes blink {
  50% {
    opacity: 0.25;
  }
}

.bench p {
  color: var(--muted);
}

.bench .tools {
  margin-top: 0.4rem;
  color: var(--faint);
  font-size: var(--t-small);
}

/* Skills */

.kit {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2rem 2.5rem;
}

/* Contact: the chip is powered, the layer turns gold */

.contact {
  justify-content: space-between;
  padding-bottom: 2rem;
}

.contact .content {
  margin-block: auto;
  width: min(44rem, 100%);
}

.contact .stretch {
  font-size: clamp(2.4rem, 5.6vw, 5rem);
}

.contact .content > p {
  margin-bottom: 2rem;
}

.links {
  display: flex;
  gap: 1.5rem;
  margin-top: 2rem;
  font-weight: 500;
}

.links a {
  text-underline-offset: 0.3em;
}

.foot {
  color: var(--faint);
  font-size: var(--t-small);
}

/* Gold theme, switched on by site.js as the contact layer arrives */

.on-gold {
  --paper: #1d1606;
  --muted: rgba(29, 22, 6, 0.78);
  --faint: rgba(29, 22, 6, 0.6);
  --line: rgba(29, 22, 6, 0.25);
  --focus: #1d1606;
  color-scheme: light;
}

.on-gold .btn {
  color: var(--gold);
}

.on-gold .btn-ghost {
  color: var(--paper);
}

.on-gold .name span + span {
  -webkit-text-stroke-color: var(--paper);
}

html:not(.js) .contact {
  --paper: #1d1606;
  --muted: rgba(29, 22, 6, 0.78);
  --faint: rgba(29, 22, 6, 0.6);
  --line: rgba(29, 22, 6, 0.25);
  color: var(--paper);
}

/* ---------- Responsive ---------- */

@media (max-width: 1080px) {
  .gauge {
    display: none;
  }
}

@media (max-width: 860px) {
  .nav {
    display: none;
  }

  .scrim {
    display: none;
  }

  .bar {
    justify-content: space-between;
  }

  .layer {
    padding-block: 6rem;
  }

  /* On small screens the chip sits behind the text, so the copy gets a tinted backing. */
  .panel {
    padding: 1.5rem 1.25rem;
    margin-inline: -0.25rem;
    background: color-mix(in srgb, var(--bg) 80%, transparent);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }

  /* The chip takes the top of the screen; hero and contact copy sit underneath it. */
  .hero {
    justify-content: flex-end;
    padding-bottom: 3rem;
  }

  .contact .content {
    margin-top: auto;
    margin-bottom: 2.5rem;
  }

  .contact .stretch {
    font-size: 9.5vw;
  }

  .name {
    font-size: 12.5vw;
  }

  .name span + span {
    padding-left: 0;
  }

  .cols {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
}

@media (max-width: 560px) {
  .facts,
  .kit {
    grid-template-columns: 1fr;
  }

  .pipe-stages {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 2px;
  }

  .stage {
    font-size: 0.78rem;
    font-variation-settings: "wdth" 70;
  }

  .stage:hover,
  .stage.is-active {
    font-variation-settings: "wdth" 85;
  }

  .cue {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
