/* The shell's look (release 0.3.0): tokens (light and dark), the top bar, the view area, the
   hub from docs/mockups/hub-v2.html, and the About box. The games' GitHub badge is in
   base/badge.css; the dungeon's part of the hub is in plugins/idle/hub.css. */

:root {
  --bg: #f4f3ef;
  --panel: #ffffff;
  --panel-2: #eceae4;
  --line: #d9d6cd;
  --text: #1f1e1b;
  --muted: #6b6860;
  --accent: #2f6f5e;
  --accent-soft: #dcebe6;
  --red: #c0392b;
  --red-soft: #f7dedb;
  --amber: #a86a00;
  --amber-soft: #f8ecd2;
  --blue: #2b5c9a;
  --blue-soft: #dde8f6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #181816;
    --panel: #22221f;
    --panel-2: #2b2b27;
    --line: #3a3a35;
    --text: #ecebe6;
    --muted: #a09d94;
    --accent: #6fbfa8;
    --accent-soft: #23362f;
    --red: #ef7b6d;
    --red-soft: #3d2320;
    --amber: #e2b04a;
    --amber-soft: #3a3019;
    --blue: #8db6ea;
    --blue-soft: #1f2c3d;
  }
}

* {
  box-sizing: border-box;
}
/* Classes below set display, so make [hidden] win over them. */
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    14px/1.4 'Segoe UI',
    system-ui,
    sans-serif;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}
a {
  color: var(--accent);
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* top bar: the site's name on the hub; Back and the page's name inside a game or About.
   "Early access", the version and About (?) are always there. */
.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.back {
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 6px;
  padding: 4px 12px;
  font-weight: 600;
}
.name {
  font-weight: 600;
}
.sub {
  color: var(--muted);
}
.chips {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  color: var(--muted);
}
.ver {
  font-size: 11px;
  color: var(--muted);
}
.q {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  text-decoration: none;
}
.q.on,
.q:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* view area: one pane shows at a time */
.views {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
}
.pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.about {
  display: block;
  overflow: auto;
  padding: 24px;
}
.box {
  max-width: 560px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 18px;
}
.box h2 {
  margin: 0 0 8px;
  font-size: 16px;
}
.box p {
  margin: 0 0 10px;
  color: var(--muted);
}
.box p:last-child {
  margin-bottom: 0;
}
.fail {
  margin: 24px;
}

/* About's credit band: the game, its repo, its owner, its contributors */
.credit {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 22px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 10px 0;
}
.credit .game {
  font-size: 16px;
  font-weight: 700;
}
.credit .repo {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 10px;
  background: var(--panel-2);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}
.credit .repo:hover {
  border-color: var(--accent);
}
.credit .repo svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}
.credit .who {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}
.credit .who a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}
.credit .who a:hover {
  text-decoration: underline;
}
.credit img {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--line);
  vertical-align: middle;
}
.credit .n {
  font-weight: 400;
  color: var(--muted);
  font-size: 12px;
}

/* ---- the hub, from docs/mockups/hub-v2.html: the hero in the middle, the slots around ---- */

.hubview {
  flex: none;
  min-height: 100%;
  align-items: center;
  justify-content: center;
  padding: 20px 16px 28px;
}
.hub {
  width: min(940px, 100%);
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 300px) minmax(0, 1fr);
  grid-auto-rows: minmax(172px, auto);
}
/* the middle spans the first two rows of the middle column; the slots fill around it */
.hub-mid {
  grid-column: 2;
  grid-row: 1 / span 2;
}

/* a slot: one minigame */
.hub .slot {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-height: 172px;
  padding: 14px;
  color: inherit;
  text-decoration: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  transition:
    transform 0.12s,
    border-color 0.12s,
    box-shadow 0.12s;
}
.hub a.slot:hover,
.hub a.slot:focus-visible {
  border-color: var(--accent);
  transform: translateY(-3px);
  outline: none;
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.28),
    0 0 0 3px var(--accent-soft);
}
.hub .ico {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  background: #14141c;
  display: grid;
  place-items: center;
}
.hub a.slot:hover .ico,
.hub a.slot:focus-visible .ico {
  animation: hub-hop 0.45s steps(3) infinite;
}
.hub .ico .sprite {
  width: 72%;
  height: 72%;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  animation: hub-shake 2.2s steps(2) infinite;
}
.hub .keys {
  display: flex;
  gap: 3px;
}
.hub .keys b {
  width: 14px;
  height: 16px;
  border-radius: 3px;
  background: #f0c35a;
  color: #0d1420;
  font:
    800 9px/16px 'Consolas',
    monospace;
  text-align: center;
  box-shadow: 0 2px 0 #b8862b;
  animation: hub-press 1.8s steps(2) infinite;
}
.hub .keys b:nth-child(2) {
  animation-delay: 0.3s;
}
.hub .keys b:nth-child(3) {
  animation-delay: 0.6s;
}
.hub .slot h2 {
  margin: 2px 0 0;
  font-size: 16px;
}
.hub .slot p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.hub .foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin-top: auto;
  width: 100%;
}
.hub .go {
  border: 1px solid var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 2px 12px;
  font-size: 12px;
  font-weight: 600;
}
/* the slot's live line, written by the game's hub module (the dungeon's state) */
.hub .live {
  font:
    700 11px/1.3 'Consolas',
    'Courier New',
    monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.hub .live[data-state='running'],
.hub .live[data-state='wait'],
.hub .live[data-state='boss'] {
  color: var(--accent);
}
.hub .live::before {
  content: '';
  display: inline-block;
  margin-right: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.hub .live[data-state='running']::before,
.hub .live[data-state='wait'],
.hub .live[data-state='boss']::before {
  animation: hub-pulse 1.2s ease-in-out infinite;
}

/* a slot with no game yet: drawn, not openable */
.hub .slot.later {
  position: relative;
  overflow: hidden;
  border-style: dashed;
  background: none;
  cursor: default;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
}
.hub .slot.later .ico {
  background: var(--panel-2);
  font:
    700 24px/1 'Consolas',
    monospace;
  color: var(--muted);
  animation: hub-drift 3s ease-in-out infinite;
}
.hub .slot.later + .slot.later .ico {
  animation-delay: -1.5s;
}
.hub .slot.later .go {
  border-color: var(--line);
  color: var(--muted);
  background: none;
}
.hub .slot.later::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    110deg,
    transparent 40%,
    rgba(143, 111, 198, 0.14) 50%,
    transparent 60%
  );
  background-size: 250% 100%;
  animation: hub-sweep 5s linear infinite;
}

/* the middle's stage: always dark, in both themes, like the dungeon's scene */
.hub-mid {
  position: relative;
  min-height: 360px;
  display: flex;
  flex-direction: column;
  background: radial-gradient(90% 70% at 50% 35%, #2b2350, #14141c 75%);
  border: 1px solid #34344a;
  border-radius: 14px;
  overflow: hidden;
  color: #fff;
}
.hub-mid::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 22%;
  width: 70%;
  aspect-ratio: 1;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(143, 111, 198, 0.45), transparent);
  animation: hub-glow 4s ease-in-out infinite;
}
.hub-star {
  position: absolute;
  width: 3px;
  height: 3px;
  background: #cfc6ff;
  opacity: 0.7;
  animation: hub-twinkle 2.4s steps(3) infinite;
}
.hub-stage {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
}
/* the middle without the dungeon: a plain welcome */
.hub-welcome {
  margin: auto;
  padding: 24px;
  text-align: center;
  color: #b9c0d4;
}
.hub-welcome b {
  display: block;
  margin-bottom: 6px;
  color: #fff;
  font-size: 18px;
}

@keyframes hub-twinkle {
  50% {
    opacity: 0.15;
  }
}
@keyframes hub-glow {
  50% {
    opacity: 0.45;
    transform: translateX(-50%) scale(1.12);
  }
}
@keyframes hub-press {
  0%,
  70% {
    transform: none;
    box-shadow: 0 2px 0 #b8862b;
  }
  80% {
    transform: translateY(2px);
    box-shadow: none;
  }
}
@keyframes hub-shake {
  0%,
  60% {
    transform: none;
  }
  70% {
    transform: translate(-2px, 1px) rotate(-4deg);
  }
  80% {
    transform: translate(2px, -1px) rotate(4deg);
  }
  90% {
    transform: translate(-1px, 0) rotate(-2deg);
  }
}
@keyframes hub-hop {
  50% {
    transform: translateY(-5px);
  }
}
@keyframes hub-pulse {
  50% {
    opacity: 0.25;
  }
}
@keyframes hub-drift {
  50% {
    transform: translateY(-10px);
  }
}
@keyframes hub-sweep {
  from {
    background-position: 120% 0;
  }
  to {
    background-position: -130% 0;
  }
}

/* larger, sized so the hub fills a 1920 x 1080 screen without a scroll */
@media (min-width: 701px) {
  .hubview {
    padding: clamp(16px, 2.4vh, 32px) clamp(16px, 2vw, 40px);
  }
  .hub {
    width: min(1640px, 100%);
    gap: clamp(14px, 1.3vw, 26px);
    grid-template-columns: minmax(0, 1fr) minmax(300px, 1.1fr) minmax(0, 1fr);
    grid-template-rows: 1fr 1fr;
    min-height: min(840px, calc(100vh - 170px));
  }
  .hub .slot {
    padding: clamp(16px, 1.5vw, 30px);
    gap: clamp(6px, 0.9vh, 12px);
    border-radius: 18px;
    border-width: 2px;
  }
  .hub .ico {
    width: clamp(64px, 5.6vw, 108px);
    height: clamp(64px, 5.6vw, 108px);
    border-radius: 16px;
  }
  .hub .keys {
    gap: 5px;
  }
  .hub .keys b {
    width: clamp(16px, 1.45vw, 28px);
    height: clamp(18px, 1.65vw, 32px);
    border-radius: 5px;
    font-size: clamp(10px, 0.9vw, 17px);
    line-height: clamp(18px, 1.65vw, 32px);
  }
  .hub .slot h2 {
    font-size: clamp(18px, 1.7vw, 32px);
  }
  .hub .slot p {
    font-size: clamp(13px, 1.05vw, 20px);
  }
  .hub .go {
    font-size: clamp(13px, 1vw, 19px);
    padding: 0.3em 1.4em;
    border-width: 2px;
  }
  .hub .live {
    font-size: clamp(11px, 0.8vw, 15px);
  }
  .hub .slot.later .ico {
    font-size: clamp(26px, 2.6vw, 50px);
  }
  .hub-mid {
    border-radius: 18px;
    border-width: 2px;
  }
}
@media (min-width: 1400px) {
  body {
    font-size: 16px;
  }
  .topbar {
    padding: 12px 24px;
  }
  .name {
    font-size: 22px;
  }
  .sub {
    font-size: 17px;
  }
  .chip {
    font-size: 14px;
    padding: 4px 14px;
  }
  .ver {
    font-size: 13px;
  }
  .q {
    width: 36px;
    height: 36px;
    font-size: 17px;
  }
  .back {
    font-size: 17px;
    padding: 6px 16px;
  }
}

/* phone: two slots, the hero, two slots; the page scrolls as a whole */
@media (max-width: 700px) {
  .app {
    height: auto;
    min-height: 100vh;
  }
  .views {
    overflow: visible;
  }
  .topbar .sub {
    display: none;
  }
  .hubview {
    justify-content: flex-start;
    padding: 12px;
  }
  .hub {
    gap: 10px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-auto-rows: auto;
  }
  .hub-mid {
    grid-column: 1 / -1;
    grid-row: 2;
    min-height: 380px;
  }
  .hub .slot {
    min-height: 150px;
    padding: 12px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .hub *,
  .hub *::before,
  .hub *::after,
  .hub-mid::before {
    animation: none !important;
  }
  .hub .slot {
    transition: none;
  }
}
