/* Load after style.css, only on /items. The layout follows /store: a parchment rail, a toolbar, and the
   game's teal window glass holding the item list and the picked item. */

/* The art carries its own dark teal left side; the crop keeps the readers and the catalog in the strip. */
.banner--items .banner__art { object-position: 50% 60%; }
.banner--items .banner__copy { padding: 3.2rem 0 0 2.4rem; }
.banner--items h1 { font-size: 3.25rem; line-height: 1; }
.banner--items .ornament { width: 22rem; margin-top: .55rem; }

.itemdb {
  display: grid;
  grid-template-columns: 13.5rem minmax(0, 1fr);
  grid-template-areas:
    'rail toolbar'
    'rail results';
  column-gap: 1.25rem;
  align-items: start;
  width: min(var(--content-width), calc(100% - 2.5rem));
  padding-block: 1.35rem 2.5rem;
}

/* --- Rail: item types on parchment --- */

.idb-rail {
  grid-area: rail;
  display: grid;
  /* minmax(0, …): on tablets the shelves scroll in one row instead of widening the page */
  grid-template-columns: minmax(0, 1fr);
  gap: .85rem;
  padding: .85rem 1rem 1rem;
  border: 1px solid var(--gold-line);
  border-radius: 6px;
  background: #F8ECDC;
  box-shadow: inset 0 0 0 3px #FBF3E6, 0 1px 3px rgb(80 50 20 / 12%);
}

.idb-shelves ul {
  display: grid;
  gap: .15rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.idb-shelf-group {
  margin-top: .45rem;
  padding: .55rem .6rem .15rem;
  border-top: 1px solid var(--gold-line);
  color: var(--gold-ink);
  font: 600 .75rem var(--font-body);
  letter-spacing: .1em;
  text-transform: uppercase;
}

.idb-shelf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  width: 100%;
  min-height: 2.1rem;
  padding: .25rem .6rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text);
  background: none;
  font-size: .9375rem;
  text-align: left;
}

.idb-shelf--nested { padding-left: 1.1rem; }

.idb-shelf:hover {
  border-color: var(--gold-line);
  background: #FCF5E8;
}

.idb-shelf[aria-pressed='true'] {
  border-color: var(--gold);
  background: #FCF5E8;
  box-shadow: inset 3px 0 0 var(--gold);
  font-weight: 600;
}

.idb-shelf__count {
  flex: none;
  color: var(--muted);
  font: 400 .9375rem var(--font-numeral);
}

.idb-rail__note {
  padding-top: .75rem;
  border-top: 1px solid var(--gold-line);
  color: var(--muted);
  font-size: .875rem;
}

.idb-rail__note a { color: var(--link); }

/* --- Toolbar --- */

.idb-toolbar {
  grid-area: toolbar;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.idb-search { flex: 1; }

.idb-toolbar :is(input, select) {
  width: 100%;
  min-width: 0;
  min-height: 2.4rem;
  padding: .35rem .9rem;
  border: 1px solid #C9A46A;
  border-radius: var(--radius);
  color: var(--text);
  background-color: #FCF5E8;
  font-size: .9375rem;
}

.idb-search input {
  padding-left: 3rem;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234A4036' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-4-4'/%3E%3C/svg%3E") 1rem 50% / 1.15rem no-repeat,
    #FCF5E8;
}

.idb-toolbar select {
  appearance: none;
  padding-right: 2rem;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='%233A2412' stroke-width='1.6'%3E%3Cpath d='m1 1.5 5 5 5-5'/%3E%3C/svg%3E") right .7rem center / .75rem no-repeat,
    #FCF5E8;
}

.idb-kind select { width: 14rem; }
.idb-sort select { width: 11.5rem; }
.idb-toolbar select:disabled { opacity: .6; }

.idb-results {
  grid-area: results;
  min-width: 0;
}

.idb-results__header {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-block: .85rem .95rem;
}

.idb-results__header h2 {
  flex: none;
  color: var(--brown);
  font: 400 1.375rem var(--font-numeral);
  -webkit-text-stroke: .03em currentColor;
}

.idb-results__header .ornament { flex: 1; }

/* --- The game's window glass. Its tokens are prefixed so the portal's own stay untouched. --- */

.idb-album,
.idb-dialog {
  --idb-text: #FFF5DF;
  --idb-muted: #C9C3B4;
  --idb-line: rgb(205 170 110 / 28%);
  --idb-line-strong: rgb(205 170 110 / 55%);
  --idb-well: rgb(0 0 0 / 24%);
  --idb-side: 23rem;
  color: var(--idb-text);
}

.idb-album :focus-visible,
.idb-dialog :focus-visible { outline-color: var(--focus-on-dark); }

.idb-album {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--idb-side);
  align-items: start;
  border: 1px solid var(--idb-line);
  border-radius: 16px;
  background:
    linear-gradient(to left, rgb(0 0 0 / 12%) var(--idb-side), transparent var(--idb-side)),
    radial-gradient(120% 80% at 50% -10%, rgb(240 194 115 / 8%), transparent 60%),
    linear-gradient(180deg, #0E3D45, #061E24);
  box-shadow: 0 12px 32px rgb(40 24 8 / 28%), 0 0 0 1px rgb(205 170 110 / 18%);
}

.idb-album__list {
  min-width: 0;
  min-height: 24rem;
  align-self: stretch;
  padding: 12px;
  border-right: 1px solid var(--idb-line);
}

/* The item follows the reader down a long list. */
.idb-album__side {
  position: sticky;
  top: 0;
  max-height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

:is(.idb-album__side, .idb-dialog)::-webkit-scrollbar { width: 8px; }
:is(.idb-album__side, .idb-dialog)::-webkit-scrollbar-thumb { border-radius: 8px; background: rgb(205 170 110 / 35%); }
:is(.idb-album__side, .idb-dialog)::-webkit-scrollbar-track { background: transparent; }

/* --- List rows, like the game's inventory list: icon, name with slots, type --- */

.idb-rows {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.idb-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) minmax(0, 11rem) 3.5rem;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 4px 12px 4px 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: inherit;
  background: none;
  text-align: left;
}

.idb-rows li:nth-child(even) .idb-row { background: rgb(255 255 255 / 3%); }

.idb-row:hover {
  border-color: var(--idb-line);
  background: rgb(240 194 115 / 8%);
}

.idb-row[aria-current] {
  border-color: var(--idb-line-strong);
  background: linear-gradient(90deg, rgb(240 194 115 / 20%), rgb(240 194 115 / 6%));
  box-shadow: inset 3px 0 0 var(--gold-bright);
}

.idb-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 7px;
  color: #B89A66;
  background: radial-gradient(90% 80% at 50% 40%, #FBF6EA, #ECE2CB);
  box-shadow: inset 0 0 0 1px rgb(168 123 51 / 45%);
}

.idb-icon img {
  width: 24px;
  height: 24px;
  image-rendering: pixelated;
}

.idb-no-icon { width: 20px; height: 20px; }

.idb-row__name {
  overflow: hidden;
  color: var(--idb-text);
  font-size: .9375rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.idb-row__kind {
  overflow: hidden;
  color: var(--idb-muted);
  font-size: .8125rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.idb-row__meta {
  color: var(--gold-bright);
  font: 400 .9375rem var(--font-numeral);
  text-align: right;
}

.idb-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
  color: var(--idb-muted);
  font-size: .8125rem;
}

.idb-empty {
  display: grid;
  gap: 12px;
  justify-items: center;
  padding: 4rem 1rem;
  color: var(--idb-muted);
  text-align: center;
}

.idb-ghost,
.idb-world {
  appearance: none;
  border: 1px solid var(--idb-line-strong);
  border-radius: 6px;
  color: var(--idb-text);
  background: linear-gradient(180deg, rgb(240 194 115 / 16%), rgb(199 153 75 / 8%));
  transition: background .15s, border-color .15s;
}

.idb-ghost {
  min-height: 2.4rem;
  padding: 7px 14px;
  font: 600 .8125rem var(--font-body);
}

:is(.idb-ghost, .idb-world):hover {
  border-color: var(--gold-bright);
  background: linear-gradient(180deg, rgb(240 194 115 / 30%), rgb(199 153 75 / 16%));
}

/* --- Detail --- */

.idb-detail {
  display: grid;
  gap: 16px;
  padding: 20px 18px 24px;
}

.idb-detail--loading { color: var(--idb-muted); }

.idb-detail__head {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

/* kRO collection art (75x100, painted on white) on the game's parchment plate; multiply drops the white. */
.idb-plate {
  display: grid;
  place-items: center;
  aspect-ratio: 3 / 4;
  padding: 5px;
  border-radius: 7px;
  color: #B89A66;
  background: radial-gradient(90% 80% at 50% 40%, #FBF6EA, #ECE2CB);
  box-shadow: inset 0 0 0 1px rgb(168 123 51 / 45%), 0 6px 14px rgb(0 0 0 / 40%);
}

.idb-plate img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  mix-blend-mode: multiply;
}

.idb-plate img.idb-plate__icon { width: 48px; height: 48px; }
.idb-plate .idb-no-icon { width: 46%; height: auto; }

.idb-detail__name {
  color: var(--idb-text);
  font: 400 1.375rem/1.15 var(--font-heading);
  -webkit-text-stroke: .02em currentColor;
  overflow-wrap: anywhere;
}

.idb-detail__kind {
  margin-top: 4px;
  color: var(--gold-bright);
  font-size: .875rem;
}

.idb-detail__id {
  margin-top: 2px;
  color: var(--idb-muted);
  font: 400 .875rem var(--font-numeral);
}

.idb-stats {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--idb-line);
  border-radius: 10px;
  background: var(--idb-well);
}

.idb-stats div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.idb-stats dt {
  flex: none;
  color: var(--idb-muted);
  font-size: .8125rem;
}

.idb-stats dd {
  margin: 0;
  color: var(--idb-text);
  font-size: .875rem;
  text-align: right;
}

.idb-desc {
  color: var(--idb-text);
  font-size: .875rem;
  line-height: 1.55;
}

.idb-trade {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.idb-trade li,
.idb-badge {
  padding: 2px 9px;
  border: 1px solid var(--idb-line-strong);
  border-radius: 999px;
  color: var(--idb-text);
  font: 600 .75rem var(--font-body);
}

.idb-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--idb-line);
  color: var(--idb-text);
  font: 400 1.125rem var(--font-heading);
}

.idb-section-title__count {
  color: var(--idb-muted);
  font: 400 1rem var(--font-numeral);
}

.idb-drops { display: grid; gap: 10px; }

.idb-worlds {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: 6px;
}

.idb-world {
  min-height: 2.25rem;
  padding: 4px 8px;
  font: 600 .75rem var(--font-body);
}

.idb-world[aria-pressed='true'] {
  border-color: var(--gold-bright);
  color: #1F1608;
  background: linear-gradient(180deg, #F4D38F, #D6A24F);
}

.idb-drops__list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.idb-drop {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 10px;
  padding: 8px 10px;
  border: 1px solid var(--idb-line);
  border-radius: 8px;
  background: var(--idb-well);
}

.idb-drop__mob {
  color: var(--idb-text);
  font-size: .875rem;
  font-weight: 600;
}

.idb-drop__lv {
  color: var(--idb-muted);
  font-weight: 400;
}

.idb-badge {
  display: inline-block;
  margin-left: 2px;
  padding: 0 7px;
  font-size: .6875rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  vertical-align: 1px;
}

.idb-badge--mvp { border-color: #E3B54F; color: #1F1608; background: linear-gradient(180deg, #F4D38F, #D6A24F); }
.idb-badge--boss { border-color: #C46C76; color: #FFD9DD; }

.idb-drop__chance {
  color: var(--gold-bright);
  font: 400 1.0625rem var(--font-numeral);
  text-align: right;
}

.idb-drop__maps {
  display: flex;
  flex-wrap: wrap;
  grid-column: 1 / -1;
  gap: 2px 10px;
  color: var(--idb-muted);
  font-size: .75rem;
}

.idb-map__count { opacity: .75; }
.idb-map--none { font-style: italic; }

.idb-others summary {
  padding: 4px 2px;
  color: var(--idb-muted);
  font-size: .8125rem;
  cursor: pointer;
}

.idb-others summary:hover { color: var(--idb-text); }
.idb-others[open] summary { margin-bottom: 6px; }

.idb-note {
  color: var(--idb-muted);
  font-size: .8125rem;
  line-height: 1.45;
}

/* --- Phone dialog: the same detail, full screen --- */

.idb-dialog {
  width: 100%;
  max-width: none;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 0;
  background:
    radial-gradient(120% 80% at 50% -10%, rgb(240 194 115 / 8%), transparent 60%),
    linear-gradient(180deg, #0E3D45, #061E24);
}

.idb-dialog::backdrop { background: rgb(6 30 36 / 78%); }

.idb-dialog__close {
  position: sticky;
  z-index: 4;
  top: 0;
  display: flex;
  justify-content: flex-end;
  height: 0;
  margin: 0;
}

.idb-dialog__close button {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  margin: .5rem;
  padding: 0;
  border: 1px solid var(--idb-line-strong);
  border-radius: 50%;
  color: var(--idb-text);
  background: rgb(6 30 36 / 80%);
}

.idb-dialog__close svg { width: 1rem; height: 1rem; }
.idb-dialog__close button:hover { background: #0E3D45; }
.idb-dialog .idb-detail { padding-top: 24px; }
.idb-dialog .idb-detail__head { padding-right: 3rem; }

/* Narrow desktop: the type column goes, the name keeps its room. */
@media (max-width: 72rem) {
  .idb-row { grid-template-columns: 34px minmax(0, 1fr) 3.5rem; }
  .idb-row__kind { display: none; }
}

/* Tablet: the rail lies across the top, item types in a row. */
@media (max-width: 60rem) {
  .itemdb {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      'rail'
      'toolbar'
      'results';
    row-gap: 1rem;
  }

  .idb-shelves ul {
    display: flex;
    align-items: center;
    gap: .4rem;
    overflow-x: auto;
    padding: 2px 2px 4px;
  }

  .idb-shelf-group {
    flex: none;
    margin: 0;
    padding: 0 .1rem 0 .5rem;
    border-top: 0;
    border-left: 1px solid var(--gold-line);
  }

  .idb-shelf,
  .idb-shelf--nested {
    width: auto;
    min-height: 2.5rem;
    padding: .25rem .75rem;
    border-color: var(--gold-line);
    background: #FCF5E8;
    white-space: nowrap;
  }

  .idb-shelf[aria-pressed='true'] { box-shadow: inset 0 -3px 0 var(--gold); }
  .idb-rail__note { padding-top: .6rem; }
  .idb-row { grid-template-columns: 34px minmax(0, 1fr) minmax(0, 9rem) 3.5rem; }
  .idb-row__kind { display: block; }
  .idb-album { --idb-side: 20rem; }
}

/* Phone: the list alone; the item opens in the dialog. */
@media (max-width: 47.9375rem) {
  /* The art fills the phone banner behind the copy: a shade keeps the tagline readable. ::after comes
     after the img in the tree, so at the same z-index it paints over it (the shared ::before does not). */
  .banner--items::after {
    content: '';
    position: absolute;
    z-index: -1;
    inset: 0;
    background: rgb(6 36 44 / 55%);
  }

  .banner--items h1 { font-size: 2.25rem; }
  .banner--items .banner__copy { padding: 2.25rem 0; }
  .banner--items .ornament { width: min(16rem, 100%); }

  .itemdb { width: calc(100% - 2 * var(--gutter)); }
  .idb-toolbar { flex-wrap: wrap; gap: .75rem; }
  .idb-search { flex: 1 1 100%; }
  .idb-kind,
  .idb-sort { flex: 1 1 10rem; }
  .idb-kind select,
  .idb-sort select { width: 100%; }
  .idb-toolbar :is(input, select) { min-height: 2.75rem; }

  .idb-album {
    grid-template-columns: minmax(0, 1fr);
    background:
      radial-gradient(120% 80% at 50% -10%, rgb(240 194 115 / 8%), transparent 60%),
      linear-gradient(180deg, #0E3D45, #061E24);
  }

  .idb-album__list { padding: 8px 6px; border-right: 0; }
  .idb-album__side { display: none; }
  .idb-row {
    grid-template-columns: 34px minmax(0, 1fr) auto;
    grid-template-areas:
      'icon name meta'
      'icon kind meta';
    row-gap: 0;
    min-height: 52px;
  }

  .idb-icon { grid-area: icon; }
  .idb-row__name { grid-area: name; }
  .idb-row__kind { grid-area: kind; display: block; }
  .idb-row__meta { grid-area: meta; }
  .idb-dialog .idb-desc { font-size: .9375rem; }
  .idb-ghost,
  .idb-world { min-height: 2.75rem; }
}

@media (forced-colors: active) {
  .idb-plate,
  .idb-icon,
  .idb-dialog { border: 1px solid CanvasText; }
  .idb-row[aria-current] { outline: 2px solid Highlight; }
  .idb-shelf[aria-pressed='true'],
  .idb-world[aria-pressed='true'] { outline: 2px solid Highlight; }
}
