/* ASMODEVS palette and type, shared with Alchemy and Vesalius; item tooltips in Diablo II's Exocet */

@font-face {
  font-family: "Chakra Petch";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/chakra-petch-400.woff2") format("woff2");
}

@font-face {
  font-family: "Chakra Petch";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/chakra-petch-600.woff2") format("woff2");
}

/* Exocet Blizzard Light, from the old Diablogistic POC (commercial Emigre font, published without a web licence for now: see README) */
@font-face {
  font-family: "Exocet";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/exocet.woff2") format("woff2"), url("../fonts/exocet.ttf") format("truetype");
}

:root {
  --bg: #070405;
  --bg-raised: #0f0808;
  --panel: rgba(16, 9, 10, 0.9);
  --line: #2a1416;
  --line-strong: #4a2226;
  --text: #e8d4d0;
  --text-muted: #8e6f6b;
  --red: #ff4034;
  --red-deep: #b00e16;
  --ghost-dark: #6c060e;
  --ghost-pink: #ff3460;
  /* Cut corners, like the demo's buttons */
  --cut: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  --cut-sm: polygon(5px 0, 100% 0, 100% calc(100% - 5px), calc(100% - 5px) 100%, 0 100%, 0 5px);
  --header-h: 64px;

  /* Diablo II item colours */
  --d2-tooltip: rgba(0, 0, 0, 0.82);
  --d2-white: #d6d6d6;
  --d2-grey: #8a8a8a;
  --d2-magic: #6969ff;
  --d2-rare: #ffff64;
  --d2-set: #00c400;
  --d2-unique: #c7b377;
  --d2-crafted: #ffa800;
  --d2-runeword: #c7b377;
}

*, *::before, *::after { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: "Chakra Petch", "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
::selection { background: var(--red-deep); color: var(--text); }
* { scrollbar-color: var(--line-strong) transparent; scrollbar-width: thin; }

a { color: var(--text); text-decoration-color: var(--red-deep); }
a:hover { color: var(--red); }

[hidden] { display: none !important; }

.wrap { width: min(100% - 32px, 1320px); margin-inline: auto; }

main { flex: 1; padding: 28px 0 56px; }

h1, h2 { margin: 0; font-weight: 600; line-height: 1.15; }
h1 { font-family: "Exocet", "Chakra Petch", serif; font-size: clamp(1.6rem, 3vw, 2.2rem); letter-spacing: 0.04em; }
.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 8px 24px; margin-bottom: 22px; }
.page-intro { margin: 6px 0 0; color: var(--text-muted); }

/* Header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(7, 4, 5, 0.88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 28px;
  min-height: var(--header-h);
  padding: 8px 0;
}

.brand { display: flex; align-items: center; gap: 12px; color: var(--text-muted); }
.brand-mark { display: block; }
.brand-logo { display: block; width: 56px; height: auto; }
.brand-mark:hover .brand-logo, .brand-mark:focus-visible .brand-logo { animation: brand-glitch-burst 0.42s steps(1, end) 1; }
.brand-text { display: grid; gap: 3px; line-height: 1; color: inherit; text-decoration: none; }
.brand-name { color: var(--text); font-family: "Exocet", "Chakra Petch", serif; font-size: 19px; letter-spacing: 0.08em; }
.brand-by { font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; }
.brand-text:hover .brand-by { color: var(--red); }

/* Only on hover, so it doesn't distract. Ghosts sit left (maroon) and right (pink), as in the demo's glitch stack */
@keyframes brand-glitch-burst {
  0%   { filter: drop-shadow(-3px 0 var(--ghost-dark)) drop-shadow(3px 0 var(--ghost-pink)); transform: translateX(2px); }
  20%  { filter: none; transform: none; }
  35%  { filter: drop-shadow(-4px 0 var(--ghost-dark)) drop-shadow(2px 0 var(--ghost-pink)); transform: translateX(-3px) skewX(-8deg); }
  60%  { filter: drop-shadow(-2px 0 var(--ghost-dark)) drop-shadow(4px 0 var(--ghost-pink)); transform: translateX(1px); }
  80%, 100% { filter: none; transform: none; }
}

.nav { display: flex; gap: 22px; }
.nav a { color: var(--text-muted); font-weight: 500; text-decoration: none; padding: 4px 0; border-bottom: 2px solid transparent; }
.nav a:hover { color: var(--text); }
.nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--red); }

.acting { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; position: relative; }
.acting-label { color: var(--text-muted); font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; }
.acting select { width: auto; min-width: 170px; }
.acting-new {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 300px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 2px solid var(--red-deep);
  backdrop-filter: blur(8px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
}
.acting-new input { flex: 1 1 100%; }
.acting-message { flex-basis: 100%; margin: 0; color: var(--red); font-size: 12px; }
.acting-message:empty { display: none; }

/* Panels (asmodevs chrome) */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 2px solid var(--red-deep);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 10px 14px;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* The diamond from the demo's slider thumb */
.panel-title::before {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  background: var(--red);
  transform: rotate(45deg);
}

.panel-body { padding: 12px 14px 14px; border-top: 1px solid var(--line); }

.pt-toggle {
  display: none;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.pt-toggle:hover { background: var(--red-deep); border-color: var(--red-deep); }

/* Foldable blocks (sell form): −/+ at the top right; while folded, the header shows what is chosen in the block */
.panel-toggle { display: block; flex: none; width: 26px; height: 26px; font-size: 15px; }
.panel.is-collapsed > .panel-body { display: none; }
.panel-summary {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-left: 4px;
  padding-left: 14px;
  border-left: 1px solid var(--line-strong);
  overflow: hidden;
  cursor: pointer;
}
.panel:not(.is-collapsed) .panel-summary { display: none; }
.panel-summary-sprite { flex: none; width: 16px; height: 24px; object-fit: contain; }
.panel-summary-name {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-family: "Exocet", "Chakra Petch", serif;
  font-size: 14px;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.panel-summary:hover .panel-summary-name { text-decoration: underline; text-underline-offset: 3px; }
.panel-summary-meta { flex: none; color: var(--text-muted); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.panel-summary-runes { display: flex; flex: none; gap: 2px; }
.panel-summary-runes img { width: 18px; height: 18px; }
@media (max-width: 760px) { .panel-summary-meta { display: none; } }

/* Cut corners with the border closed across them (as in asmodevs-alchemy): the border is drawn by `border` on the
   straight edges and by two gradients on the diagonals, so the clip-path never leaves a corner open. Components set
   --edge (border colour), --fill (background) and --corner (cut size); their states change ONLY these variables, never
   border-color or background, or the diagonals would stop matching. */
.chip span, .picker-tag, .check-mark, .base-tile, .detail-item, .item-card, .runeword-tile, .socket-slot, .swatch span {
  --edge: var(--line-strong);
  --fill: transparent;
  --corner: 5px;
  border: 1px solid var(--edge);
  background:
    linear-gradient(to bottom right, transparent 50%, var(--edge) 50%, var(--edge) calc(50% + 1px), transparent calc(50% + 1px))
      top left / var(--corner) var(--corner) no-repeat border-box,
    linear-gradient(to top left, transparent 50%, var(--edge) 50%, var(--edge) calc(50% + 1px), transparent calc(50% + 1px))
      bottom right / var(--corner) var(--corner) no-repeat border-box,
    var(--fill);
  clip-path: polygon(var(--corner) 0, 100% 0, 100% calc(100% - var(--corner)), calc(100% - var(--corner)) 100%, 0 100%, 0 var(--corner));
}

/* Buttons */

.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 0;
  background: var(--red);
  color: var(--bg);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  clip-path: var(--cut-sm);
}
.action-button:hover { background: #ff5a4f; color: var(--bg); }
.action-button:active { transform: translateY(1px); }
.action-button.is-ghost { background: var(--line-strong); color: var(--text); }
.action-button.is-ghost:hover { background: var(--red-deep); }
.action-button.is-large { padding: 13px 22px; font-size: 14px; clip-path: var(--cut); }
.action-button:disabled { background: var(--line); color: var(--text-muted); cursor: not-allowed; transform: none; }

/* Form fields */

.field { display: grid; gap: 5px; margin: 0 0 14px; }
.field:last-child { margin-bottom: 0; }
.field-label, legend.field-label {
  padding: 0;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.field-hint { margin: 0; color: var(--text-muted); font-size: 12px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: end; margin: 0 0 14px; }
.field-row > .field { margin: 0; }
fieldset.field { border: 0; padding: 0; min-width: 0; }

.field-control {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  line-height: 20px;
}
input.field-control, select.field-control { height: 36px; }
.field-control::placeholder { color: var(--text-muted); }
.field-control:focus { border-color: var(--red); outline: none; }
.field-control:disabled { color: var(--text-muted); }
select.field-control { cursor: pointer; }
.field-control[aria-invalid="true"] { border-color: var(--red); }

.check { position: relative; display: flex; align-items: center; gap: 9px; min-height: 24px; cursor: pointer; user-select: none; }
.check:has(input:disabled) { cursor: default; opacity: 0.45; }
/* Next to text inputs (a form field's control), as tall as them */
.field > .check { min-height: 36px; }

/* Checkboxes are switches: a hidden native checkbox drives a cut-corner track with a sliding cut-corner knob.
   Markup: <label class="check"><input type="checkbox"><span class="check-mark" aria-hidden="true"></span>Text</label>
   (Chamfered-box and diamond alternatives are kept in design/checkbox-alternatives.md.) */
.check input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.check-mark { --fill: var(--bg); position: relative; flex: none; width: 38px; height: 20px; }
.check-mark::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  background: var(--text-muted);
  clip-path: polygon(3px 0, 100% 0, 100% calc(100% - 3px), calc(100% - 3px) 100%, 0 100%, 0 3px);
  transition: left 0.15s, background 0.15s;
}
.check:hover .check-mark { --edge: var(--text-muted); }
.check input:checked + .check-mark { --edge: var(--red); --fill: color-mix(in srgb, var(--red-deep) 55%, var(--bg)); }
.check input:checked + .check-mark::after { left: 21px; background: var(--red); }
.check input:focus-visible + .check-mark { --edge: var(--red); --fill: rgba(255, 64, 52, 0.18); }
.check input:checked:focus-visible + .check-mark { --fill: color-mix(in srgb, var(--red-deep) 75%, var(--bg)); }

/* Toggle chips (tier, quality): checkbox or radio inside a label */
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block;
  padding: 4px 9px;
  color: var(--c, var(--text));
  font-size: 12px;
}
.chip:hover span { --edge: var(--text-muted); }
.chip input:checked + span { --edge: var(--red); --fill: color-mix(in srgb, var(--red-deep) 55%, transparent); }
.chip input:focus-visible + span { --edge: var(--red); --fill: rgba(255, 64, 52, 0.18); }

/* Multiple choice searchable list (picker.js): chosen tags and a text box that only filters the list below */
.picker-box {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 36px;
  padding: 4px;
  border: 1px solid var(--line);
  background: var(--bg);
  cursor: text;
}
.picker-box:focus-within { border-color: var(--red); }
.picker-tags { display: contents; margin: 0; padding: 0; list-style: none; }
.picker-tag {
  --fill: color-mix(in srgb, var(--red-deep) 30%, transparent);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 2px 2px 2px 8px;
  color: var(--text);
  font-size: 12px;
}
.picker-tag > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-tag-remove {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.picker-tag-remove:hover, .picker-tag-remove:focus-visible { color: var(--text); background: var(--red-deep); outline: none; }
.picker-input {
  flex: 1 1 120px;
  min-width: 0;
  height: 26px;
  padding: 0 5px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
.picker-input::placeholder { color: var(--text-muted); }
.picker-input:focus { outline: none; }
/* Opens in the flow (not floating): the filters panel scrolls, and would clip a floating list */
.picker-list {
  max-height: 280px;
  margin: -1px 0 0;
  padding: 0 0 4px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  background: var(--bg-raised);
  list-style: none;
  overscroll-behavior: contain;
}
.picker-group {
  position: sticky;
  top: 0;
  padding: 6px 9px 4px;
  background: var(--bg-raised);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.picker-option {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 5px 9px;
  font-size: 13px;
  cursor: pointer;
}
.picker-option:hover, .picker-option.is-active { background: color-mix(in srgb, var(--red-deep) 35%, transparent); }
.picker-hint { flex-shrink: 0; max-width: 55%; color: var(--text-muted); font-size: 11px; text-align: right; }
.picker-empty { padding: 8px 9px; color: var(--text-muted); font-size: 12px; }

/* Status boxes (loading / empty / error) */

.status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin: 0;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-left: 2px solid var(--red);
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.status.is-error { color: var(--text); text-transform: none; letter-spacing: 0; font-size: 14px; }
.status + .status { margin-top: 10px; }

.notice {
  margin: 0 0 16px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-left: 2px solid var(--d2-set);
  background: color-mix(in srgb, var(--d2-set) 8%, var(--bg));
}
.notice.is-error { border-left-color: var(--red); background: color-mix(in srgb, var(--red) 8%, var(--bg)); }
.notice ul { margin: 4px 0 0; padding-left: 18px; }

/* Diablo II tooltip */

.d2-tooltip {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 14px 12px;
  background: var(--d2-tooltip);
  color: var(--d2-white);
  font-family: "Exocet", "Chakra Petch", serif;
  font-size: 13px;
  line-height: 1.35;
  letter-spacing: 0.02em;
  text-align: center;
}
.d2-tooltip.is-large { gap: 16px; padding: 22px 18px; font-size: 16px; }
.d2-text p { margin: 0; }
.d2-name { font-size: 1.08em; }
/* Item picture: the sprite fills a box of its inventory proportions, and the sockets are laid over it */
.d2-picture { position: relative; width: 98px; aspect-ratio: 2 / 3; }
.d2-picture.is-large { width: 196px; }
.d2-sprite { display: block; width: 100%; height: 100%; object-fit: contain; }
/* Ethereal items are drawn translucent in the game; only the item, never what sits in its sockets */
.d2-sprite.is-ethereal { opacity: 0.55; }

/* Sockets: centres from data/socket-layouts.json as % of the box; --cell is one inventory cell (% of the width) */
.sockets { position: absolute; inset: 0; pointer-events: none; }
.socket {
  position: absolute;
  width: calc(var(--cell) * 0.82);
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  /* Empty: a dark, semi-transparent hole with a faint rim, like the game draws it over the item */
  background: radial-gradient(circle, rgba(0, 0, 0, 0.62) 58%, rgba(0, 0, 0, 0.4) 72%, rgba(0, 0, 0, 0.15) 100%);
  box-shadow: inset 0 0 0 1px rgba(196, 178, 150, 0.32), inset 0 2px 5px rgba(0, 0, 0, 0.85), 0 0 2px rgba(0, 0, 0, 0.6);
}
.socket.is-filled { width: calc(var(--cell) * 0.9); background: none; box-shadow: none; }
.socket img { display: block; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8)); }

.q-normal, .q-superior { color: var(--d2-white); }
.q-plain, .q-low { color: var(--d2-grey); }
.q-magic { color: var(--d2-magic); }
.q-rare { color: var(--d2-rare); }
.q-set { color: var(--d2-set); }
.q-unique { color: var(--d2-unique); }
.q-crafted { color: var(--d2-crafted); }
.q-runeword { color: var(--d2-runeword); }
.d2-text .d2-set-name { margin-top: 6px; color: var(--d2-unique); }

/* Item cards (market, my listings) */

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

.item-card {
  --corner: 8px;
  --fill: var(--bg-raised);
  display: flex;
  flex-direction: column;
  height: 100%;
  color: var(--text);
  text-decoration: none;
}
.item-card:hover, .item-card:focus-visible { --edge: var(--red); color: var(--text); outline: none; }
.item-card .d2-tooltip { flex: 1; align-content: start; background: transparent; }

.item-card-top, .item-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  font-size: 11px;
}
.item-card-top { border-bottom: 1px solid var(--line); }
.item-card-foot { border-top: 1px solid var(--line); }
.item-card-tier { color: var(--text-muted); letter-spacing: 0.1em; text-transform: uppercase; }
.item-card-meta { display: grid; justify-items: end; gap: 2px; min-width: 0; }
.item-card-seller { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-card-offers { color: var(--red); font-weight: 600; letter-spacing: 0.06em; white-space: nowrap; }

.badge {
  flex: none;
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  clip-path: var(--cut-sm);
}
.badge.is-available { background: color-mix(in srgb, var(--d2-set) 18%, transparent); color: #6fdc6f; }
.badge.is-sold { background: var(--red-deep); color: var(--text); }
.badge.is-in_trade { background: color-mix(in srgb, var(--d2-crafted) 22%, transparent); color: var(--d2-crafted); }

/* Prices in runes and gems */

.price { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 0; padding: 0; list-style: none; }
.price li { display: flex; align-items: center; gap: 3px; }
.price img { display: block; width: 28px; height: 28px; }
.price-qty { color: var(--text); font-size: 12px; font-variant-numeric: tabular-nums; }
.price.is-large { gap: 10px 18px; }
.price.is-large img { width: 40px; height: 40px; }
.price.is-large .price-qty { font-size: 15px; }
.price-name { color: var(--text-muted); font-size: 13px; }

/* Market */

.market { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 24px; align-items: start; }
.filters { position: sticky; top: calc(var(--header-h) + 16px); max-height: calc(100dvh - var(--header-h) - 32px); overflow: auto; }
.filters-actions { display: flex; gap: 8px; margin-top: 16px; }
.filters-actions .action-button { flex: 1; }

.stat-filters { display: grid; gap: 6px; margin: 0 0 8px; padding: 0; list-style: none; }
.stat-filter { display: grid; grid-template-columns: 1fr 70px 28px; gap: 6px; align-items: center; font-size: 12px; }
.stat-filter-label { color: var(--d2-magic); font-family: "Exocet", "Chakra Petch", serif; font-size: 12px; }
.stat-filter-flag { color: var(--text-muted); font-size: 11px; text-align: center; }

.icon-button {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.icon-button:hover { background: var(--red-deep); border-color: var(--red-deep); color: var(--text); }

.results-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.results-count { margin: 0; color: var(--text-muted); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; }
.results-sort { display: flex; align-items: center; gap: 8px; }
.results-sort select { width: auto; }

.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 22px; color: var(--text-muted); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }

/* Listing detail */

.detail { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.detail-item { --edge: var(--line); --fill: var(--bg-raised); --corner: 8px; display: grid; justify-items: center; padding: 24px; }
.detail-item .d2-tooltip { min-width: min(100%, 360px); }
.detail-meta { margin: 12px 0 0; color: var(--text-muted); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0 0 16px; font-size: 14px; }
.facts dt { color: var(--text-muted); font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; align-self: center; }
.facts dd { margin: 0; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.detail-actions .is-wide { flex: 1 1 100%; }
.detail-note { flex-basis: 100%; margin: 0; color: var(--text-muted); font-size: 12px; }
/* Offers (listing detail): the right column stacks Trade with the offer form (buyers) or the offers (seller) */
.detail-side { display: grid; gap: 18px; }
.sold-box, .own-offer, .trade-box { display: grid; gap: 10px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.sold-box p, .own-offer p, .trade-box p { margin: 0; }
.trade-box { padding: 12px; border: 1px solid var(--line); border-left: 2px solid var(--d2-crafted); background: var(--bg); }
.trade-box .action-button { justify-self: start; }
.own-offer .action-button { justify-self: start; }
.offer-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.offer { display: grid; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); background: var(--bg); }
.offer p { margin: 0; }
.offer-head { display: flex; justify-content: space-between; gap: 8px; }
.offer-buyer { font-weight: 600; }
.offer-date { color: var(--text-muted); font-size: 12px; }
.offer-actions { display: flex; gap: 8px; }
.offer-submit { display: grid; gap: 10px; margin-top: 14px; }
/* My offers: the offer under its listing's card */
.offer-card { display: grid; }
.offer-strip { display: grid; gap: 6px; padding: 8px 10px; border: 1px solid var(--line); border-top: 0; background: var(--bg-raised); font-size: 12px; }
.offer-strip.is-accepted { border-left: 2px solid var(--d2-set); }
.offer-strip.is-pending { border-left: 2px solid var(--red); }
.offer-strip.is-accepted.is-listing-in_trade, .offer-strip.is-pending.is-listing-in_trade { border-left-color: var(--d2-crafted); }
.offer-strip-label { color: var(--text-muted); }
.back-link { display: inline-block; margin-bottom: 16px; color: var(--text-muted); font-size: 13px; text-decoration: none; }

/* Sell form */

.sell { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.sell-steps { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
/* Blocks not shown yet (nothing chosen) take no room, not even the gap */
.sell-steps > :empty { display: none; }
/* Parts of one block (Item properties: general, magic properties, sockets), separated by a line */
.panel-part:empty { display: none; }
.panel-part:not(:empty) ~ .panel-part:not(:empty) { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.panel-subsection-title { margin: 0 0 12px; color: var(--text); font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; }
.sell-preview-body { padding: 0; }
.sell-preview { position: sticky; top: calc(var(--header-h) + 16px); }
.sell-preview .d2-tooltip { min-height: 300px; align-content: start; }
.sell-preview .price { justify-content: center; padding: 12px; border-top: 1px solid var(--line); }
.sell-submit { display: grid; gap: 10px; padding: 14px; border-top: 1px solid var(--line); }

.tier-group + .tier-group { margin-top: 16px; }
.tier-group-title { margin: 0 0 8px; color: var(--text-muted); font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; }
.base-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 6px; }
.base-tile {
  --edge: var(--line);
  --fill: var(--bg);
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 8px 6px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.base-tile img { width: 49px; height: 73px; object-fit: contain; }
.base-tile-name { font-family: "Exocet", "Chakra Petch", serif; font-size: 11.5px; line-height: 1.2; text-align: center; }
.base-tile-meta { color: var(--text-muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.base-tile:hover { --edge: var(--text-muted); }
.sell-steps .chips + .field-hint { margin-top: 10px; }
.base-tile[aria-pressed="true"] { --edge: var(--red); --fill: color-mix(in srgb, var(--red-deep) 22%, var(--bg)); }
.base-tile:focus-visible { outline: none; --edge: var(--red); }
.base-tile:disabled { cursor: default; }
/* Unique and set item tiles: name, set, base and level stacked from the top, whatever the row's height */
.named-tile { align-content: start; gap: 2px; }
.named-tile img { margin-bottom: 4px; }
.named-tile .base-tile-name { margin-bottom: 2px; }
.named-tile .base-tile-meta { line-height: 1.3; text-align: center; }

.details-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; align-items: start; }
.details-grid .is-full { grid-column: 1 / -1; }

.stat-add { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 12px; }
.stat-rows, .price-rows { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.stat-row { display: grid; grid-template-columns: 1fr 90px 28px; gap: 8px; align-items: center; }
.stat-row-label { color: var(--d2-magic); font-family: "Exocet", "Chakra Petch", serif; font-size: 13px; }
.stat-row-flag { color: var(--text-muted); font-size: 12px; text-align: center; }
.empty-hint { margin: 0; color: var(--text-muted); font-size: 13px; }

.currency-group + .currency-group { margin-top: 10px; }
.currency-grid { display: flex; flex-wrap: wrap; gap: 4px; }
.currency-button {
  width: 40px;
  height: 40px;
  padding: 2px;
  border: 1px solid var(--line);
  background: var(--bg);
  cursor: pointer;
}
.currency-button img { display: block; width: 100%; height: 100%; }
.currency-button:hover, .currency-button:focus-visible { border-color: var(--red); outline: none; }
.currency-button[aria-pressed="true"] { border-color: var(--red); background: color-mix(in srgb, var(--red-deep) 30%, var(--bg)); }
.price-rows { margin-top: 12px; }
.price-row { display: grid; grid-template-columns: 32px 1fr 80px 28px; gap: 8px; align-items: center; }
.price-row img { width: 32px; height: 32px; }
.price-total { margin: 10px 0 0; color: var(--text-muted); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }

/* Runewords (sell form) */

.runeword-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; }
.runeword-tile {
  --edge: var(--line);
  --fill: var(--bg);
  display: grid;
  gap: 4px;
  padding: 8px 10px;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.runeword-tile:hover { --edge: var(--text-muted); }
.runeword-tile:focus-visible { outline: none; --edge: var(--red); }
.runeword-tile[aria-pressed="true"] { --edge: var(--red); --fill: color-mix(in srgb, var(--red-deep) 22%, var(--bg)); }
.runeword-tile:disabled { cursor: not-allowed; opacity: 0.45; }
.runeword-tile:disabled:hover { --edge: var(--line); }
.runeword-name { color: var(--d2-runeword); font-family: "Exocet", "Chakra Petch", serif; font-size: 13px; }
.runeword-runes { display: flex; gap: 2px; }
.runeword-runes img { width: 22px; height: 22px; }
.runeword-meta { color: var(--text-muted); font-size: 11px; }
.runeword-text { margin: 10px 0 0; padding: 8px 10px; border-left: 2px solid var(--d2-magic); color: var(--d2-magic); font-family: "Exocet", "Chakra Petch", serif; font-size: 12px; }
.runeword-text p { margin: 0; }
.stat-row.is-locked .field-control { color: var(--text-muted); }
.stat-range { color: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-row.has-range { grid-template-columns: 1fr 90px auto; }

/* Socket editor (sell form): one slot per socket, in fill order */

.socket-slots { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.socket-slot {
  --edge: var(--line);
  --fill: var(--bg);
  display: grid;
  grid-template-columns: 36px auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
}
.socket-slot.is-next { --edge: var(--line-strong); }
.socket-slot.is-locked { opacity: 0.5; }
.socket-slot-icon { width: 36px; height: 36px; border-radius: 50%; background: radial-gradient(circle, rgba(0, 0, 0, 0.7) 58%, rgba(0, 0, 0, 0.3) 100%); box-shadow: inset 0 0 0 1px rgba(196, 178, 150, 0.32); }
.socket-slot-icon img { display: block; width: 100%; height: 100%; }
.socket-slot-label { white-space: nowrap; color: var(--text-muted); font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; }
.socket-slot-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.socket-slot-controls select { width: auto; min-width: 180px; flex: 1; }

/* Jewel colour swatches (sell form and market filter) */

.swatches { display: flex; flex-wrap: wrap; gap: 4px; }
.swatch { position: relative; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch span { --edge: var(--line); --fill: var(--bg); display: block; width: 34px; height: 34px; padding: 3px; }
.swatch span img { display: block; width: 100%; height: 100%; }
.swatch:hover span { --edge: var(--text-muted); }
.swatch input:checked + span { --edge: var(--red); --fill: color-mix(in srgb, var(--red-deep) 30%, var(--bg)); }
.swatch input:focus-visible + span { --edge: var(--red); }

/* Tabs (my listings), styled like the asmodevs language switch */

.tabs { display: inline-flex; margin-bottom: 18px; border: 1px solid var(--line); border-top: 2px solid var(--red-deep); background: var(--panel); }
.tabs button {
  padding: 8px 16px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
}
.tabs button + button { border-left: 1px solid var(--line); }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { background: var(--red); color: var(--bg); }

/* Footer */

.site-footer { border-top: 1px solid var(--line); padding: 18px 0; color: var(--text-muted); font-size: 12px; }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }

@media (prefers-reduced-motion: reduce) {
  .check-mark::after { transition: none; }
  .brand-mark:hover .brand-logo, .brand-mark:focus-visible .brand-logo { animation: none; }
}

/* Narrow screens: one column, the filters fold into a collapsible panel. Keep in sync with SMALL_SCREEN in market.js. */
@media (max-width: 960px) {
  .detail, .sell { grid-template-columns: 1fr; }
  .sell-preview { position: static; order: -1; }
  .sell-preview .d2-tooltip { min-height: 0; }
}

@media (max-width: 760px) {
  main { padding-top: 18px; }
  .header-inner { gap: 8px 16px; }
  .brand-logo { width: 44px; }
  .brand-by { display: none; }
  .brand-name { font-size: 16px; }
  .nav { order: 3; flex-basis: 100%; gap: 18px; }
  .acting-label { display: none; }
  .acting select { min-width: 140px; }
  .acting-new { width: min(300px, calc(100vw - 32px)); }

  .market { grid-template-columns: 1fr; }
  .filters { position: static; max-height: none; }
  .pt-toggle { display: block; }
  .filters.is-collapsed .panel-body { display: none; }

  .item-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .details-grid { grid-template-columns: 1fr; }
  .detail-item { padding: 12px; }
}

/* Touch screens: larger targets, and 16px text in inputs so iOS doesn't zoom in when they are focused */
@media (pointer: coarse) {
  .field-control { font-size: 16px; }
  .action-button { padding: 10px 14px; }
  .icon-button { width: 36px; height: 36px; }
}
