:root {
  --bg: #12100f;
  --panel: #1c1917;
  --panel-2: #241f1c;
  --line: #362f2a;
  --text: #f2ece6;
  --muted: #a29489;
  --accent: #f4a15d;
  --accent-dim: #7a4f28;
  --green: #7fd18b;
  --red: #e58b7b;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
}

code {
  font-family: "Cascadia Mono", Consolas, monospace;
  background: #00000033;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 4px;
  font-size: 0.9em;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #1f1a17, #17140f);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand { display: flex; align-items: center; gap: 14px; }
.donut { font-size: 34px; }
.topbar h1 { margin: 0; font-size: 19px; letter-spacing: 0.2px; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.status { display: flex; align-items: center; gap: 14px; }
.countdown { text-align: right; line-height: 1.1; }
.countdown span { font-size: 22px; font-variant-numeric: tabular-nums; color: var(--accent); }
.countdown small { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.7px; }

main { max-width: 1180px; margin: 0 auto; padding: 24px 28px 64px; display: flex; flex-direction: column; gap: 20px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
}

.panel h2 { margin: 0 0 6px; font-size: 15px; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }

.row { display: flex; gap: 10px; margin-top: 12px; }

input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
}
input:focus { outline: none; border-color: var(--accent-dim); box-shadow: 0 0 0 3px #f4a15d1f; }

button {
  background: var(--accent);
  color: #241505;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.5; cursor: default; }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); font-weight: 500; }
button.link { background: none; color: var(--muted); padding: 4px 8px; font-size: 18px; line-height: 1; }
button.link:hover { color: var(--red); }

.results { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.results li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
}
.results .meta { color: var(--muted); font-size: 13px; }
.results strong { font-weight: 600; }

.table-wrap { overflow-x: auto; margin-top: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; font-weight: 600; }
th.num, td.num { text-align: right; }
tbody tr:hover { background: #ffffff06; }
.item-name { font-weight: 600; }
.item-sub { color: var(--muted); font-size: 12px; font-weight: 400; }
.price { font-variant-numeric: tabular-nums; }
.unit { display: block; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.na { color: var(--muted); }
.row-error { color: var(--red); font-size: 12px; }

.alert {
  margin-top: 14px;
  background: #40211b;
  border: 1px solid #6d3a2c;
  color: #ffd9cf;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
}

.note ul { margin: 10px 0 0; padding-left: 20px; color: var(--muted); font-size: 13px; }
.note li { margin-bottom: 6px; }
.note strong { color: var(--text); }

.hidden { display: none !important; }

/* ---- spinning item icons ---- */

.icon {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  perspective: 140px;
}

.icon-bob,
.icon-spin {
  display: block;
  width: 100%;
  height: 100%;
}

/* Two elements: the outer one bobs, the inner one spins. Both animate
   transform, so they cannot share an element. */
.icon-bob { animation: icon-bob 3.4s ease-in-out infinite; }

.icon-spin {
  position: relative;
  transform-style: preserve-3d;
  animation: icon-spin 4.5s linear infinite;
  animation-delay: var(--spin-delay, 0ms);
}

.icon .face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  /* Minecraft textures are 16px - never let the browser smooth them. */
  image-rendering: pixelated;
  backface-visibility: hidden;
  filter: drop-shadow(0 2px 3px #0007);
}

.icon .back { transform: rotateY(180deg); }

@keyframes icon-spin {
  from { transform: rotateY(0deg); }
  to { transform: rotateY(360deg); }
}

@keyframes icon-bob {
  0%, 100% { transform: translateY(-1.5px); }
  50% { transform: translateY(1.5px); }
}

/* Unknown item, or the texture failed to load. */
.icon-blank .icon-bob { display: none; }
.icon-blank {
  border: 1px dashed var(--line);
  border-radius: 5px;
  background: #ffffff05;
}

.item-cell { display: flex; align-items: center; gap: 12px; }

@media (prefers-reduced-motion: reduce) {
  .icon-bob,
  .icon-spin { animation: none; }
}

/* ---- expandable price history ---- */

button.expand {
  flex: 0 0 auto;
  background: none;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  padding: 5px 6px;
  border-radius: 5px;
  cursor: pointer;
}
button.expand:hover { color: var(--accent); border-color: var(--line); }
button.expand[aria-expanded='true'] { color: var(--accent); }

.detail-row > td { padding: 0 12px 18px; border-bottom: 1px solid var(--line); }

.history { background: #ffffff05; border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }

.history-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.windows { display: flex; gap: 6px; flex-wrap: wrap; }

button.window {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}
button.window:hover { color: var(--text); }
button.window.active { background: var(--accent); border-color: var(--accent); color: #241505; font-weight: 600; }

.history-note { color: var(--muted); font-size: 12px; }

.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10px; font-family: inherit; }
.chart .chart-empty { fill: var(--muted); font-size: 12px; font-family: inherit; }
.chart .chart-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .chart-area { fill: var(--accent); opacity: 0.09; stroke: none; }
.chart .chart-sale { fill: var(--green); opacity: 0.85; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.stat { background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 9px 11px; }
.stat-label { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px; }
.stat-value { font-size: 16px; font-variant-numeric: tabular-nums; margin-top: 3px; }
.stat-sub { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat.up .stat-value { color: var(--green); }
.stat.down .stat-value { color: var(--red); }

/* ---- sale-price chart ---- */

.chart .chart-listing {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
  opacity: 0.55;
}
.chart .chart-spread { stroke: var(--green); stroke-width: 1.5; opacity: 0.35; }
.chart .chart-line { stroke: var(--green); }
.chart .chart-area { fill: var(--green); opacity: 0.08; }
.chart .chart-sale { fill: var(--green); opacity: 0.95; }
.chart .chart-sale:hover { fill: var(--text); }
.chart .chart-gap { fill: var(--red); opacity: 0.06; }

/*
 * The history panel sits inside a table cell, which inherits the nowrap set on
 * every th/td above - so its labels could not wrap and overflowed their cards.
 */
.detail-row > td { white-space: normal; }
.stat { min-width: 0; }
.stat-label,
.stat-sub { overflow-wrap: anywhere; }
.stat-value { overflow-wrap: anywhere; }

/* ---- footer signature ---- */

.signature-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 26px 20px 34px;
}

/*
 * The glint is a highlight swept across the text with background-clip, so the
 * letters stay put and only the shine travels.
 *
 * The gradient tiles (repeat-x) at a fixed 180px, and the animation shifts it
 * by exactly 180px per cycle - one whole tile - so the loop is seamless with no
 * stall and no jump. The tile width is in pixels rather than a percentage on
 * purpose: a percentage background-position resolves against (element width -
 * image width), which does not come out to a whole tile, leaving a visible
 * skip at the wrap. The tile also starts and ends on the base colour, so there
 * is no seam where it repeats.
 *
 * The base colour is light enough to read on its own - the shine is a highlight
 * on visible text, never the only thing making it visible.
 */
.signature {
  font-family: 'UnifrakturMaguntia', 'Old English Text MT', 'Blackadder ITC', serif;
  font-size: 15px;
  line-height: 1.6;
  letter-spacing: 0.5px;
  background-image: linear-gradient(
    105deg,
    #c8bcb3 0%,
    #c8bcb3 40%,
    #fffdfa 50%,
    #c8bcb3 60%,
    #c8bcb3 100%
  );
  background-size: 180px 100%;
  background-repeat: repeat-x;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  animation: signature-glint 5s linear infinite;
}

@keyframes signature-glint {
  from { background-position: 0 0; }
  to { background-position: 180px 0; }
}

.signature-bar .discord {
  display: inline-flex;
  color: var(--muted);
  transition: color 0.15s ease, transform 0.15s ease;
}
.signature-bar .discord svg { width: 20px; height: 20px; fill: currentColor; display: block; }
.signature-bar .discord:hover { color: #5865f2; transform: translateY(-1px); }
.signature-bar .discord:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  .signature {
    animation: none;
    background-image: none;
    color: var(--muted);
    -webkit-text-fill-color: var(--muted);
  }
}

/* A warning is not a failure - the tracker works, the data is just incomplete. */
.alert.warn {
  background: #3d3016;
  border-color: #6d5a2c;
  color: #ffeec2;
}

/* ---- price alerts ---- */

.sub-head {
  margin: 22px 0 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-top: 12px;
  align-items: end;
}

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { color: var(--muted); font-size: 12px; }
.field input[type='number'], .field input[type='text'], .field input[type='password'] { width: 100%; }

.with-unit { display: flex; align-items: center; gap: 8px; }
.with-unit em { color: var(--muted); font-style: normal; font-size: 13px; }

.field.checkbox { flex-direction: row; align-items: center; gap: 9px; }
.field.checkbox input { width: 16px; height: 16px; flex: 0 0 auto; accent-color: var(--accent); }
.field.checkbox span { color: var(--text); font-size: 14px; }

.move-down { color: var(--red); }
.move-up { color: var(--green); }

/* ---- signed-in user page ---- */

.button-link {
  display: inline-flex;
  align-items: center;
  background: var(--accent);
  color: #241505;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.button-link.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); font-weight: 500; }
.button-link:hover { filter: brightness(1.08); }

/* ---- settings page: cogwheel, threshold slider, channel switches ---- */

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  line-height: 0;
}
.icon-button svg { width: 18px; height: 18px; fill: currentColor; display: block; }
.icon-button:hover svg { fill: var(--accent); }

.slider-field { margin-top: 16px; }
.slider-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.slider-head span { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.7px; }
.slider-head output {
  font-size: 26px;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.slider-scale {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

/* A range input has to be styled per engine; unstyled it ignores the palette. */
input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  outline: none;
  margin: 0;
}
input[type='range']:disabled { opacity: 0.4; }
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text);
  border: 3px solid var(--accent);
  cursor: pointer;
}
input[type='range']::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text);
  border: 3px solid var(--accent);
  cursor: pointer;
}
input[type='range']:focus-visible { box-shadow: 0 0 0 3px #f4a15d44; }

.toggle-list { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; }
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.toggle-row:last-child { border-bottom: none; }
.toggle-text { display: flex; flex-direction: column; gap: 2px; }
.toggle-text strong { font-weight: 600; }
.toggle-text small { color: var(--muted); font-size: 12.5px; }

/* The checkbox itself becomes the track; ::before is the sliding knob. */
input.switch {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex: 0 0 auto;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  margin: 0;
}
input.switch::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  transform: translateY(-50%);
  transition: left 0.15s ease, background 0.15s ease;
}
input.switch:checked { background: var(--accent-dim); border-color: var(--accent); }
input.switch:checked::before { left: 23px; background: var(--accent); }
input.switch:disabled { opacity: 0.4; cursor: default; }
input.switch:focus-visible { box-shadow: 0 0 0 3px #f4a15d44; }

@media (prefers-reduced-motion: reduce) {
  input.switch,
  input.switch::before { transition: none; }
}

/* ---- landing page: brand, hero, and the cycling price strip ---- */

.brand { text-decoration: none; color: inherit; }
/*
 * The mark is a 500x500 PNG whose star covers only the middle ~65%, and whose
 * padding is 20px wider on the right than the left. Sized to the canvas it
 * therefore reads small and sits visibly left of centre, so the box is scaled
 * up to compensate and nudged back by half the difference.
 */
.logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  display: block;
  flex: 0 0 auto;
  transform: translate(2%, 0.7%);
}
.topbar h1 { font-size: 21px; letter-spacing: 0.3px; }

.hero { text-align: center; padding: 40px 16px 8px; }
.tagline {
  margin: 0 auto;
  max-width: 720px;
  font-size: clamp(24px, 4.4vw, 40px);
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.4px;
}
.tagline em {
  font-style: normal;
  color: var(--accent);
  /* The word being emphasised is the point of the sentence. */
  text-transform: uppercase;
}

.showcase {
  margin: 30px auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
}

/*
 * No panel: the item stands on the page. Height is reserved so swapping cards
 * never shifts the footer under the reader mid-animation.
 */
.showcase-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  min-height: clamp(300px, 42vw, 400px);
  opacity: 0;
}
.showcase-card.in { animation: showcase-in 3.4s ease forwards; }

/* One animation covers the whole slot: in, hold, out. Keeping it as a single
 * keyframe set means the card cannot be left half-faded if a tick is missed. */
@keyframes showcase-in {
  0% { opacity: 0; transform: translateY(14px) scale(0.97); }
  12% { opacity: 1; transform: translateY(0) scale(1); }
  85% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-10px) scale(0.99); }
}

.showcase-icon { flex: 0 0 auto; display: flex; }
.showcase-icon .icon {
  /* .icon is an inline span - it draws at zero unless it is laid out as a
     block. In the tables its flex parent does that for it; here nothing does. */
  display: block;
  width: clamp(150px, 24vw, 230px);
  height: clamp(150px, 24vw, 230px);
  perspective: 900px;
}
.showcase-name {
  font-size: clamp(18px, 2.4vw, 24px);
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.2px;
}

/* Minecraft chat green, with the hard offset shadow the game draws behind it. */
.mc-price {
  font-family: "Pixelify Sans", "Segoe UI", system-ui, sans-serif;
  font-size: clamp(42px, 7vw, 74px);
  font-weight: 600;
  line-height: 1;
  color: #55ff55;
  text-shadow: 0.07em 0.07em 0 #153f15;
  font-variant-numeric: tabular-nums;
}

.showcase-dots { display: flex; gap: 7px; }
.showcase-dots .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line);
  transition: background 0.25s ease;
}
.showcase-dots .dot.on { background: var(--accent); }

@media (max-width: 520px) {
  .showcase-card { min-height: 280px; gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .showcase-card.in { animation: none; opacity: 1; }
  .showcase-dots .dot { transition: none; }
}

/* ---- browse: filter and sort sit on one line ---- */

.browse-controls { flex-wrap: wrap; align-items: center; }
.browse-controls #filter { flex: 1 1 260px; }
.sort-field { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.sort-field span {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
}
.sort-field select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.sort-field select:focus-visible { outline: none; box-shadow: 0 0 0 3px #f4a15d44; }
