/* ---------------------------------------------------------------------------
   Kongy Sports Club, the main menu.

   Two borrowed languages, kept apart on purpose:
   • The PAGE is kongylabs.com: paper and ink, flare yellow, Archivo Black
     headings, mono eyebrows, square ruled cards with the site's own card
     art and stamps. Values copied from the website's Layout.astro.
   • The BUTTONS are the games': Baloo 2 pills with a bevel and a drop,
     from the Club games' style.css. They are the one thing on the page you
     press, so they look like the games you are about to be in.
--------------------------------------------------------------------------- */

:root {
  --ink: #100e0c;
  --flare: #ffc61a;
  --paper: #e9e5dc;
  --card: #f7f5f0;
  --ink-soft: #4a443c;
  --display: 'Archivo Black', system-ui, sans-serif;
  --body: 'Chivo', system-ui, sans-serif;
  --mono: 'Chivo Mono', ui-monospace, monospace;
  --bubble: 'Baloo 2', 'Nunito', system-ui, sans-serif;
  --rule: 3px;
  --gutter: clamp(16px, 4vw, 40px);

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
}

/* `hidden` must win over any display rule (.btn is inline-block). Without
   this, UNLOCK ALL and GET THE APP showed where they should not. */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.45;
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

img {
  -webkit-user-drag: none;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  margin: 0;
}

/* --- masthead ------------------------------------------------------------ */

.masthead {
  display: flex;
  flex-wrap: wrap; /* a narrow phone puts the buttons on a second row */
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  padding: 14px var(--gutter);
  background: var(--flare);
  border-bottom: var(--rule) solid var(--ink);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mark {
  display: block;
  height: 58px;
  width: auto;
  flex: none;
}

.wordmark {
  font-family: var(--display);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  font-size: clamp(1.25rem, 5.2vw, 2rem);
  line-height: 0.95;
  margin: 3px 0 0;
}

.deck {
  display: flex;
  gap: 10px;
  flex: none;
  margin-left: auto;
}

/* --- head ---------------------------------------------------------------- */

main {
  padding: 0 var(--gutter);
}

.head {
  padding: clamp(20px, 5vw, 36px) 0 18px;
  margin-bottom: clamp(18px, 3vw, 28px);
  border-bottom: var(--rule) solid var(--ink);
}

.title {
  font-family: var(--display);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: -0.03em;
  font-size: clamp(2.6rem, 11vw, 5.5rem);
  line-height: 0.9;
  margin: 0.14em 0 0;
}

.now {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 0;
  padding: 6px 12px;
  border: 2px solid var(--ink);
  background: var(--card);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.now::before {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #e8711a;
  animation: pulse 1.2s ease-in-out infinite;
}

.now.paused::before {
  animation: none;
  background: var(--ink-soft);
}

@keyframes pulse {
  50% {
    transform: scale(0.55);
    opacity: 0.5;
  }
}

/* --- the cards: kongylabs.com's .slot, with art ---------------------------- */

.bill {
  list-style: none;
  margin: 0;
  padding: 0 0 8px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr));
  gap: clamp(16px, 2.4vw, 26px);
}

.bill li {
  display: flex;
}

.slot {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  background: var(--card);
  border: var(--rule) solid var(--ink);
  cursor: pointer;
  transition:
    background 0.12s steps(2),
    color 0.12s steps(2);
}

.slot:active,
.slot.going {
  background: var(--ink);
  color: var(--flare);
}

.slot-art {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-bottom: var(--rule) solid var(--ink);
  background: var(--paper);
}

.slot-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.stamps {
  position: absolute;
  top: 9px;
  right: 9px;
  display: flex;
  gap: 6px;
}

.stamp {
  padding: 3px 8px;
  border: 2px solid var(--ink);
  background: var(--card);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.64rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  white-space: nowrap;
}

.stamp.live {
  background: var(--ink);
  color: var(--flare);
}

.slot-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 16px 18px 18px;
}

.slot h3 {
  font-family: var(--display);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  font-size: 1.5rem;
  line-height: 0.95;
  margin: 2px 0 8px;
}

.slot p {
  margin: 0 0 16px;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.slot:active p,
.slot.going p {
  color: var(--flare);
}

.slot-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 2px solid currentColor;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

/* --- the games' bubbly buttons -------------------------------------------- */

.btn {
  display: inline-block;
  text-decoration: none;
  font-family: var(--bubble);
  font-weight: 700;
  font-size: 20px;
  line-height: 1;
  letter-spacing: 0.01em;
  color: #fff;
  border: none;
  cursor: pointer;
  padding: 13px 30px 15px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffa044, #e8711a);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.45),
    inset 0 -4px 0 rgba(0, 0, 0, 0.2),
    0 6px 0 #a34a08,
    0 12px 22px -8px rgba(0, 0, 0, 0.55);
  transition:
    transform 0.09s ease,
    box-shadow 0.09s ease,
    filter 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:active,
.slot:active .btn,
.slot.going .btn {
  transform: translateY(5px);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.35),
    inset 0 -2px 0 rgba(0, 0, 0, 0.2),
    0 1px 0 #a34a08,
    0 4px 10px -6px rgba(0, 0, 0, 0.6);
}

.btn.ghost {
  background: linear-gradient(180deg, #ffffff, #e3e9e2);
  color: var(--ink);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.9),
    inset 0 -3px 0 rgba(0, 0, 0, 0.07),
    0 5px 0 #8f8a7e,
    0 12px 22px -10px rgba(0, 0, 0, 0.5);
}

.btn.ghost:active {
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.9),
    0 1px 0 #8f8a7e,
    0 4px 10px -6px rgba(0, 0, 0, 0.5);
}

.btn.small {
  font-size: 16px;
  padding: 9px 18px 11px;
}

.btn.off {
  filter: grayscale(0.8);
  opacity: 0.7;
}

/* --- footer ---------------------------------------------------------------- */

.foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 28px var(--gutter) 0;
  padding: 14px 0 22px;
  border-top: var(--rule) solid var(--ink);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-soft);
}

.empty {
  font-family: var(--mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

/* Short landscape phones: the masthead and head are a lot of height to give
   up before the first card, so tighten both. */
@media (max-height: 480px) and (orientation: landscape) {
  .mark {
    height: 44px;
  }
  .masthead {
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .head {
    padding-top: 14px;
    padding-bottom: 12px;
  }
  .title {
    font-size: 2.6rem;
  }
}

/* Phones, either way up: nine full cards is nine screens of scrolling, which
   is a website's rhythm, not a game menu's. Compact cards (art, title, PLAY);
   the description is the first thing to go. Two across in portrait. */
@media (max-width: 560px), (max-height: 480px) {
  .masthead .eyebrow {
    display: none;
  }
  .mark {
    height: 48px;
  }
  .bill {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  .slot-body {
    padding: 10px 10px 12px;
  }
  .slot h3 {
    font-size: 1.02rem;
    margin: 2px 0 10px;
  }
  .slot p {
    display: none;
  }
  .slot-foot {
    padding-top: 10px;
    border-top-width: 2px;
  }
  .slot-foot > span {
    display: none;
  }
  .slot-foot .btn {
    width: 100%;
  }
  .stamps {
    top: 6px;
    right: 6px;
    left: 6px;
    justify-content: flex-end;
    flex-wrap: wrap;
  }
  .stamp {
    font-size: 0.56rem;
    padding: 2px 5px;
    border-width: 1.5px;
  }
  .stamp.live {
    font-size: 0;
  }
  /* "Leaderboard" does not fit twice across a half-width card; a trophy does. */
  .stamp.live::after {
    content: '\1F3C6';
    font-size: 0.7rem;
  }
}

/* Landscape phones: as many compact cards across as fit, and the head on one
   short line so the first row of games is on screen at launch. */
@media (max-height: 480px) and (orientation: landscape) {
  .bill {
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  }
  .head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: 18px;
    padding-top: 10px;
    padding-bottom: 10px;
    margin-bottom: 14px;
  }
  .head .eyebrow {
    width: 100%;
  }
  .title {
    font-size: 2rem;
  }
  .now {
    margin-top: 6px;
  }
}

/* --- the unlock: stamps, locked cards, the sheet ----------------------------- */

.head-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  margin-top: 16px;
}

.head-row .now {
  margin: 0;
}

.btn.blue {
  background: linear-gradient(180deg, #7cc8ff, #2b8fe0);
  color: #04213a;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.45),
    inset 0 -4px 0 rgba(0, 0, 0, 0.18),
    0 6px 0 #18619e,
    0 12px 22px -8px rgba(0, 0, 0, 0.55);
}

.btn.blue:active,
.slot:active .btn.blue {
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.4),
    0 1px 0 #18619e,
    0 4px 10px -6px rgba(0, 0, 0, 0.6);
}

.btn.big {
  font-size: 21px;
  padding: 15px 16px 18px;
  width: 100%;
  white-space: nowrap;
}

.btn[disabled] {
  filter: grayscale(0.6);
  opacity: 0.6;
  pointer-events: none;
}

.stamp.free {
  background: var(--flare);
  color: var(--ink);
}

/* Locked games stay fully visible: the point is to see what you'd get. The
   art dims a touch and the button turns blue, so a locked card reads as
   "not yet", never as broken. */
.slot.locked .slot-art img {
  filter: saturate(0.55) brightness(0.82);
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l));
  background: rgba(16, 14, 12, 0.62);
  overflow-y: auto;
}

.sheet[hidden] {
  display: none;
}

.sheet-card {
  width: min(460px, 100%);
  background: var(--card);
  border: var(--rule) solid var(--ink);
  box-shadow: 10px 10px 0 var(--ink);
  padding: 22px 22px 20px;
  text-align: center;
  animation: sheet-in 0.18s ease-out;
}

/* A long button label wraps rather than pushing the card off a phone screen. */
.sheet-card .btn.big {
  max-width: 100%;
  white-space: normal;
}

@keyframes sheet-in {
  from {
    transform: translateY(14px);
    opacity: 0;
  }
}

.sheet-mark {
  display: block;
  height: 64px;
  width: auto;
  margin: 0 auto 10px;
}

.sheet-title {
  font-family: var(--display);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  font-size: clamp(1.6rem, 7vw, 2.2rem);
  line-height: 0.95;
  margin: 6px 0 10px;
}

.sheet-lede {
  margin: 0 auto 14px;
  max-width: 34ch;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.sheet-thumbs {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.sheet-thumbs li {
  position: relative;
  border: 2px solid var(--ink);
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--paper);
}

.sheet-thumbs img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sheet-thumbs li.picked {
  outline: 3px solid #2b8fe0;
  outline-offset: 1px;
}

.sheet-note {
  min-height: 1.3em;
  margin: 12px 0 10px;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
}

.sheet-note.bad {
  color: #b3261e;
}

.sheet-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.sheet-row .btn.small {
  font-size: 14px;
  padding: 8px 14px 10px;
}

#debug {
  margin-top: 14px;
  font-size: 12px;
}

/* A short landscape phone: the sheet goes side by side. */
@media (max-height: 480px) and (orientation: landscape) {
  .sheet-card {
    width: min(640px, 100%);
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 20px;
    text-align: left;
    padding: 16px 18px;
  }
  .sheet-card > * {
    grid-column: 1;
  }
  .sheet-mark {
    display: none;
  }
  .sheet-thumbs {
    grid-column: 2;
    grid-row: 1 / span 4;
    grid-template-columns: repeat(2, 1fr);
    align-self: start;
    margin: 0;
  }
  .sheet-lede {
    margin-left: 0;
  }
  .sheet-row {
    justify-content: flex-start;
  }
}

/* "Have a code?": a quiet text link, then a field and a button. */
.linkish {
  display: block;
  margin: 12px auto 0;
  padding: 4px 8px;
  border: none;
  background: none;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  text-decoration: underline;
  cursor: pointer;
}

.code-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 12px;
}

.code-row[hidden] {
  display: none;
}

.code-field {
  width: 11.5em;
  min-width: 0;
  padding: 9px 12px;
  border: 2px solid var(--ink);
  background: #fff;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
