/*
 * Gravlo wiki styles. Tokens mirror the cute theme of the game
 * (src/ui/theme.ts and docs/design/04-identidade-visual.md): night sky
 * backgrounds, sun yellow for everything that belongs to the player,
 * one dark ink outline of 3 px and a solid 4 px drop shadow on buttons.
 * Mobile first; wider layouts are added with min-width queries.
 */

/* Nunito (SIL Open Font License 1.1, see fonts/OFL.txt), self-hosted
   variable font: one file per script covers weights 700 and 900. */
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 700 900;
  font-display: swap;
  src: url('fonts/nunito-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 700 900;
  font-display: swap;
  src: url('fonts/nunito-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Global color roles of the game (cute theme). */
  --ink: #1b1035;
  --player: #ffd23f;
  --player-light: #fff8e1;
  --player-accent: #ffb800;
  --orbit-rim: #ffe066;
  --spark-glow: #b8f35c;
  --danger: #ff2e63;
  --ui-secondary: #f4f1de;
  --prism: #9bf6ff;
  --uncommon: #4cc9f0;
  --rare: #ff9f1c;
  --epic: #c77dff;
  --sky: #14122e;
  --sky-deep: #0b0a1f;
  --sky-accent: #2d2a5a;
  --panel: #231f4a;
  --panel-light: #332d66;
  --muted: #b3aedb;
  --text: #ffffff;

  --font: 'Nunito', 'Varela Round', 'Arial Rounded MT Bold', 'Trebuchet MS', system-ui, sans-serif;
  --radius: 18px;
  --outline: 3px solid var(--ink);
  --shadow: 0 4px 0 var(--ink);
  --gap: 16px;
  --max: 1120px;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 72px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--sky-deep);
  /* Star dust over the menu sky, drawn with gradients so it costs no request. */
  background-image:
    radial-gradient(2px 2px at 12% 18%, #fff8 50%, transparent 51%),
    radial-gradient(2px 2px at 78% 9%, #fff6 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 42% 64%, #fff5 50%, transparent 51%),
    radial-gradient(2px 2px at 88% 72%, #ffe06688 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 24% 86%, #fff5 50%, transparent 51%),
    linear-gradient(180deg, var(--sky) 0%, var(--sky-deep) 100%);
  background-size: 420px 420px, 420px 420px, 420px 420px, 420px 420px, 420px 420px, 100% 100%;
  background-attachment: fixed;
}

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

a {
  color: var(--orbit-rim);
  text-underline-offset: 3px;
}

a:hover {
  color: var(--player-light);
}

:focus-visible {
  outline: 3px solid var(--prism);
  outline-offset: 3px;
  border-radius: 6px;
}

h1,
h2,
h3 {
  font-weight: 900;
  line-height: 1.15;
  margin: 0 0 0.5em;
}

h2 {
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  color: var(--player);
  text-shadow: 0 3px 0 var(--ink);
}

h3 {
  font-size: 1.25rem;
}

p {
  margin: 0 0 1em;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--player);
  color: var(--ink);
  border: var(--outline);
  border-radius: 12px;
  font-weight: 900;
}

.skip-link:focus {
  top: 8px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Header: sticky bar with a horizontally scrollable section list on phones. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgb(11 10 31 / 92%);
  border-bottom: 3px solid var(--ink);
  backdrop-filter: blur(6px);
}

.site-header__inner {
  max-width: var(--max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px var(--gap);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  color: var(--player);
  font-weight: 900;
  font-size: 1.25rem;
  text-decoration: none;
}

.brand img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: var(--outline);
}

.site-nav {
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.site-nav::-webkit-scrollbar {
  display: none;
}

.site-nav ul {
  display: flex;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  white-space: nowrap;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  color: var(--ui-secondary);
  text-decoration: none;
}

.site-nav a:hover {
  background: var(--panel);
  color: var(--player);
}

/* Buttons: the primary game button (yellow, ink outline, solid shadow). */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 24px;
  border: var(--outline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--player);
  color: var(--ink);
  font-weight: 900;
  font-size: 1.25rem;
  text-decoration: none;
  transition: transform 80ms linear, box-shadow 80ms linear;
}

.btn:hover {
  color: var(--ink);
  background: var(--orbit-rim);
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink);
}

.btn--secondary {
  background: var(--ui-secondary);
}

.btn--secondary:hover {
  background: var(--player-light);
}

/* Layout */
main {
  display: block;
}

.section {
  max-width: var(--max);
  margin: 0 auto;
  padding: 56px var(--gap);
}

.lead {
  font-size: 1.125rem;
  color: var(--ui-secondary);
  max-width: 60ch;
}

.muted {
  color: var(--muted);
}

/* Hero */
.hero {
  position: relative;
  overflow: hidden;
  border-bottom: 3px solid var(--ink);
}

.hero__art {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.hero__body {
  max-width: var(--max);
  margin: 0 auto;
  padding: 24px var(--gap) 40px;
}

.wordmark {
  font-size: clamp(3.5rem, 16vw, 7rem);
  font-weight: 900;
  letter-spacing: 0.01em;
  color: var(--player);
  text-shadow: 0 4px 0 var(--ink), 0 0 32px rgb(255 224 102 / 45%);
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
  margin: 0;
}

.tagline {
  font-size: clamp(1.25rem, 4.5vw, 1.75rem);
  font-weight: 900;
  color: var(--spark-glow);
  margin: 0 0 12px;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
}

.facts li {
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--panel);
  border: 2px solid var(--panel-light);
  color: var(--ui-secondary);
  font-size: 0.9375rem;
}

.facts strong {
  color: var(--player);
  font-weight: 900;
}

/* Cards and grids */
.grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: 1fr;
}

.card {
  background: var(--panel);
  border: var(--outline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.card h3 {
  color: var(--player);
}

.card p:last-child,
.card ul:last-child {
  margin-bottom: 0;
}

.card ul {
  padding-left: 1.2em;
  margin: 0 0 1em;
}

.step__num {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: 8px;
  border-radius: 50%;
  border: var(--outline);
  background: var(--spark-glow);
  color: var(--ink);
  font-weight: 900;
  font-size: 1.25rem;
}

.figure {
  margin: 0;
  border: var(--outline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  background: var(--panel);
}

.figure figcaption {
  padding: 10px 16px;
  font-size: 0.9375rem;
  color: var(--muted);
}

.split {
  display: grid;
  gap: 24px;
  align-items: center;
}

/* Keyboard keys */
kbd {
  display: inline-block;
  min-width: 1.8em;
  padding: 0 6px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--ui-secondary);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 900;
  font-size: 0.875em;
  text-align: center;
  box-shadow: 0 2px 0 var(--ink);
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border: var(--outline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--panel);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}

th,
td {
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 2px solid var(--panel-light);
}

tr:last-child td {
  border-bottom: 0;
}

th {
  font-weight: 900;
  color: var(--player);
  background: var(--panel-light);
}

/* Worlds: each card takes the palette of its world. */
.world {
  --w-bg: var(--panel);
  --w-accent: var(--panel-light);
  --w-debris: var(--player);
  background: linear-gradient(160deg, var(--w-accent) 0%, var(--w-bg) 55%);
}

.world__tag {
  display: inline-block;
  margin-bottom: 8px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: var(--w-debris);
  color: var(--ink);
  font-size: 0.8125rem;
  font-weight: 900;
}

.world dl {
  margin: 0;
  display: grid;
  gap: 6px;
}

.world dt {
  font-weight: 900;
  color: var(--player);
}

.world dd {
  margin: 0 0 6px;
  color: var(--ui-secondary);
}

.world--meadow { --w-bg: #1e3b2f; --w-accent: #3e7c59; --w-debris: #b9c4cc; }
.world--harbor { --w-bg: #13293d; --w-accent: #3e6a8a; --w-debris: #e0a458; }
.world--orchard { --w-bg: #2b1b3d; --w-accent: #6a4c93; --w-debris: #ff9f43; }
.world--reef { --w-bg: #062c30; --w-accent: #14707a; --w-debris: #9bf6ff; }
.world--crown { --w-bg: #0b0a1f; --w-accent: #2d2a5a; --w-debris: #fff3b0; }

/* Cores: the cousins collection. */
.core {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.core__dot {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: var(--outline);
  background: radial-gradient(circle at 35% 32%, var(--player-light) 0 18%, var(--c, var(--player)) 42%);
}

.core h3 {
  margin-bottom: 2px;
}

.core p {
  margin: 0;
}

.core .unlock {
  margin-top: 6px;
  font-size: 0.875rem;
  color: var(--muted);
}

/* Evolution reveal (native details, no script). */
details.reveal {
  margin-top: var(--gap);
}

details.reveal > summary {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 0 20px;
  border: var(--outline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--player);
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
  list-style: none;
}

details.reveal > summary::-webkit-details-marker {
  display: none;
}

details.reveal[open] > summary {
  margin-bottom: var(--gap);
}

.gold {
  color: var(--player);
  font-weight: 900;
}

/* Tips */
.tips {
  counter-reset: tip;
  list-style: none;
  padding: 0;
  margin: 0;
}

.tips li {
  position: relative;
  padding: 16px 16px 16px 64px;
  margin-bottom: 12px;
  background: var(--panel);
  border: var(--outline);
  border-radius: var(--radius);
}

.tips li::before {
  counter-increment: tip;
  content: counter(tip);
  position: absolute;
  left: 14px;
  top: 14px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--player);
  color: var(--ink);
  font-weight: 900;
}

/* Gallery */
.gallery {
  display: grid;
  gap: var(--gap);
  grid-template-columns: 1fr;
  padding: 0;
  margin: 0;
  list-style: none;
}

.gallery a {
  display: block;
  text-decoration: none;
  color: inherit;
}

.gallery img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

/* Footer */
.site-footer {
  border-top: 3px solid var(--ink);
  background: var(--sky-deep);
}

.site-footer__inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 40px var(--gap);
  text-align: center;
}

.site-footer p {
  color: var(--muted);
  font-size: 0.9375rem;
}

/* Tablet */
@media (min-width: 640px) {
  .grid--2,
  .grid--3,
  .grid--4,
  .gallery {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Desktop */
@media (min-width: 1024px) {
  .grid--3,
  .gallery {
    grid-template-columns: repeat(3, 1fr);
  }

  .grid--4 {
    grid-template-columns: repeat(4, 1fr);
  }

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

  .split--reverse > :first-child {
    order: 2;
  }

  /* Two columns so the copy never covers the mascot: text left, art right. */
  .hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    align-items: center;
    gap: 32px;
    padding: 48px max(var(--gap), calc((100% - var(--max)) / 2 + var(--gap)));
  }

  .hero__art {
    grid-column: 2;
    grid-row: 1;
    border: var(--outline);
    border-radius: var(--radius);
    box-shadow: var(--shadow), 0 0 48px rgb(255 224 102 / 25%);
  }

  .hero__body {
    grid-column: 1;
    grid-row: 1;
    padding: 0;
  }
}

/* Respect the "less motion" preference, like the game setting does. */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
