/* The shop as a JRPG "Buying" screen: a list panel and an item panel over a starry blue
   backdrop, with a pixel glove cursor. Reasoning: docs/DECISIONS.md D54. */

.rpg-shop {
  --ink: #f2f6ff;
  --ink-dim: #b8c8ec;
  --navy: #081233;
  --panel-top: rgba(28, 58, 120, .9);
  --panel-low: rgba(8, 20, 56, .92);
  --rim: rgba(205, 225, 255, .75);
  --line: rgba(205, 225, 255, .28);
  --cyan: #8fe6ff;
  --gold: #ffd56b;
  --shadow-text: 2px 2px 0 #030820;
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--navy);
  color: var(--ink);
  font-family: var(--font-label);
  font-size: 32px;   /* Pixel Operator is drawn on a 16px grid; only 16, 32 and 48 stay crisp */
  line-height: 1.25;
  text-shadow: var(--shadow-text);
  overflow-x: hidden;
}
.rpg-shop *, .rpg-shop *::before, .rpg-shop *::after { box-sizing: border-box; }
.rpg-shop a { color: inherit; }

/* ---------- backdrop: deep blue, drifting motes, faint scanlines ---------- */
.sky {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(1.5px 1.5px at 20% 30%, #cfe6ff 50%, transparent 51%) 0 0 / 180px 160px,
    radial-gradient(1px 1px at 70% 60%, #9fd4ff 50%, transparent 51%) 0 0 / 120px 140px,
    radial-gradient(2px 2px at 40% 80%, #ffffff 50%, transparent 51%) 0 0 / 260px 220px,
    radial-gradient(ellipse 55% 45% at 72% 42%, #2a55c8 0%, #142b80 45%, transparent 78%),
    linear-gradient(180deg, #060e30 0%, #0a1852 55%, #040a28 100%);
  animation: drift 90s linear infinite;
}
.sky::after {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 20, .2) 0 1px, transparent 1px 3px);
}
@keyframes drift { to { background-position: 180px -160px, -120px -280px, 260px -440px, 0 0, 0 0; } }

/* ---------- panels ---------- */
.panel {
  position: relative;
  border: 1px solid var(--rim);
  border-radius: 6px;
  background: linear-gradient(170deg, var(--panel-top) 0%, var(--panel-low) 60%);
  box-shadow: inset 0 0 0 1px rgba(10, 20, 60, .8), inset 0 1px 0 2px rgba(255, 255, 255, .06), 0 10px 30px rgba(0, 0, 10, .5);
}

.screen {
  position: relative; z-index: 1;
  max-width: 1240px; margin: 0 auto; padding: 32px 24px 16px;
  display: grid; gap: 18px 20px;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  grid-template-areas: "buying detail" "bar bar" "fine fine";
}
.buying { grid-area: buying; display: flex; flex-direction: column; padding: 18px 0 0; min-height: 560px; }
.detail { grid-area: detail; padding: 18px 24px 22px; display: flex; flex-direction: column; }
.bar { grid-area: bar; }
.fine { grid-area: fine; }

/* ---------- buying panel ---------- */
.buying-head { padding: 0 22px 12px; border-bottom: 1px solid var(--line); }
.buying-head h1 { margin: 0; font-size: 48px; font-weight: 700; line-height: 1; }
.shop-name { margin: 4px 0 0; color: var(--ink-dim); }

.cats { padding: 12px 22px; border-bottom: 1px solid var(--line); text-align: center; }
.cats-row { display: flex; align-items: center; justify-content: center; gap: 10px; }
.cats-tabs { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.cat {
  font: inherit; color: var(--ink-dim); text-shadow: inherit; cursor: pointer;
  padding: 0 14px; border-radius: 4px; border: 1px solid var(--line); background: rgba(4, 12, 40, .55);
}
.cat:hover { color: var(--ink); border-color: var(--rim); }
.cat[aria-selected="true"] { color: var(--navy); text-shadow: none; background: var(--ink); border-color: var(--ink); }

.item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; }

.items { list-style: none; margin: 0; padding: 4px 0; flex: 1; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--rim) transparent; }
.items li[hidden] { display: none; }
.item {
  position: relative; min-height: 48px; padding: 6px 22px 6px 62px;
  text-decoration: none; border-bottom: 1px solid rgba(205, 225, 255, .1);
}
.item-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.item-name::before {   /* the pixel tee, like an item-type icon */
  content: ""; flex: none; width: 24px; height: 20px; background: var(--ink-dim);
  -webkit-mask: url("img/tee.svg") center / contain no-repeat; mask: url("img/tee.svg") center / contain no-repeat;
}
.item-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-price { color: var(--ink); font-variant-numeric: tabular-nums; }
.item:hover { background: rgba(255, 255, 255, .05); }
.item[aria-current="true"] {
  background: linear-gradient(90deg, rgba(143, 230, 255, .34) 0%, rgba(143, 230, 255, .14) 65%, rgba(143, 230, 255, .04) 100%);
  box-shadow: inset 0 1px 0 rgba(143, 230, 255, .6), inset 0 -1px 0 rgba(143, 230, 255, .6);
}
.item[aria-current="true"] .item-name::before { background: var(--cyan); }
.item[aria-current="true"] .item-price { color: var(--gold); }
.item::after {    /* the glove */
  content: ""; position: absolute; left: 14px; top: 50%;
  width: 36px; height: 20px; margin-top: -10px;
  background: url("img/cursor.svg") center / 36px 20px no-repeat;
  image-rendering: pixelated; filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, .5));
  opacity: 0;
}
.item[aria-current="true"]::after { opacity: 1; animation: point .7s steps(2) infinite; }
@keyframes point { 50% { transform: translateX(-4px); } }

.tag { font-size: 16px; line-height: 20px; padding: 0 6px; border-radius: 3px; background: var(--gold); color: var(--navy); text-shadow: none; }
.empty { padding: 18px 22px; color: var(--ink-dim); }

.total {
  display: flex; align-items: center; gap: 14px; padding: 14px 22px;
  border-top: 1px solid var(--rim); background: rgba(3, 9, 34, .55); border-radius: 0 0 6px 6px;
}
.total-label { color: var(--ink-dim); }
.total-price { flex: 1; text-align: right; font-size: 48px; font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; }
.buy {
  flex: none; padding: 6px 16px; font-weight: 700; text-decoration: none;
  color: var(--navy) !important; text-shadow: none;
  background: linear-gradient(180deg, #fff3c4, var(--gold) 55%, #e0a63a);
  border: 1px solid #fff8e0; border-radius: 4px; box-shadow: 0 0 0 2px #030820, 0 3px 0 2px rgba(0, 0, 0, .45);
}
.buy:hover { filter: brightness(1.08); }
.buy:active { transform: translateY(2px); }

/* ---------- detail panel ---------- */
.detail h2 {
  display: flex; align-items: center; gap: 12px; margin: 0; padding-bottom: 10px;
  font-size: 48px; font-weight: 700; line-height: 1; border-bottom: 1px solid var(--line);
}
.tee-ico { flex: none; width: 48px; height: 40px; background: var(--cyan); -webkit-mask: url("img/tee.svg") center / contain no-repeat; mask: url("img/tee.svg") center / contain no-repeat; }
.desc { margin: 12px 0 18px; color: var(--cyan); line-height: 1.25; min-height: 1.25em; }
.plate {
  position: relative; align-self: center; width: min(100%, 440px); aspect-ratio: 1;
  border: 1px solid var(--rim); border-radius: 4px; overflow: hidden; background: #fff;
  box-shadow: 0 0 0 4px rgba(4, 12, 40, .7), 0 0 40px rgba(143, 230, 255, .25);
}
.plate img { display: block; width: 100%; height: 100%; object-fit: cover; }
.plate::after {   /* a light sweep each time the item changes */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, .75) 50%, transparent 65%);
}
.plate.shine::after { animation: sweep .5s ease-out; }
@keyframes sweep { from { opacity: 1; transform: translateX(-100%); } to { opacity: 1; transform: translateX(100%); } }

/* ---------- bottom bar ---------- */
.bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px;
  padding: 8px 4px; font-size: 16px; border-top: 1px solid var(--line);
}
.bar-keys { margin-left: auto; }
.bar-keys, .leave { color: var(--ink-dim); }
.leave { text-decoration: none; }
.leave:hover { color: var(--gold); }
kbd {
  display: inline-block; min-width: 22px; padding: 0 4px; margin-right: 2px;
  font: 700 16px/18px var(--font-label); text-align: center; color: var(--navy); text-shadow: none;
  background: var(--ink-dim); border-radius: 3px; box-shadow: 0 2px 0 #4c5d9c;
}
.cats-key { margin: 0; }
.sound {
  font: inherit; color: var(--ink-dim); text-shadow: inherit; cursor: pointer;
  padding: 1px 10px; border: 1px solid var(--line); border-radius: 3px; background: none;
}
.sound[aria-pressed="true"] { color: var(--gold); border-color: var(--gold); }
.clock { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.clock-ico { width: 14px; height: 14px; border: 2px solid var(--ink); border-radius: 50%; position: relative; }
.clock-ico::after { content: ""; position: absolute; left: 3px; top: 1px; width: 4px; height: 4px; border-left: 2px solid var(--ink); border-bottom: 2px solid var(--ink); }

.fine { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; margin: 0 0 12px; font-size: 16px; color: var(--ink-dim); text-align: center; }
.fine a:hover { color: var(--gold); }

.rpg-shop :focus-visible { outline: 2px dashed var(--gold); outline-offset: 2px; }
.item:focus-visible { outline-offset: -3px; }

/* ---------- opening: the panels unfold ---------- */
.js .panel, .js .bar { animation: open-win .24s steps(5) both; }
.js .detail { animation-delay: .1s; }
.js .bar { animation-delay: .2s; }
@keyframes open-win { from { transform: scaleY(.04); opacity: .3; } }

/* ---------- phones and tablets ---------- */
@media (max-width: 860px) {
  .buying-head h1, .detail h2, .total-price { font-size: 32px; }
  .item-label { white-space: normal; line-height: 1; padding: 4px 0; }
  .shop-name, .cat { font-size: 16px; }
  .cat { padding: 4px 12px; }
  .item { padding-left: 54px; }
  .item::after { left: 10px; }
  .screen { padding: 16px 16px 8px; gap: 14px; grid-template-columns: minmax(0, 1fr); grid-template-areas: "detail" "buying" "bar" "fine"; }
  .buying { min-height: 0; }
  /* The item panel rides along at the top so a tapped row's photo stays in view. */
  .detail {
    position: sticky; top: 0; z-index: 3; padding: 10px 14px 12px;
    display: grid; grid-template-columns: 132px minmax(0, 1fr); grid-template-rows: auto 1fr; gap: 8px 14px;
    background: linear-gradient(170deg, #1c3a78 0%, #08143a 70%);
    border-radius: 0 0 6px 6px;
  }
  .detail h2 { grid-column: 1 / -1; padding-bottom: 8px; }
  .tee-ico { width: 24px; height: 20px; }
  .buy { font-size: 16px; padding: 8px 14px; }
  .plate { grid-column: 1; grid-row: 2; width: 132px; align-self: start; box-shadow: 0 0 0 3px rgba(4, 12, 40, .7); }
  .desc { grid-column: 2; grid-row: 2; margin: 0; font-size: 16px; }

  .bar-keys, .cats-key, .leave kbd { display: none; }
  .item { padding-right: 16px; }
  .total { padding: 12px 16px; flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  .sky, .item[aria-current="true"]::after,
  .plate.shine::after, .js .panel, .js .bar { animation: none !important; }
}
