/* Home page: hero, mode tiles, the three playable demos, defenders and features.
   Loads on top of theme.css. The arcade pieces copy the app's gameplay look
   (docs/visual-style.md, "Gameplay"): flat cel sky, white word tags, dashed
   saffron holes, saffron bullets, answer keys with a darker rim. */

/* ── Hero ────────────────────────────────────────────────────────────────── */

.hero {
  position: relative;
  background: var(--cobalt);
  color: var(--blanc);
  padding: 26px 0 clamp(56px, 8vw, 96px);
  overflow: hidden;
}
.hero .shards-top { width: clamp(150px, 22vw, 280px); }

.hero .topbar { margin-bottom: clamp(32px, 6vw, 60px); padding-right: clamp(0px, 14vw, 200px); }

.hero-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.95fr);
  grid-template-rows: auto auto;
  column-gap: clamp(32px, 5vw, 64px);
  row-gap: 26px;
  align-items: center;
}
.hero-copy { grid-column: 1; grid-row: 1; align-self: end; }
.hero-cta { grid-column: 1; grid-row: 2; align-self: start; }
.hero-arcade-col { grid-column: 2; grid-row: 1 / span 2; }

.hero h1 {
  font-size: clamp(2.5rem, 6vw, 4rem);
  margin-bottom: 1rem;
  text-wrap: balance;
}
.hero h1 em { font-style: normal; color: var(--safra); }

.hero-lead {
  font-size: clamp(1.05rem, 1.6vw, 1.2rem);
  color: rgba(255, 255, 255, 0.94);
  max-width: 34rem;
  margin-bottom: 0;
}

.hero-points {
  list-style: none;
  margin: 0 0 1.6rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.hero-points li {
  font-size: 0.9rem;
  font-weight: 700;
  padding: 5px 13px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.28);
}

.stores { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }

.store-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 9px 20px 9px 16px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--tinta);
  background: var(--tinta);
  color: var(--blanc);
  font: inherit;
  text-align: left;
  text-decoration: none;
  transition: transform 140ms ease;
}
a.store-btn:hover { transform: translateY(-1px); }
a.store-btn:focus-visible { outline: 3px solid var(--safra); outline-offset: 3px; }
.store-btn[aria-disabled="true"] {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.45);
  cursor: default;
}
.store-btn svg { flex: none; }
.store-btn b { display: block; font: 800 1.1rem/1.15 var(--display); }
.store-btn small { display: block; font-size: 0.76rem; opacity: 0.85; letter-spacing: 0.02em; }

.notify { font-size: 0.95rem; color: rgba(255, 255, 255, 0.9); margin: 0; }
.notify a { color: var(--blanc); font-weight: 700; }

.hero-arcade-col .arcade { box-shadow: 0 30px 70px -24px rgba(8, 20, 50, 0.7); }

/* ── Sections ────────────────────────────────────────────────────────────── */

section { padding: clamp(56px, 8vw, 92px) 0; }
.section-head { max-width: 44rem; margin-bottom: clamp(26px, 4vw, 40px); }
.section-head h2 { font-size: clamp(1.9rem, 3.6vw, 2.6rem); margin-bottom: 0.7rem; color: var(--cobalt); }
.section-head p { color: var(--tinta-suau); font-size: 1.05rem; margin: 0; }

.band-white { background: var(--blanc); border-block: 1px solid var(--vora); }

/* ── Mode tiles (ModeTile) ───────────────────────────────────────────────── */

.mode-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
}
.mode-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 168px;
  padding: 18px 20px 20px;
  border-radius: var(--radius-card);
  background: var(--tile);
  color: var(--on);
  text-decoration: none;
}
.mode-tile .glyph { font: 800 2.4rem/1 var(--display); margin-bottom: 8px; }
.mode-tile h3 { font-family: var(--text); font-weight: 700; font-size: 1.12rem; line-height: 1.25; }
.mode-tile p { margin: 0; font-size: 0.95rem; line-height: 1.45; }
.mode-tile .try {
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--blanc);
  color: var(--tinta);
}
a.mode-tile { transition: transform 140ms ease; }
a.mode-tile:hover { transform: translateY(-2px); }
a.mode-tile:focus-visible { outline: 3px solid var(--tinta); outline-offset: 3px; }

.m-tutorial { --tile: var(--safra); --on: var(--tinta); }
.m-bv { --tile: var(--cobalt); --on: var(--blanc); }
.m-accent { --tile: var(--teula); --on: var(--blanc); }
.m-ssc { --tile: var(--safra); --on: var(--tinta); }
.m-sil { --tile: var(--oliva); --on: var(--blanc); }
.m-pair { --tile: var(--mar); --on: var(--blanc); }

/* ── Demo cards ──────────────────────────────────────────────────────────── */

.demos { display: grid; gap: 28px; }

.demo {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr);
  gap: clamp(20px, 3.5vw, 44px);
  align-items: start;
  background: var(--blanc);
  border: 1px solid var(--vora);
  border-radius: var(--radius-panel);
  padding: clamp(18px, 3vw, 32px);
}
.demo-info .badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.demo-info .badge span {
  display: inline-grid;
  place-items: center;
  min-width: 58px;
  height: 46px;
  padding: 0 10px;
  border-radius: 12px;
  font: 800 1.5rem/1 var(--display);
  background: var(--tile);
  color: var(--on);
}
.demo-info h3 { font-size: clamp(1.6rem, 2.8vw, 2rem); color: var(--cobalt); margin-bottom: 0.6rem; }
.demo-info p { color: var(--tinta-suau); }
.demo-info .rule {
  color: var(--tinta);
  background: var(--fons);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 0.95rem;
}
.demo-info .rule b { color: var(--cobalt); }
.kbd-hint { font-size: 0.88rem; margin: 0; }
kbd {
  display: inline-block;
  min-width: 1.7em;
  padding: 1px 6px;
  border: 1px solid var(--vora);
  border-bottom-width: 3px;
  border-radius: 7px;
  background: var(--blanc);
  font: 700 0.85rem/1.4 var(--text);
  text-align: center;
  color: var(--tinta);
}

/* ── Arcade: HUD, sky, words, keys ───────────────────────────────────────── */

.arcade {
  position: relative;
  border-radius: 22px;
  overflow: hidden;
  background: var(--cel);
  border: 1px solid var(--vora);
  user-select: none;
  -webkit-user-select: none;
}

.hud {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 10px 10px 0;
  padding: 7px 14px;
  border-radius: 14px;
  background: var(--blanc);
  box-shadow: 0 2px 6px rgba(24, 32, 47, 0.12);
  font-size: 0.85rem;
  color: var(--tinta-suau);
}
.hud-score { font: 800 1.35rem/1 var(--display); color: var(--cobalt); font-variant-numeric: tabular-nums; }
.hud-score small { font: 700 0.75rem var(--text); color: var(--tinta-suau); margin-left: 3px; }
.hud-progress { display: flex; gap: 3px; }
.hud-progress i {
  width: 12px;
  height: 14px;
  border-radius: 3px;
  background: var(--blau-lightest);
}
.hud-progress i.ok { background: var(--oliva); }
.hud-progress i.ko { background: var(--teula); }
.hud-count { font: 800 0.95rem/1 var(--display); font-variant-numeric: tabular-nums; min-width: 3.2em; text-align: right; }

.sky {
  position: relative;
  height: clamp(320px, 34vw, 400px);
  overflow: hidden;
  background:
    url('/px/sun.png') 88% 16% / 40px auto no-repeat,
    url('/px/cloud1.png') 10% 34% / 80px auto no-repeat,
    url('/px/cloud3.png') 78% 58% / 88px auto no-repeat;
  image-rendering: pixelated;
}
.hero .sky { height: clamp(300px, 34vw, 410px); }

.ground {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  /* As in the app: the Montgrí spans the whole width (808 x 312), in front
     of the band of clouds, which the app draws half a screen width tall. */
  aspect-ratio: 2 / 1;
  background:
    url('/px/montgri_001.png') center bottom / 100% auto no-repeat,
    url('/px/nuvols_fons.png') left bottom / auto 100% repeat-x;
  image-rendering: pixelated;
  pointer-events: none;
}

.word {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  will-change: transform;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.tag {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 10px;
  background: var(--blanc);
  box-shadow: 0 3px 8px rgba(24, 32, 47, 0.12);
  font: 700 1.25rem/1.25 var(--text);
  color: var(--tinta);
  white-space: nowrap;
  transition: background 200ms ease, color 200ms ease;
}
.seg { display: inline-block; }
.seg.hole {
  min-width: 0.95em;
  height: 1.25em;
  border: 2px dashed var(--groc-darkest);
  background: var(--groc-lightest);
  border-radius: 6px;
  text-align: center;
  line-height: 1.1;
  margin: 0 1px;
  color: transparent;
}
.seg.mark {
  background: var(--safra);
  color: var(--tinta);
  border-radius: 5px;
  padding: 0 2px;
}
.seg.ok { background: var(--oliva); border: 2px solid var(--oliva); color: var(--blanc); border-radius: 5px; }
.seg.ko { background: var(--teula); border: 2px solid var(--teula); color: var(--blanc); border-radius: 5px; }
.seg.mark.ok, .seg.mark.ko { border: none; padding: 0 3px; }

.word.won .tag { color: var(--oliva); }
.word.lost .tag { color: var(--teula); }
.word.won .tag .seg.ok,
.word.lost .tag .seg.ko,
.word.lost .tag .seg.fix { background: transparent; border-color: transparent; color: inherit; text-decoration: underline 3px; text-underline-offset: 4px; }
.word.won .seg.mark, .word.lost .seg.mark { background: transparent; }
/* Once settled, a hole is just a letter again, so the word reads as one. */
.word.won .seg.hole, .word.lost .seg.hole,
.word.won .seg.mark, .word.lost .seg.mark {
  min-width: 0; height: auto; margin: 0; padding: 0; border: 0; line-height: inherit;
}
.word.gone { opacity: 0; transition: opacity 500ms ease 700ms; }

.note {
  margin-top: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}
.word.won .note { background: var(--verd-lightest); color: var(--verd-darkest); }
.word.lost .note { background: var(--vermell-lightest); color: var(--vermell-darkest); }

@keyframes shake {
  0%, 100% { translate: 0 0; }
  25% { translate: -5px 0; }
  75% { translate: 5px 0; }
}
.word.lost .tag { animation: shake 240ms ease-in-out 2; }

.bullet {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border-radius: 7px;
  background: var(--safra);
  color: var(--tinta);
  font: 700 1.1rem/1 var(--text);
  rotate: -12deg;
  box-shadow: 0 2px 4px rgba(24, 32, 47, 0.2);
  pointer-events: none;
}

.pop {
  position: absolute;
  z-index: 2;
  font: 800 1.4rem/1 var(--display);
  color: var(--oliva);
  text-shadow: 0 2px 0 var(--blanc), 0 0 8px var(--blanc);
  pointer-events: none;
  animation: floatUp 1100ms ease-out forwards;
}
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, 10px); }
  20% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -40px); }
}

/* Start / pause card over the sky */
.sky-card {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(191, 227, 247, 0.55);
}
.sky-card[hidden] { display: none; }
.sky-card > div {
  max-width: 300px;
  padding: 20px 22px;
  border-radius: var(--radius-panel);
  background: var(--blanc);
  text-align: center;
  box-shadow: 0 10px 30px -10px rgba(24, 32, 47, 0.35);
}
.sky-card p { margin: 0 0 14px; font-size: 0.98rem; }

/* Answer keys (AnswerKey): slot colours cobalt, teula, … with a darker rim */
.keys {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 12px 12px 14px;
  background: var(--blanc);
  border-top: 1px solid var(--vora);
}
.key {
  --rim: var(--cobalt-deep);
  flex: 0 1 132px;
  min-height: 62px;
  padding: 6px 10px 8px;
  border: none;
  border-radius: 16px;
  background: var(--fill);
  color: var(--blanc);
  box-shadow: 0 5px 0 var(--rim);
  font: 700 1.7rem/1 var(--text);
  cursor: pointer;
  touch-action: manipulation;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: transform 70ms ease, box-shadow 70ms ease;
}
.key .kl { display: block; line-height: 1; }
.kl-mark { width: 30px; height: 30px; }
.kl-mark path { fill: none; stroke: currentColor; stroke-width: 4; stroke-linecap: round; }
.key small { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.02em; opacity: 0.95; }
.key:active, .key.pressed { transform: translateY(5px); box-shadow: 0 0 0 var(--rim); }
.key:focus-visible { outline: 3px solid var(--safra); outline-offset: 3px; }
.key:disabled { cursor: default; }
.k0 { --fill: var(--cobalt); --rim: var(--cobalt-deep); }
.k1 { --fill: var(--teula); --rim: var(--vermell-darkest); }

/* Result panel (GameOverView + AnsweredWordsView) */
.demo-result {
  margin-top: 14px;
  padding: 16px 18px;
  border-radius: 18px;
  background: var(--fons);
  border: 1px solid var(--vora);
}
.demo-result[hidden] { display: none; }
.result-title { font: 800 1.35rem/1.2 var(--display); color: var(--cobalt); margin: 0 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; padding: 0; list-style: none; }
.chips li { padding: 3px 10px; border-radius: 10px; font-weight: 700; font-size: 0.95rem; }
.chips .ok { background: var(--verd-lightest); color: var(--verd-darkest); }
.chips .ko { background: var(--vermell-lightest); color: var(--vermell-darkest); }
.chips .ko::before { content: '✗ '; }
.chips .ok::before { content: '✓ '; }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ── Defenders ───────────────────────────────────────────────────────────── */

.defenders { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); }
.defender {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--blanc);
  border: 1px solid var(--vora);
  border-radius: var(--radius-card);
  overflow: hidden;
}
/* The sprites are stored one pixel per art pixel (site/tools/build_pixel_art.py)
   and scaled up here without smoothing. */
.defender .art {
  height: 118px;
  padding: 12px 12px 0;
  background: var(--cel);
  display: flex;
}
.defender .art img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  image-rendering: pixelated;
}
.defender figcaption {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 14px 14px;
}
.defender h3 { font-size: 1.05rem; line-height: 1.2; color: var(--cobalt); flex: 1; }
.price {
  display: inline-block;
  padding: 2px 11px;
  border-radius: 999px;
  font: 800 0.9rem/1.5 var(--display);
  background: var(--blau-lightest);
  color: var(--cobalt);
}
.price.free { background: var(--oliva); color: var(--blanc); }

/* ── Feature grid ────────────────────────────────────────────────────────── */

.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.card {
  background: var(--blanc);
  border: 1px solid var(--vora);
  border-radius: var(--radius-card);
  padding: 20px 22px 22px;
}
.band-white .card, .band-white .defender { background: var(--fons); }
.card h3 { font-size: 1.25rem; margin-bottom: 0.4rem; color: var(--cobalt); }
.card p { margin: 0; color: var(--tinta-suau); font-size: 0.98rem; }
.card .chip {
  display: inline-block;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  margin-bottom: 12px;
  rotate: -8deg;
}

.numbers {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-top: 28px;
}
.number { text-align: center; padding: 16px 10px; background: var(--blanc);
  border: 1px solid var(--vora); border-radius: var(--radius-card); }
.number b { display: block; font: 800 clamp(1.8rem, 3.4vw, 2.4rem)/1.1 var(--display); color: var(--cobalt); }
.number span { font-size: 0.92rem; color: var(--tinta-suau); }

/* ── Closing CTA ─────────────────────────────────────────────────────────── */

.closing {
  position: relative;
  overflow: hidden;
  background: var(--cobalt);
  color: var(--blanc);
  text-align: center;
}
.closing h2 { font-size: clamp(1.9rem, 4vw, 2.7rem); margin-bottom: 0.8rem; }
.closing h2 em { font-style: normal; color: var(--safra); }
.closing p { color: rgba(255, 255, 255, 0.94); max-width: 36rem; margin: 0 auto 1.6rem; }
.closing .stores { justify-content: center; }
.closing .shell { position: relative; z-index: 1; }

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 880px) {
  .hero-grid { display: flex; flex-direction: column; align-items: stretch; }
  .hero-copy { order: 1; }
  .hero-arcade-col { order: 2; }
  .hero-cta { order: 3; }
  .demo { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .hero .topbar { padding-right: 90px; margin-bottom: 40px; }
  .hero .shards-top { width: 96px; }
  .demo { padding: 16px 12px; border-radius: 20px; }
  .demo-info { padding: 0 4px; }
  .tag { font-size: 1.1rem; padding: 4px 8px; }
  .hud { margin: 8px 8px 0; padding: 6px 10px; }
  .hud-progress i { width: 8px; height: 12px; }
  .key { min-height: 58px; }
}

@media (prefers-reduced-motion: reduce) {
  .word.lost .tag { animation: none; }
  .pop { animation-duration: 1ms; }
}
