*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #020617;
  --card: #020617;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.12);
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border-subtle: #1f2937;
  --radius-lg: 18px;
  --radius-md: 10px;
  --content-width: 860px;
  --page-width: 1180px;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Inter", sans-serif;
  background: radial-gradient(circle at top, #020617 0, #000 65%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ===== Header ===== */

.project-header {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(18px);
  background: linear-gradient(
    to bottom,
    rgba(2, 6, 23, 0.9),
    rgba(2, 6, 23, 0.3)
  );
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.project-header__inner {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0.9rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.project-header__back {
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
}

.project-header__back:hover {
  color: var(--text);
}

.project-header__label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
}

/* ===== Main Layout ===== */

.project-main {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 2.5rem 1.25rem 3rem;
}

/* nav + card wrapper */
.project-page {
  display: flex;
  align-items: flex-start;
  gap: 2.25rem;
}

.project {
  background: radial-gradient(
    circle at top left,
    rgba(56, 189, 248, 0.06),
    rgba(15, 23, 42, 0.95)
  );
  border-radius: var(--radius-lg);
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.8);
  padding: 2.2rem 1.8rem 2.4rem;
  flex: 1 1 auto;
  min-width: 0;
  max-width: var(--content-width);
  position: relative;
  z-index: 1;
}

/* ===== Hero Section ===== */

.project__hero {
  margin-bottom: 2.2rem;
}

.project__title {
  font-size: 1.8rem;
  margin: 0 0 0.6rem;
}

.project__subtitle {
  margin: 0 0 1.5rem;
  color: var(--muted);
  max-width: 32rem;
}

.project-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 1.6rem;
}

.project-meta__group {
  margin: 0;
}

.project-meta__group dt {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.project-meta__group dd {
  margin: 0;
  font-size: 0.95rem;
}

/* Hero Image */

.project__image-wrapper {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: #020617;
  margin-top: 1.6rem;
}

.project__image {
  display: block;
  width: 100%;
  height: auto;
}

.project-video {
  display: block;
  width: 100%;
  max-width: 640px;
  margin: 0.75rem auto 1.25rem;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: #000;
  position: relative;
  z-index: 1;
}

/* ===== Body Sections ===== */

.project-section {
  margin-top: 2rem;
}

.project-section:first-of-type {
  margin-top: 0;
}

.project-section h2 {
  font-size: 1.1rem;
  margin: 0 0 0.6rem;
}

.project-section h3 {
  font-size: 1rem;
  margin: 1.4rem 0 0.4rem;
}

.project-section h4 {
  font-size: 0.95rem;
  margin: 1.1rem 0 0.35rem;
}

.project-section p {
  margin: 0 0 0.9rem;
  color: var(--muted);
}

.project-section ul,
.project-section ol {
  margin: 0 0 0.9rem;
  padding-left: 1.1rem;
  color: var(--muted);
}

.project-section li {
  margin-bottom: 0.3rem;
}

.project-section--columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.75rem;
}

/* offset anchor jumps for sticky header (desktop baseline) */
.project-section,
.project__hero {
  scroll-margin-top: 100px;
}

/* ===== Figures / Images ===== */

.project-figure {
  margin: 1.5rem 0;
  border-radius: var(--radius-md);
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: radial-gradient(circle at top, rgba(15, 23, 42, 0.9), #020617);
  padding: 0.75rem;
}

.project-figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
}

.project-figure figcaption {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ===== Buttons ===== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1.4rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s ease-out, box-shadow 0.12s ease-out,
    background 0.12s ease-out, border-color 0.12s ease-out;
}

.btn--primary {
  background: radial-gradient(
    circle at 0 0,
    #38bdf8,
    #2563eb 45%,
    #4c1d95 100%
  );
  box-shadow: 0 18px 35px rgba(37, 99, 235, 0.45);
  color: #f9fafb;
}

.btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 22px 45px rgba(15, 23, 42, 0.9);
}

.btn--ghost {
  background: rgba(15, 23, 42, 0.9);
  border-color: rgba(148, 163, 184, 0.5);
  color: var(--text);
}

.btn--ghost:hover {
  background: rgba(15, 23, 42, 1);
}

/* ===== Code Blocks ===== */

.code-block {
  margin: 1.4rem 0;
  border-radius: var(--radius-md);
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: #020617;
  overflow: hidden;
}

.code-block__title {
  padding: 0.55rem 0.9rem;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid rgba(148, 163, 184, 0.35);
  background: radial-gradient(
    circle at top left,
    rgba(56, 189, 248, 0.18),
    rgba(15, 23, 42, 0.95)
  );
}

.code-block pre {
  margin: 0;
  padding: 0.8rem 1rem 0.9rem;
  overflow-x: auto;
  font-size: 0.8rem;
  line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
}

.code-block code {
  color: #e5e7eb;
}

/* ===== Project Layout with Side Nav (desktop) ===== */

.project-sidenav {
  flex: 0 0 220px;
  position: sticky;
  /* move up by 2px vs previous value */
  top: calc(3.1rem - 2px);
  align-self: flex-start;
  padding: 0.9rem 0.95rem;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: radial-gradient(
    circle at top left,
    rgba(15, 23, 42, 0.96),
    rgba(2, 6, 23, 0.98)
  );
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.75);
  font-size: 0.8rem;
  z-index: 20; /* above videos/content, below header */
}

.project-sidenav__list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.project-sidenav__list li {
  margin-bottom: 0.25rem;
}

.project-sidenav__title-item {
  pointer-events: none;
}

.project-sidenav__title {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.7rem;
  color: var(--muted);
  display: block;
  padding: 0.32rem 0.55rem;
}

.project-sidenav__link {
  display: block;
  padding: 0.32rem 0.55rem;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  transition: background 0.12s ease-out, color 0.12s ease-out,
    transform 0.12s ease-out;
}

.project-sidenav__link:hover {
  background: var(--accent-soft);
  color: var(--text);
  transform: translateX(1px);
}

/* ===== Responsive tweaks ===== */

@media (min-width: 720px) {
  .project-section--columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Mobile / narrow layout */
@media (max-width: 900px) {
  .project-main {
    max-width: var(--content-width);
  }

  .project-page {
    flex-direction: column;
  }

  /* Sticky nav: just under header, 2-column layout */
  .project-sidenav {
    position: sticky;
    /* keep same offset, but moved up 2px */
    top: calc(3.1rem - 2px);
    flex: none;
    width: 100%;
    display: block;
    padding: 0.6rem 0.75rem 0.6rem;
    margin-bottom: 1.1rem;
    border-radius: 0 0 14px 14px; /* flat top corners on mobile */
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.7);
    max-height: calc(100vh - 3.5rem);
    overflow-y: auto;
  }

  .project-sidenav__list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: auto;
    column-gap: 0.9rem;
    row-gap: 0.1rem;
  }

  /* Explicit placement:
     left column: title + first 3 links
     right column: remaining 4 links */
  .project-sidenav__list li:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
  }

  .project-sidenav__list li:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
  }

  .project-sidenav__list li:nth-child(3) {
    grid-column: 1;
    grid-row: 3;
  }

  .project-sidenav__list li:nth-child(4) {
    grid-column: 1;
    grid-row: 4;
  }

  .project-sidenav__list li:nth-child(5) {
    grid-column: 2;
    grid-row: 1;
  }

  .project-sidenav__list li:nth-child(6) {
    grid-column: 2;
    grid-row: 2;
  }

  .project-sidenav__list li:nth-child(7) {
    grid-column: 2;
    grid-row: 3;
  }

  .project-sidenav__list li:nth-child(8) {
    grid-column: 2;
    grid-row: 4;
  }

  .project-sidenav__link {
    padding: 0.25rem 0.55rem;
  }

  .project {
    max-width: 100%;
  }

  /* Make anchor jumps land lower so titles aren't hidden behind nav */
  .project-section,
  .project__hero {
    scroll-margin-top: 195px;
  }

  /* Custom mobile play button overlay */
  .project-video::before,
  .project-video::after {
    content: "";
    position: absolute;
    pointer-events: none;
    transition: opacity 0.2s ease-out;
  }

  .project-video::before {
    width: 56px;
    height: 56px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.9);
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
  }

  .project-video::after {
    border-style: solid;
    border-width: 10px 0 10px 18px;
    border-color: transparent transparent transparent #f9fafb;
    left: 50%;
    top: 50%;
    transform: translate(-40%, -50%);
  }

  .project-video.is-playing::before,
  .project-video.is-playing::after {
    opacity: 0;
  }
}

@media (max-width: 600px) {
  .project {
    padding: 1.6rem 1.25rem 1.9rem;
  }

  .project-meta {
    gap: 1rem;
  }

  .project__title {
    font-size: 1.5rem;
  }
}
