/* THE LANDING PAGE'S LAYOUT (Figma frame `1:92`). Every colour, size, font,
   border and shadow is a token of web/shared/tokens.css and every text,
   button, tag and card a class of web/shared/components.css; this file only
   places them. */

:root {
  /* The space above and below a section: the design's 80px at 1440px. */
  --section: clamp(3rem, 5.6vw, 5rem);
  /* The header's height, fixed so the hero can fill the rest of the first
     screen (.hero-inner): the 44px buttons and 10px above and below. */
  --header-height: 4rem;
  /* The headline's distance from the bottom of the first screen. */
  --hero-bottom: 1.875rem;
  /* A spring as an easing: a damped spring from 0 to 1 (damping ratio 0.45,
     16 rad/s) sampled over 0.7 s, so it overshoots by a fifth and settles.
     For transitions of 0.7 s. */
  --spring: linear(0, 0.07, 0.243, 0.463, 0.688, 0.887, 1.04, 1.142, 1.194, 1.205, 1.185, 1.147, 1.101, 1.055, 1.016, 0.987, 0.968, 0.959, 0.958, 0.963, 0.972, 0.981, 0.99, 0.998, 1.004, 1.007, 1.009, 1.008, 1);
}

html {
  scroll-behavior: smooth;
  /* A mascot thrown to the window's edge or the sticker's corner never
     scrolls the page sideways. html's own overflow keeps the body's from
     passing to the viewport, which would stop the page from scrolling. */
  overflow-x: clip;
}

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

/* The notebook's grid reaches the bottom of a short page too. */
body {
  min-height: 100dvh;
  overflow-x: clip;
}

a:focus-visible, button:focus-visible, summary:focus-visible, .cards-track:focus-visible {
  outline: 0.125rem solid var(--primary);
  outline-offset: 0.25rem;
}

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

p, h1, h2, h3, ul {
  margin: 0px;
}

ul {
  padding: 0px;
  list-style: none;
}

/* The accent words of a headline ("game", "play", "community"). */
.highlight {
  color: var(--accent);
}

/* A line break the design sets at its width; a narrower screen wraps. */
@media (max-width: 1023px) {
  .wide-break {
    display: none;
  }
}

.skip-link {
  position: absolute;
  left: 1.25rem;
  top: -6.25rem;
  z-index: 110;
  padding: 0.75rem;
  border: var(--line) solid var(--primary);
  border-radius: 0.75rem;
  background: var(--background);
}

.skip-link:focus {
  top: 0.75rem;
}

/* THE HEADER: the wordmark, then the links and the two account buttons at
   the right. It scrolls with the page; it stacks above the hero, so the
   narrow screen's menu opens over the sticker and the mascots. */
/* The bar (Figma "Header" 1:95): White at half strength over the notebook,
   so the grid shows through, and a soft shadow below it. It stacks above
   the hero, whose shadow-less content would otherwise cover its shadow and
   whose sticker springs up towards it. */
.header {
  position: relative;
  z-index: 100;
  background: color-mix(in srgb, var(--white) 50%, transparent);
  box-shadow: 0px 0.125rem 0.25rem var(--shade);
}

.header-bar {
  position: relative;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 2rem;
  height: var(--header-height);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-left: auto;
}

/* THE MENU of a narrow screen: a native disclosure, no script. */
.menu {
  display: none;
  position: relative;
}

.menu summary {
  list-style: none;
}

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

.menu-bars, .menu-bars::before, .menu-bars::after {
  content: "";
  position: relative;
  display: block;
  width: 1.125rem;
  height: var(--line);
  background: currentColor;
}

.menu-bars::before {
  position: absolute;
  top: -0.375rem;
}

.menu-bars::after {
  position: absolute;
  top: 0.375rem;
}

.menu[open] .menu-bars {
  background: transparent;
}

.menu[open] .menu-bars::before {
  top: 0px;
  transform: rotate(45deg);
}

.menu[open] .menu-bars::after {
  top: 0px;
  transform: rotate(-45deg);
}

.menu nav {
  position: absolute;
  right: 0px;
  top: 3.5rem;
  z-index: 5;
  display: flex;
  flex-direction: column;
  min-width: 13.75rem;
  padding: 0.5rem;
  border: var(--line) solid var(--primary);
  border-radius: var(--radius);
  background: var(--background);
  font: 500 var(--size-body)/1 var(--font);
  letter-spacing: -0.02em;
}

.menu nav a {
  padding: 0.875rem 1rem;
  border-radius: 0.75rem;
  text-decoration: none;
}

.menu nav a:hover {
  background: var(--border);
}

/* LOGGED IN (landing.mjs): the account's menu takes the place of Log in and Create now. */
.menu.account-menu {
  display: none;
}

.logged-in .menu.account-menu {
  display: block;
}

.logged-in .header [data-auth] {
  display: none;
}

/* The narrow screen's menu holds only Create now and Log in: logged in, it
   would open empty, so the account's menu stands alone. */
.logged-in .menu:not(.account-menu) {
  display: none;
}

/* THE HERO: the heap of mascots over the one-line headline, the sticker in
   the top right corner. It fills the first screen below the header and
   sets the heap and the headline at its bottom, the headline --hero-bottom
   above the screen's edge, on any display. 100svh is the screen with a
   phone's browser bars shown, so they never cover the headline. The top
   padding keeps the heap clear of the sticker on a short screen, where the
   hero grows past the first screen instead. */
.hero-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 1.5rem;
  min-height: calc(100svh - var(--header-height));
  padding-block: clamp(8.5rem, 15vw, 13.75rem) var(--hero-bottom);
}

.hero h1 {
  text-align: center;
}

/* On a desktop the headline is one line, as in the design: set in Satoshi
   it is 13.2 times its size wide (measured), so it takes the smaller of the
   Display size and what the row holds beside a 16px scrollbar. */
@media (min-width: 1280px) {
  .hero h1 {
    font-size: min(var(--size-display), calc((100vw - 2 * var(--gutter) - 1rem) / 13.3));
  }
}

/* THE STICKER "I help you create": an Accent disc in a Primary ring, tilted,
   with the design's drop shadow. It is a button: a press stacks the mascots
   (landing.mjs), so it shows the pointing hand, and while the stacking runs
   it is disabled and shows the plain arrow. The button is round, so the
   focus ring is too. */
.sticker {
  position: absolute;
  /* One grid square (30px) below the header, clear of it when it springs up. */
  top: 1.875rem;
  right: var(--gutter);
  width: clamp(6.5rem, 12vw, 10.75rem);
  padding: 0px;
  border: 0px;
  border-radius: 50%;
  background: none;
  cursor: pointer;
  transform: rotate(12deg);
  filter: drop-shadow(var(--shadow));
  transition: transform 0.7s var(--spring), filter 0.7s var(--spring);
}

.sticker:disabled {
  cursor: default;
}

.sticker svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

/* Under a pointer the sticker springs up towards the viewer: it grows,
   lifts a little and its shadow falls further and softer, as of a sticker
   peeled off the page. Only where a pointer hovers (a touch screen would
   leave it lifted after a tap). */
@media (hover: hover) {
  .sticker:hover {
    transform: translateY(-0.375rem) rotate(12deg) scale(1.15);
    filter: drop-shadow(0.875rem 1.125rem 0.875rem var(--shade));
  }
}

@media (prefers-reduced-motion: reduce) {
  .sticker {
    transition: none;
  }
}

.sticker .disc {
  fill: var(--accent);
  stroke: var(--primary);
  stroke-width: 3.2px;
}

/* 18 units of the sticker's 172-unit viewBox (the design's caps on the
   arc), not a page font size: it scales with the sticker. */
.sticker text {
  fill: var(--primary);
  font: 500 18px var(--font);
}

/* THE HEAP (tumble.mjs PILE): the box is the S's frame of 215.5 design units;
   the heap hangs out of it to the left (to -55 units), above it (to -65) and
   to the right (to +25.5), so the box is moved right by half the difference
   and given the room above. The T, the O and the L are drawn where their
   fall onto the S leaves them, turned as it leaves them, so the page without
   its script shows the heap; landing.mjs drops them from above into these
   places. They are hidden until the script takes over, or shown a moment
   after load when there is none. */
.hero-mascots {
  --heap: clamp(9.375rem, 17vw, 13.4688rem);
  position: relative;
  left: calc(var(--heap) * 0.068);
  width: var(--heap);
  aspect-ratio: 215.5 / 191;
  margin-top: calc(var(--heap) * 0.31);
}

.hero-mascot {
  position: absolute;
  width: 75.4%;
  height: auto;
  pointer-events: none;
  transform-origin: 0px 0px;
  touch-action: none;
}

/* THE DRAG HINT: "Drag me" curved down towards the heap's upper left (the
   L's side, clear of the O hanging further out below), sized with the heap.
   Hidden until landing.mjs makes the mascots grabbable (data-drag="ready");
   it fades in once the fall has settled and fades out
   on the first grab (data-drag="done"). */
.drag-hint {
  position: absolute;
  left: -66%;
  top: 4%;
  width: 62%;
  height: auto;
  overflow: visible;
  opacity: 0;
  pointer-events: none;
  transform: rotate(-60deg);
}

/* 22 units of the hint's 110-unit viewBox: it scales with the heap. */
.drag-hint text {
  fill: var(--primary);
  font: 500 22px var(--font);
}

@keyframes drag-hint-appear {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes drag-hint-leave {
  from { opacity: 1; }
  to { opacity: 0; }
}

.hero-mascots[data-drag="ready"] .drag-hint {
  animation: drag-hint-appear 0.4s ease 1.2s both;
}

.hero-mascots[data-drag="done"] .drag-hint {
  animation: drag-hint-leave 0.25s ease both;
}

.hero-mascot :is(path, rect, ellipse) {
  pointer-events: visiblepainted;
  cursor: grab;
}

.hero-mascot.held :is(path, rect, ellipse) {
  cursor: grabbing;
}

@keyframes mascot-appear {
  100% {
    opacity: 1;
  }
}

.m-t {
  left: 41.428%;
  top: 24.263%;
  transform: rotate(-0.785rad);
  opacity: 0;
  animation: 0.01s ease 0.6s 1 normal forwards running mascot-appear;
}

.m-s {
  left: 24.6%;
  top: 42.4%;
}

.hero-mascot.m-oh {
  left: -26.708%;
  top: 42.425%;
  width: 51.04%;
  opacity: 0;
  animation: 0.01s ease 0.6s 1 normal forwards running mascot-appear;
}

/* THE TWO BESIDE THE HEAP (landing.mjs): the I lying left of it and the J
   standing on its row of three right of it, both on the S's floor (their bottoms where the S's
   is: its top plus the S's height less theirs), 20 units clear of the
   heap's reach (x -55 to 241 units of the 215.5-unit box). The I is 215
   units long, the J 162.5. They fall in with the heap (landing.mjs), so they
   are hidden until the script takes over, as the falling three are. Below a
   tablet's width there is no room beside
   the heap: they are not shown, and the physics leaves them out. */
.hero-mascot.m-eye {
  left: -133.411%;
  top: 69.885%;
  width: 99.768%;
  opacity: 0;
  animation: 0.01s ease 0.6s 1 normal forwards running mascot-appear;
}

.m-jay {
  left: 119.954%;
  top: 42.4%;
  opacity: 0;
  animation: 0.01s ease 0.6s 1 normal forwards running mascot-appear;
}

@media (max-width: 719px) {
  .hero-mascot:is(.m-eye, .m-jay) {
    display: none;
  }
}

.m-el {
  left: -9.118%;
  top: -10.017%;
  transform: rotate(-0.2776rad);
  opacity: 0;
  animation: 0.01s ease 0.6s 1 normal forwards running mascot-appear;
}

/* THE SHOWCASE: the still of quine in action across the whole width, then
   the statement under it. */
.showcase {
  display: flex;
  flex-direction: column;
  gap: clamp(2.5rem, 6vw, 6rem);
  padding-block: var(--section);
}

.showcase-still {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  box-shadow: var(--shadow);
}

.statement {
  text-align: center;
}

/* THE FEATURES: three cards, the lead and the calls to action. */
.features {
  padding-block: var(--section);
}

.features-inner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3rem;
}

.feature-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0px, 1fr));
  gap: 1.5rem;
  width: 100%;
}

/* A card: its mascot at the top, centred, the title and the text at the
   foot; cards of one row are one height. */
.feature {
  --k: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-height: 23.125rem;
  padding: 2.25rem 2.25rem 2.5rem;
}

.feature .mascot {
  align-self: center;
  height: auto;
  margin-bottom: auto;
  /* The design's 60px between the mascot's box and the title, less the gap. */
  padding-bottom: 2.5rem;
  overflow: visible;
}

.m-l {
  width: calc(10.1562rem * var(--k));
}

.m-o {
  width: calc(6.875rem * var(--k));
}

/* The I lies flat: it stands lower, centred in the others' 110px. */
.m-i {
  width: calc(13.4375rem * var(--k));
  margin-top: calc(1.6875rem * var(--k));
}

/* The L's speed lines are Accent (the art's own colour is Primary). */
.mascot .speed {
  stroke: var(--accent);
}

.features-lead {
  max-width: 53rem;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.cta-row .glyph {
  width: 1.375rem;
  height: 1.375rem;
}

/* THE COMMUNITY: the heading, the grid of listings and Show more. */
.discover {
  padding-bottom: var(--section);
}

.discover-head {
  padding-top: var(--section);
  margin-bottom: 3rem;
}

.discover-head h2 {
  max-width: 40.125rem;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0px, 1fr));
  gap: 1.25rem;
}

/* Newest | Top and the tag chips above the grid: outlined buttons, the
   chosen one filled. */
.community-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  margin-bottom: 1.5rem;
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.button.chip {
  padding: 0.375rem 0.875rem;
}

.button.chip[aria-pressed="true"] {
  background: var(--primary);
  color: var(--background);
}

/* A card (landing.mjs `card`): the picture, the title and creator (and the
   credit of a fork), Play and Report at the foot. The body fills the card,
   so a row of cards with and without a credit line has its Play buttons on
   one line; a long name ends in an ellipsis instead of growing the card. */
.thumb {
  display: block;
  flex: 0 0 auto;
  width: 100%;
  height: auto;
  aspect-ratio: 330 / 200;
  object-fit: cover;
}

/* A listing without a picture shows the card's quiet fill where it would be. */
.thumb-empty {
  background: var(--border);
}

.game .body {
  flex: 1;
  justify-content: space-between;
  min-width: 0px;
}

.game .head {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0px;
}

.game :is(.title, .creator, .credit, .facts) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.credit a {
  color: inherit;
}

.game .actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* The card's rating and tags: one quiet line under the creator. */
.game .facts {
  color: var(--muted);
}

/* Report is a quiet link beside Play: Body text in the muted Primary, since
   the type scale has no smaller size. */
.game .report {
  margin-left: 0.5rem;
  color: var(--muted);
}

/* "Show more" under the grid, or the one line a community without listings shows. */
.games-more {
  display: flex;
  justify-content: center;
  padding-top: 2rem;
}

/* THE NEWEST GAMES carousel (index.html keeps it commented out; landing.mjs
   fills it when it is there). */
.popular {
  padding-block: var(--section);
}

.popular-head {
  display: flex;
  align-items: flex-end;
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.slider-controls {
  display: flex;
  gap: 0.75rem;
}

.round::before {
  content: "";
  width: 1.25rem;
  height: 1.25rem;
  background: currentColor;
  mask: url("shared/icons/arrow-right.svg") center / contain no-repeat;
}

.round[data-slide="-1"]::before {
  transform: scaleX(-1);
}

.round:disabled {
  opacity: 0.4;
  cursor: default;
}

.cards-track {
  display: flex;
  gap: 1.25rem;
  padding: 0.125rem var(--gutter) 0.625rem;
  overflow-x: auto;
  scroll-snap-type: x;
  scroll-padding-inline: var(--gutter);
  scrollbar-width: none;
}

.cards-track::-webkit-scrollbar {
  display: none;
}

.cards-track > li {
  flex: 0 0 min(20.625rem, 76vw);
  scroll-snap-align: start;
}

/* THE QUESTIONS: the heading over a column of cards, one question each. */
.faq-inner {
  display: flex;
  flex-direction: column;
  gap: 3rem;
  padding-block: var(--section);
}

.faq-inner h2 {
  max-width: 40.125rem;
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* A question: the card's summary is the question beside its toggle, which
   takes the place of the browser's own marker. The card's inner space (the
   design's 28px, 36px at the left) is the summary's and the answer's
   padding, not the card's, so a click anywhere on a closed card, its edge
   included, opens it. Open, the summary's bottom shrinks to the design's
   12px between question and answer, in step with the answer's growth. */
.faq-item {
  --faq-pad: 1.75rem;
  --faq-pad-left: 2.25rem;
  /* A strong ease-out: the card answers the click in its first frame and
     settles gently; a slow start (plain `ease`) reads as lag. */
  --faq-motion: 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.faq-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: var(--faq-pad) var(--faq-pad) var(--faq-pad) var(--faq-pad-left);
  list-style: none;
  cursor: pointer;
  transition: padding-bottom var(--faq-motion);
}

.faq-item[open] summary {
  padding-bottom: 0.75rem;
}

/* The card clips what lies outside it, so the focus ring sits inside. */
.faq-item summary:focus-visible {
  outline-offset: -0.5rem;
  border-radius: var(--radius);
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

/* The answer keeps a readable measure (the design's 760px of text). */
.faq-item p {
  max-width: calc(47.5rem + var(--faq-pad) + var(--faq-pad-left));
  padding: 0px var(--faq-pad) var(--faq-pad) var(--faq-pad-left);
}

/* OPENING AND CLOSING: the card uncovers the answer as it grows to its
   height, without a fade (text fading in from nothing reads as a late
   reaction); in the group the closing answer shrinks as the opening one grows.
   `interpolate-size` lets the height run to `auto`, and `content-visibility`
   switches discretely at the end, so a closing answer stays visible while it
   shrinks. Only where the browser can interpolate to `auto`: where it
   cannot, `auto` would jump halfway through the transition, so the answer
   opens at once as before. */
@supports (interpolate-size: allow-keywords) {
  .faq-item {
    interpolate-size: allow-keywords;
  }
  .faq-item::details-content {
    block-size: 0px;
    overflow: clip;
    transition: block-size var(--faq-motion), content-visibility var(--faq-motion) allow-discrete;
  }
  .faq-item[open]::details-content {
    block-size: auto;
  }
}

/* THE TOGGLE: an icon button drawn by the summary, not a control of its own
   (the summary is). Open it is the filled Icon Button with a minus; closed,
   a plus in Primary on Secondary, without the ring. Plus and minus are two
   bars in the current colour: the upright one turns flat as a question
   opens. */
.faq-toggle {
  position: relative;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.faq-item:not([open]) .faq-toggle {
  border-color: var(--secondary);
  background: var(--secondary);
  color: var(--primary);
}

.faq-toggle::before, .faq-toggle::after {
  content: "";
  position: absolute;
  width: 0.75rem;
  height: 0.15625rem;
  border-radius: 0.15625rem;
  background: currentColor;
  transition: transform 0.18s ease;
}

.faq-item:not([open]) .faq-toggle::after {
  transform: rotate(90deg);
}

.faq-item summary:hover .faq-toggle {
  opacity: 0.86;
}

@media (prefers-reduced-motion: reduce) {
  .faq-toggle, .faq-toggle::before, .faq-toggle::after, .faq-item summary, .faq-item::details-content {
    transition: none;
  }
}

/* A small desktop: three listings a row keep a card's name readable. */
@media (max-width: 1199px) {
  .games-grid {
    grid-template-columns: repeat(3, minmax(0px, 1fr));
  }
}

/* A TABLET: the header's Log in and Create now give way to the menu, which
   holds both; the grid goes to two columns and the feature cards stack. */
@media (max-width: 1023px) {
  .header-actions > .button {
    display: none;
  }
  .menu {
    display: block;
  }
  .header-actions {
    gap: 0.5rem;
  }
  .header-actions .icon-link {
    min-width: 2.75rem;
    min-height: 2.75rem;
  }
  .feature {
    --k: 0.65;
    min-height: 0px;
    padding: 1.75rem 1.5rem 2rem;
  }
  .games-grid {
    grid-template-columns: repeat(2, minmax(0px, 1fr));
  }
}

/* Below a tablet's width the three feature cards stack. */
@media (max-width: 719px) {
  .feature-cards {
    grid-template-columns: minmax(0px, 1fr);
  }
  .feature {
    --k: 1;
  }
}

/* A PHONE: one card per row, the CTAs stacked full-width, the header down
   to the wordmark and the menu. */
@media (max-width: 559px) {
  .header-bar {
    gap: 0.75rem;
  }
  /* No room beside the heap: the hint curves over it instead. */
  .drag-hint {
    left: 12%;
    top: -74%;
    transform: rotate(-4deg);
  }
  .header-bar .icon-link {
    display: none;
  }
  .hero-inner {
    padding-top: 8rem;
  }
  .feature {
    --k: 0.8;
  }
  .features-inner {
    gap: 2rem;
  }
  .cta-row {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }
  .discover-head {
    margin-bottom: 2rem;
  }
  .faq-inner {
    gap: 2rem;
  }
  .faq-item {
    --faq-pad: 1.25rem;
    --faq-pad-left: 1.5rem;
  }
  .games-grid {
    grid-template-columns: minmax(0px, 1fr);
    gap: 1rem;
  }
}
