:root {
  --bg: #0A0A0A;
  --paper: #F5F5F5;
  --muted: #A3A3A3;
  --dim: #737373;
  --line: rgba(245, 245, 245, 0.16);
  --red: #DC2626;
  --panel: rgba(245, 245, 245, 0.045);
  --panel-strong: rgba(245, 245, 245, 0.08);
  --shadow: rgba(0, 0, 0, 0.38);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(220, 38, 38, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(220, 38, 38, 0.06) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.92), transparent 86%);
  z-index: -2;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.68) 100%);
  z-index: -1;
}

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

button {
  color: inherit;
  font: inherit;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon-sprite path,
.icon-sprite circle {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 72px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 10, 10, 0.82);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: max-content;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--red);
  color: var(--red);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.brand-name,
.eyebrow,
.filter,
.card-index,
.card-meta,
.source-link,
.section-count,
.viewer-bar {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0;
}

.brand-name {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.filters::-webkit-scrollbar {
  display: none;
}

.filter {
  border: 1px solid var(--line);
  background: transparent;
  padding: 9px 11px;
  font-size: 11px;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 180ms ease, color 180ms ease, background 180ms ease;
}

.filter:hover,
.filter.is-active {
  color: var(--paper);
  border-color: var(--red);
  background: rgba(220, 38, 38, 0.16);
}

.hero {
  position: relative;
  min-height: 70svh;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(320px, 0.96fr);
  align-items: center;
  gap: 36px;
  padding: 48px 48px 36px;
  border-bottom: 1px solid var(--line);
}

.hero-grid {
  position: absolute;
  inset: 0;
  opacity: 0.45;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(245, 245, 245, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(245, 245, 245, 0.045) 1px, transparent 1px);
  background-size: 84px 84px;
}

.hero-copy {
  position: relative;
  z-index: 2;
  max-width: 780px;
}

.eyebrow {
  margin: 0 0 18px;
  color: var(--red);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 720px;
  margin-bottom: 22px;
  font-size: 84px;
  line-height: 0.92;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

.hero-lede {
  max-width: 620px;
  margin-bottom: 34px;
  color: #CFCFCF;
  font-size: 19px;
  line-height: 1.45;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  max-width: 680px;
  border: 1px solid var(--line);
  background: var(--line);
}

.hero-stats div {
  min-height: 92px;
  padding: 18px;
  background: rgba(10, 10, 10, 0.82);
}

.hero-stats strong {
  display: block;
  margin-bottom: 8px;
  color: var(--paper);
  font-size: 34px;
  line-height: 1;
}

.hero-stats span {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  text-transform: uppercase;
}

.access-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.hero-access-form {
  max-width: 680px;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  background: rgba(245, 245, 245, 0.045);
}

.access-form label {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.access-form label span,
.form-status {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.access-form label span {
  color: var(--paper);
}

.access-form input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: rgba(10, 10, 10, 0.82);
  color: var(--paper);
  padding: 0 14px;
  font: inherit;
  outline: none;
}

.access-form input:focus {
  border-color: var(--red);
}

.access-form button {
  min-height: 46px;
  border: 1px solid var(--red);
  border-radius: 0;
  background: var(--red);
  color: var(--paper);
  padding: 0 18px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  cursor: pointer;
}

.access-form button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.form-status {
  grid-column: 1 / -1;
  min-height: 15px;
  margin: 0;
  color: var(--muted);
}

.hero-visual {
  position: relative;
  z-index: 1;
  justify-self: center;
  width: min(34vw, 440px);
  min-width: 280px;
  aspect-ratio: 1;
  transform-style: preserve-3d;
}

.hero-visual svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.plate-a {
  animation: drift-a 8s ease-in-out infinite;
}

.plate-b {
  animation: drift-b 7s ease-in-out infinite;
}

.rupture {
  stroke-dasharray: 18 13;
  animation: dash 2.6s linear infinite;
}

.node-cloud circle {
  animation: pulse 2.8s ease-in-out infinite;
}

.node-cloud circle:nth-child(2) { animation-delay: 0.25s; }
.node-cloud circle:nth-child(3) { animation-delay: 0.5s; }
.node-cloud circle:nth-child(4) { animation-delay: 0.75s; }
.node-cloud circle:nth-child(5) { animation-delay: 1s; }

.library {
  padding: 54px 48px 84px;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.section-head h2 {
  margin: 0;
  font-size: 40px;
  line-height: 1;
  text-transform: uppercase;
}

.section-count {
  margin: 0;
  color: var(--dim);
  font-size: 12px;
  text-transform: uppercase;
}

.style-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.library-cta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 520px);
  gap: 28px;
  align-items: end;
  margin-top: 18px;
  padding: 28px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
}

.library-cta h2 {
  max-width: 680px;
  margin-bottom: 12px;
}

.library-cta p:not(.eyebrow):not(.form-status) {
  max-width: 620px;
  margin-bottom: 0;
  color: #CFCFCF;
  font-size: 16px;
  line-height: 1.45;
}

.style-card {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 18px 60px var(--shadow);
  opacity: 0;
  transform: translateY(18px);
  transition: transform 240ms ease, opacity 240ms ease, border-color 180ms ease, background 180ms ease;
}

.style-card.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.style-card:hover {
  border-color: color-mix(in srgb, var(--accent, var(--red)) 72%, var(--paper));
  background: var(--panel-strong);
}

.style-card.is-hidden {
  display: none;
}

.preview-window {
  position: relative;
  height: 226px;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px),
    #050505;
  background-size: 28px 28px;
}

.preview-window::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.035), inset 0 -70px 90px rgba(0,0,0,0.72);
}

.preview-window iframe {
  width: 1200px;
  height: 760px;
  border: 0;
  transform: scale(0.32);
  transform-origin: 0 0;
  pointer-events: none;
  background: #050505;
}

.project-preview iframe {
  width: 860px;
  height: 620px;
  transform: scale(0.38);
}

.animation-preview iframe {
  width: 1280px;
  height: 720px;
  transform: scale(0.31);
}

.preview-action {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(245, 245, 245, 0.2);
  background: rgba(10, 10, 10, 0.82);
  color: var(--paper);
  cursor: pointer;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.preview-action:hover {
  border-color: var(--accent, var(--red));
  background: rgba(220, 38, 38, 0.28);
  transform: translateY(-2px);
}

.preview-action svg,
.source-link svg,
.viewer-close svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.card-body {
  padding: 18px;
}

.card-index {
  margin-bottom: 10px;
  color: var(--accent, var(--red));
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.card-body h3 {
  margin-bottom: 10px;
  font-size: 24px;
  line-height: 1.05;
  text-transform: uppercase;
}

.card-text {
  min-height: 66px;
  margin-bottom: 16px;
  color: #BDBDBD;
  font-size: 14px;
  line-height: 1.45;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.card-meta span {
  border: 1px solid rgba(245,245,245,0.14);
  padding: 5px 7px;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.source-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--paper);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.source-link:hover {
  color: var(--accent, var(--red));
}

.viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(3px);
}

.viewer[hidden] {
  display: none;
}

.viewer-panel {
  display: grid;
  grid-template-rows: 52px minmax(0, 1fr);
  width: 90vw;
  height: 90vh;
  border: 1px solid var(--line);
  background: rgba(10, 10, 10, 0.96);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.72);
}

.viewer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 0 18px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.viewer-close {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
}

.viewer-close:hover {
  border-color: var(--red);
  color: var(--red);
}

.viewer iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #050505;
}

@keyframes drift-a {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  50% { transform: translate(-20px, 15px) rotate(-2deg); }
}

@keyframes drift-b {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  50% { transform: translate(22px, -12px) rotate(2deg); }
}

@keyframes dash {
  to { stroke-dashoffset: -62; }
}

@keyframes pulse {
  0%, 100% { opacity: 0.34; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.7); }
}

@media (max-width: 1120px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .hero-visual {
    order: -1;
    width: min(68vw, 420px);
    min-width: 280px;
  }

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

@media (max-width: 760px) {
  .topbar {
    position: relative;
    align-items: stretch;
    flex-direction: column;
    padding: 14px;
  }

  .filters {
    padding-bottom: 2px;
  }

  .hero,
  .library {
    padding-left: 18px;
    padding-right: 18px;
  }

  .hero {
    min-height: auto;
    gap: 20px;
    padding-top: 28px;
    padding-bottom: 28px;
  }

  .hero-visual {
    width: min(58vw, 220px);
    min-width: 0;
  }

  h1 {
    margin-bottom: 16px;
    font-size: 42px;
  }

  .hero-lede {
    margin-bottom: 22px;
    font-size: 16px;
  }

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

  .access-form,
  .library-cta {
    grid-template-columns: 1fr;
  }

  .access-form button {
    width: 100%;
  }

  .hero-stats div {
    min-height: 74px;
    padding: 14px 16px;
  }

  .hero-stats strong {
    font-size: 30px;
  }

  .section-head {
    display: block;
  }

  .section-head h2 {
    margin-bottom: 12px;
    font-size: 30px;
  }

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

  .preview-window {
    height: 210px;
  }

  .preview-window iframe {
    transform: scale(0.31);
  }

  .project-preview iframe {
    transform: scale(0.35);
  }

  .animation-preview iframe {
    transform: scale(0.3);
  }
}

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