/* ==========================================================================
   Paper Meteor — papercut night-sky theme
   Palette lifted from the official papercut logo:
   navy sky, teal / gold / orange / ember paper layers, cream lettering.
   The sky itself is a Three.js scene (sky3d.js) on the #sky canvas.
   ========================================================================== */

:root {
  --bg: #0e1a2b;
  --bg-deep: #0a1420;
  --panel: #152a41;
  --panel-edge: rgba(244, 232, 204, 0.10);
  --teal: #2e8c96;
  --teal-deep: #1c5f6e;
  --gold: #eda63a;
  --orange: #e0662f;
  --ember: #c74b2c;
  --cream: #f4e8cc;
  --cream-dim: rgba(244, 232, 204, 0.66);
  --cream-faint: rgba(244, 232, 204, 0.42);
  --ink: #2a2118;
  --ink-soft: #5c4f3d;
  --paper: #f6edd8;
  --shadow: 0 10px 30px rgba(4, 9, 16, 0.45);
  --font-display: 'Fredoka', 'Trebuchet MS', 'Segoe UI', sans-serif;
  --font-body: 'Nunito', 'Segoe UI', Arial, sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--cream);
  line-height: 1.7;
  overflow-x: hidden;
}

/* deep-space gradient behind the WebGL sky; also the no-JS fallback */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(46, 140, 150, 0.14), transparent 55%),
    radial-gradient(90% 60% at 85% 8%, rgba(237, 166, 58, 0.07), transparent 60%),
    linear-gradient(180deg, #0b1522 0%, #0e1a2b 45%, #122438 100%);
}

::selection {
  background: var(--gold);
  color: var(--ink);
}

.wrap {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 24px;
}

/* --- animated sky canvas ------------------------------------------------- */

#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

header.site,
main,
footer.site {
  position: relative;
  z-index: 1;
}

/* --- header --------------------------------------------------------------- */

header.site {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 14px 0;
  background: rgba(10, 20, 32, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(244, 232, 204, 0.06);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

header.site.scrolled {
  background: rgba(10, 20, 32, 0.88);
  box-shadow: 0 6px 24px rgba(4, 9, 16, 0.5);
}

header.site .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.brand {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--cream);
  display: inline-flex;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  display: block;
  width: 38px;
  height: 38px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(4, 9, 16, 0.6));
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.brand:hover .brand-mark {
  transform: rotate(-12deg) scale(1.08);
}

nav.site a {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--cream-dim);
  text-decoration: none;
  margin-left: 24px;
  position: relative;
  padding-bottom: 3px;
  transition: color 0.25s ease;
}

nav.site a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--teal), var(--gold), var(--orange));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
}

nav.site a:hover {
  color: var(--cream);
}

nav.site a:hover::after {
  transform: scaleX(1);
}

/* --- hero ------------------------------------------------------------------ */

.hero {
  position: relative;
  min-height: 94vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  /* bottom padding keeps the CTAs clear of the 3D paper hills */
  padding: 40px 0 230px;
  margin-top: -71px; /* pull behind the translucent sticky header */
}

.hero-inner {
  position: relative;
  padding: 0 24px;
  max-width: 780px;
}

.meteor-mark {
  display: block;
  width: clamp(140px, 26vw, 210px);
  height: auto;
  margin: 0 auto 10px;
  filter: drop-shadow(0 18px 30px rgba(4, 9, 16, 0.65));
  animation: bob 5.5s ease-in-out infinite;
  will-change: transform;
}

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-14px) rotate(-2.5deg); }
}

.hero h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.8rem, 8vw, 5rem);
  line-height: 1.05;
  letter-spacing: 0.015em;
  color: var(--cream);
  text-shadow: 0 4px 0 rgba(199, 75, 44, 0.35), 0 14px 34px rgba(4, 9, 16, 0.7);
}

.hero h1 .word {
  display: inline-block;
  opacity: 0;
  transform: translateY(0.55em) rotate(3deg);
  animation: word-in 0.7s cubic-bezier(0.22, 1.2, 0.36, 1) forwards;
}

.hero h1 .word:nth-child(2) { animation-delay: 0.14s; }

@keyframes word-in {
  to { opacity: 1; transform: translateY(0) rotate(0deg); }
}

/* "— GAME STUDIO —" lockup line, matching the footer treatment */
.hero-tag {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 16px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(0.78rem, 1.8vw, 0.95rem);
  letter-spacing: 0.45em;
  text-indent: 0.45em; /* balance the tracking */
  text-transform: uppercase;
  color: var(--cream-dim);
  opacity: 0;
  animation: fade-up 0.8s ease 0.45s forwards;
}

.hero-tag::before,
.hero-tag::after {
  content: "";
  width: 34px;
  height: 2px;
  border-radius: 2px;
  background: var(--cream-dim);
  opacity: 0.6;
}

.hero .cta-row {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 34px;
  opacity: 0;
  animation: fade-up 0.8s ease 0.65s forwards;
}

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

/* --- buttons --------------------------------------------------------------- */

.btn {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.02em;
  text-decoration: none;
  padding: 13px 30px;
  border-radius: 999px;
  display: inline-block;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--orange));
  color: var(--ink);
  box-shadow: 0 6px 0 rgba(199, 75, 44, 0.55), 0 14px 30px rgba(4, 9, 16, 0.5);
}

.btn-primary:hover {
  transform: translateY(-3px) rotate(-1deg);
  box-shadow: 0 9px 0 rgba(199, 75, 44, 0.55), 0 20px 36px rgba(4, 9, 16, 0.55);
}

.btn-primary:active {
  transform: translateY(2px);
  box-shadow: 0 3px 0 rgba(199, 75, 44, 0.55), 0 8px 18px rgba(4, 9, 16, 0.5);
}

.btn-ghost {
  color: var(--cream);
  border: 2px solid rgba(244, 232, 204, 0.35);
}

.btn-ghost:hover {
  transform: translateY(-3px);
  border-color: var(--cream);
  box-shadow: 0 12px 26px rgba(4, 9, 16, 0.45);
}

/* --- sections --------------------------------------------------------------- */

main {
  padding-bottom: 30px;
}

section {
  padding: 72px 0 24px;
}

section h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  color: var(--cream);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 14px;
}

section h2::before {
  content: "";
  width: 14px;
  height: 14px;
  background: linear-gradient(135deg, var(--gold), var(--orange));
  transform: rotate(45deg);
  border-radius: 3px;
  box-shadow: 3px 3px 0 rgba(46, 140, 150, 0.55);
  flex: none;
}

.section-sub {
  color: var(--cream-dim);
  max-width: 46em;
  margin-bottom: 10px;
}

/* --- cards ------------------------------------------------------------------ */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 22px;
  margin-top: 26px;
}

.card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 16px;
  padding: 28px 26px 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  transform-style: preserve-3d;
  will-change: transform;
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--teal-deep), var(--teal), var(--gold), var(--orange), var(--ember));
}

.card:hover {
  box-shadow: 0 22px 46px rgba(4, 9, 16, 0.6);
}

.card h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.25rem;
  color: var(--cream);
  margin-bottom: 8px;
}

.card p {
  color: var(--cream-dim);
  font-size: 0.98rem;
}

.card .links {
  margin-top: 16px;
}

.card .links a,
a.doc-link {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--gold);
  text-decoration: none;
  margin-right: 20px;
  transition: color 0.2s ease;
}

.card .links a:hover,
a.doc-link:hover {
  color: var(--cream);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.badge {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  background: linear-gradient(135deg, var(--gold), var(--orange));
  border-radius: 999px;
  padding: 4px 14px;
  margin-bottom: 12px;
}

/* --- scroll reveal ----------------------------------------------------------- */

.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.reveal.in {
  opacity: 1;
  transform: translateY(0);
}

.card-grid .reveal:nth-child(2) { transition-delay: 0.1s; }
.card-grid .reveal:nth-child(3) { transition-delay: 0.2s; }

/* --- legal article (cream paper sheet on the night sky) ---------------------- */

article.legal {
  margin: 60px auto 80px;
  max-width: 820px;
  background: var(--paper);
  color: var(--ink);
  border-radius: 18px;
  padding: clamp(28px, 6vw, 64px);
  box-shadow: 0 8px 0 rgba(199, 75, 44, 0.5), 0 16px 0 rgba(237, 166, 58, 0.35), 0 30px 60px rgba(4, 9, 16, 0.65);
}

article.legal h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.9rem, 5vw, 2.5rem);
  color: var(--ink);
  margin-bottom: 6px;
}

article.legal .updated {
  color: var(--ink-soft);
  font-size: 0.85rem;
  margin-bottom: 30px;
}

article.legal h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.3rem;
  color: var(--ink);
  margin: 34px 0 10px;
  display: block;
}

article.legal h2::before { content: none; }

article.legal h3 {
  font-family: var(--font-display);
  color: var(--ink);
}

article.legal p,
article.legal li {
  margin-bottom: 12px;
  color: var(--ink);
}

article.legal ul,
article.legal ol {
  padding-left: 24px;
}

article.legal h3 {
  font-size: 1.05rem;
  margin: 24px 0 8px;
}

article.legal .table-scroll {
  overflow-x: auto;
  margin: 14px 0 18px;
}

article.legal table {
  border-collapse: collapse;
  width: 100%;
  min-width: 560px;
  font-size: 0.92rem;
  line-height: 1.5;
}

article.legal th,
article.legal td {
  border: 1px solid #e0d3b2;
  padding: 9px 13px;
  text-align: left;
  vertical-align: top;
}

article.legal th {
  background: #efe3c6;
  font-family: var(--font-display);
  font-weight: 600;
}

article.legal td { margin: 0; }
article.legal td p { margin: 0; }

article.legal code {
  background: #efe3c6;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.88em;
}

article.legal table a,
article.legal p a:not(.doc-link) {
  color: var(--ember);
  word-break: break-word;
}

article.legal .card {
  background: #fffaf0;
  border: 1px solid #e8dcc0;
  box-shadow: 0 6px 16px rgba(42, 33, 24, 0.08);
  margin-top: 14px;
}

article.legal .card h3 { color: var(--ink); }
article.legal .card p { color: var(--ink-soft); }
article.legal .card .links a { color: var(--ember); }
article.legal .card .links a:hover { color: var(--ink); }
article.legal a.doc-link { color: var(--ember); }
article.legal a.doc-link:hover { color: var(--ink); }
article.legal .muted { color: var(--ink-soft); font-size: 0.95rem; }

.placeholder {
  background: #ffe3c8;
  color: #7a3d14;
  padding: 1px 6px;
  border-radius: 5px;
}

/* --- footer -------------------------------------------------------------------- */

footer.site {
  background: rgba(10, 20, 32, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-top: 1px solid rgba(244, 232, 204, 0.07);
  padding: 44px 0 52px;
  margin-top: 60px;
}

footer.site .wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
}

/* transparent mark + type — no boxed lockup image */
.footer-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-decoration: none;
}

.footer-brand img {
  width: 92px;
  height: auto;
  margin-bottom: 6px;
  filter: drop-shadow(0 8px 18px rgba(4, 9, 16, 0.6));
}

.footer-word {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.55rem;
  letter-spacing: 0.05em;
  color: var(--cream);
  line-height: 1.1;
}

.footer-tag {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.68rem;
  letter-spacing: 0.42em;
  text-indent: 0.42em; /* balance the tracking */
  text-transform: uppercase;
  color: var(--cream-dim);
}

.footer-tag::before,
.footer-tag::after {
  content: "";
  width: 26px;
  height: 2px;
  border-radius: 2px;
  background: var(--cream-dim);
  opacity: 0.6;
}

.footer-links {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.9rem;
}

.footer-links a {
  color: var(--cream-dim);
  text-decoration: none;
  margin: 0 12px;
  transition: color 0.2s ease;
}

.footer-links a:hover {
  color: var(--gold);
}

.footer-fine {
  font-size: 0.82rem;
  color: var(--cream-faint);
}

/* --- reduced motion -------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .meteor-mark,
  .hero h1 .word,
  .hero-tag,
  .hero .cta-row {
    animation: none;
    opacity: 1;
    transform: none;
  }
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .btn, .brand-mark, .card { transition: none; }
}

/* --- small screens ----------------------------------------------------------------- */

@media (max-width: 560px) {
  nav.site a { margin-left: 14px; font-size: 0.88rem; }
  .hero { padding-bottom: 200px; }
  section { padding: 56px 0 16px; }
}
