/* Theme tokens and global defaults */
*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  /* Brand colors */
  --color-blue: #3f72af;
  --color-blue-rgb: 63, 114, 175;
  --color-cyan: #00c6ff;
  --color-cyan-rgb: 0, 198, 255;

  /* Page and text colors */
  --color-page: #05070c;
  --color-text: #f5f7fb;
  --color-text-muted: #b9c1d0;
  --color-text-soft: #d8e6fa;
  --color-ink: #07111d;
  --color-ink-soft: #0b111a;
  --color-ink-strong: #111827;
  --color-button: #f3f6fb;
  --color-button-hover: #e8eef8;
  --color-button-soft-hover: #dcecff;
  --color-link: #7fdcff;
  --color-back-link: #c9d8ef;
  --color-focus: #69c9ff;

  /* Surfaces and borders */
  --color-surface: rgba(255, 255, 255, 0.06);
  --color-surface-border: rgba(255, 255, 255, 0.12);
  --color-accent-border: rgba(83, 145, 220, 0.32);
  --color-nav-surface: rgba(14, 18, 28, 0.78);
  --color-accent-surface: rgba(var(--color-blue-rgb), 0.18);

  /* Reusable gradients */
  --gradient-accent: linear-gradient(to right, var(--color-blue), var(--color-cyan));
  --gradient-accent-hover: linear-gradient(to right, #5590d3, #39d3ff);

  /* Typography */
  --font-body: system-ui, -apple-system, sans-serif;
  --line-height-body: 1.7;
  --line-height-copy: 1.8;
  --font-size-section-heading: clamp(1.75rem, 3.5vw, 2.75rem);

  /* Layout and effects */
  --content-width: 1000px;
  --about-content-width: 820px;
  --section-space: clamp(42px, 5vw, 64px);
  --section-space-mobile: 38px;
  --project-side-space: clamp(20px, 4vw, 48px);
  --radius-pill: 9999px;
  --blur-surface: blur(8px);
}

body {
  background-color: var(--color-page);
  margin: 0;
  font-family: var(--font-body);
  min-height: 100vh;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(1000px, 100vw);
  height: min(1000px, 100vw);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--color-blue-rgb), 0.17) 0%, rgba(255, 255, 255, 0.035) 38%, transparent 72%);
  filter: blur(24px);
  pointer-events: none;
  z-index: -1;
}

/* Page layout */
main {
  width: calc(100% - 48px);
  margin: 0 auto;
}

/* Navigation */
nav {
  position: fixed;
  top: 16px;
  left: 50%;
  z-index: 10;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  padding: 6px;
  background-color: var(--color-nav-surface);
  border: 1px solid var(--color-surface-border);
  border-radius: 50px;
  width: fit-content;
  max-width: calc(100vw - 24px);
  flex-wrap: nowrap;
  margin: 0;
  backdrop-filter: var(--blur-surface);
  transform: translateX(-50%);
}

nav a {
  display: inline-block;
  white-space: nowrap;
  color: var(--color-text-muted);
  text-decoration: none;
  font-weight: 500;
  padding: 9px clamp(6px, 2vw, 16px);
  border-radius: var(--radius-pill);
  transition: color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

a {
  transition: transform 0.2s ease-in-out;
}

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

nav a:hover {
  color: var(--color-text);
  background-color: var(--color-surface-border);
}

nav a.active {
  color: var(--color-ink-strong);
  background-color: var(--color-text);
}

nav a.active:hover {
  color: var(--color-ink-strong);
  background-color: var(--color-button-hover);
}

a:focus-visible,
.skill-item:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 4px;
}

section,
footer {
  scroll-margin-top: 96px;
}

/* Let long text wrap instead of overflowing on narrow screens */
#hero h1,
#hero p,
.project-card h3,
.project-card p {
  overflow-wrap: anywhere;
}

/* Hero */
#hero {
  display: flex;
  justify-content: center;
  text-align: center;
  margin: 20px auto 0;
  padding: clamp(88px, 14vh, 140px) 0 clamp(72px, 10vh, 104px);
}

#hero > div {
  max-width: 860px;
  margin: 0 auto;
}

#hero h1 {
  color: var(--color-text);
  font-size: clamp(2.8rem, 7vw, 5.4rem);
  letter-spacing: -0.055em;
  line-height: 1.03;
  margin: 0 0 18px;
}

#hero h1 span {
  background: var(--gradient-accent);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}

#hero p {
  color: var(--color-text-muted);
  font-size: clamp(1rem, 1.8vw, 1.2rem);
  line-height: var(--line-height-body);
  margin: 0;
}

.hero-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.hero-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 140px;
  padding: 12px 20px;
  border: 1px solid var(--color-surface-border);
  border-radius: var(--radius-pill);
  color: var(--color-text);
  text-decoration: none;
  font-weight: 600;
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.hero-actions a:first-child {
  color: var(--color-ink);
  background: var(--gradient-accent);
  border-color: transparent;
}

.hero-actions a:hover {
  background-color: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
}

.hero-actions a:first-child:hover {
  background: var(--gradient-accent-hover);
}

/* About */
#about {
  margin: 0 auto;
  padding: var(--section-space) 0;
  text-align: center;
}

#about h2 {
  background: var(--gradient-accent);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  font-size: var(--font-size-section-heading);
  margin: 0 0 24px;
}

#about > div {
  max-width: var(--about-content-width);
  width: 100%;
  margin: 0 auto;
  background-color: var(--color-surface);
  border: 1px solid var(--color-surface-border);
  border-radius: 24px;
  padding: clamp(24px, 3.2vw, 36px) clamp(20px, 3.4vw, 40px);
  backdrop-filter: var(--blur-surface);
}

#about p {
  color: var(--color-text-muted);
  line-height: var(--line-height-copy);
  margin: 0;
}

#about > a {
  display: inline-block;
  margin-top: 20px;
  padding: 12px 22px;
  color: var(--color-ink-soft);
  background-color: var(--color-button);
  border-radius: var(--radius-pill);
  text-decoration: none;
  font-weight: 600;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

#about > a:hover {
  background-color: var(--color-button-soft-hover);
}

#projects {
  margin: 0 var(--project-side-space);
  padding: var(--section-space) 0;
  text-align: center;
}

#projects h2 {
  background: var(--gradient-accent);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  font-size: var(--font-size-section-heading);
  margin: 0 0 24px;
}

/* Skills and tools */
#skills {
  margin: 0 auto;
  padding: var(--section-space) 0;
  text-align: center;
}

#skills h2 {
  background: var(--gradient-accent);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  font-size: var(--font-size-section-heading);
  margin: 0 0 32px;
}

.skills-grid {
  --cols: 7;
  --gap-x: clamp(12px, 2.2vw, 30px);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  width: min(100%, 840px);
  margin: 0 auto;
  gap: 24px var(--gap-x);
}

.skills-row {
  display: contents;
}

.skill-item {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 calc((100% - (var(--cols) - 1) * var(--gap-x)) / var(--cols));
  max-width: 72px;
  aspect-ratio: 1;
  color: var(--color-text);
  background-color: var(--color-surface);
  border: 1px solid var(--color-surface-border);
  border-radius: 50%;
  font-size: 1rem;
  font-weight: 700;
  cursor: default;
  backdrop-filter: var(--blur-surface);
  transition: transform 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.skill-item:hover {
  transform: translateY(-4px);
  border-color: rgba(var(--color-cyan-rgb), 0.55);
  background-color: var(--color-accent-surface);
  z-index: 2;
}

.skill-item img {
  width: 52%;
  height: 52%;
  object-fit: contain;
}

.skill-item::before {
  content: attr(data-skill);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translate(-50%, 4px);
  padding: 6px 10px;
  color: var(--color-text);
  background-color: var(--color-ink-strong);
  border: 1px solid var(--color-blue);
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  z-index: 1;
}

.skill-item:hover::before,
.skill-item:focus-visible::before {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

/* Project cards */
.project-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(16px, 1.7vw, 20px);
  width: 100%;
  margin: 0 auto;
}

.project-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  text-align: left;
  background-color: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--color-surface-border);
  border-radius: clamp(14px, 1.4vw, 18px);
  backdrop-filter: var(--blur-surface);
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}

.project-card:hover {
  transform: translateY(-6px);
  border-color: rgba(0, 198, 255, 0.38);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
}

.project-card > img {
  display: block;
  width: 100%;
  height: 220px;
  object-fit: contain;
  object-position: center;
  padding: 10px;
  background: radial-gradient(ellipse at 50% 100%, rgba(var(--color-blue-rgb), 0.14), transparent 72%);
}

.project-card-content {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  padding: clamp(12px, 1.4vw, 16px);
}

.project-card h3 {
  color: var(--color-text);
  font-size: clamp(1rem, 1.2vw, 1.1rem);
  margin: 0 0 6px;
}

.project-card p {
  color: var(--color-text-muted);
  line-height: 1.5;
  margin: 0 0 12px;
}

.project-technologies {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
  margin-bottom: 10px;
}

.project-technologies span {
  color: var(--color-text);
  background-color: rgba(var(--color-blue-rgb), 0.23);
  border: 1px solid var(--color-accent-border);
  border-radius: var(--radius-pill);
  padding: 4px 8px;
  font-size: 0.74rem;
}

.project-card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: auto;
}

/* Project detail pages */
.project-detail-page main {
  max-width: var(--content-width);
}

.project-detail {
  padding: clamp(112px, 15vh, 150px) 0 72px;
}

.project-detail-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(220px, 0.7fr);
  grid-template-areas: "back image" "copy image";
  align-items: center;
  column-gap: clamp(20px, 4vw, 48px);
  padding: clamp(28px, 5vw, 56px);
  margin-bottom: 22px;
  background: linear-gradient(115deg, rgba(var(--color-blue-rgb), 0.23), rgba(255, 255, 255, 0.035) 68%);
  border: 1px solid var(--color-surface-border);
  border-radius: 26px;
}

.back-link {
  grid-area: back;
  align-self: end;
  color: var(--color-back-link);
  text-decoration: none;
  font-size: 0.92rem;
  margin-bottom: 28px;
}

.back-link:hover {
  color: var(--color-text);
  font-size: 0.96rem;
}

.project-eyebrow {
  color: var(--color-link);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 0 0 10px;
}

.project-detail-copy {
  grid-area: copy;
  align-self: start;
  min-width: 0;
}

.project-detail-hero h1 {
  color: var(--color-text);
  font-size: clamp(3rem, 8vw, 5.4rem);
  letter-spacing: -0.055em;
  line-height: 1;
  margin: 0;
}

.project-detail-hero .truck-yard-title {
  font-size: clamp(2rem, 5vw, 3.8rem);
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.project-subtitle {
  color: var(--color-text-soft);
  font-weight: 600;
  font-size: clamp(1.05rem, 2.2vw, 1.35rem);
  margin: 14px 0 8px;
}

.project-intro {
  max-width: 580px;
  color: var(--color-text-muted);
  line-height: var(--line-height-body);
  margin: 0;
}

.project-detail-image {
  grid-area: image;
  display: block;
  width: 100%;
  max-height: 340px;
  object-fit: contain;
  filter: drop-shadow(0 18px 36px rgba(0, 0, 0, 0.35));
}

.stash-detail-hero {
  grid-template-columns: minmax(0, 1.3fr) minmax(180px, 0.7fr);
}

.stash-logo {
  max-height: 180px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--color-surface-border);
  border-radius: 18px;
}

.detail-panel {
  margin-top: 18px;
  padding: clamp(22px, 3.5vw, 34px);
  border: 1px solid var(--color-surface-border);
  border-radius: 22px;
  backdrop-filter: var(--blur-surface);
}

.detail-panel h2 {
  color: var(--color-text);
  font-size: clamp(1.25rem, 2.5vw, 1.65rem);
  margin: 0 0 14px;
}

.detail-panel p,
.feature-list {
  color: var(--color-text-muted);
  line-height: var(--line-height-copy);
  margin: 0;
}

.feature-list {
  padding-left: 1.25rem;
}

.feature-list li + li {
  margin-top: 8px;
}

.feature-list strong {
  color: var(--color-text);
}

.project-screenshots {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.project-screenshots figure {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--color-surface-border);
  border-radius: 14px;
}

.project-screenshots figure:first-child {
  grid-column: 1 / -1;
}

.project-screenshots img {
  display: block;
  width: 100%;
  height: auto;
}

.project-screenshots figcaption {
  padding: 12px 14px;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.video-frame {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #02040a;
  border: 1px solid var(--color-surface-border);
  border-radius: 16px;
}

.video-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.video-fallback {
  margin: 14px 0 0 !important;
  font-size: 0.92rem;
}

.video-fallback a {
  color: var(--color-link);
  text-underline-offset: 3px;
}

.detail-technologies {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
}

.detail-technologies span {
  color: var(--color-text);
  background: rgba(var(--color-blue-rgb), 0.23);
  border: 1px solid var(--color-accent-border);
  border-radius: var(--radius-pill);
  padding: 7px 12px;
  font-size: 0.9rem;
}

.project-more {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  color: var(--color-ink-soft);
  background: var(--color-button);
  border-radius: var(--radius-pill);
  text-align: center;
  text-decoration: none;
  font-weight: 600;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.project-more:hover {
  background-color: var(--color-button-soft-hover);
}

.project-more img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

/* Footer */
footer {
  background-color: var(--color-page);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 24px 16px;
}

footer::before {
  content: "";
  position: absolute;
  top: -24px;
  left: 0;
  width: 100%;
  height: 24px;
  background: linear-gradient(to top, rgba(255, 255, 255, 0.35), transparent);
  pointer-events: none;
}

footer a {
  color: var(--color-text);
}

footer > a {
  color: var(--color-text-muted);
  text-decoration: none;
}

footer > a:hover {
  color: var(--color-text);
}

.social-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
}

.social-links a {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 46px;
  height: 46px;
  background-color: var(--color-surface);
  border: 1px solid var(--color-surface-border);
  border-radius: 50%;
  text-decoration: none;
  transition: transform 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.social-links a:hover {
  border-color: rgba(var(--color-cyan-rgb), 0.55);
  background-color: var(--color-accent-surface);
}

.social-links img {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

/* Responsive layouts */
@media (max-width: 900px) {
  .project-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
  }

  .skills-grid {
    --cols: 5;
    --gap-x: clamp(12px, 2vw, 18px);
    width: min(100%, 620px);
    row-gap: 20px;
  }

  .skill-item {
    font-size: 0.9rem;
  }

  .project-card-content {
    padding: 14px;
  }

  .project-technologies span {
    padding: 4px 7px;
    font-size: 0.72rem;
  }

  .project-more {
    padding: 8px 11px;
  }
}

@media (max-width: 640px) {
  main {
    width: calc(100% - 36px);
  }

  nav {
    gap: 4px;
    padding: 7px;
    max-width: calc(100vw - 4px);
  }

  nav a {
    padding: 10px clamp(8px, 2.2vw, 15px);
    font-size: clamp(0.86rem, 2.9vw, 1.05rem);
  }

  #hero {
    padding: 100px 0 68px;
  }

  #hero h1 {
    font-size: clamp(3.15rem, 8vw, 3.3rem);
  }

  #hero h1 span {
    font-size: 1.08em;
  }

  #hero p {
    max-width: 34ch;
    margin: 0 auto;
    font-size: 0.98rem;
  }

  #about,
  #skills,
  #projects {
    padding: var(--section-space-mobile) 0;
  }

  #skills h2 {
    margin-bottom: 24px;
  }

  .project-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .skills-grid {
    --cols: 3;
    --gap-x: clamp(12px, 4vw, 20px);
    width: min(100%, 460px);
    row-gap: 18px;
  }

  .skill-item {
    font-size: 0.85rem;
  }

  .project-card-content {
    padding: 13px;
  }

  .hero-actions a {
    min-width: 126px;
    padding: 11px 16px;
  }

  .project-detail {
    padding-top: 104px;
  }

  .project-detail-hero {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "back" "copy" "image";
    row-gap: 12px;
    padding: 24px;
  }

  .back-link {
    margin: 0 0 16px;
  }

  .project-intro {
    max-width: none;
  }

  .project-detail-image {
    justify-self: center;
    width: min(72%, 280px);
    max-height: 240px;
  }

  .stash-detail-hero {
    grid-template-columns: minmax(0, 1fr);
  }

  .stash-logo {
    width: min(68%, 230px);
    max-height: 110px;
  }

  .project-screenshots {
    grid-template-columns: minmax(0, 1fr);
  }

  .project-screenshots figure:first-child {
    grid-column: auto;
  }

  .detail-panel {
    border-radius: 18px;
  }
}

@media (max-width: 400px) {
  nav a {
    padding: 9px clamp(4px, 1.4vw, 6px);
    font-size: clamp(0.76rem, 2.45vw, 0.88rem);
  }

  #hero {
    padding-top: 92px;
  }

  #hero h1 span {
    font-size: 1.04em;
  }

  .hero-actions {
    gap: 8px;
  }

  .project-card {
    border-radius: 14px;
  }

  .project-card h3 {
    font-size: 1.05rem;
  }

  .project-card p {
    font-size: 0.9rem;
  }
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
