/* Item search as a classic parchment book (2026-09-28). Sits on member.css (cm-book, cm-heading, cm-breadcrumb),
   same ink as the event / equipment books. Replaces item-database.css + item-database-nexus.css (the dark
   Nexus-era panels). Production CSP: everything lives here, nothing inline. */
.classic-itembook { --ib-ink:#4d3a2a; --ib-muted:#836b4c; --ib-wine:#7d414b; --ib-gold:#a4844c; --ib-line:#b59a6655; --ib-paper:#fffaf0; --ib-paper-2:#fbf3df; }
.ib-page .container { max-width: 1140px; }
.classic-itembook [hidden] { display: none !important; }
.ib-book :is(h1,h2,h3) { font-weight: 700; color: var(--ib-ink); }
.ib-book h2, .ib-book h3 { margin: 0; line-height: 1.5; }
.ib-seal { display: grid; place-items: center; width: 57px; height: 66px; flex-shrink: 0; color: #ead4a5; background: var(--ib-wine); clip-path: polygon(50% 0,96% 20%,96% 74%,50% 100%,4% 74%,4% 20%); }
.ib-seal svg { width: 28px; height: 28px; }

/* labels, notes, empty states */
.ib-label { display: flex; align-items: center; gap: 9px; margin: 0 0 14px !important; font-size: 19px; }
.ib-label svg { width: 21px; height: 21px; color: #9d7b46; }
.ib-count { display: inline-grid; place-items: center; min-width: 26px; padding: 1px 8px; border: 1px solid #c2a76c66; border-radius: 3px; background: #f1dfb5; color: #805b28; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cm-book .ib-note { margin: 0 0 14px; color: var(--ib-muted); font-size: 12px; line-height: 1.8; }
.cm-book .ib-empty { margin: 0; padding: 22px 18px; border: 1px dashed #b79b6a99; border-radius: 3px; background: #f3e6c6a0; color: #7a6238; font-size: 14px; text-align: center; }
.ib-alert { display: grid; gap: 4px; margin: 0 0 22px; padding: 15px 17px; border: 1px solid #ac6b6e; border-left-width: 3px; border-radius: 3px; background: #f1dfd7; color: #8b4148; font-size: 13px; }
.ib-back { margin: -10px 0 18px !important; font-size: 13px; }
.ib-back a { color: var(--ib-wine); }
.ib-section + .ib-section { margin-top: 30px; padding-top: 24px; border-top: 1px solid var(--ib-line); }

/* buttons: style.css gives every <button> the template's orange image, a fixed 182x42 box, white uppercase
   text and a drop shadow. :where() keeps this reset at one class of specificity, so the component rules
   below (same specificity, later) still win. */
.ib-book :where(button) { width: auto; height: auto; background-image: none; color: inherit !important; font-family: inherit; text-transform: none; text-shadow: none; letter-spacing: 0; filter: none; }
.ib-book :where(button):hover { filter: none; }

/* buttons */
.ib-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 18px; border: 1px solid #bca175; border-radius: 3px; background: #fff7e3; color: var(--ib-wine) !important; font: inherit; font-size: 14px; font-weight: 600; line-height: 1.4; text-decoration: none; cursor: pointer; }
.ib-button:hover { border-color: var(--ib-wine); }
.ib-button--wine { border-color: #5c2b34; background: linear-gradient(115deg,#884b54,#6e343f); color: #fff0d2 !important; }
.ib-button--wine:hover { background: #773c47; color: #fff0d2 !important; }

/* search */
.ib-search { position: relative; margin: 0 0 28px; padding: 18px 20px; border: 1px solid var(--ib-line); border-top: 3px solid var(--ib-gold); border-radius: 3px; background: #fffaf0c9; box-shadow: 0 6px 15px #74562609; }
.ib-search__label { display: block; margin-bottom: 9px; color: #634931; font-size: 15px; font-weight: 600; }
.ib-search__row { position: relative; display: flex; gap: 10px; align-items: center; }
.ib-search__icon { position: absolute; z-index: 2; left: 13px; top: 50%; width: 20px; height: 20px; color: #9d7b46; transform: translateY(-50%); pointer-events: none; }
.ib-search__icon svg { width: 20px; height: 20px; }
.ib-search input { flex: 1; min-width: 0; min-height: 48px; padding: 10px 40px 10px 42px; border: 1px solid #b89a68; border-radius: 3px; background: #fffdf7; color: #4d3a2a; font: inherit; font-size: 16px; }
.ib-search input::placeholder { color: #a28c6a; }
.ib-search input:focus { outline: 2px solid #87464c; outline-offset: 1px; }
.ib-search__spinner { position: absolute; right: 118px; top: 50%; width: 18px; height: 18px; margin-top: -9px; border: 2px solid #d7c298; border-top-color: var(--ib-wine); border-radius: 50%; animation: ib-spin .8s linear infinite; }
.ib-search--filter .ib-search__spinner { display: none; }
@keyframes ib-spin { to { transform: rotate(360deg); } }
.cm-book .ib-search__hint { margin-top: 8px; color: var(--ib-muted); font-size: 12px; }
.ib-search__results { position: absolute; left: 20px; right: 20px; top: calc(100% - 26px); z-index: 30; max-height: min(460px, 70vh); overflow-y: auto; padding: 6px; border: 1px solid #b89a68; border-radius: 3px; background: #fffaf0; box-shadow: 0 16px 34px #3b2a1c45; }
.item-search-message { padding: 14px 12px; color: var(--ib-muted); font-size: 13px; text-align: center; }
.item-search-result { display: grid; grid-template-columns: 44px minmax(0,1fr) auto; align-items: center; gap: 12px; width: 100%; padding: 8px 10px; border: 0; border-radius: 3px; background: transparent; color: var(--ib-ink) !important; font: inherit; text-align: left; cursor: pointer; }
.item-search-result + .item-search-result { border-top: 1px solid #b59a6630; }
.item-search-result:hover, .item-search-result.is-active { background: #f3e5c6; }
.item-search-result__icon { display: grid; place-items: center; width: 44px; height: 44px; padding: 3px; border: 1px solid #b89c66; border-radius: 4px; background: #4c463c; }
.item-search-result__icon img { width: 36px; height: 36px; object-fit: contain; }
.item-search-result strong { display: block; overflow: hidden; color: #4a3423; font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.item-search-result small { display: block; overflow: hidden; color: var(--ib-muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.item-search-result__type { color: var(--ib-wine); font-size: 11px; font-weight: 600; white-space: nowrap; }
.item-search-result__type:empty { display: none; }

/* icon frame (the in-game slot look) */
.ib-icon { display: grid; place-items: center; width: 46px; height: 46px; flex-shrink: 0; padding: 3px; border: 1px solid #b89c66; border-radius: 4px; background: #4c463c; }
.ib-icon img { width: 38px; height: 38px; object-fit: contain; }
.ib-icon img.is-fallback { opacity: .5; }
.ib-icon--large { width: 74px; height: 74px; padding: 5px; border-width: 2px; }
.ib-icon--large img { width: 58px; height: 58px; }

/* rank colours = the in-game slot frame colours (frames/*.webp), darkened for paper */
.ib-rank--normal { color: #4a3423 !important; }
.ib-rank--magic { color: #56761a !important; }
.ib-rank--rare { color: #3346a8 !important; }
.ib-rank--epic { color: #b8561a !important; }
.ib-rank--unique { color: #7a3fb4 !important; }
.ib-rank--legend { color: #b8305e !important; }
.ib-rank--named { color: #9a7200 !important; }

/* rows (featured, rewards, dungeon items) */
.ib-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.ib-list--two { grid-template-columns: repeat(2, minmax(0,1fr)); column-gap: 12px; }
.ib-row { display: grid; grid-template-columns: 46px minmax(0,1fr) auto; align-items: center; gap: 13px; padding: 9px 12px; border: 1px solid #b79b6a40; border-radius: 3px; background: #fffaf0a8; color: var(--ib-ink); text-decoration: none; transition: border-color .15s, background .15s; }
.ib-row:hover { border-color: #7d414b88; background: #fff6e2; }
.ib-row__main { display: grid; min-width: 0; }
.ib-row__main strong { overflow: hidden; font-size: 15px; font-weight: 700; line-height: 1.45; text-overflow: ellipsis; white-space: nowrap; }
.ib-row__main small { overflow: hidden; color: var(--ib-muted); font-size: 12px; line-height: 1.5; text-overflow: ellipsis; white-space: nowrap; }
.ib-row__go { color: #a78a54; font-size: 22px; }
.ib-row__rate { display: grid; justify-items: end; color: var(--ib-wine); font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ib-row__rate small { color: var(--ib-muted); font-size: 10px; font-weight: 400; }
.box-odds-hint { display: block; color: var(--ib-muted); font-size: 10px; font-weight: 400; }

/* landing */
.ib-landing { display: grid; grid-template-columns: minmax(0,1.6fr) minmax(0,1fr); gap: 28px; align-items: start; }
.ib-landing .ib-section + .ib-section { margin-top: 0; padding-top: 0; border-top: 0; }
.ib-dungeon-link { padding: 22px; border: 1px solid var(--ib-line); border-left: 3px solid var(--ib-wine); border-radius: 3px; background: var(--ib-paper); }
.cm-book .ib-dungeon-link p { margin-bottom: 16px; color: var(--ib-muted); font-size: 13px; line-height: 1.85; }

/* item header */
.ib-item-head { display: flex; align-items: center; gap: 18px; padding-bottom: 20px; margin-bottom: 18px; border-bottom: 1px solid #a888514d; }
.ib-item-head__text { min-width: 0; }
.ib-item-head h1 { margin: 3px 0 2px; font-size: 30px; line-height: 1.35; overflow-wrap: anywhere; }
.cm-book .ib-item-head__rank { color: var(--ib-muted); font-size: 13px; }
.ib-facts { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; margin: 0 0 26px; }
.ib-facts > div { padding: 10px 14px; border: 1px solid var(--ib-line); border-radius: 3px; background: var(--ib-paper-2); min-width: 0; }
.ib-facts dt { color: var(--ib-muted); font-size: 11px; }
.ib-facts dd { margin: 2px 0 0; color: var(--ib-ink); font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }

/* tabs */
.ib-tablist { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--ib-line); }
.ib-tablist button { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 8px 18px; border: 1px solid #b79b6a88; border-radius: 3px; background: var(--ib-paper-2); color: #6d5636 !important; font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.ib-tablist button span { padding: 0 7px; border-radius: 3px; background: #e9d9b3; color: #7a5b2e; font-size: 12px; font-variant-numeric: tabular-nums; }
.ib-tablist button:hover:not(:disabled) { border-color: var(--ib-wine); color: var(--ib-wine) !important; }
.ib-tablist button.is-active { border-color: #5c2b34; background: var(--ib-wine); color: #f6e4bd !important; }
.ib-tablist button.is-active span { background: #f6e4bd33; color: #f6e4bd; }
.ib-tablist button:disabled { opacity: .45; cursor: default; }
.ib-tablist button:focus-visible { outline: 3px solid #b8892a; outline-offset: 2px; }
.ib-panel { display: none; }
.ib-panel.is-active { display: block; }

/* drop locations */
.ib-places { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.ib-place { padding: 12px 16px 10px; border: 1px solid var(--ib-line); border-left: 3px solid var(--ib-gold); border-radius: 3px; background: var(--ib-paper); }
.ib-place__name { margin: 0 0 6px !important; font-size: 16px; }
.ib-ways { display: grid; margin: 0; padding: 0; list-style: none; }
.ib-way { display: grid; grid-template-columns: minmax(0,1fr) minmax(90px,auto) 52px 82px; align-items: center; gap: 12px; padding: 7px 0; border-top: 1px dashed #b59a6644; font-size: 13px; }
.ib-way:first-child { border-top: 0; }
.ib-way__source { display: grid; min-width: 0; }
.ib-way__source strong { color: #5b4330; font-weight: 600; overflow-wrap: anywhere; }
.ib-way__source small { color: var(--ib-muted); font-size: 11px; }
.ib-way__diff { color: #6f5838; font-size: 12px; }
.ib-way__qty { color: var(--ib-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.ib-way__rate { color: var(--ib-wine); font-size: 15px; font-variant-numeric: tabular-nums; text-align: right; }
.ib-more { margin-top: 12px; }
.ib-more > summary { display: inline-block; margin-bottom: 10px; color: var(--ib-wine); font-size: 13px; font-weight: 600; cursor: pointer; }
.ib-more > summary:focus-visible { outline: 2px solid #87464c; outline-offset: 3px; }

/* calculator / simulator */
.ib-tool { margin: 0 0 20px; padding: 16px 18px; border: 1px solid var(--ib-line); border-top: 3px solid var(--ib-gold); border-radius: 3px; background: #fffaf0c9; }
.ib-tool h3 { margin-bottom: 10px !important; font-size: 16px; }
.ib-tool__controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-bottom: 12px; }
.ib-tool__controls label { display: grid; gap: 4px; color: var(--ib-muted); font-size: 12px; }
/* margin 0: the template's style.css gives every select a 15px bottom margin, which pushed the button below the selects */
.ib-tool select { margin: 0; min-width: 96px; min-height: 42px; padding: 8px 10px; border: 1px solid #b89a68; border-radius: 3px; background: #fffdf7; color: #594330; font: inherit; font-size: 15px; }
.enhance-calc__result, .box-sim__result { margin: 0 0 12px; padding: 14px; border: 1px solid var(--ib-line); border-radius: 3px; background: var(--ib-paper-2); }
.enhance-calc__figures { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
.enhance-calc__figures > div { display: grid; gap: 2px; }
.enhance-calc__figures span { color: var(--ib-muted); font-size: 11px; line-height: 1.5; }
.enhance-calc__figures b { color: var(--ib-wine); font-size: 20px; font-variant-numeric: tabular-nums; }
.cm-book .enhance-calc__range, .cm-book .box-sim__summary { margin: 10px 0 6px; color: #6f5838; font-size: 12px; }
.cm-book .enhance-calc__warning { margin: 8px 0; padding: 8px 10px; border-left: 3px solid #9b5960; background: #f1dfd7; color: #8b4148; font-size: 12px; }
.enhance-calc__materials, .box-sim__list, .ib-materials { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 0; padding: 0; list-style: none; }
.enhance-calc__materials li, .box-sim__list li, .ib-materials li { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border: 1px solid #b69c6960; border-radius: 3px; background: #fffaf0; color: #5b4330; font-size: 12px; }
.enhance-calc__materials img, .box-sim__list img, .ib-materials img { width: 24px; height: 24px; padding: 1px; border-radius: 3px; background: #4c463c; object-fit: contain; }
.enhance-calc__materials b, .box-sim__list b, .ib-materials b { color: var(--ib-wine); font-variant-numeric: tabular-nums; }
.cm-book .box-sim__empty { margin-top: 8px; color: var(--ib-muted); font-size: 12px; }

/* enhancement table */
.ib-table-wrap { overflow-x: auto; border: 1px solid var(--ib-line); border-radius: 3px; background: var(--ib-paper); }
.ib-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ib-table th { padding: 10px 12px; border-bottom: 1px solid #b59a6688; background: #f3e5c6; color: #6d5636; font-size: 12px; font-weight: 600; text-align: left; white-space: nowrap; }
.ib-table td { padding: 9px 12px; border-top: 1px solid #b59a6633; color: #5b4330; vertical-align: middle; }
.ib-plus { display: inline-grid; place-items: center; min-width: 38px; padding: 2px 8px; border: 1px solid #c2a76c66; border-radius: 3px; background: #f1dfb5; color: #805b28; font-weight: 700; font-variant-numeric: tabular-nums; }
.ib-good { color: #3f6b36 !important; font-weight: 700; font-variant-numeric: tabular-nums; }
.ib-bad { color: #9b3f47 !important; font-weight: 700; font-variant-numeric: tabular-nums; }

/* dungeon list */
.ib-places-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.ib-place-link { display: grid; gap: 2px; height: 100%; padding: 11px 14px; border: 1px solid #b79b6a40; border-left: 3px solid var(--ib-gold); border-radius: 3px; background: #fffaf0a8; color: var(--ib-ink); text-decoration: none; }
.ib-place-link:hover { border-color: #7d414b88; background: #fff6e2; }
.ib-place-link strong { font-size: 14px; font-weight: 700; line-height: 1.45; overflow-wrap: anywhere; }
.ib-place-link small { color: var(--ib-muted); font-size: 12px; }

.ib-book :is(a,button,summary,[tabindex]):focus-visible { outline: 2px solid #87464c; outline-offset: 3px; }

@media (prefers-reduced-motion: reduce) { .ib-search__spinner { animation: none; } .ib-row, .ib-tablist button { transition: none; } }

@media (max-width: 900px) {
    .ib-landing { grid-template-columns: minmax(0,1fr); }
    .ib-places-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .ib-facts { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .ib-list--two { grid-template-columns: minmax(0,1fr); }
}

@media (max-width: 640px) {
    .ib-search { padding: 14px; }
    .ib-search__row { flex-wrap: wrap; }
    .ib-search__row .ib-button { width: 100%; }
    .ib-search__icon { top: 24px; transform: none; margin-top: -10px; }
    .ib-search__spinner { right: 12px; top: 24px; }
    .ib-search__results { left: 14px; right: 14px; top: calc(100% - 20px); }
    .ib-item-head { gap: 12px; }
    .ib-icon--large { width: 60px; height: 60px; }
    .ib-icon--large img { width: 46px; height: 46px; }
    .ib-item-head h1 { font-size: 23px; }
    .ib-tablist button:disabled { display: none; }
    .ib-tablist button { flex: 1 1 auto; justify-content: center; padding-inline: 10px; font-size: 14px; }
    .ib-place { padding: 10px 12px 8px; }
    .ib-way { grid-template-columns: minmax(0,1fr) auto; grid-template-areas: "src rate" "diff qty"; gap: 2px 10px; }
    .ib-way__source { grid-area: src; }
    .ib-way__rate { grid-area: rate; }
    .ib-way__diff { grid-area: diff; }
    .ib-way__qty { grid-area: qty; text-align: right; }
    .ib-places-grid { grid-template-columns: minmax(0,1fr); }
    .ib-row { grid-template-columns: 42px minmax(0,1fr) auto; gap: 10px; padding: 8px 10px; }
    .ib-icon { width: 42px; height: 42px; }
    .ib-icon img { width: 34px; height: 34px; }
    .enhance-calc__figures { grid-template-columns: repeat(2, minmax(0,1fr)); }
    /* the enhancement table becomes one card per level */
    .ib-table-wrap { overflow: visible; border: 0; background: transparent; }
    .ib-table thead { display: none; }
    .ib-table, .ib-table tbody, .ib-table tr, .ib-table td { display: block; width: 100%; }
    .ib-table tr { margin-bottom: 8px; padding: 8px 12px; border: 1px solid var(--ib-line); border-radius: 3px; background: var(--ib-paper); }
    .ib-table td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 5px 0; border-top: 1px dashed #b59a6644; text-align: right; }
    .ib-table td:first-child { border-top: 0; }
    .ib-table td::before { content: attr(data-label); color: var(--ib-muted); font-size: 11px; font-weight: 400; text-align: left; }
    .ib-table .ib-materials { justify-content: flex-end; }
}
.item-search-result > span:nth-child(2) { min-width: 0; }

/* ---- in-game item slot: icon + rank frame (item-database/frames, cut from uit_itemslotbutton.dds) + stack count.
   The game draws the 50px icon full-cell and lays the 50px frame over it, so the icon fills the box and
   the frame image covers its edge. Boxes without a frame keep the plain look above. */
.ib-slot { position: relative; }
.ib-slot.has-frame { padding: 0; border: 0; border-radius: 6px; background: #1b1712; overflow: hidden; }
.ib-slot.has-frame > img:first-child { width: 100%; height: 100%; padding: 0; border-radius: 0; background: none; object-fit: cover; }
.ib-slot .ib-slot__frame { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border-radius: 0; background: none; pointer-events: none; }
.ib-slot__count {
    position: absolute; right: 4px; bottom: 1px; color: #fff; font-size: 12px; font-weight: 700; line-height: 1;
    font-variant-numeric: tabular-nums; pointer-events: none;
    text-shadow: 1px 0 0 #000, -1px 0 0 #000, 0 1px 0 #000, 0 -1px 0 #000, 1px 1px 1px #000;
}
.ib-icon--large .ib-slot__count { font-size: 15px; right: 6px; bottom: 3px; }
/* 24px chips in the material lists and the box simulator */
.ib-icon--small { width: 26px; height: 26px; padding: 1px; border-width: 0; border-radius: 3px; }
.ib-icon--small.has-frame { border-radius: 3px; }
.ib-icon--small > img:first-child { width: 100%; height: 100%; }
