/*
 * Hearthmakers' project page, in the game's own look: the same tokens as the
 * game's ui/theme.ts, and boards, signs, plaques and parchment painted at each
 * element's size by the game's painter (js/painter.js). Flat fills, right
 * angles and black outlines; nothing here is an image of a panel.
 */

@font-face {
  font-family: 'Alegreya';
  src: url('../assets/fonts/Alegreya-Regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: 'Alegreya';
  src: url('../assets/fonts/Alegreya-Italic.ttf') format('truetype');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'Alegreya';
  src: url('../assets/fonts/Alegreya-Bold.ttf') format('truetype');
  font-weight: 700;
  font-display: swap;
}

/* The pixel font's digits blur when small (its 5 reads as an S): numbers come from here, as in the game. */
@font-face {
  font-family: 'Numbers';
  src: url('../assets/fonts/Alegreya-Bold.ttf') format('truetype');
  unicode-range: U+25, U+2B, U+2F, U+30-3A;
  size-adjust: 120%;
  font-display: swap;
}

@font-face {
  font-family: 'Pixelify Sans';
  src: url('../assets/fonts/PixelifySans-Regular.woff2') format('woff2');
  font-display: swap;
}

:root {
  --ink: #2b1f14;
  --ink-soft: #57432d;
  --ink-accent: #8a5a1c;
  --paper: #c8b48a;
  --paper-light: #e6dcc8;
  --paper-line: #b08858;
  --menu-gold: #e8c860;
  --menu-active: #e6dcc8;
  --control-gold-light: #ffe156;
  --wood-frame: #766858;
  --wood-light: #a6957e;
  --wood-dark: #5e5246;
  --board: #3a3432;
  --plaque: #3a2a1c;
  --plaque-lip: #4a3624;
  --go: #4f8434;
  --go-dark: #3d6b2a;
  --text-muted: #a39a86;
  --font: 'Alegreya', Georgia, serif;
  --control-font: 'Numbers', 'Pixelify Sans', var(--font);
  --outline: -2px -2px 0 #000, 0 -2px 0 #000, 2px -2px 0 #000, 2px 0 0 #000, 2px 2px 0 #000, 0 2px 0 #000, -2px 2px 0 #000, -2px 0 0 #000;
  --outline-thin: -1px -1px 0 #000, 0 -1px 0 #000, 1px -1px 0 #000, 1px 0 0 #000, 1px 1px 0 #000, 0 1px 0 #000, -1px 1px 0 #000, -1px 0 0 #000;
  --page-width: 1140px;
  --button-height: 52px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 84px;
}

body {
  margin: 0;
  font: 400 19px/1.5 var(--font);
  color: var(--ink);
  background: #1b1c3b;
  -webkit-font-smoothing: antialiased;
}

/* The dusk the book floats in, fixed behind the whole page. */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: -2;
  background: linear-gradient(180deg, #1b1c3b 0%, #2c2547 34%, #5e3f5a 66%, #9c6462 88%, #c58a68 100%);
}

/* Sparks rising from the hearth, over the backdrop and under the content. */
.embers {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.embers span {
  position: absolute;
  bottom: -12px;
  left: var(--x);
  width: var(--size, 4px);
  height: var(--size, 4px);
  background: #ffcf4a;
  box-shadow: 0 0 6px 2px rgba(255, 140, 30, 0.8);
  opacity: 0;
  animation: ember-rise var(--time, 9s) linear var(--delay, 0s) infinite;
}

@keyframes ember-rise {
  0% {
    transform: translate(0, 0);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  50% {
    transform: translate(var(--sway, 30px), -55vh);
  }
  80% {
    opacity: 0.8;
  }
  100% {
    transform: translate(0, -110vh);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .embers {
    display: none;
  }
}

a {
  color: inherit;
}

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

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

/* Scrollbars as in the game: a square dark thumb on a shaded track. */
::-webkit-scrollbar {
  width: 16px;
}

::-webkit-scrollbar-track {
  background-color: rgba(0, 0, 0, 0.4);
}

::-webkit-scrollbar-thumb {
  background: #322f28;
  border: 2px solid #000;
}

/* --- painted pieces: the flat colour until the painter has run ---------------- */

.board,
.sign,
.section-title,
.parchment,
.plaque {
  image-rendering: pixelated;
  background-position: 0 0;
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

.board.painted,
.sign.painted,
.section-title.painted,
.parchment.painted,
.plaque.painted {
  background-color: transparent;
  background-image: var(--painted);
}

/* A board: its field sits inside the frame, above the ledge and the slab. */
.board {
  padding: 30px 36px 54px;
  background-color: var(--board);
  color: var(--paper-light);
}

/* The shingle a title hangs on, its text in the wheat of the menus. */
.sign,
.section-title {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 18px 28px 12px;
  background-color: var(--board);
  font: 400 32px/1.1 var(--control-font);
  letter-spacing: 0.02em;
  color: var(--menu-gold);
  text-shadow: var(--outline);
  text-align: center;
}

/* The wooden beam each shingle's hooks hang from, wider than the shingle. */
.sign,
.section-title {
  position: relative;
}

.sign::before,
.section-title::before {
  content: '';
  position: absolute;
  top: -15px;
  left: -27px;
  right: -27px;
  height: 18px;
  border: 3px solid #000;
  background: var(--wood-frame);
  box-shadow: inset 0 3px 0 var(--wood-light), inset 0 -3px 0 var(--wood-dark), 0 5px 10px rgba(0, 0, 0, 0.5);
}

.section-title {
  width: fit-content;
  min-width: min(440px, 100%);
  min-height: 96px;
  margin: 0 auto 28px;
}

/* Parchment: the content stays inside its stepped line. */
.parchment {
  padding: 30px 36px 42px;
  background-color: var(--paper);
  color: var(--ink);
}

.parchment h3 {
  margin: 0 0 8px;
  font: 400 25px/1.2 var(--control-font);
  letter-spacing: 0.01em;
  color: var(--ink-soft);
}

.parchment p {
  margin: 0 0 12px;
}

.parchment p:last-child {
  margin-bottom: 0;
}

.parchment strong {
  color: var(--ink);
}

.parchment a {
  color: var(--ink-accent);
}

/* The game's buttons as links: a wooden frame, a black line, a flat face. */
.primary,
.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--button-height);
  padding: 0 22px;
  border: 3px solid #000;
  background: var(--face);
  box-shadow:
    inset 0 3px 0 var(--wood-light),
    inset 0 -3px 0 var(--wood-dark),
    inset 0 0 0 3px var(--wood-frame),
    inset 0 0 0 6px #000,
    inset 0 9px 0 var(--face-lip);
  font: 400 21px/1 var(--control-font);
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--menu-gold);
  text-shadow: var(--outline-thin);
  transition: transform 0.12s ease;
}

.primary {
  --face: var(--go-dark);
  --face-lip: var(--go);
}

.secondary {
  --face: var(--plaque);
  --face-lip: var(--plaque-lip);
}

.primary:hover,
.secondary:hover {
  color: var(--menu-active);
  filter: brightness(1.12);
}

.primary:active,
.secondary:active {
  transform: translateY(1px);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 22px;
}

/* A square as in the HUD: a thin wooden frame, a heavier foot, a dark field, one icon. */
.square {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 66px;
  height: 72px;
  padding-bottom: 6px;
  border: 3px solid #000;
  background: var(--board);
  box-shadow:
    inset 0 0 0 3px var(--wood-frame),
    inset 0 0 0 6px #000,
    inset 0 -9px 0 var(--wood-dark);
}

.square img {
  width: 42px;
  height: 42px;
}

/* A picture of the game, in the same frame as the HUD's parts; pressing it opens it whole. */
.shot {
  display: block;
  border: 3px solid #000;
  background: #000;
  box-shadow: 0 0 0 3px var(--wood-frame), 0 0 0 6px #000, 0 18px 30px rgba(0, 0, 0, 0.45);
  margin: 6px;
}

.shot img {
  width: 100%;
  height: auto;
}

/* --- top bar ------------------------------------------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--board);
  border-bottom: 3px solid #000;
  box-shadow: inset 0 -3px 0 var(--wood-frame), inset 0 -6px 0 #000, 0 6px 18px rgba(0, 0, 0, 0.5);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 10px 16px 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font: 400 25px/1 var(--control-font);
  color: var(--menu-gold);
  text-shadow: var(--outline);
}

.logo img {
  width: 40px;
  height: 40px;
  image-rendering: pixelated;
}

.nav {
  display: flex;
  gap: 20px;
  margin-left: auto;
}

.nav a,
.lang {
  font: 400 18px/1 var(--control-font);
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--menu-gold);
  text-shadow: var(--outline-thin);
}

.nav a:hover,
.nav a[aria-current='page'],
.lang:hover {
  color: var(--menu-active);
}

/* The other language, on a small plaque. */
.lang {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border: 3px solid #000;
  background: var(--plaque);
  box-shadow: inset 0 0 0 3px var(--wood-frame), inset 0 0 0 6px #000;
}

/* --- hero: the game's main menu, its sheet beside the book --------------------- */

.hero {
  position: relative;
  max-width: 1400px;
  min-height: min(760px, calc(100vh - 70px));
  margin: 0 auto;
  padding: 44px 16px 40px;
  display: flex;
  align-items: center;
}

.hero-world {
  position: absolute;
  top: 50%;
  right: 0;
  width: 76%;
  height: auto;
  transform: translateY(-50%);
  /* The picture's own dusk melts into the page's on every side. */
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 12%, #000 78%, transparent 96%), linear-gradient(90deg, transparent 0, #000 10%, #000 90%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(180deg, transparent 0, #000 12%, #000 78%, transparent 96%), linear-gradient(90deg, transparent 0, #000 10%, #000 90%, transparent 100%);
  mask-composite: intersect;
}

.sheet {
  position: relative;
  width: min(470px, 100%);
  margin-left: max(0px, calc((100% - var(--page-width)) / 2));
}

.sheet .sign {
  position: relative;
  z-index: 1;
  min-height: 112px;
  font-size: 44px;
}

.sheet .board {
  margin: -12px 18px 0;
  text-align: center;
}

.tagline {
  margin: 8px 0 0;
  font-style: italic;
  font-size: 22px;
  color: var(--menu-gold);
}

.sheet .board p {
  margin-top: 12px;
}

.sheet .actions {
  flex-direction: column;
  align-items: stretch;
}

.version {
  font-size: 15px;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

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

.section {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 72px 16px 0;
}

.lead {
  max-width: 820px;
  margin: 0 auto;
  font-size: 21px;
}

/* A part of the game: its picture beside its card, each row turned the other way. */
.feature {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  align-items: center;
  gap: 30px;
  margin-top: 34px;
}

.feature:nth-of-type(even) .shot {
  order: 2;
}

.feature-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
}

.feature-head h3 {
  margin: 0;
}

.feature ul {
  margin: 0;
  padding-left: 20px;
}

.feature li {
  margin-bottom: 4px;
}

/* The three biomes. */
.biomes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 26px;
}

.biome .shot {
  margin-bottom: 18px;
}

.biome .parchment {
  height: calc(100% - 200px);
  min-height: 170px;
}

/* What was made for the game, counted. */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px 12px;
  margin-top: 28px;
  padding-left: 42px;
  padding-right: 42px;
  text-align: center;
}

.stats b {
  display: block;
  font: 400 40px/1.1 var(--control-font);
  color: var(--menu-gold);
  text-shadow: var(--outline);
}

.stats span {
  display: block;
  font-size: 17px;
  line-height: 1.25;
  color: var(--paper-light);
}

/* Cards with a square at their head: where to play, what comes next. */
.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
  margin-top: 28px;
}

/* The game's windows, side by side. */
.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.gallery figure {
  margin: 0;
}

.gallery .shot {
  aspect-ratio: 16 / 10;
  overflow: hidden;
}

.gallery .shot img {
  height: 100%;
  object-fit: cover;
  object-position: top;
}

.gallery figcaption {
  margin-top: 14px;
  text-align: center;
  font: 400 19px/1.2 var(--control-font);
  color: var(--menu-gold);
  text-shadow: var(--outline-thin);
}

/* Questions, each opening in place. */
.faq {
  max-width: 820px;
  margin: 0 auto;
}

.faq details + details {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 2px solid var(--paper-line);
}

.faq summary {
  cursor: pointer;
  font: 400 22px/1.25 var(--control-font);
  color: var(--ink-soft);
}

.faq details p {
  margin: 8px 0 0;
}

/* Community and thanks. */
.community {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 26px;
  align-items: stretch;
}

.community .board {
  text-align: center;
}

.community .board p {
  margin: 0 0 12px;
}

.role {
  display: inline-block;
  padding: 8px 14px;
  border: 3px solid #000;
  background: #1c1b1b;
  font: 400 19px/1 var(--control-font);
  color: var(--menu-gold);
  text-shadow: var(--outline-thin);
}

.credits {
  max-width: 820px;
  margin: 26px auto 0;
  font-size: 16px;
  text-align: center;
  color: var(--paper-light);
}

.credits a {
  color: var(--menu-gold);
}

/* --- legal pages: the terms and the privacy policy, on one long parchment ------- */

.legal {
  max-width: 880px;
}

.legal .parchment {
  padding: 36px 42px 48px;
  font-size: 18px;
}

.legal .updated {
  font-style: italic;
  color: var(--ink-soft);
}

.legal h2 {
  margin: 26px 0 8px;
  font: 400 24px/1.2 var(--control-font);
  color: var(--ink-soft);
}

.legal ul {
  margin: 0 0 12px;
  padding-left: 22px;
}

.legal li {
  margin-bottom: 6px;
}

.legal code {
  font-size: 15px;
}

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

.footer {
  margin-top: 90px;
  padding: 26px 16px;
  background: var(--board);
  border-top: 3px solid #000;
  box-shadow: inset 0 3px 0 var(--wood-frame), inset 0 6px 0 #000;
  text-align: center;
  font-size: 16px;
  color: var(--text-muted);
}

.footer p {
  margin: 4px 0;
}

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

/* --- narrower screens ----------------------------------------------------------- */

@media (max-width: 1000px) {
  .nav {
    display: none;
  }

  .lang {
    margin-left: auto;
  }

  .hero {
    display: block;
    min-height: 0;
    padding-top: 12px;
  }

  .hero-world {
    position: static;
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    transform: none;
  }

  .sheet {
    margin: -30px auto 0;
  }

  .feature,
  .community {
    grid-template-columns: 1fr;
  }

  .feature:nth-of-type(even) .shot {
    order: 0;
  }

  .biomes,
  .cards {
    grid-template-columns: 1fr;
    max-width: 620px;
    margin-left: auto;
    margin-right: auto;
  }

  .biome .parchment {
    height: auto;
    min-height: 0;
  }

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

/* A phone on its side: the menu comes before the picture. */
@media (max-width: 1000px) and (max-height: 500px) {
  .hero {
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 12px;
  }

  .sheet {
    margin: 0 auto;
  }
}

@media (max-width: 720px) {
  body {
    font-size: 18px;
  }

  .logo {
    font-size: 21px;
  }

  .section {
    padding-top: 56px;
  }

  .section-title {
    min-width: 0;
    width: 100%;
    font-size: 26px;
  }

  /* No room past the shingle on a narrow screen: the beam stays within the page. */
  .sign::before,
  .section-title::before {
    left: 0;
    right: 0;
  }

  .sheet .sign {
    font-size: 34px;
    min-height: 96px;
  }

  .board {
    padding: 26px 24px 52px;
  }

  .parchment {
    padding: 28px 26px 40px;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
    padding-left: 24px;
    padding-right: 24px;
  }

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

  .legal .parchment {
    padding: 28px 26px 42px;
  }
}
