:root {
  --bg: #071016;
  --paper: rgba(11, 25, 32, 0.82);
  --ink: #edf7ef;
  --muted: #9fb6b7;
  --line: rgba(145, 245, 232, 0.18);
  --accent: #50e6d2;
  --accent-soft: rgba(80, 230, 210, 0.14);
  --warm: #ff8c67;
  --lime: #c6f450;
  --shadow: 0 26px 70px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: "Segoe UI", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, #071016 0%, #0b171c 48%, #111a1c 100%);
}

#terrain-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  opacity: 1;
}

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

.page-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  gap: 24px;
  align-items: end;
  min-height: clamp(460px, 64vw, 660px);
  padding: clamp(26px, 5vw, 56px);
  border: 1px solid var(--line);
  border-radius: 30px;
  background:
    linear-gradient(90deg, rgba(3, 11, 16, 0.94) 0%, rgba(3, 11, 16, 0.78) 36%, rgba(3, 11, 16, 0.18) 72%),
    linear-gradient(180deg, rgba(3, 11, 16, 0.04), rgba(3, 11, 16, 0.8)),
    url("./factory-hero.png") center / cover no-repeat;
  box-shadow: var(--shadow);
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(80, 230, 210, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(80, 230, 210, 0.06) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(90deg, rgba(0, 0, 0, 0.5), transparent 58%);
}

.hero-copy,
.hero-note {
  position: relative;
  z-index: 1;
}

.eyebrow,
.section-kicker,
.hero-label,
.app-number,
.app-status {
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow,
.section-kicker {
  margin: 0 0 12px;
  color: var(--lime);
  font-size: 0.76rem;
  font-weight: 700;
}

.hero h1 {
  position: relative;
  margin: 0;
  padding-bottom: 0.14em;
  max-width: 700px;
  font-size: clamp(3rem, 7vw, 6.2rem);
  line-height: 1.12;
  letter-spacing: 0;
  text-shadow: 0 0 28px rgba(80, 230, 210, 0.18);
}

.glitch-in {
  opacity: 0;
  transform: translateY(12px);
  filter: blur(8px);
}

.glitch-in.is-visible {
  animation: glitch-fade-in 920ms steps(1, end) var(--glitch-delay, 0ms) both;
}

.glitch-title::before,
.glitch-title::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
}

.glitch-title::before {
  color: #50e6d2;
  transform: translateX(-2px);
  clip-path: inset(0 0 58% 0);
}

.glitch-title::after {
  color: #ff8c67;
  transform: translateX(2px);
  clip-path: inset(48% 0 0 0);
}

.glitch-title.is-visible::before,
.glitch-title.is-visible::after {
  animation: glitch-ghost 920ms steps(1, end) var(--glitch-delay, 0ms) both;
}

@keyframes glitch-fade-in {
  0% {
    opacity: 0;
    transform: translateY(18px) skewX(-4deg);
    filter: blur(10px);
    clip-path: inset(0 0 92% 0);
  }
  12% {
    opacity: 0.72;
    transform: translateY(0) skewX(3deg);
    filter: blur(2px);
    clip-path: inset(52% 0 26% 0);
  }
  20% {
    opacity: 0.28;
    transform: translateY(7px) skewX(-2deg);
    filter: blur(6px);
    clip-path: inset(18% 0 58% 0);
  }
  34% {
    opacity: 0.9;
    transform: translateY(0) skewX(1deg);
    filter: blur(1px);
    clip-path: inset(0 0 0 0);
  }
  42% {
    opacity: 0.58;
    transform: translateX(-3px);
    filter: blur(3px);
    clip-path: inset(70% 0 8% 0);
  }
  55% {
    opacity: 1;
    transform: translateX(2px);
    filter: blur(0);
    clip-path: inset(0 0 0 0);
  }
  100% {
    opacity: 1;
    transform: none;
    filter: none;
    clip-path: inset(0 0 0 0);
  }
}

@keyframes glitch-ghost {
  0%, 10%, 22%, 42%, 100% {
    opacity: 0;
  }
  12%, 20% {
    opacity: 0.65;
  }
  34%, 38% {
    opacity: 0.45;
  }
}

.lead {
  max-width: 43rem;
  margin: 24px 0 0;
  color: rgba(237, 247, 239, 0.82);
  font-size: 1.05rem;
  line-height: 2.05;
}

.hero-note {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: end;
  gap: 14px;
  min-height: 160px;
  padding: 26px 26px 28px;
  border: 1px solid rgba(145, 245, 232, 0.26);
  border-radius: 18px;
  background: rgba(2, 10, 14, 0.66);
  color: #edf7ef;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  cursor: pointer;
  text-decoration: none;
  transition:
    border-color 180ms ease,
    background 180ms ease,
    box-shadow 180ms ease;
}

.hero-note:hover,
.hero-note:focus-visible {
  border-color: rgba(145, 245, 232, 0.72);
  background: rgba(5, 20, 25, 0.78);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 0 28px rgba(80, 230, 210, 0.14);
}

.hero-note:focus-visible {
  outline: 3px solid rgba(145, 245, 232, 0.5);
  outline-offset: 4px;
}

.hero-share-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(237, 247, 239, 0.28);
  border-radius: 999px;
  background: rgba(2, 10, 14, 0.72);
  color: #edf7ef;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
  box-shadow: 0 0 24px rgba(80, 230, 210, 0.16);
  transition:
    border-color 180ms ease,
    background 180ms ease,
    color 180ms ease,
    transform 180ms ease;
}

.hero-note:hover .hero-share-badge,
.hero-note:focus-visible .hero-share-badge {
  border-color: rgba(145, 245, 232, 0.76);
  background: #edf7ef;
  color: #061015;
  transform: translateY(-1px);
}

.hero-count {
  justify-self: end;
  font-size: clamp(4rem, 7vw, 5.8rem);
  font-weight: 800;
  line-height: 0.98;
}

.hero-label {
  align-self: end;
  color: rgba(237, 247, 239, 0.7);
  font-size: 1rem;
  font-weight: 700;
}

main {
  margin-top: 32px;
}

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

.section-head h2 {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 2.4rem);
}

.section-sub {
  max-width: 36rem;
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

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

.app-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.reveal-card {
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity 560ms ease,
    transform 560ms cubic-bezier(0.2, 0.8, 0.2, 1);
  transition-delay: var(--reveal-delay, 0ms);
}

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

.card-media {
  display: block;
  aspect-ratio: 800 / 418;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(80, 230, 210, 0.12), rgba(255, 140, 103, 0.12));
}

.card-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1);
  transition: transform 280ms ease;
}

.card-media:hover img,
.card-media:focus-visible img {
  transform: scale(1.06);
}

.card-body {
  padding: 22px 22px 24px;
}

.card-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.app-number {
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
}

.app-status {
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(198, 244, 80, 0.12);
  color: var(--lime);
  font-size: 0.72rem;
  font-weight: 700;
}

.app-status.muted {
  background: rgba(242, 142, 114, 0.12);
  color: #9c5b47;
}

.card-body h3 {
  margin: 14px 0 10px;
  font-size: 1.6rem;
  line-height: 1.2;
}

.card-desc {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
}

.card-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-top: 20px;
}

.card-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.app-credit {
  flex: 0 1 250px;
  margin: 0 0 2px auto;
  color: rgba(211, 247, 255, 0.66);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.68rem;
  line-height: 1.45;
  text-align: right;
}

.app-credit span {
  display: block;
}

.app-credit strong {
  color: rgba(239, 255, 252, 0.9);
  font-weight: 700;
}

.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 999px;
  font-weight: 700;
}

.btn-primary {
  background: var(--accent);
  color: #061015;
}

.btn-secondary {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
}

.readme-page {
  background:
    linear-gradient(180deg, #071016 0%, #0b171c 100%);
}

.readme-shell {
  position: relative;
  z-index: 1;
  width: min(900px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.readme-nav {
  margin-bottom: 18px;
}

.readme-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--accent);
  font-weight: 700;
}

.readme-content {
  padding: clamp(24px, 5vw, 48px);
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(11, 25, 32, 0.88);
  box-shadow: var(--shadow);
}

.readme-content h1,
.readme-content h2,
.readme-content h3 {
  line-height: 1.3;
}

.readme-content h1 {
  margin: 0 0 18px;
  font-size: clamp(2rem, 5vw, 3.2rem);
}

.readme-content h2 {
  margin: 42px 0 16px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  font-size: clamp(1.35rem, 3vw, 2rem);
}

.readme-content h3 {
  margin: 28px 0 12px;
  font-size: 1.15rem;
}

.readme-content p,
.readme-content li,
.readme-content blockquote,
.readme-content td,
.readme-content th {
  line-height: 1.85;
}

.readme-content p,
.readme-content ul,
.readme-content ol,
.readme-content blockquote,
.readme-content table,
.readme-content pre {
  margin: 0 0 18px;
}

.readme-content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 18px 0 22px;
  border-radius: 18px;
  box-shadow: 0 14px 34px rgba(24, 52, 59, 0.14);
}

.readme-content blockquote {
  padding: 14px 18px;
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  background: rgba(80, 230, 210, 0.1);
  color: var(--ink);
}

.readme-content code {
  padding: 0.15em 0.35em;
  border-radius: 6px;
  background: rgba(237, 247, 239, 0.09);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.92em;
}

.readme-content pre {
  overflow-x: auto;
  padding: 16px;
  border-radius: 14px;
  background: #020a0e;
  color: #edf7ef;
}

.readme-content pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}

.readme-content table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 12px;
}

.readme-content th,
.readme-content td {
  padding: 10px 12px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.readme-content th {
  background: rgba(80, 230, 210, 0.12);
}

@media (max-width: 820px) {
  .page-shell {
    width: min(100% - 20px, 1120px);
    padding-top: 20px;
  }

  .hero {
    grid-template-columns: 1fr;
    padding: 24px;
  }

  .hero-note {
    min-height: auto;
  }

  .section-head {
    flex-direction: column;
    align-items: start;
  }

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

  .card-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .app-credit {
    align-self: flex-end;
    max-width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card-media img,
  .reveal-card,
  .glitch-in,
  .glitch-title::before,
  .glitch-title::after {
    transition: none;
    animation: none;
  }

  .reveal-card,
  .glitch-in {
    opacity: 1;
    transform: none;
    filter: none;
  }
}
