/*
 * The Party Pie site: the home page and one page per game, written by
 * server/scripts/site.mjs. The tokens are the app's own (src/theme/tokens.ts,
 * design/DIRECTION.md): the cupboard's ground, the mark's red, one hue per
 * family, and Bricolage Grotesque for display.
 */

@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('/site/fonts/BricolageGrotesque_700Bold.ttf') format('truetype');
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('/site/fonts/BricolageGrotesque_800ExtraBold.ttf') format('truetype');
  font-weight: 800;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ground: #f7f5f0;
  --raised: #ffffff;
  --ink: #1e1a15;
  --ink-2: #5e574d;
  --rule: rgba(30, 26, 21, 0.1);
  --cream: #fff9f0;
  --red: #d12f15;
  --red-edge: #8e2410;
  --display: 'Bricolage Grotesque', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --margin: 20px;
  --section: clamp(56px, 9vw, 112px);
  --ambient: 0 12px 28px rgba(64, 32, 12, 0.14);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 17px/1.55 var(--ui);
  font-variant-numeric: tabular-nums;
}

::selection {
  background: var(--red);
  color: var(--cream);
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
  border-radius: 6px;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--display);
  text-wrap: balance;
}

h1 {
  font-weight: 800;
  font-size: clamp(2.75rem, 1.4rem + 5.6vw, 5.75rem);
  line-height: 0.95;
  letter-spacing: -0.035em;
}

h2 {
  font-weight: 800;
  font-size: clamp(2rem, 1.35rem + 2.6vw, 3.25rem);
  line-height: 1;
  letter-spacing: -0.03em;
}

h3 {
  font-weight: 700;
  font-size: 1.375rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

p {
  margin: 0;
}

.wrap {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--margin);
}

.read {
  max-width: 68ch;
}

/* ---------------------------------------------------------------- bar */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 16px;
  padding-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.375rem;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}

.bar nav {
  display: flex;
  align-items: center;
  gap: 24px;
  font-weight: 600;
}

.bar nav a:not(.store) {
  text-decoration: none;
}

.bar nav a:not(.store):hover {
  text-decoration: underline;
}

.store {
  display: inline-block;
  border-radius: 10px;
}

.store img {
  width: auto;
  height: 54px;
}

.bar .store img {
  height: 40px;
}

@media (max-width: 559px) {
  .bar .store {
    display: none;
  }
}

/* ---------------------------------------------------------------- hero */

.hero {
  background: var(--red);
  color: var(--cream);
}

.hero ::selection {
  background: var(--cream);
  color: var(--red);
}

.hero a:focus-visible {
  outline-color: var(--cream);
}

.hero-in {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  align-items: center;
  gap: 40px;
  padding-top: clamp(24px, 5vw, 64px);
  padding-bottom: clamp(56px, 8vw, 104px);
}

.hero-copy {
  display: grid;
  justify-items: start;
  gap: 24px;
}

.lede {
  font-size: clamp(1.125rem, 1rem + 0.5vw, 1.375rem);
  line-height: 1.45;
  max-width: 34ch;
}

.hero .note {
  font-weight: 600;
}

@media (max-width: 799px) {
  .hero-in {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .hero .pie {
    order: -1;
    width: min(64vw, 280px);
  }
}

/* The mark, layered the way the app's PieMark is: inside, pie, eyes, lid. */
.pie {
  position: relative;
  width: 100%;
  max-width: 500px;
  justify-self: center;
  aspect-ratio: 720 / 691;
}

.pie img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.pie .eyes {
  position: absolute;
  inset: 0;
  transform-origin: 37.94% 59.98%;
}

.pie .lid {
  transform-origin: 95.92% 60.09%;
}

/* The one moment: the lid lifts, the eyes pop in, and the pie looks at the headline. */
@media (prefers-reduced-motion: no-preference) {
  .pie .lid {
    animation: lid-open 900ms 200ms both;
  }

  .pie .eyes {
    animation: eyes-pop 420ms 420ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
  }

  .pie .pupils {
    animation: glance 360ms 1500ms cubic-bezier(0.22, 1, 0.36, 1) both;
  }
}

@keyframes lid-open {
  0% {
    transform: rotate(-13.75deg);
    animation-timing-function: cubic-bezier(0.3, 0, 0.2, 1);
  }
  45% {
    transform: rotate(3deg);
    animation-timing-function: ease-in-out;
  }
  72% {
    transform: rotate(-1deg);
    animation-timing-function: ease-in-out;
  }
  100% {
    transform: rotate(0deg);
  }
}

@keyframes eyes-pop {
  from {
    transform: scale(0);
  }
  to {
    transform: scale(1);
  }
}

/* From the icon's pose (looking right) to the far left of the whites. */
@keyframes glance {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-6.15%);
  }
}

/* ---------------------------------------------------------------- sections */

.section {
  padding-top: var(--section);
  padding-bottom: var(--section);
}

.section > .wrap > h2 {
  max-width: 18ch;
}

.section-lede {
  margin-top: 16px;
  color: var(--ink-2);
  font-size: 1.125rem;
  max-width: 52ch;
}

/* How it plays: three facts, side by side from tablet up. */
.facts-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 40px;
  margin: 40px 0 0;
  padding: 0;
  list-style: none;
}

.facts-list li {
  display: grid;
  gap: 12px;
  align-content: start;
  padding-top: 24px;
  border-top: 2px solid var(--ink);
}

.facts-list p {
  color: var(--ink-2);
}

@media (max-width: 799px) {
  .facts-list {
    grid-template-columns: 1fr;
    gap: 32px;
  }
}

/* ---------------------------------------------------------------- shelves */

.shelves {
  padding-top: 0;
}

.shelf {
  margin-top: 56px;
  scroll-margin-top: 24px;
}

.shelf-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-bottom: 20px;
}

.shelf-head h3 {
  font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.025em;
}

.shelf-head p {
  color: var(--ink-2);
}

/* A family is at most two rows of seven on a wide screen. */
.boxes {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 28px 16px;
  margin: 0;
  padding: 0 0 8px;
  list-style: none;
}

/* Narrower than that, a shelf scrolls sideways, the way it does in the app. */
@media (max-width: 1099px) {
  .boxes {
    display: flex;
    gap: 14px;
    margin: 0 calc(-1 * var(--margin));
    padding: 4px var(--margin) 24px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding: 0 var(--margin);
    scrollbar-width: thin;
    scrollbar-color: rgba(30, 26, 21, 0.25) transparent;
  }

  .boxes li {
    flex: 0 0 clamp(150px, 40vw, 180px);
    scroll-snap-align: start;
  }
}

/* A game box: its cover, then a band in the family's deep hue, standing on its edge. */
.box {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  border-radius: 18px;
  overflow: hidden;
  background: var(--band);
  color: var(--cream);
  text-decoration: none;
  box-shadow: 0 6px 0 var(--edge), var(--ambient);
  transition: transform 160ms ease-out, box-shadow 160ms ease-out;
}

.box img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--fill);
}

.box:hover {
  transform: translateY(-3px);
  box-shadow: 0 9px 0 var(--edge), 0 18px 34px rgba(64, 32, 12, 0.18);
}

.box:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--edge), 0 6px 14px rgba(64, 32, 12, 0.14);
}

.box:focus-visible {
  outline-offset: 5px;
  border-radius: 18px;
}

.box-band {
  display: grid;
  gap: 6px;
  flex: 1;
  align-content: start;
  padding: 12px 14px 16px;
}

.box-name {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.25rem;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.box-line {
  font-size: 0.875rem;
  line-height: 1.35;
}

.box-meta {
  margin-top: 2px;
  font-size: 0.8125rem;
  font-weight: 600;
}

.box-meta span {
  white-space: nowrap;
}

.free {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--cream);
  color: var(--ink);
  font-size: 0.8125rem;
  font-weight: 700;
}

/* ---------------------------------------------------------------- price */

.price {
  background: var(--raised);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.price-in {
  display: grid;
  grid-template-columns: minmax(0, 300px) minmax(0, 1fr);
  align-items: center;
  gap: clamp(32px, 6vw, 80px);
}

.price-in > div {
  display: grid;
  justify-items: start;
  gap: 20px;
}

.price-in p {
  max-width: 54ch;
  font-size: 1.125rem;
}

@media (max-width: 719px) {
  .price-in {
    grid-template-columns: 1fr;
  }

  .price-in img {
    width: 150px;
  }
}

/* ---------------------------------------------------------------- questions */

.faq {
  margin: 40px 0 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 40px 56px;
}

.faq div {
  display: grid;
  gap: 8px;
  align-content: start;
}

.faq dt {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.375rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.faq dd {
  margin: 0;
  color: var(--ink-2);
}

@media (max-width: 799px) {
  .faq {
    grid-template-columns: 1fr;
    gap: 32px;
  }
}

/* ---------------------------------------------------------------- game page */

.game-head {
  background: var(--band);
  color: var(--cream);
}

.game-head ::selection {
  background: var(--cream);
  color: var(--band);
}

.game-head a:focus-visible {
  outline-color: var(--cream);
}

.game-head-in {
  display: grid;
  grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
  align-items: center;
  gap: clamp(28px, 5vw, 64px);
  padding-top: clamp(32px, 5vw, 64px);
  padding-bottom: clamp(48px, 6vw, 80px);
}

.game-head-in > div {
  display: grid;
  justify-items: start;
  gap: 20px;
}

.cover {
  border-radius: 18px;
  overflow: hidden;
  background: var(--fill);
  box-shadow: 0 6px 0 var(--edge), 0 18px 36px rgba(20, 10, 4, 0.28);
}

.cover img {
  width: 100%;
  aspect-ratio: 1;
}

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-weight: 600;
}

@media (max-width: 719px) {
  .game-head-in {
    grid-template-columns: 1fr;
  }

  .cover {
    width: min(100%, 300px);
  }
}

.howto .read > h2 {
  margin-bottom: 24px;
}

.steps {
  display: grid;
  gap: 12px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  display: grid;
  grid-template-columns: 40px 1fr;
  align-items: baseline;
  font-size: 1.25rem;
  line-height: 1.35;
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--deep);
}

.guide section {
  margin-top: 40px;
}

.guide h3 {
  margin-bottom: 12px;
}

.guide p + p {
  margin-top: 12px;
}

.cta {
  display: grid;
  justify-items: start;
  gap: 20px;
  margin-top: 56px;
  padding: clamp(24px, 4vw, 32px);
  border-radius: 18px;
  background: var(--raised);
  box-shadow: 0 1px 2px rgba(30, 26, 21, 0.06), var(--ambient);
}

.cta h2 {
  font-size: 1.75rem;
}

/* Wide enough, the way to get the game stays beside its rules. */
@media (min-width: 960px) {
  .howto-in {
    display: grid;
    grid-template-columns: minmax(0, 68ch) minmax(280px, 360px);
    justify-content: space-between;
    align-items: start;
    gap: 56px;
  }

  .cta {
    position: sticky;
    top: 24px;
    margin-top: 0;
  }
}

.more {
  padding-top: 0;
}

.more h2 {
  margin-bottom: 24px;
}

/* ---------------------------------------------------------------- footer */

.foot {
  background: var(--red);
  color: var(--cream);
  padding-top: 56px;
  padding-bottom: 56px;
}

.foot ::selection {
  background: var(--cream);
  color: var(--red);
}

.foot a:focus-visible {
  outline-color: var(--cream);
}

.foot-in {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 32px;
}

.foot-in > div {
  display: grid;
  gap: 16px;
  max-width: 40ch;
}

.foot nav ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-weight: 600;
}

/* ---------------------------------------------------------------- languages */

/*
 * Bricolage Grotesque has no CJK glyphs, so the app draws Japanese and Korean
 * in the system face; those pages follow, and drop the negative tracking that
 * only suits the Latin face.
 */
:lang(ja) :is(h1, h2, h3, .brand, .box-name, .faq dt, .steps li::before),
:lang(ko) :is(h1, h2, h3, .brand, .box-name, .faq dt, .steps li::before) {
  font-family: var(--ui);
  letter-spacing: 0;
}

/* The 13 names of the site, at the foot of every page, each its own language's. */
.langs ul {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.9375rem;
}

.langs a {
  text-decoration-color: transparent;
}

.langs a:hover {
  text-decoration-color: currentColor;
}

.langs a[aria-current='page'] {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.24em;
}

/* The collections a game belongs to, under its facts. */
.collections {
  max-width: 46ch;
  font-size: 0.9375rem;
  font-weight: 600;
}

/* ---------------------------------------------------------------- find a game */

.find {
  padding-top: 0;
}

.find-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
  font-weight: 600;
}

/* ---------------------------------------------------------------- press */

.press-head .read {
  display: grid;
  gap: 16px;
  margin-top: 24px;
  font-size: 1.125rem;
}

.facts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 40px;
  margin: 32px 0 0;
  padding: 0;
  list-style: none;
}

.facts-grid li {
  padding: 12px 0;
  border-top: 1px solid var(--rule);
  font-weight: 600;
}

@media (max-width: 799px) {
  .facts-grid {
    grid-template-columns: 1fr;
  }
}

.press-sub {
  margin-top: 48px;
  margin-bottom: 16px;
}

.press-note {
  color: var(--ink-2);
}

.press-files {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.press-files a {
  display: grid;
  gap: 8px;
  font-weight: 600;
  text-decoration: none;
}

.press-files img {
  border-radius: 12px;
  box-shadow: var(--ambient);
}

.press-files a:hover span {
  text-decoration: underline;
}

.press-files span {
  color: var(--ink-2);
  font-size: 0.875rem;
  font-weight: 400;
}

/* Six store screenshots; narrower than a desktop, they scroll sideways like a shelf. */
.shots {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 16px;
  margin: 0;
  padding: 0 0 8px;
  list-style: none;
}

.shots img {
  width: 100%;
  aspect-ratio: 1320 / 2868;
  border-radius: 18px;
  border: 1px solid var(--rule);
  background: var(--raised);
}

@media (max-width: 1099px) {
  .shots {
    display: flex;
    gap: 14px;
    margin: 0 calc(-1 * var(--margin));
    padding: 4px var(--margin) 24px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding: 0 var(--margin);
    scrollbar-width: thin;
    scrollbar-color: rgba(30, 26, 21, 0.25) transparent;
  }

  .shots li {
    flex: 0 0 clamp(160px, 44vw, 200px);
    scroll-snap-align: start;
  }
}

.press-covers {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 20px 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.press-covers a {
  display: grid;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9375rem;
  text-decoration: none;
}

.press-covers img {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 14px;
  background: var(--ground);
  box-shadow: 0 4px 0 rgba(30, 26, 21, 0.18);
}

.press-covers a:hover span {
  text-decoration: underline;
}
