/* -----------------------------------------------------------------------------
   Ben Merrill — Portfolio design system
   Dark-first, 8px scale, ~200ms ease interactions
   ----------------------------------------------------------------------------- */

:root {
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 40px;
  --space-6: 48px;
  --space-7: 56px;
  --space-8: 64px;
  --space-10: 80px;
  --space-12: 96px;
  --space-16: 128px;

  --radius-sm: 10px;
  --radius-md: 12px;
  --radius-lg: 14px;

  --container: 1120px;
  --container-narrow: 720px;

  --bg-base: #050506;
  --bg-surface: #0c0c0e;
  --bg-elevated: #121214;
  --bg-glass: rgba(12, 12, 14, 0.72);

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-default: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.14);

  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;

  --accent: #6366f1;
  --accent-soft: rgba(99, 102, 241, 0.14);
  --accent-glow: rgba(99, 102, 241, 0.35);
  --accent-2: #22d3ee;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 12px 40px -12px rgba(0, 0, 0, 0.65);
  --shadow-card: 0 0 0 1px var(--border-subtle), var(--shadow-md);
  --shadow-card-hover: 0 0 0 1px var(--border-default), 0 24px 48px -16px rgba(0, 0, 0, 0.75);

  --ease: 200ms cubic-bezier(0.25, 0.1, 0.25, 1);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font);
  font-feature-settings: "cv02", "cv11", "ss01";
  line-height: 1.6;
  letter-spacing: -0.02em;
  color: var(--text-secondary);
  background-color: var(--bg-base);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body > * {
  position: relative;
  z-index: 1;
}

::selection {
  background: var(--accent-soft);
  color: var(--text-primary);
}

/* Ambient background */
.page-atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 100% 70% at 50% -25%, rgba(99, 102, 241, 0.18), transparent 55%),
    radial-gradient(ellipse 50% 40% at 100% 10%, rgba(34, 211, 238, 0.06), transparent 50%),
    radial-gradient(ellipse 45% 35% at 0% 30%, rgba(99, 102, 241, 0.08), transparent 50%),
    linear-gradient(180deg, var(--bg-base) 0%, #080809 50%, var(--bg-base) 100%);
}

.page-atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.4;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, black 0%, transparent 70%);
}

/* Typography */
h1,
h2,
h3 {
  color: var(--text-primary);
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 1.15;
}

h1 {
  font-size: clamp(2.5rem, 6vw + 0.5rem, 4.25rem);
  font-weight: 700;
  letter-spacing: -0.055em;
}

h2 {
  font-size: clamp(1.5rem, 2vw + 1rem, 2rem);
}

h3 {
  font-size: 1.125rem;
  letter-spacing: -0.03em;
}

p {
  line-height: 1.7;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Layout utilities */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--space-3);
}

.section {
  padding-block: var(--space-10);
}

.section--tight-top {
  padding-top: var(--space-6);
}

.section__eyebrow {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.section__header {
  max-width: 36rem;
  margin-bottom: var(--space-8);
}

.section__title {
  margin-bottom: var(--space-2);
}

.section__lede {
  font-size: 1.0625rem;
  color: var(--text-muted);
  letter-spacing: -0.02em;
}

/* Site header / nav */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding-block: var(--space-2);
  border-bottom: 1px solid transparent;
  transition: background var(--ease), border-color var(--ease), backdrop-filter var(--ease);
}

.site-header.is-scrolled {
  background: var(--bg-glass);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-bottom-color: var(--border-subtle);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--space-3);
}

/* Logo */
.logo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  font-size: 0.9375rem;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.logo__mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent) 0%, #4f46e5 100%);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12) inset, var(--shadow-sm);
}

.logo__mark svg {
  display: block;
}

.logo__text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.logo__name {
  font-size: 0.9375rem;
}

.logo__tag {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* Nav links */
.nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.nav__link {
  padding: var(--space-1) var(--space-2);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition: color var(--ease), background var(--ease);
}

.nav__link:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.nav__link:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg-base), 0 0 0 4px var(--accent-glow);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-height: 40px;
  padding: 0 var(--space-3);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition:
    transform var(--ease),
    background var(--ease),
    border-color var(--ease),
    box-shadow var(--ease),
    color var(--ease);
}

.btn--primary {
  color: #0a0a0a;
  background: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow-sm);
}

.btn--primary:hover {
  transform: translateY(-1px);
  background: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.btn--ghost {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-default);
}

.btn--ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg-base), 0 0 0 4px var(--accent-glow);
}

.btn .btn__icon {
  width: 14px;
  height: 14px;
  opacity: 0.85;
}

/* Hero */
.hero {
  padding-block: var(--space-8) var(--space-10);
  text-align: center;
}

.hero__inner {
  max-width: 800px;
  margin-inline: auto;
}

.hero__title {
  margin-bottom: var(--space-3);
  background: linear-gradient(180deg, #fff 0%, #e4e4e7 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero__sub {
  font-size: clamp(1.0625rem, 1.2vw + 0.9rem, 1.25rem);
  color: var(--text-secondary);
  max-width: 34rem;
  margin-inline: auto;
  margin-bottom: var(--space-6);
  letter-spacing: -0.02em;
}

.hero__sub strong {
  color: var(--text-primary);
  font-weight: 600;
}

.hero__cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

/* Project grid */
.project-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  list-style: none;
}

.project-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: var(--space-4);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0) 45%),
    var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition:
    transform var(--ease),
    border-color var(--ease),
    box-shadow var(--ease);
}

.project-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  transition: opacity var(--ease);
  background: radial-gradient(600px 240px at 100% 0%, var(--accent-soft), transparent 65%);
  pointer-events: none;
}

.project-tile:hover {
  transform: translateY(-4px) scale(1.01);
  border-color: var(--border-default);
  box-shadow: var(--shadow-card-hover);
}

.project-tile:hover::before {
  opacity: 1;
}

.project-tile__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  position: relative;
  z-index: 1;
}

.project-tile__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.project-tile__badge svg {
  width: 20px;
  height: 20px;
}

.project-tile__tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.tag {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
}

.project-tile__title {
  position: relative;
  z-index: 1;
  margin-bottom: var(--space-2);
}

.project-tile__desc {
  position: relative;
  z-index: 1;
  font-size: 0.9375rem;
  color: var(--text-muted);
  flex: 1;
  margin-bottom: var(--space-4);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.project-tile__meta {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-bottom: var(--space-3);
}

.chip {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  transition: border-color var(--ease), background var(--ease);
}

.project-tile:hover .chip {
  border-color: var(--border-default);
  background: rgba(255, 255, 255, 0.05);
}

.project-tile__action {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-top: auto;
  transition: gap var(--ease), color var(--ease);
}

.project-tile__action svg {
  width: 14px;
  height: 14px;
  opacity: 0.7;
  transition: transform var(--ease), opacity var(--ease);
}

.project-tile:hover .project-tile__action {
  gap: 10px;
  color: #fff;
}

.project-tile:hover .project-tile__action svg {
  transform: translateX(2px);
  opacity: 1;
}

.project-tile__action:focus-visible {
  outline: none;
  border-radius: var(--radius-sm);
  box-shadow: 0 0 0 2px var(--bg-base), 0 0 0 4px var(--accent-glow);
}

/* About */
.about {
  max-width: 38rem;
}

.about__lede {
  max-width: none;
}

.about__intro .about__lede + .about__lede {
  margin-top: var(--space-3);
}

.about__name {
  color: var(--text-primary);
  font-weight: 600;
}

.section__header--connect {
  margin-bottom: 0;
}

/* Focus — single panel, stacked rows */
.focus-panel {
  list-style: none;
  max-width: 800px;
  margin-inline: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.focus-row {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-4) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--ease);
}

.focus-row:last-child {
  border-bottom: 0;
}

.focus-row:hover {
  background: rgba(255, 255, 255, 0.02);
}

.focus-row__glyph {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  color: #a5b4fc;
  background: var(--accent-soft);
  border: 1px solid var(--border-subtle);
}

.focus-row__glyph svg {
  width: 20px;
  height: 20px;
}

.focus-row__title {
  font-size: 1rem;
  margin-bottom: 4px;
}

.focus-row__text {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.65;
  margin: 0;
}

/* Connect / form */
.connect {
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
}

.connect__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-8);
  align-items: start;
}

.form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.form__group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.form__group input,
.form__group textarea {
  width: 100%;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  transition: border-color var(--ease), box-shadow var(--ease);
}

.form__group input::placeholder,
.form__group textarea::placeholder {
  color: var(--text-muted);
}

.form__group input:focus,
.form__group textarea:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: 0 0 0 2px var(--bg-base), 0 0 0 4px var(--accent-soft);
}

.form__group textarea {
  min-height: 140px;
  resize: vertical;
}

.form-status {
  display: none;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
}

.form-status.is-visible {
  display: block;
}

.form-status--success {
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.1);
}

.form-status--error {
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.1);
}

/* Footer */
.site-footer {
  padding-block: var(--space-8);
}

.site-footer__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  text-align: center;
}

.site-footer__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
}

.site-footer__social {
  display: flex;
  gap: var(--space-2);
}

.site-footer__social a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  transition: color var(--ease), border-color var(--ease), background var(--ease), transform var(--ease);
}

.site-footer__social a:hover {
  color: var(--text-primary);
  border-color: var(--border-default);
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-2px);
}

.site-footer__social a:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg-base), 0 0 0 4px var(--accent-glow);
}

.site-footer__social svg {
  width: 18px;
  height: 18px;
}

.site-footer__legal {
  font-size: 0.8125rem;
  color: var(--text-muted);
  max-width: 28rem;
  line-height: 1.6;
}

.site-footer__legal a {
  color: var(--text-secondary);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color var(--ease);
}

.site-footer__legal a:hover {
  color: var(--text-primary);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Animations */
@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero__inner {
  animation: fade-up 600ms var(--ease) both;
}

/* Responsive */
@media (max-width: 960px) {
  .connect__grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .site-header__inner {
    flex-wrap: wrap;
    row-gap: var(--space-2);
  }

  .nav {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }

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

  .project-tile__top {
    flex-direction: column;
  }

  .project-tile__tags {
    justify-content: flex-start;
  }

  .hero__cta {
    flex-direction: column;
    width: 100%;
  }

  .hero__cta .btn {
    width: 100%;
  }
}

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

  html {
    scroll-behavior: auto;
  }
}
