/* Dungeon keys — full in-game tooltip cards (DungeonKeys::renderTooltip).
 * Used inline in news/guides ([dungeon-keys] shortcode, grid), as hover card through the
 * central tooltip (tooltip.php type=dungeon_key → .dkey--tip; tooltip.js loads this file on
 * pages that lack it) and on /database/dungeon-keys[/{slug}] (list table + detail page).
 * Mobile-first: one column, grid from 700px. */

.dkey-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    align-items: start;
    margin: 1rem 0 1.5rem;
}
@media (min-width: 700px) {
    .dkey-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
}

.dkey {
    --dkey-c: #ffd700;
    position: relative;
    box-sizing: border-box;
    width: 100%;
    max-width: 380px;
    min-width: 0;
    padding: 14px 16px 12px;
    background: linear-gradient(180deg, #121217 0%, #0d0d10 45%, #0b0b0d 100%);
    border: 1px solid color-mix(in srgb, var(--dkey-c) 42%, #1a1a1f);
    border-radius: 3px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.55);
    color: #c9c6bd;
    font-family: 'Roboto', var(--font-body, sans-serif);
    font-size: 13.5px;
    line-height: 1.45;
    text-align: left;
    overflow: hidden;
    overflow-wrap: anywhere;
}
.dkey::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 70px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--dkey-c) 22%, transparent) 0%, transparent 100%);
    pointer-events: none;
}
.dkey > * { position: relative; }

.dkey--common    { --dkey-c: #dddddd; }
.dkey--magic     { --dkey-c: #6969ff; }
.dkey--rare      { --dkey-c: #ffd700; }
.dkey--legendary { --dkey-c: #bf642f; }
.dkey--unique    { --dkey-c: #c7b377; }

/* Head */
.dkey__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}
.dkey__titles { min-width: 0; }
.dkey__name {
    color: var(--dkey-c);
    font-size: 17px;
    font-weight: 700;
    line-height: 1.2;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}
.dkey__sub {
    color: var(--dkey-c);
    opacity: 0.85;
    font-size: 12.5px;
    margin-top: 3px;
}
.dkey__icon {
    display: block;
    flex-shrink: 0;
    width: 48px;
    height: 72px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}
.dkey__rule {
    height: 1px;
    margin: 10px 0 9px;
    background: linear-gradient(90deg, transparent, #4a4a55 15%, #4a4a55 85%, transparent);
}

/* Body */
.dkey__body > :last-child { margin-bottom: 0; }
.dkey p { margin: 0 0 7px; }
.dkey__text { color: #c9c6bd; }
.dkey__b { color: #f0ece2; font-weight: 700; }
.dkey__o { color: #d9a441; }
.dkey__y { color: #ffd700; }
.dkey__r { color: #e0714f; }

.dkey__bullets,
.dkey__src,
.dkey__affixes {
    list-style: none;
    margin: 0 0 8px;
    padding: 0;
}
.dkey__bullet {
    position: relative;
    margin: 0 0 4px;
    padding-left: 15px;
}
.dkey__bullet::before,
.dkey__dot {
    color: #8a8a8a;
    font-size: 9px;
}
.dkey__bullet::before {
    content: '\25C6';
    position: absolute;
    left: 1px;
    top: 3px;
}
.dkey__req { color: #b4b0a6; }
.dkey__section { color: #8f8c85; }
.dkey__loc { color: #f0ece2; }
.dkey__place { color: #f0ece2; font-weight: 700; }
.dkey__in { color: #8f8c85; }
.dkey__line { color: #c9c6bd; }
.dkey__line--accent,
.dkey__src-item { color: #c8873f; }
.dkey__src-head { color: #8a8a8a; font-size: 12.5px; margin: 4px 0 2px; }
.dkey__src-item { margin: 3px 0; font-size: 13px; }

/* Icons (inline SVG / source images) */
.dkey__ico {
    display: inline-block;
    width: 15px;
    height: 15px;
    margin-right: 3px;
    vertical-align: -3px;
    color: currentColor;
}
.dkey__ico svg { display: block; width: 100%; height: 100%; }
.dkey__src-ico {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 4px;
    object-fit: contain;
    vertical-align: -3px;
}

/* Affixes */
.dkey__affhead {
    margin: 10px -16px 9px;
    padding: 4px 16px;
    background: linear-gradient(90deg, transparent, #26262d 18%, #26262d 82%, transparent);
    text-align: center;
}
.dkey__affhead span {
    color: #b9b5aa;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}
.dkey__affix { margin: 0 0 7px; }
.dkey__affix-name { display: block; color: #f0ece2; }
.dkey__affix--reward .dkey__affix-name { color: #c9a86a; }
.dkey__affix--danger .dkey__affix-name { color: #e8837f; }
.dkey__affix--rare .dkey__affix-name { color: #ffd700; }
.dkey__affix-desc {
    display: block;
    padding-left: 15px;
    color: #8f8c85;
    font-size: 12.5px;
}
.dkey__random { color: #8f8c85; font-style: italic; }
.dkey__example { color: #7a7870; font-size: 11.5px; font-style: italic; }
.dkey__flavor { color: #7c7a74; font-style: italic; font-size: 12.5px; margin-top: 9px !important; }
.dkey__amalg { color: #9c998f; font-style: italic; font-size: 12.5px; }

/* Footer */
.dkey__foot {
    margin-top: 10px;
    text-align: right;
    font-size: 12px;
    color: #9c998f;
}
.dkey__flags {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}
.dkey__flag--season { color: #7fcf7f; }
.dkey__flag--voh { color: #5fbf5f; }
.dkey__flag--loh { color: #e05a4a; }
.dkey__sell {
    margin-top: 7px;
    padding-top: 6px;
    border-top: 1px solid #2a2a33;
    color: #8f8c85;
}

/* Card name as link to the detail page (inline cards in articles) */
.dkey__name-link { color: inherit; text-decoration: none; }
.dkey__name-link:hover,
.dkey__name-link:focus-visible { text-decoration: underline; text-underline-offset: 3px; }

/* Articles: the card must not inherit the article typography */
.guide-view__markdown .dkey p,
.guide-view__markdown .dkey li { font-size: inherit; line-height: inherit; }
.guide-view__markdown .dkey ul { margin-left: 0; padding-left: 0; }
.guide-view__markdown .dkey li::marker { content: none; }
.guide-view__markdown .dkey img { margin: 0; border-radius: 0; }
.guide-view__markdown .dkey a.dkey__name-link { color: inherit; }

/* ── Central tooltip variant (.dkey--tip) ─────────────────────────────────────
   api/v1/tooltip.php type=dungeon_key renders the card with .dkey--tip. The frame comes
   from the host: .item-tooltip (tooltip.js hover box, tooltip.css) or the detail header
   card (.db-detail__ttcard, database.css). The card only keeps its own background and
   rarity glow — no second border, no shadow, no width cap of its own. */
.dkey--tip {
    width: 100%;
    max-width: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}
/* Hover box: a bit wider than the default 340px (long affix lines), rarity-tinted frame */
.item-tooltip:has(> .dkey--tip) {
    max-width: 380px;
    background: #0b0b0d;
    overflow: hidden;
}
.item-tooltip:has(> .dkey--magic)     { border-color: color-mix(in srgb, #6969ff 42%, #1a1a1f); }
.item-tooltip:has(> .dkey--rare)      { border-color: color-mix(in srgb, #ffd700 42%, #1a1a1f); }
.item-tooltip:has(> .dkey--legendary) { border-color: color-mix(in srgb, #bf642f 42%, #1a1a1f); }
.item-tooltip:has(> .dkey--unique)    { border-color: color-mix(in srgb, #c7b377 42%, #1a1a1f); }
/* Mobile top bar: full width, the close button sits above the card */
.item-tooltip--mobile-top:has(> .dkey--tip) { max-width: none; }
.item-tooltip--mobile-top > .dkey--tip { padding-top: 18px; }
/* Detail header card: database.css frames every ".db-detail__ttcard > div" neutrally —
   the key card keeps its rarity border instead, at in-game width. */
.db-detail__ttcard > .dkey--tip {
    width: 360px;
    max-width: 100%;
    border: 1px solid color-mix(in srgb, var(--dkey-c) 42%, #1a1a1f);
    border-radius: 3px;
}
@media (max-width: 900px) {
    .db-detail__ttcard > .dkey--tip { width: 100%; }
}

/* ── Database list + detail (/database/dungeon-keys[/{slug}]) ─────────────── */
.dkey-name--common    { color: #dddddd; }
.dkey-name--magic     { color: #6969ff; }
.dkey-name--rare      { color: #ffd700; }
.dkey-name--legendary { color: #bf642f; }
.dkey-name--unique    { color: #c7b377; }

.dkey-table__icon,
.dkey-related__icon,
.dkey-detail__icon { object-fit: contain; }
.dkey-table__icon { width: 26px; height: 38px; }
.dkey-table__region { color: var(--text-muted, #7a7870); }
.dkey-table__loc,
.dkey-table__origin { font-size: 0.9rem; }
.dkey-table__origin { color: var(--text-secondary, #9c998f); white-space: nowrap; }
.dkey-group-badge { text-decoration: none; white-space: nowrap; }

.dkey-detail__icon { width: auto; height: 64px; }
.dkey-detail__list { margin: 0.25rem 0 0.75rem 1.1rem; padding: 0; color: var(--text-secondary, #b4b0a6); line-height: 1.6; }
.dkey-detail__list li { margin: 0 0 0.25rem; }
.dkey-detail__req { color: var(--text-secondary, #b4b0a6); font-style: italic; }
.dkey-detail__affixes { margin: 0; }
.dkey-detail__affixes dt { margin: 0.6rem 0 0.1rem; color: #f0ece2; font-weight: 600; }
.dkey-detail__affixes dt:first-child { margin-top: 0; }
.dkey-detail__affixes dd { margin: 0 0 0 1rem; color: var(--text-secondary, #9c998f); line-height: 1.55; }
.dkey-detail__affix--reward { color: #c9a86a !important; }
.dkey-detail__affix--danger { color: #e8837f !important; }
.dkey-detail__affix--rare   { color: #ffd700 !important; }
.dkey-detail__note,
.dkey-detail__flavor { color: var(--text-muted, #7a7870); font-style: italic; font-size: 0.9rem; margin: 0.75rem 0 0; }

.mention--dkey { cursor: help; }

/* Overview page of a key group (pages/database/dungeon-key-group.php, switch dkey_group_page) */
.dkey-group__flavor { color: var(--text-muted, #7a7870); font-size: 0.95rem; margin: 0.75rem 0 0; padding-left: 0.9rem; border-left: 2px solid var(--border, #2a2a35); }
.dkey-group__quote { color: var(--text, #e0ddd5); margin: 0.6rem 0 0; padding: 0.5rem 0.9rem; border-left: 2px solid #ffd700; background: rgba(255, 215, 0, 0.04); }
.dkey-group__overview { margin: 0 0 1rem; }
