:root {
  color-scheme: dark;
  --bg: #131315;
  --surface: #000000;
  --surface-elevated: #0a0a0c;
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);
  --border-accent: rgba(255, 84, 0, 0.42);
  --ink: #ffffff;
  --ink-secondary: #d3d3d3;
  --ink-muted: #8a8a93;
  --accent: #ff5400;
  --accent-hover: #e62500;
  --accent-soft: rgba(255, 84, 0, 0.12);
  --radius-panel: 16px;
  --radius-item: 12px;
  --radius-pill: 999px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-arrow: cubic-bezier(0.645, 0.045, 0.355, 1);
}

* {
  box-sizing: border-box;
}

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

main:focus {
  outline: none;
}

::selection {
  background-color: var(--accent);
  color: #000000;
}

html {
  min-height: 100%;
  background-color: var(--bg);
}

body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--bg);
  color: var(--ink);
  font-family: Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background-image: radial-gradient(
    ellipse 900px 480px at 50% 0px,
    rgba(255, 84, 0, 0.06) 0%,
    transparent 65%
  );
}

h1,
h2,
h3,
p,
ul,
ol {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
  touch-action: manipulation;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  inset: 12px auto auto 12px;
  z-index: 60;
  transform: translateY(calc(-100% - 24px));
  padding: 10px 16px;
  color: var(--ink);
  background: #171619;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  transition: transform 160ms var(--ease-out);
}

.skip-link:focus-visible {
  transform: translateY(0);
}

.shell {
  width: min(100%, 1040px);
  min-height: 100dvh;
  margin-inline: auto;
  padding: clamp(16px, 3vw, 32px) clamp(16px, 4vw, 32px) clamp(24px, 4vw, 40px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Entrance choreography: non-uniform delays, one entrance per container */
.enter {
  opacity: 0;
  transform: translateY(10px) scale(0.985);
  animation: surface-enter 480ms var(--ease-out) var(--enter-delay, 0ms) both;
}

.project-grid.enter {
  transform: translateY(10px);
  animation-name: grid-enter;
}

@keyframes surface-enter {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes grid-enter {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Top bar */
.topbar {
  --enter-delay: 0ms;
  position: sticky;
  top: 14px;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 10px 6px 20px;
  background-color: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-pill);
}

@supports not (backdrop-filter: blur(1px)) {
  .topbar {
    background-color: #000000;
  }
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand-root,
.brand-here {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.brand-root {
  color: var(--ink-muted);
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 150ms ease;
}

.brand-sep {
  color: rgba(255, 255, 255, 0.24);
  user-select: none;
  flex-shrink: 0;
}

.brand-here {
  color: var(--ink);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 150ms ease;
}

.topbar-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.topbar-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition:
    background-color 150ms ease,
    color 150ms ease,
    transform 100ms var(--ease-out);
}

.topbar-cta:active {
  transform: scale(0.97);
  transition-duration: 160ms;
}

/* Main stack */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* Hero bento */
.hero {
  --enter-delay: 55ms;
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: end;
  min-height: clamp(260px, 40svh, 380px);
  padding: clamp(28px, 4.5vw, 48px);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
}

.hero-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.hero-scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.86) 0%,
    rgba(0, 0, 0, 0.24) 55%,
    transparent 100%
  );
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 52ch;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hero-kicker {
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.hero-title {
  font-size: clamp(2.85rem, 8vw, 5.25rem);
  font-weight: 600;
  line-height: 0.96;
  letter-spacing: -0.035em;
  color: var(--ink);
  text-wrap: balance;
}

.hero-title .dot {
  color: var(--accent);
}

.hero-lead {
  font-size: clamp(1.05rem, 2.2vw, 1.35rem);
  font-weight: 500;
  line-height: 1.45;
  color: var(--ink-secondary);
  max-width: 44ch;
  text-wrap: pretty;
}

/* Generic bento panel */
.panel {
  --enter-delay: 105ms;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  padding: clamp(24px, 3.6vw, 36px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.panel-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
}

/* Empty bench state */
.bench-empty {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr);
  gap: 24px;
  align-items: center;
  padding-top: 4px;
}

.bench-empty-copy {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.55;
  color: var(--ink-muted);
  max-width: 48ch;
  text-wrap: pretty;
}

.bench-slug-preview {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--surface-elevated);
  color: var(--ink-secondary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  width: fit-content;
}

.bench-slug-preview .slug-accent {
  color: var(--accent);
}

/* Visual project showcase grid */
.project-grid {
  --enter-delay: 105ms;
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 12px;
}

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

.project-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
  padding: clamp(18px, 2.5vw, 24px);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  transition:
    border-color 180ms ease,
    transform 180ms var(--ease-out);
}

.project-card:has(.project-card-main:focus-visible) {
  border-color: var(--accent);
}

.project-card:has(.project-card-main:active) {
  transform: scale(0.992);
  transition-duration: 120ms;
}

.project-card-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

.project-card-main::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.project-card-main:focus-visible {
  outline: none;
}

.project-grid.is-single .project-card-main {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  align-items: start;
  gap: clamp(20px, 3vw, 32px);
}

.project-media {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius-item);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background-color: #0b0b0d;
  display: grid;
  place-items: center;
}

.project-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
  transition: transform 280ms var(--ease-out);
}

.project-media.is-fallback {
  background: radial-gradient(circle at 50% 45%, rgba(255, 84, 0, 0.14), #0b0b0d 72%);
}

.project-media-fallback-icon {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 14px;
}

.project-media-fallback-slug {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 16px;
  color: var(--ink-muted);
}

.project-body {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.project-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.project-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--surface-elevated);
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

.project-heading-group {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.project-name {
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.025em;
  color: var(--ink);
}

.project-slug {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  color: var(--ink-muted);
}

.project-summary {
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-secondary);
  line-height: 1.5;
  max-width: 60ch;
  text-wrap: pretty;
}

.project-foot {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.project-foot .arrow-badge {
  margin-left: auto;
}

.card-pill {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding-inline: 4px;
  margin-left: -4px;
  color: var(--ink-muted);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition:
    color 150ms ease,
    transform 100ms var(--ease-out);
}

.card-pill:active {
  transform: scale(0.97);
  transition-duration: 160ms;
}

.arrow-badge {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--ink);
  color: #000000;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transform: rotate(4deg);
  transition:
    transform 180ms var(--ease-arrow),
    background-color 160ms ease;
}

.arrow-badge svg {
  width: 15px;
  height: 15px;
  display: block;
}

/* Project detail page */
.detail-hero {
  --enter-delay: 55ms;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  padding: clamp(28px, 4.5vw, 44px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.detail-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius-item);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #0b0b0d;
}

.detail-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  width: fit-content;
  color: var(--ink-muted);
  font-size: 14px;
  font-weight: 600;
  transition:
    color 150ms ease,
    transform 100ms var(--ease-out);
}

.detail-title {
  font-size: clamp(2.1rem, 5.5vw, 3.6rem);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.03em;
  color: var(--ink);
  text-wrap: balance;
}

.detail-summary {
  font-size: clamp(1rem, 2vw, 1.2rem);
  color: var(--ink-secondary);
  max-width: 60ch;
  text-wrap: pretty;
}

.detail-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.pill-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  background: var(--surface-elevated);
  color: var(--ink);
  transition:
    background-color 150ms ease,
    border-color 150ms ease,
    color 150ms ease,
    transform 100ms var(--ease-out);
}

.pill-action.is-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #000000;
}

.pill-action:active {
  transform: scale(0.97);
  transition-duration: 160ms;
}

.prose {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 68ch;
  color: var(--ink-secondary);
  font-size: 16px;
  line-height: 1.65;
}

.prose h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.02em;
  margin-top: 8px;
}

.prose h4 {
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  margin: 6px 0 0;
}

.prose a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 4px;
  transition: color 150ms ease;
}

.prose ul,
.prose ol {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em;
  background: rgba(255, 255, 255, 0.07);
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--ink);
}

.prose pre {
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
  border-radius: var(--radius-item);
  border: 1px solid var(--border);
  background: var(--surface-elevated);
}

.prose pre code {
  background: transparent;
  padding: 0;
}

/* Social links strip + Footer */
.footer-block {
  --enter-delay: 145ms;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.social-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.social-pill {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 52px;
  padding: 14px 20px;
  border-radius: var(--radius-pill);
  background-color: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition:
    border-color 160ms ease,
    transform 100ms var(--ease-out);
}

.social-pill::before {
  content: "";
  position: absolute;
  inset: 0;
  background-color: var(--accent);
  clip-path: inset(0 100% 0 0);
  transition: clip-path 160ms var(--ease-out);
  z-index: 0;
}

.social-pill > span {
  position: relative;
  z-index: 1;
  transition: color 160ms ease;
}

.social-pill .social-arrow {
  font-size: 14px;
  color: var(--ink-muted);
  transition:
    color 160ms ease,
    transform 180ms var(--ease-out);
}

.social-pill.is-accent {
  background-color: var(--accent);
  border-color: var(--accent);
  color: #000000;
}

.social-pill.is-accent::before {
  background-color: var(--accent-hover);
}

.social-pill.is-accent .social-arrow {
  color: rgba(0, 0, 0, 0.72);
}

.social-pill:active {
  transform: scale(0.97);
  transition-duration: 160ms;
}

.footer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background-color: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-muted);
}

.footer-bar strong {
  color: var(--ink);
  font-weight: 600;
}

.footer-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: rgba(255, 84, 0, 0.45);
  transition:
    color 150ms ease,
    text-decoration-color 150ms ease;
}

/* Keyboard focus parity (no motion) */
.topbar-cta:focus-visible {
  background-color: var(--accent);
  color: #000000;
}

.card-pill:focus-visible,
.footer-link:focus-visible {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.project-card:has(.project-card-main:focus-visible) .arrow-badge {
  background-color: var(--accent);
}

/* Hover states strictly gated for fine pointers */
@media (hover: hover) and (pointer: fine) {
  .brand-root:hover {
    color: var(--ink);
  }

  .topbar-cta:hover {
    background-color: var(--accent);
    color: #000000;
  }

  .project-card:hover {
    border-color: rgba(255, 84, 0, 0.34);
    transform: translateY(-3px);
  }

  .project-card:hover .project-media img {
    transform: scale(1.025);
  }

  .project-card:hover .arrow-badge {
    background-color: var(--accent);
    transform: rotate(-8deg) scale(1.06);
  }

  .card-pill:hover {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 4px;
  }

  .back-link:hover {
    color: var(--ink);
    transform: translateX(-2px);
  }

  .pill-action:hover {
    border-color: var(--border-accent);
    color: var(--accent);
  }

  .pill-action.is-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: var(--ink);
  }

  .prose a:hover,
  .footer-link:hover {
    color: var(--ink);
    text-decoration-color: var(--accent);
  }

  .social-pill:hover {
    border-color: var(--accent);
  }

  .social-pill:hover::before {
    clip-path: inset(0 0 0 0);
    transition-duration: 220ms;
  }

  .social-pill:hover > span {
    color: #000000;
  }

  .social-pill:hover .social-arrow {
    color: #000000;
    transform: translate(2px, -2px);
  }

  .social-pill.is-accent:hover {
    border-color: var(--accent-hover);
  }

  .social-pill.is-accent:hover > span,
  .social-pill.is-accent:hover .social-arrow {
    color: var(--ink);
  }
}

/* Active states after hover rules so press wins on desktop */
.back-link:active,
.back-link:hover:active {
  transform: scale(0.97);
  transition-duration: 160ms;
}

/* Responsive */
@media (max-width: 780px) {
  .topbar {
    padding: 6px 10px 6px 16px;
    flex-wrap: wrap;
    border-radius: 22px;
  }

  .bench-empty {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  .project-grid.is-single .project-card-main {
    grid-template-columns: minmax(0, 1fr);
  }

  .social-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .footer-bar {
    flex-direction: column;
    align-items: flex-start;
    border-radius: var(--radius-panel);
    padding: 16px 20px;
    gap: 6px;
  }
}

@media (max-width: 400px) {
  .social-pill {
    padding: 12px 14px;
    font-size: 15px;
  }
}

/* Reduced motion: collapse choreography and remove all movement */
@media (prefers-reduced-motion: reduce) {
  .enter,
  .project-grid.enter {
    opacity: 0;
    transform: none;
    animation: reduced-fade 180ms ease-out 0ms both;
  }

  @keyframes reduced-fade {
    to {
      opacity: 1;
    }
  }

  .skip-link,
  .social-pill::before {
    transition: none;
  }

  .arrow-badge,
  .social-pill,
  .social-arrow,
  .topbar-cta,
  .pill-action,
  .back-link,
  .project-card,
  .project-media img,
  .card-pill {
    transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease;
  }

  .project-card:hover,
  .project-card:has(.project-card-main:active),
  .project-card:hover .project-media img,
  .project-card:hover .arrow-badge,
  .back-link:hover,
  .back-link:active,
  .back-link:hover:active,
  .social-pill:active,
  .social-pill:hover .social-arrow,
  .topbar-cta:active,
  .pill-action:active,
  .card-pill:active {
    transform: none;
  }
}
