/* h_da PICO-8 Showcase */

@font-face {
  font-family: 'Open Sans';
  src: url('../fonts/open-sans-regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Open Sans';
  src: url('../fonts/open-sans-600.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: 'Open Sans';
  src: url('../fonts/open-sans-700.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  /* PICO-8 palette */
  --p8-black: #000000;
  --p8-navy: #1d2b53;
  --p8-purple: #7e2553;
  --p8-green: #008751;
  --p8-brown: #ab5236;
  --p8-darkgrey: #5f574f;
  --p8-grey: #c2c3c7;
  --p8-white: #fff1e8;
  --p8-red: #ff004d;
  --p8-orange: #ffa300;
  --p8-yellow: #ffec27;
  --p8-lime: #00e436;
  --p8-blue: #29adff;
  --p8-lavender: #83769c;
  --p8-pink: #ff77a8;
  --p8-peach: #ffccaa;
  /* h_da */
  --hda-red: #a50f19;

  --bg: #0f1324;
  --panel: #182042;
  --panel-2: #222b56;
  --line: #2a3460;
  --ink: var(--p8-white);
  --muted: #b3b6cc;
  --dim: #8085a6;
  --focus: var(--p8-yellow);
  --font: 'Open Sans', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;

  --cart-w: 80px;
  --gap: 12px;
  --pad-x: 32px;
  --tv-pad: 22px;
  --tv-chin: 30px;
  /* page header + TV frame + game details below the TV, for sizing the screen to the window */
  --chrome-h: 345px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}

html {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--font);
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 72px;
}
body {
  margin: 0;
  background: var(--bg);
  border-top: 4px solid var(--hda-red);
}
a {
  color: var(--p8-blue);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
a:hover {
  color: var(--p8-white);
}
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}
button {
  font: inherit;
  color: inherit;
}
img {
  max-width: 100%;
}
kbd {
  display: inline-block;
  min-width: 1.7em;
  padding: 0 0.35em;
  margin: 1px 1px;
  border-radius: 4px;
  background: var(--panel-2);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.35);
  font: 600 0.8rem/1.6 var(--font);
  text-align: center;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 8px 14px;
  background: var(--p8-yellow);
  color: #000;
  font-weight: 700;
}
.skip:focus {
  top: 12px;
}
.small {
  font-size: 0.85rem;
}
.px-word {
  display: inline-block;
  vertical-align: middle;
  overflow: visible;
}

/* ------------------------------------------------------------------ stage */

.stage {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  padding: 20px var(--pad-x) 0;
  background: radial-gradient(110% 65% at 50% 0%, #2b3d7c 0%, rgba(43, 61, 124, 0) 62%),
    linear-gradient(180deg, #1d2b53 0%, #172146 60%, #121937 100%);
}
.stage::after {
  /* faint starfield */
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: radial-gradient(circle, rgba(255, 241, 232, 0.22) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(255, 241, 232, 0.12) 0 1px, transparent 1.5px);
  background-size: 97px 61px, 53px 89px;
  background-position: 11px 7px, 31px 41px;
  -webkit-mask-image: linear-gradient(#000 0%, transparent 62%);
  mask-image: linear-gradient(#000 0%, transparent 62%);
}

/* the floor everything stands on, with a dithered horizon like a PICO-8 screen */
.floor {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 30%;
  min-height: 120px;
  z-index: -1;
  background: linear-gradient(180deg, #7e2553 0%, #5a1a40 45%, #33102b 100%);
}
.floor::before,
.floor::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 8px;
  background-size: 8px 8px;
  image-rendering: pixelated;
}
.floor::before {
  top: -8px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' shape-rendering='crispEdges'%3E%3Cpath fill='%237e2553' d='M0 2h2v2H0zM2 0h2v2H2z'/%3E%3C/svg%3E");
}
.floor::after {
  top: -16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' shape-rendering='crispEdges'%3E%3Cpath fill='%237e2553' d='M0 3h1v1H0zM2 1h1v1H2z'/%3E%3C/svg%3E");
}

.stage-grid {
  position: relative;
  max-width: 1480px;
  margin: 0 auto;
  padding-bottom: 36px;
  display: grid;
  gap: 14px 36px;
  align-items: center;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas: 'brand brand' 'tv tv' 'now now' 'touch touch' 'left right' 'pager pager';
}

/* brand header */
.brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: 20px;
}
.brand-hda img {
  display: block;
  width: 66px;
  height: auto;
}
.brand-text {
  flex: 1;
  min-width: 0;
}
.brand-kicker {
  margin: 0 0 6px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.brand-title {
  margin: 0;
  color: var(--p8-white);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  line-height: 1;
}
.brand-title .px-word {
  height: 30px;
  width: auto;
}
.brand-intro {
  margin: 10px 0 0;
  color: var(--muted);
  max-width: 52ch;
}
.brand-p8 img {
  display: block;
  width: 140px;
  height: auto;
}

/* TV */
.tv-area {
  grid-area: tv;
  display: flex;
  justify-content: center;
  min-width: 0;
}
.tv {
  position: relative;
  padding: var(--tv-pad) var(--tv-pad) calc(var(--tv-pad) + var(--tv-chin));
  border-radius: calc(var(--tv-pad) + 12px);
  background: linear-gradient(180deg, #4b5178 0%, #30355a 7%, #262a47 60%, #1f2239 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.16), inset 0 -4px 0 rgba(0, 0, 0, 0.35),
    inset 2px 0 0 rgba(255, 255, 255, 0.04), inset -2px 0 0 rgba(0, 0, 0, 0.2), 0 0 0 1px #0a0c18,
    0 34px 40px -24px rgba(0, 0, 0, 0.85);
}
.tv::after {
  /* soft light on the floor in front of the screen */
  content: '';
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -30px;
  height: 30px;
  z-index: -1;
  background: radial-gradient(50% 50% at 50% 0%, rgba(41, 173, 255, 0.18), transparent);
  opacity: 0;
  transition: opacity 0.6s ease;
}
.stage.is-running .tv::after {
  opacity: 1;
}
.tv-screen {
  position: relative;
  width: var(--screen-w);
  aspect-ratio: var(--ar, 1);
  border-radius: 14px;
  overflow: hidden;
  background: #04050a;
  box-shadow: 0 0 0 3px #11142a, 0 0 0 4px rgba(255, 255, 255, 0.07), inset 0 0 0 1px #000;
  transition: width 0.35s ease;
}
.tv-screen iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: transparent;
  color-scheme: normal;
}
.tv-screen::after {
  /* a little glass reflection */
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: radial-gradient(130% 90% at 18% -10%, rgba(255, 255, 255, 0.07), transparent 42%);
  box-shadow: inset 0 0 36px rgba(0, 0, 0, 0.55);
}
.tv-screen:fullscreen {
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
  border-radius: 0;
  background: #000;
}
.tv-screen:fullscreen::after {
  display: none;
}
.tv-chin {
  position: absolute;
  left: calc(var(--tv-pad) + 4px);
  right: calc(var(--tv-pad) + 4px);
  bottom: 0;
  height: calc(var(--tv-pad) + var(--tv-chin));
  display: flex;
  align-items: center;
  gap: 14px;
  color: #8c91b8;
}
.tv-mark {
  height: 12px;
  width: auto;
  opacity: 0.55;
}
.tv-model {
  margin-left: auto;
  opacity: 0.6;
}
.tv-model .px-word {
  height: 10px;
  width: auto;
}
.tv-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #5a1020;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: background 0.3s, box-shadow 0.3s;
}
.stage.is-loaded .tv-led {
  background: var(--p8-red);
  box-shadow: 0 0 8px rgba(255, 0, 77, 0.7);
}
.stage.is-running .tv-led {
  background: var(--p8-lime);
  box-shadow: 0 0 8px rgba(0, 228, 54, 0.8);
}

/* screen sizes: square carts vs. 3-screen (3:1) carts */
.stage {
  --screen-w: min(560px, calc(100vw - 2 * var(--pad-x) - 2 * var(--tv-pad)), 64vh);
  /* below the TV the cartridges share the page width: two halves of --cols carts each
     (16px spare for a scrollbar) */
  --cols: 2;
  --rows: 1;
  --cart-w: clamp(64px, (min(100vw - 2 * var(--pad-x), 1480px) - 52px - 2 * (var(--cols) - 1) * var(--gap)) / (2 * var(--cols)), 128px);
}
.stage[data-format='wide'] {
  --screen-w: min(1152px, calc(100vw - 2 * var(--pad-x) - 2 * var(--tv-pad)), 156vh);
}

/* now playing: title and buttons share the first line, the details use the full width below */
.now {
  grid-area: now;
  justify-self: center;
  width: 100%;
  max-width: calc(var(--screen-w) + 2 * var(--tv-pad));
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 24px;
}
.now-text {
  display: contents;
}
.now-title {
  grid-column: 1;
  margin: 0;
  font-size: 1.4rem;
  line-height: 1.25;
  font-weight: 700;
}
.now-meta,
.now-desc,
.now-hint {
  grid-column: 1 / -1;
}
.now-meta {
  margin: 4px 0 0;
  color: var(--muted);
}
.now-meta a {
  color: var(--p8-blue);
  text-decoration: none;
}
.now-meta a:hover {
  text-decoration: underline;
}
.now-meta span:not(:empty)::after {
  content: ' · ';
  color: var(--dim);
}
.now-desc {
  margin: 6px 0 0;
}
.now-hint {
  margin: 6px 0 0;
  font-size: 0.85rem;
  color: var(--dim);
}
.now-hint strong {
  color: var(--p8-yellow);
  font-weight: 600;
}

.tools {
  grid-row: 1;
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tool {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), inset 0 -3px 0 rgba(0, 0, 0, 0.35);
  transition: background 0.12s, color 0.12s;
}
.tool svg {
  width: 20px;
  height: 20px;
  display: block;
}
.tool:hover {
  background: #2e3970;
  color: var(--ink);
}
.tool:active {
  transform: translateY(1px);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.35);
}
.tool:disabled {
  opacity: 0.38;
  cursor: default;
  transform: none;
}
.tool[aria-pressed='true'] {
  color: var(--p8-yellow);
}
#btn-sound .snd-off,
#btn-sound[aria-pressed='true'] .snd-on {
  display: none;
}
#btn-sound[aria-pressed='true'] .snd-off {
  display: inline;
}
.tool-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: auto;
  min-width: 7.5rem;
  padding: 0 18px 0 13px;
  background: var(--p8-red);
  color: #fff;
  font-weight: 700;
}
.tool-primary:hover {
  background: #ff2a68;
  color: #fff;
}
.tool-sm {
  width: 34px;
  height: 34px;
}
.tool-sm svg {
  width: 18px;
  height: 18px;
}
.tool-text {
  display: inline-flex;
  width: auto;
  gap: 7px;
  padding: 0 12px 0 10px;
  font-size: 0.85rem;
  font-weight: 600;
}

/* cartridge shelves: two halves below the TV (narrow windows, 3:1 carts) or beside it.
   --cols and --rows (on .stage) also tell gallery.js how many cartridges a page holds. */
.side {
  display: contents;
}
.deck {
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cart-w));
  gap: var(--gap);
  align-self: start;
}
#deck-left {
  grid-area: left;
  justify-self: end;
}
#deck-right {
  grid-area: right;
  justify-self: start;
}
.deck-tools {
  grid-area: pager;
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 8px;
}
.page-label {
  min-width: 4.2em;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* a cartridge: the .p8.png image (160x205) with its 128x128 label window at (16, 24) */
/* the cart image has rounded corners and a cut-off corner at the bottom right: no box behind it,
   and shadows (drop-shadow) follow its shape */
.cart {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 160 / 205;
  filter: drop-shadow(0 5px 4px rgba(0, 0, 0, 0.6));
  transition: transform 0.14s ease, filter 0.14s ease;
}
.cart img {
  display: block;
  width: 100%;
  height: 100%;
}
.cart-label {
  position: absolute;
  left: 10%;
  top: 11.707%;
  width: 80%;
  height: 62.439%;
  background: var(--p8-navy);
  color: var(--p8-white);
  container-type: inline-size;
}
.cart-label-text {
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 7cqw 11cqw;
  width: 100%;
  height: 100%;
  padding: 8cqw;
}
.cart-label .px-word {
  height: 13cqw;
  width: auto;
  max-width: 100%;
}
.cart-badge {
  position: absolute;
  right: 4%;
  top: 2.5%;
  padding: 0 4px;
  border-radius: 2px;
  background: var(--p8-yellow);
  color: #000;
  font: 700 10px/14px var(--font);
}

.slot {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 4px;
}
.slot:hover .cart,
.slot:focus-visible .cart {
  transform: translateY(-4px);
  filter: drop-shadow(0 10px 7px rgba(0, 0, 0, 0.7));
}
.slot[aria-current='true'] .cart,
.card[aria-current='true'] .cart {
  outline: 2px solid var(--p8-yellow);
  outline-offset: 3px;
  filter: drop-shadow(0 0 10px rgba(255, 236, 39, 0.45));
}
.slot-empty {
  aspect-ratio: 160 / 205;
  border-radius: 4px;
  border: 2px dashed rgba(255, 241, 232, 0.08);
}

/* touch controls */
.touchpad {
  grid-area: touch;
  justify-self: center;
  width: 100%;
  max-width: 560px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 6px 0;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.dpad {
  position: relative;
  width: 138px;
  height: 138px;
  flex: none;
}
.dpad::before,
.dpad::after {
  content: '';
  position: absolute;
  border-radius: 8px;
  background: #2b3366;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.1), inset 0 -4px 0 rgba(0, 0, 0, 0.35);
}
.dpad::before {
  left: 33%;
  width: 34%;
  top: 0;
  height: 100%;
}
.dpad::after {
  top: 33%;
  height: 34%;
  left: 0;
  width: 100%;
}
.tp-menu {
  align-self: flex-start;
  margin-top: 10px;
  padding: 6px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.tp-buttons {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.tp-btn {
  width: 66px;
  height: 66px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  font-size: 1.35rem;
  font-weight: 700;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.25), inset 0 -5px 0 rgba(0, 0, 0, 0.3);
}
.tp-o {
  background: var(--p8-red);
  margin-top: 26px;
}
.tp-x {
  background: var(--p8-blue);
  color: #08131f;
}
.tp-btn.down,
.tp-menu.down {
  transform: translateY(2px);
  filter: brightness(1.15);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.3);
}

@media (min-width: 520px) {
  .stage {
    --cols: 3;
  }
}

/* the intro wraps to two lines on narrower windows: more room for the page header */
@media (max-width: 1099px) {
  :root {
    --chrome-h: 370px;
  }
}

/* square carts on wider windows: shelves beside the TV, details and page buttons below it.
   The TV is as big as the window allows with all of that in view. */
@media (min-width: 640px) {
  .stage:not([data-format='wide']) {
    --cols: 1;
    --rows: 3;
    --cart-w: clamp(
      80px,
      min(
        (100vh - var(--chrome-h) - 48px) * 0.21,
        (100vw - 2 * var(--pad-x) - 2 * var(--tv-pad) - 72px - min(560px, 100vh - var(--chrome-h) - 48px)) / 2
      ),
      120px
    );
    --screen-w: min(560px, calc(100vw - 2 * var(--pad-x) - 2 * var(--tv-pad) - 2 * var(--cart-w) - 72px), max(260px, 100vh - var(--chrome-h) - 48px));
  }
  .stage:not([data-format='wide']) .stage-grid {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      'brand brand brand'
      'left tv right'
      'now now now'
      'pager pager pager'
      'touch touch touch';
  }
  .stage:not([data-format='wide']) .deck {
    align-self: center;
  }
  /* the details keep room for title and buttons on one line, also under a smaller TV */
  .now {
    max-width: max(calc(var(--screen-w) + 2 * var(--tv-pad)), 640px);
  }
  .tools {
    gap: 4px;
  }
  .tools .tool {
    width: 36px;
    height: 36px;
  }
  .tools .tool-primary {
    width: auto;
    min-width: 7rem;
    padding: 0 14px 0 11px;
  }
}

@media (min-width: 760px) {
  .stage[data-format='wide'] {
    --cols: 4;
  }
}

/* wide windows: two columns of cartridges on each side of square carts, page buttons under the
   right shelf; 3:1 carts keep their shelves below the TV */
@media (min-width: 1080px) {
  .brand-intro {
    max-width: none;
  }
  .stage:not([data-format='wide']) {
    --cols: 2;
    --rows: 3;
    /* shelf cartridges grow with the window, up to about the size of the shelves on lexaloffle.com,
       but never at the expense of the TV (narrow, tall windows) */
    --cart-w: clamp(
      80px,
      min(
        (100vh - var(--chrome-h)) * 0.21,
        (100vw - 2 * var(--pad-x) - 2 * var(--tv-pad) - 2 * var(--gap) - 72px - min(560px, 100vh - var(--chrome-h))) / 4
      ),
      136px
    );
    --screen-w: min(560px, calc(100vw - 2 * var(--pad-x) - 2 * var(--tv-pad) - 4 * var(--cart-w) - 2 * var(--gap) - 72px), max(300px, 100vh - var(--chrome-h)));
  }
  .stage:not([data-format='wide']) .stage-grid {
    grid-template-areas:
      'brand brand brand'
      'left tv right'
      '. now .'
      '. touch .';
  }
  .stage:not([data-format='wide']) .side {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-self: center;
  }
  .stage:not([data-format='wide']) .side-left {
    grid-area: left;
    align-items: flex-end;
  }
  .stage:not([data-format='wide']) .side-right {
    grid-area: right;
    align-items: flex-start;
  }
  .stage:not([data-format='wide']) .deck {
    align-self: auto;
  }
  .stage[data-format='wide'] {
    --cols: 5;
    --screen-w: min(1152px, calc(100vw - 2 * var(--pad-x) - 2 * var(--tv-pad)), 150vh - 330px);
  }
}
@media (min-width: 1600px) {
  .stage:not([data-format='wide']) {
    --screen-w: min(640px, calc(100vw - 2 * var(--pad-x) - 2 * var(--tv-pad) - 4 * var(--cart-w) - 2 * var(--gap) - 72px), max(300px, 100vh - var(--chrome-h)));
  }
}

@media (max-width: 720px) {
  :root {
    --pad-x: 16px;
    --tv-pad: 12px;
    --tv-chin: 22px;
  }
  .stage {
    padding-top: 18px;
  }
  .brand {
    flex-wrap: wrap;
    gap: 12px 14px;
  }
  .brand-hda img {
    width: 48px;
  }
  .brand-text {
    flex-basis: calc(100% - 64px);
  }
  .brand-title .px-word {
    height: 20px;
  }
  .brand-intro {
    font-size: 0.95rem;
  }
  .brand-p8 {
    display: none;
  }
  .tv-screen {
    border-radius: 9px;
  }
  .now-title {
    font-size: 1.2rem;
  }
  .now {
    grid-template-columns: minmax(0, 1fr);
  }
  .tools {
    grid-row: auto;
    grid-column: 1;
    margin-top: 14px;
  }
  .dpad {
    width: 124px;
    height: 124px;
  }
  .tp-btn {
    width: 58px;
    height: 58px;
  }
  .tp-menu {
    padding: 6px 10px;
  }
}

/* ------------------------------------------------------------------ filter bar */

.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(15, 19, 36, 0.94);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.bar-inner {
  max-width: 1480px;
  margin: 0 auto;
  padding: 10px var(--pad-x);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  padding: 6px 13px;
  border: 0;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.chip:hover {
  background: #2e3970;
}
.chip[aria-pressed='true'] {
  background: var(--p8-blue);
  color: #07121e;
}
.chip .n {
  margin-left: 6px;
  font-weight: 400;
  opacity: 0.7;
}
.search {
  position: relative;
  flex: 0 1 320px;
  display: flex;
}
.search svg {
  position: absolute;
  left: 10px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  color: var(--dim);
  pointer-events: none;
}
.search input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0a0e1d;
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
}
.search input::placeholder {
  color: var(--dim);
}

/* ------------------------------------------------------------------ library */

.library {
  max-width: 1480px;
  margin: 0 auto;
  padding: 8px var(--pad-x) 48px;
}
.course {
  margin-top: 36px;
}
.course-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 14px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 2px solid #212a52;
}
.course-sem {
  margin: 0;
  padding: 1px 10px;
  border-radius: 4px;
  background: var(--p8-purple);
  font-weight: 700;
  font-size: 0.9rem;
}
.course-title {
  margin: 0;
  font-size: 1.3rem;
  line-height: 1.3;
}
.course-count {
  margin: 0 0 0 auto;
  color: var(--dim);
  font-size: 0.9rem;
}
.course-desc {
  flex-basis: 100%;
  margin: 4px 0 0;
  max-width: 78ch;
  color: var(--muted);
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 160px);
  gap: 28px 24px;
}
.card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
}
.card .cart {
  width: 160px;
  margin-bottom: 8px;
}
.card .cart img {
  image-rendering: pixelated;
}
.card:hover .cart,
.card:focus-visible .cart {
  transform: translateY(-4px);
  filter: drop-shadow(0 11px 8px rgba(0, 0, 0, 0.75));
}
.card-title {
  font-weight: 700;
  line-height: 1.3;
}
.card-by {
  font-size: 0.85rem;
  color: var(--muted);
}
.empty {
  margin: 48px 0;
  text-align: center;
  color: var(--muted);
}
@media (max-width: 720px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 22px 14px;
  }
  .card .cart {
    width: 100%;
  }
}

/* ------------------------------------------------------------------ about & footer */

.about {
  background: linear-gradient(180deg, #141a33, #11162b);
  border-top: 1px solid var(--line);
}
.about-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 48px var(--pad-x);
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 32px 56px;
}
.section-title {
  margin: 0 0 18px;
  color: var(--p8-peach);
}
.section-title .px-word {
  height: 18px;
  width: auto;
}
.about p {
  margin: 0 0 14px;
  max-width: 68ch;
}
.about h3 {
  margin: 4px 0 12px;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.keys {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin-bottom: 14px;
}
.keys th,
.keys td {
  padding: 6px 8px 6px 0;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid #232b52;
}
.keys thead th {
  color: var(--dim);
  font-weight: 600;
  font-size: 0.8rem;
}
.keys tbody th {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}
.about-controls .small {
  color: var(--muted);
}
@media (max-width: 860px) {
  .about-inner {
    grid-template-columns: minmax(0, 1fr);
  }
}

.foot {
  background: #0b0e1c;
  border-top: 1px solid #1c2342;
  color: var(--muted);
}
.foot-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px var(--pad-x) 36px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px 28px;
}
.foot-logo img {
  display: block;
  width: 54px;
  height: auto;
  opacity: 0.85;
}
.foot-text {
  flex: 1 1 360px;
}
.foot-text p {
  margin: 0 0 4px;
}
.foot-text strong {
  color: var(--ink);
}
.foot-links {
  display: flex;
  gap: 18px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 8px;
  background: var(--p8-yellow);
  color: #000;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
