/* The world's own board language (GardenUIBuilder.cs): plank boards in a dark frame, green studded
   title bars, brown item cards with dark wells, chunky buttons that sit on a lip, Fredoka with a
   dark outline. */

@font-face {
  font-family: "Fredoka";
  src: url("/fonts/Fredoka-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Fredoka";
  src: url("/fonts/Fredoka-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-display: swap;
}

:root {
  --frame: #3e2210;
  --frame-deep: #2e1a0b;
  --brown: #7a4a26;
  --card: #5c3319;
  --well: #3a1f0e;
  --cream: #f2e3c9;
  --muted: #e0c9a6;
  --green: #54c24d;
  --green-dark: #2e7d2a;
  --yellow: #ffc928;
  --yellow-dark: #c48a0e;
  --blue: #5ab8e8;
  --blue-dark: #2b78a8;
  --price: #5cff5c;
  --red: #e23b3b;
  --ink-outline:
    0 2px 0 var(--frame), 0 -2px 0 var(--frame), 2px 0 0 var(--frame), -2px 0 0 var(--frame),
    1.5px 1.5px 0 var(--frame), -1.5px 1.5px 0 var(--frame), 1.5px -1.5px 0 var(--frame), -1.5px -1.5px 0 var(--frame),
    0 4px 0 rgba(46, 26, 11, 0.55);
  --ink-outline-thin:
    0 1.5px 0 var(--frame), 0 -1.5px 0 var(--frame), 1.5px 0 0 var(--frame), -1.5px 0 0 var(--frame),
    1px 1px 0 var(--frame), -1px 1px 0 var(--frame), 1px -1px 0 var(--frame), -1px -1px 0 var(--frame),
    0 3px 0 rgba(46, 26, 11, 0.55);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --pop: cubic-bezier(0.34, 1.56, 0.64, 1);
  color-scheme: dark;
  accent-color: var(--yellow);
}

* { box-sizing: border-box; }

html {
  background: var(--frame-deep);
  scrollbar-color: var(--brown) var(--frame-deep);
}

body {
  margin: 0;
  min-height: 100vh;
  font: 600 1rem/1.4 "Fredoka", ui-rounded, system-ui, sans-serif;
  color: var(--cream);
  /* The plaza floor: the board planks under a shade, so the framed boards sit in front of it. */
  background:
    linear-gradient(rgba(36, 18, 6, 0.45), rgba(36, 18, 6, 0.45)),
    #734624 url("/ui/tex-planks.png") 0 0 / 220px;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--yellow); color: var(--frame); }

a { color: inherit; }

:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
  border-radius: 14px;
}

h1, h2, h3, p { margin: 0; }

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

/* White Fredoka with the in-game dark outline. */
.ink {
  color: #fff;
  font-weight: 700;
  text-shadow: var(--ink-outline);
  /* The outline would otherwise close up the gaps between words. */
  word-spacing: 0.15em;
}

/* ---------- Top ---------- */

.top {
  max-width: 1200px;
  margin: 0 auto;
  padding: 22px 20px 6px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 6px 22px;
}

.brand img {
  display: block;
  width: 168px;
  height: auto;
  filter: drop-shadow(0 6px 0 rgba(46, 26, 11, 0.6));
}

.tagline {
  color: var(--muted);
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 12px 3px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--price);
  font-weight: 700;
  font-size: 0.85rem;
}
.status::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px rgba(92, 255, 92, 0.18);
}
.status.offline { color: #ff8a8a; }
.status.offline::before { box-shadow: none; }

.links { display: flex; gap: 12px; }

/* ---------- Chunky buttons: a face on a darker lip ---------- */

.btn {
  --face: var(--yellow);
  --lip: var(--yellow-dark);
  --lip-h: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 10px 22px;
  border: 3px solid var(--frame);
  border-radius: 16px;
  background: var(--face);
  box-shadow: inset 0 calc(-1 * var(--lip-h)) 0 var(--lip), 0 4px 0 rgba(46, 26, 11, 0.5);
  color: #fff;
  font: 700 1.1rem/1 "Fredoka", sans-serif;
  text-decoration: none;
  text-shadow: var(--ink-outline-thin);
  word-spacing: 0.15em;
  cursor: pointer;
  transition: transform 120ms var(--ease-out), box-shadow 120ms var(--ease-out), filter 120ms;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { filter: brightness(1.07); }
.btn:active {
  transform: translateY(3px);
  box-shadow: inset 0 -3px 0 var(--lip), 0 1px 0 rgba(46, 26, 11, 0.5);
}
.btn-blue { --face: var(--blue); --lip: var(--blue-dark); }
.btn-green { --face: var(--green); --lip: var(--green-dark); }
.btn-brown { --face: var(--brown); --lip: var(--frame); }
.btn-small { min-height: 42px; padding: 6px 16px; font-size: 1rem; border-radius: 14px; --lip-h: 5px; }

/* ---------- Boards ---------- */

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 20px 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
}

.board {
  border: 6px solid var(--frame);
  border-radius: 28px;
  background: var(--frame);
  box-shadow: 0 10px 0 rgba(20, 10, 3, 0.55), 0 18px 40px rgba(10, 5, 1, 0.45);
  overflow: hidden;
}

/* The green studded title bar. */
.bar {
  position: relative;
  padding: 16px 18px 20px;
  border-radius: 22px 22px 0 0;
  background: var(--green);
  box-shadow: inset 0 -7px 0 var(--green-dark);
  isolation: isolate;
}
.bar::before {
  content: "";
  position: absolute;
  inset: 6px;
  z-index: -1;
  border-radius: 16px;
  background: url("/ui/tex-studs.png") 0 0 / 34px;
  opacity: 0.55;
}
.hud .bar { border-radius: 22px; }

.bar-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: clamp(1.6rem, 3vw, 2.15rem);
  line-height: 1.1;
}
.bar-title img {
  width: 1.4em;
  height: 1.4em;
  margin-block: -0.2em;
  object-fit: contain;
  filter: drop-shadow(0 3px 0 rgba(20, 40, 10, 0.5));
}

.bar-slim {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  flex-wrap: wrap;
  padding: 14px 20px 19px;
}
/* A single shop's clock, in the game's dark in-bar pill. */
.bar-note {
  padding: 6px 16px 7px;
  border-radius: 999px;
  background: rgba(16, 52, 14, 0.62);
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.18);
  font-size: 1.05rem;
}

/* ---------- HUD pills ---------- */

.pills {
  margin-top: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.45fr) minmax(0, 1fr);
  gap: 12px;
}

.pill {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 12px 14px 18px 12px;
  border-radius: 20px;
  background: rgba(16, 52, 14, 0.62);
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.18);
}

.pill-icon {
  flex: none;
  width: 60px;
  height: 60px;
  object-fit: contain;
  filter: drop-shadow(0 3px 0 rgba(20, 40, 10, 0.5));
}

.pill-body { min-width: 0; display: grid; gap: 1px; }

.pill-value {
  font-size: 1.4rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.pill-sub { font-size: 0.95rem; color: #f0ffe8; line-height: 1.3; }
.pill-sub .blurb { display: block; color: #e3f7da; }
.pill-sub .blurb:empty { display: none; }
.when time, .when { font-weight: 700; color: #fff; }

/* The draining lip: how much of the current spell is left. */
.drain {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 7px;
  height: 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.drain > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--yellow);
  transform: scaleX(var(--left, 1));
  transform-origin: left;
  transition: transform 1s linear;
}

.pill.away .pill-icon { filter: grayscale(0.7) brightness(0.8); }
.pill.live { background: rgba(80, 40, 0, 0.42); box-shadow: inset 0 0 0 3px var(--yellow); }

/* ---------- Stock wall ---------- */

.planks {
  padding: 18px 18px 20px;
  background: #7a4a26 url("/ui/tex-planks.png") 0 0 / 220px;
  border-radius: 0 0 22px 22px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}
.tab { gap: 8px; padding-inline: 16px 18px; }
.tab img { width: 30px; height: 30px; object-fit: contain; filter: drop-shadow(0 2px 0 rgba(46, 26, 11, 0.6)); }
.tab .count {
  min-width: 26px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  font-size: 0.9rem;
  text-shadow: none;
}
.tab[aria-selected="true"] { --face: var(--green); --lip: var(--green-dark); }
.tab[aria-selected="false"] { --face: var(--brown); --lip: var(--frame); }

.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
  gap: 14px;
}

.card {
  --rarity: #a8a8a8;
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 8px;
  padding: 9px 9px 11px;
  border: 4px solid var(--frame);
  border-radius: 20px;
  background: var(--card);
  box-shadow: 0 5px 0 rgba(30, 15, 5, 0.55);
  animation: deal 380ms var(--pop) both;
  animation-delay: calc(var(--i, 0) * 28ms);
}

@keyframes deal {
  from { opacity: 0; transform: translateY(10px) scale(0.92); }
}

.well {
  position: relative;
  display: grid;
  place-items: center;
  height: 104px;
  border-radius: 14px;
  background: var(--well);
  box-shadow: inset 0 0 0 3px var(--rarity), inset 0 8px 14px rgba(0, 0, 0, 0.35);
}
.well img.item-icon {
  width: 80px;
  height: 80px;
  object-fit: contain;
  filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.35));
}
.well .from {
  position: absolute;
  top: 7px;
  left: 7px;
  width: 26px;
  height: 26px;
  object-fit: contain;
  opacity: 0.9;
}
.tag-new {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 2px solid var(--frame);
  background: var(--yellow);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  text-shadow: var(--ink-outline);
}

.card-text { display: grid; gap: 2px; text-align: center; }
.card-name { font-size: 1.12rem; line-height: 1.15; }
.card-rarity { font-size: 0.86rem; font-weight: 700; color: var(--rarity); }

.card-foot { display: grid; gap: 8px; }

.price {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--price);
  text-shadow: var(--ink-outline);
}
.price img { width: 22px; height: 22px; }

.stock {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  padding: 7px 10px 8px;
  border-radius: 14px;
  background: var(--well);
  color: var(--muted);
  font-size: 0.9rem;
}
.stock b { font-size: 1.3rem; color: var(--yellow); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5); }

.card.sold-out { background: #4a2a15; }
.card.sold-out .well img.item-icon { filter: grayscale(1) brightness(0.55); }
.card.sold-out .stock { color: #ff9a9a; }

.empty {
  grid-column: 1 / -1;
  padding: 26px 18px;
  border-radius: 18px;
  background: var(--well);
  color: var(--muted);
  text-align: center;
  font-size: 1.05rem;
}
.empty strong { color: #fff; }

.wall-foot { display: flex; justify-content: flex-end; margin-top: 18px; }
#show-sold-out[aria-pressed="true"] { --face: var(--green); --lip: var(--green-dark); }

/* ---------- Footer ---------- */

.foot {
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px 20px 40px;
  color: var(--muted);
  font-size: 0.92rem;
  display: grid;
  gap: 4px;
}

/* ---------- Narrow screens ---------- */

@media (max-width: 1020px) {
  .pills { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .top { grid-template-columns: auto minmax(0, 1fr); padding-top: 16px; }
  .brand img { width: 128px; }
  .links { grid-column: 1 / -1; }
  .links { flex-wrap: wrap; gap: 10px; }
  .links .btn { flex: 1 1 40%; padding-inline: 10px; font-size: 1rem; white-space: nowrap; }
  .tagline { font-size: 0.95rem; }
  main { padding-inline: 10px; gap: 16px; }
  .board { border-width: 5px; border-radius: 24px; }
  .bar { padding: 12px 12px 18px; }
  .bar-title { font-size: 1.5rem; }
  .pills { gap: 8px; margin-top: 10px; }
  .pill { gap: 8px; padding: 8px 10px 15px 8px; border-radius: 16px; }
  .pill-icon { width: 36px; height: 36px; }
  .pill-value { font-size: 1.02rem; }
  .pill-sub { font-size: 0.85rem; }
  .pill-sub .blurb { display: none; }
  .drain { left: 10px; right: 10px; bottom: 5px; height: 5px; }
  .bar-slim { padding: 10px 14px 16px; }
  .bar-note { font-size: 0.92rem; padding: 4px 12px 5px; }
  .planks { padding: 12px 10px 14px; }
  .tabs { gap: 8px; flex-wrap: nowrap; overflow-x: auto; margin-inline: -10px; padding: 0 10px 6px; scrollbar-width: none; }
  .tab { flex: none; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .well { height: 88px; }
  .well img.item-icon { width: 64px; height: 64px; }
  .card-name { font-size: 1rem; }
}

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