/* The page is laid out like the console it's about: a screen between two Joy-Con
   rails and a row of tiles. The icons supply all the colour, so
   everything else stays neutral except the selection ring and the rails. */

:root {
  --bg: #2b2c30;
  --raised: #393a3f;
  --sunk: #222327;
  --ink: #ffffff;
  --muted: #b7bac2;
  --line: rgba(255, 255, 255, .14);
  --sel-a: #19f0d0;
  --sel-b: #2ab4ff;
  --sel-ink: #33efd6;
  --on-sel: #05241f;
  --blue: #00b9e8;
  --red: #ff4c3f;
  --rail: 10px;
  --gutter: clamp(16px, 3vw, 44px);
  --radius: 5px;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #ececee;
  --raised: #ffffff;
  --sunk: #dddee2;
  --ink: #2b2c30;
  --muted: #585b63;
  --line: rgba(0, 0, 0, .15);
  --sel-a: #00d0b4;
  --sel-b: #0f9be8;
  --sel-ink: #006f65;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { background: var(--bg); -webkit-text-size-adjust: 100%; }

/* No visible scrollbars. Wheel, touch and keyboard scrolling still work. */
html, .detail { scrollbar-width: none; }
html::-webkit-scrollbar, .detail::-webkit-scrollbar { display: none; }

body {
  margin: 0;
  padding-inline: var(--rail);
  background: var(--bg);
  color: var(--ink);
  font: 500 16px/1.5 "M PLUS 1", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
button { font: inherit; color: inherit; }
img { display: block; }

.sr {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

:focus-visible { outline: 3px solid var(--sel-a); outline-offset: 2px; }

/* ---- Joy-Con rails ---- */
.rail {
  position: fixed; top: 0; bottom: 0; width: var(--rail); z-index: 30;
}
.rail-left { left: 0; background: var(--blue); }
.rail-right { right: 0; background: var(--red); }

/* ---- top bar ---- */
.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 18px var(--gutter) 6px;
}
.me {
  display: flex; align-items: center; gap: 12px;
  font-weight: 700; text-decoration: none; min-width: 0;
}
.me img {
  width: 44px; height: 44px; border-radius: 50%;
  box-shadow: 0 0 0 2px var(--ink);
}
.me span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me:hover img { box-shadow: 0 0 0 3px var(--sel-a); }

.top-right { display: flex; align-items: center; gap: 6px; flex: none; }
.icon-btn {
  display: grid; place-items: center;
  width: 44px; height: 44px;
  background: none; border: 0; border-radius: 50%;
  cursor: pointer; color: var(--ink);
}
.icon-btn:hover { background: var(--line); }

/* ---- intro ---- */
.intro { padding: 22px var(--gutter) 6px; }
h1 {
  margin: 0;
  font-size: clamp(30px, 4.4vw, 56px);
  line-height: 1.08; font-weight: 800; letter-spacing: -.02em;
  text-wrap: balance;
}
.intro p { margin: 10px 0 0; color: var(--muted); font-size: clamp(15px, 1.3vw, 18px); }
.intro p b { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }

h2 { margin: 0; font-size: 20px; font-weight: 700; line-height: 1.3; }

/* ---- tiles ---- */
.tile {
  position: relative; display: block;
  color: inherit; text-decoration: none;
  outline: none;
  scroll-margin-block: 96px 40px;
  -webkit-tap-highlight-color: transparent;
}
.art {
  position: relative; display: block; aspect-ratio: 1;
  transition: transform .16s cubic-bezier(.3, 1.6, .5, 1);
}
.art img {
  width: 100%; height: 100%;
  border-radius: var(--radius);
  background: var(--accent, var(--raised));
}
.tile.is-selected { z-index: 3; }
.tile.is-selected .art { transform: scale(1.025); }

/* The HOME-menu selection ring: a thick border pulsing between teal and blue. */
.tile.is-selected .art::after {
  content: ""; position: absolute; inset: -6px;
  border: 4px solid var(--sel-a);
  border-radius: 8px;
  pointer-events: none;
  animation: ring 1.05s ease-in-out infinite alternate;
}
@keyframes ring {
  from { border-color: var(--sel-a); box-shadow: 0 0 10px color-mix(in srgb, var(--sel-a) 65%, transparent); }
  to   { border-color: var(--sel-b); box-shadow: 0 0 20px color-mix(in srgb, var(--sel-b) 75%, transparent); }
}
.tile.nudge .art { animation: nudge .22s ease-out; }
@keyframes nudge {
  30% { transform: translate(var(--nudge-x, 0), var(--nudge-y, 0)) scale(1.025); }
}

/* Name: floats above the selected tile where there's a pointer; a caption on touch. */
.name {
  display: block; font-size: 13px; line-height: 1.3; font-weight: 500;
}
@media (hover: hover) {
  .name {
    position: absolute; left: 50%; bottom: calc(100% + 11px);
    transform: translateX(calc(-50% + var(--shift, 0px)));
    display: none;
    padding: 2px 10px;
    border-radius: 6px;
    background: var(--bg);
    color: var(--sel-ink);
    font-size: 16px; font-weight: 700;
    white-space: nowrap;
  }
  .tile.is-selected .name { display: block; }
}
@media (hover: none) {
  .name { margin-top: 7px; color: var(--muted); text-align: center; }
  .tile.is-selected .art { transform: none; }
  .tile.is-selected .art::after { display: none; }
}

.tile.is-off .art img { filter: saturate(.2) brightness(.72); transition: filter .15s; }
.tile.is-off.is-selected .art img { filter: none; }
.flag {
  position: absolute; left: 6px; bottom: 6px;
  padding: 0 7px; border-radius: 4px;
  background: rgba(0, 0, 0, .78); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 20px;
}

/* ---- latest row: runs off the edge of the screen, like HOME ---- */
.latest { margin-top: 18px; }
.latest h2 { padding-inline: var(--gutter); }
.row-wrap { position: relative; }
.row {
  display: grid; grid-auto-flow: column;
  grid-auto-columns: clamp(150px, 15.5vw, 240px);
  gap: 14px;
  padding: 50px var(--gutter) 20px;
  overflow-x: auto;
  scroll-padding-inline: var(--gutter);
  scrollbar-width: none;
}
.row::-webkit-scrollbar { display: none; }
@media (hover: none) { .row { padding-top: 14px; } }

.row-nav {
  position: absolute; top: calc(50% + 12px); z-index: 4;
  width: 46px; height: 46px; margin-top: -23px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: var(--raised); color: var(--ink);
  box-shadow: 0 2px 12px rgba(0, 0, 0, .4);
  cursor: pointer;
  transition: opacity .15s;
}
.row-nav:hover { background: var(--ink); color: var(--bg); }
.row-nav.prev { left: 8px; }
.row-nav.next { right: 8px; }
.row-nav[disabled] { opacity: 0; pointer-events: none; }
@media (hover: none) { .row-nav { display: none; } }

/* ---- all software ---- */
.all { padding: 22px var(--gutter) 44px; }
.all-head {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 12px 18px;
  margin-bottom: 52px;
}
.all-head h2 { white-space: nowrap; }
.count { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; margin-left: 2px; }
.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-left: auto; }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  min-height: 38px; padding: 0 14px;
  border: 0; border-radius: 19px;
  background: var(--raised);
  font-size: 14px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
}
.pill i { font-style: normal; color: var(--muted); margin-left: 5px; font-variant-numeric: tabular-nums; }
.pill:hover { box-shadow: inset 0 0 0 2px var(--muted); }
.pill[aria-pressed="true"] { background: var(--ink); color: var(--bg); font-weight: 700; }
.pill[aria-pressed="true"] i { color: inherit; opacity: .7; }
:root[data-theme="light"] .pill:not([aria-pressed="true"]) { box-shadow: inset 0 0 0 1px var(--line); }

.sort .pill { background: none; padding: 0 11px; color: var(--muted); }
.sort .pill[aria-pressed="true"] { background: var(--raised); color: var(--ink); }
:root[data-theme="light"] .sort .pill { box-shadow: none; }
:root[data-theme="light"] .sort .pill[aria-pressed="true"] { box-shadow: inset 0 0 0 1px var(--line); }

.search {
  display: flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 14px;
  border-radius: 19px;
  background: var(--raised);
  color: var(--muted);
}
.search:focus-within { box-shadow: 0 0 0 3px var(--sel-a); }
.search input {
  width: 150px; border: 0; outline: 0; padding: 0;
  background: none; color: var(--ink);
  font: inherit; font-size: 14px;
}
.search input::placeholder { color: var(--muted); opacity: 1; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(96px, 10.2vw, 148px), 1fr));
  gap: clamp(8px, .95vw, 14px);
}
.empty { color: var(--muted); padding: 32px 0; }
.empty button {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--ink); text-decoration: underline;
}

/* ---- footer ---- */
.foot {
  padding: 26px var(--gutter) 34px;
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: 14px;
}
.foot p { margin: 8px 0 0; max-width: 70ch; }

/* ---- detail panel ---- */
.detail {
  width: min(900px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0; border: 0; border-radius: 14px;
  color: var(--ink);
  background:
    radial-gradient(110% 95% at 0% 0%, color-mix(in srgb, var(--accent, #888) 36%, transparent), transparent 62%),
    var(--raised);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .55);
  overflow: hidden auto;
}
.detail[open] { animation: rise .2s cubic-bezier(.2, .9, .3, 1); }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.985); } }
.detail::backdrop { background: rgba(12, 12, 14, .74); backdrop-filter: blur(5px); }

.d-close { position: absolute; top: 10px; right: 10px; }
.d-body {
  display: grid; grid-template-columns: 256px minmax(0, 1fr);
  gap: 30px; padding: 30px;
}
.d-icon {
  width: 256px; height: 256px; border-radius: 8px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, .4);
}
.d-kicker { margin: 0 44px 4px 0; color: var(--muted); font-size: 14px; }
.d-title {
  margin: 0 36px 0 0;
  font-size: clamp(26px, 3.2vw, 36px); line-height: 1.12;
  font-weight: 800; letter-spacing: -.015em;
  text-wrap: balance;
}
.d-desc { margin: 12px 0 0; font-weight: 400; line-height: 1.55; }
.d-desc:empty { display: none; }

.d-meta {
  display: flex; flex-wrap: wrap; gap: 10px 26px;
  margin: 18px 0 0;
}
.d-meta div { min-width: 0; }
.d-meta dt { color: var(--muted); font-size: 12px; }
.d-meta dd { margin: 0; font-family: var(--mono); font-weight: 500; font-size: 14px; }

.d-note {
  margin-top: 18px; padding: 12px 14px;
  border-left: 3px solid var(--sel-a);
  border-radius: 0 6px 6px 0;
  background: color-mix(in srgb, var(--sunk) 62%, transparent);
  font-size: 15px; font-weight: 400; line-height: 1.5;
}
.d-note:empty { display: none; }
.d-note strong { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 1px; }
.d-note.is-warn { border-left-color: var(--red); }

.d-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 8px 18px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--ink) 11%, transparent);
  font-size: 15px; font-weight: 700; text-decoration: none;
  overflow-wrap: anywhere;
}
.btn:hover { background: color-mix(in srgb, var(--ink) 20%, transparent); }
.btn-main { background: var(--sel-a); color: var(--on-sel); }
.btn-main:hover { background: color-mix(in srgb, var(--sel-a) 82%, #fff); }
.btn small { font: 400 12px var(--mono); opacity: .8; }

.noscript { padding: 40px var(--gutter); }

/* ---- small and touch screens ---- */
@media (max-width: 860px), (hover: none) {
  .tile { scroll-margin-block: 24px; }
}
@media (max-width: 720px) {
  :root { --rail: 5px; }
  .all-head { margin-bottom: 24px; }
  .tools { margin-left: 0; width: 100%; }
  .search { flex: 1 1 100%; }
  .search input { width: 100%; }
  #filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; width: calc(100% + 2 * var(--gutter)); margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter); }
  #filters::-webkit-scrollbar { display: none; }
  .row { grid-auto-columns: 42vw; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 12px 10px; }

  .detail { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; margin: 0; border-radius: 0; }
  .d-body { grid-template-columns: 1fr; gap: 18px; padding: 22px 18px 18px; }
  .d-icon { width: min(52vw, 208px); height: auto; aspect-ratio: 1; }
  .d-actions { flex-direction: column; }
  /* The panel can scroll on a phone, so keep the way out on screen. */
  .d-close { position: fixed; z-index: 2; background: var(--raised); }
}

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