/* ==========================================================================
   Catoban landing page
   Palette mirrors src/theme/palette.ts in the game so the site and the app
   read as one thing.
   ========================================================================== */

:root {
  --bg:         #191919;
  --stone:      #4c4c4c;
  --mortar:     #3c3c3c;
  --floor:      #282523;
  --floor-alt:  #2c2927;
  --panel:      #332f2b;
  --basket:     #8a6a3f;
  --basket-dk:  #5c4527;
  --gold:       #e8b13a;
  --settled:    #57c9a5;
  --yarn-a:     #d95d7c;
  --yarn-d:     #8fc46b;
  --ink:        #f2ede4;
  --ink-dim:    #8a8580;

  --pixel: 'Silkscreen', 'Courier New', monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  --measure: 1120px;
  --gap: 24px;
}

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

html { scroll-behavior: smooth; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--gold); }

/* Pixel art must never be smoothed. */
.brand-icon, .hero-icon, .closer-art, .card-sprite, #demo {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--gold);
  color: var(--bg);
  padding: 8px 16px;
  font-family: var(--pixel);
  z-index: 100;
}
.skip-link:focus { left: 8px; top: 8px; }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

/* --------------------------------------------------------------------------
   Top bar
   -------------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: rgba(25, 25, 25, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 2px solid var(--floor);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}

.brand-icon { width: 32px; height: 32px; }

.brand-name {
  font-family: var(--pixel);
  font-size: 18px;
  letter-spacing: 0.04em;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--pixel);
  font-size: 13px;
}

.topnav a {
  color: var(--ink-dim);
  text-decoration: none;
  padding: 8px 10px;
  letter-spacing: 0.04em;
}

.topnav a:hover { color: var(--ink); }

.topnav-cta {
  color: var(--bg) !important;
  background: var(--gold);
  border: 2px solid var(--basket-dk);
}
.topnav-cta:hover { background: #f4c355; }

/* The three text links crowd the CTA off narrow phones; the CTA is the one
   that has to survive. */
@media (max-width: 560px) {
  .topnav a:not(.topnav-cta) { display: none; }
}

/* --------------------------------------------------------------------------
   Shared section furniture
   -------------------------------------------------------------------------- */

main > section {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 72px 20px;
}

.section-title {
  font-family: var(--pixel);
  font-size: clamp(20px, 3.4vw, 28px);
  line-height: 1.4;
  letter-spacing: 0.02em;
  margin: 0 0 8px;
  color: var(--ink);
}

.section-sub {
  color: var(--ink-dim);
  margin: 0 0 32px;
  font-size: 15px;
}

.section-title + .rules-grid,
.section-title + .feature-grid,
.section-title + .price-grid { margin-top: 36px; }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 52px;
  padding: 10px 24px;
  border: 2px solid var(--basket-dk);
  background: var(--gold);
  color: var(--bg);
  font-family: var(--pixel);
  text-decoration: none;
  letter-spacing: 0.04em;
  transition: transform 80ms ease, background-color 120ms ease;
}

.btn:hover { background: #f4c355; }
.btn:active { transform: translateY(2px); }

.btn-sub { font-size: 10px; opacity: 0.75; }
.btn-main { font-size: 16px; }

.btn-outline {
  background: transparent;
  border-color: var(--basket);
  color: var(--gold);
  font-size: 14px;
}
.btn-outline:hover { background: rgba(138, 106, 63, 0.15); }

.btn-large { min-height: 64px; padding: 12px 40px; }
.btn-large .btn-main { font-size: 20px; }

/* --------------------------------------------------------------------------
   Hero
   -------------------------------------------------------------------------- */

.hero {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  align-items: center;
  gap: 48px;
  padding-top: 64px !important;
  padding-bottom: 88px !important;
}

/* 128px is 512/4 — an exact divisor of the source, so every game pixel lands
   on the same number of screen pixels. Off-ratio sizes visibly ripple. */
.hero-icon {
  width: 128px;
  height: 128px;
  border: 2px solid var(--floor);
  margin-bottom: 20px;
}

.hero-title {
  font-family: var(--pixel);
  font-size: clamp(40px, 7vw, 64px);
  line-height: 1.1;
  letter-spacing: 0.02em;
  margin: 0;
}

.hero-tagline {
  font-family: var(--pixel);
  font-size: clamp(14px, 2.2vw, 18px);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--yarn-d);
  margin: 10px 0 0;
}

.hero-lede {
  max-width: 46ch;
  color: var(--ink-dim);
  margin: 22px 0 0;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 14px;
  margin-top: 32px;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  list-style: none;
  margin: 28px 0 0;
  padding: 0;
  font-family: var(--pixel);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.hero-badges li::before {
  content: '\2022';
  color: var(--settled);
  margin-right: 8px;
}

/* -- the live sprite demo -- */

/* Hug the board rather than stretching the grid column — otherwise the frame
   sits far wider than the 384px canvas inside it. */
.hero-demo {
  width: max-content;
  max-width: 100%;
  margin: 0 auto;
}

.demo-frame {
  border: 2px solid var(--mortar);
  background: var(--bg);
  padding: 12px;
}

/* 384px = the 128px board at exactly 3x. */
#demo {
  width: 384px;
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

.demo-caption {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
  font-family: var(--pixel);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.demo-moves { color: var(--gold); }

@media (max-width: 860px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 40px;
    text-align: center;
  }
  .hero-icon { margin-left: auto; margin-right: auto; }
  .hero-lede { margin-left: auto; margin-right: auto; }
  .cta-row, .hero-badges { justify-content: center; }
}

/* --------------------------------------------------------------------------
   Rules
   -------------------------------------------------------------------------- */

.rules {
  border-top: 2px solid var(--floor);
  border-bottom: 2px solid var(--floor);
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: var(--gap);
}

.rule {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.rule-num {
  font-family: var(--pixel);
  font-size: 22px;
  color: var(--basket);
  line-height: 1.2;
}

.rule p { margin: 0; color: var(--ink-dim); }

/* --------------------------------------------------------------------------
   Features
   -------------------------------------------------------------------------- */

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--gap);
  list-style: none;
  margin: 0;
  padding: 0;
}

.card {
  background: var(--floor);
  border: 2px solid var(--floor-alt);
  padding: 24px;
}

/* Sprites are punched out of the shared atlas by main.js — it sets the
   background-position for each [data-sprite]. */
.card-sprite {
  display: block;
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  background-image: url('assets/atlas.png');
  background-repeat: no-repeat;
  /* Atlas is 8 columns of 16px = 128px wide; scaled 3x for a 48px sprite. */
  background-size: 384px auto;
}

.card h3 {
  font-family: var(--pixel);
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0.02em;
  margin: 0 0 10px;
  color: var(--ink);
}

.card p {
  margin: 0;
  font-size: 15px;
  color: var(--ink-dim);
}

/* --------------------------------------------------------------------------
   Screenshots
   -------------------------------------------------------------------------- */

.shots {
  display: flex;
  gap: 20px;
  overflow-x: auto;
  /* Without this, `overflow-x: auto` computes overflow-y to auto too and the
     strip eats the page's vertical wheel events. */
  overflow-y: hidden;
  padding: 4px 0 16px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-color: var(--basket) var(--floor);
  scrollbar-width: thin;
}

.shots::-webkit-scrollbar { height: 10px; }
.shots::-webkit-scrollbar-track { background: var(--floor); }
.shots::-webkit-scrollbar-thumb { background: var(--basket); }
.shots::-webkit-scrollbar-thumb:hover { background: var(--gold); }

.shot {
  flex: 0 0 auto;
  width: 220px;
  padding: 0;
  border: 2px solid var(--mortar);
  background: var(--bg);
  cursor: pointer;
  scroll-snap-align: start;
  transition: border-color 120ms ease, transform 120ms ease;
}

.shot:hover {
  border-color: var(--gold);
  transform: translateY(-3px);
}

.shot img { width: 100%; }

/* --------------------------------------------------------------------------
   Pricing
   -------------------------------------------------------------------------- */

.price-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--gap);
}

.price-card {
  position: relative;
  background: var(--floor);
  border: 2px solid var(--floor-alt);
  padding: 28px 24px;
}

.price-card-featured {
  border-color: var(--basket);
  background: var(--panel);
}

.price-flag {
  position: absolute;
  top: -13px;
  left: 24px;
  background: var(--gold);
  color: var(--bg);
  font-family: var(--pixel);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 5px 10px;
}

.price-name {
  font-family: var(--pixel);
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin: 0;
}

.price-tag {
  font-family: var(--pixel);
  font-size: 26px;
  color: var(--gold);
  margin: 10px 0 20px;
}

.price-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 15px;
  color: var(--ink-dim);
}

.price-list li {
  padding-left: 24px;
  margin-bottom: 8px;
  position: relative;
}

.price-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 9px;
  width: 10px;
  height: 10px;
  background: var(--settled);
}

.price-note {
  margin: 32px 0 0;
  font-size: 15px;
  color: var(--ink-dim);
}

/* --------------------------------------------------------------------------
   Closing CTA
   -------------------------------------------------------------------------- */

.closer {
  text-align: center;
  border-top: 2px solid var(--floor);
}

/* 512px is half the 1024px source — again an exact ratio. */
.closer-art {
  max-width: 512px;
  width: 100%;
  margin: 0 auto 28px;
  border: 2px solid var(--floor);
}

.closer-line {
  font-family: var(--pixel);
  font-size: clamp(15px, 2.6vw, 20px);
  line-height: 1.6;
  margin: 0 0 32px;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.footer {
  border-top: 2px solid var(--floor);
  background: var(--floor);
}

.footer-inner {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 40px 20px 56px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 28px;
  font-family: var(--pixel);
  font-size: 12px;
  letter-spacing: 0.04em;
  margin-bottom: 24px;
}

.footer-links a { color: var(--ink); text-decoration: none; }
.footer-links a:hover { color: var(--gold); }

.footer-credits,
.footer-copy {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--ink-dim);
}

/* --------------------------------------------------------------------------
   Lightbox
   -------------------------------------------------------------------------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  background: rgba(12, 12, 12, 0.94);
}

.lightbox[hidden] { display: none; }

.lightbox-img {
  max-height: 84vh;
  max-width: min(100%, 420px);
  border: 2px solid var(--mortar);
}

.lightbox-close,
.lightbox-nav {
  background: transparent;
  border: 2px solid var(--mortar);
  color: var(--ink);
  font-size: 26px;
  line-height: 1;
  width: 48px;
  height: 48px;
  cursor: pointer;
  flex: 0 0 auto;
}

.lightbox-close:hover,
.lightbox-nav:hover { border-color: var(--gold); color: var(--gold); }

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 30px;
}

.lightbox-caption {
  position: absolute;
  bottom: 20px;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--pixel);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin: 0;
}

/* On phones the side arrows steal width from the image; drop to swipe +
   the close button, which is what people reach for anyway. */
@media (max-width: 620px) {
  .lightbox-nav { display: none; }
}
