/* Badge/Pill Component Styles */
.badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-card-data);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    width: fit-content;
}

/* Rarity Badge Colors */
.rarity-common {
    background: #4a5568;
    color: #ffffff;
}
.rarity-uncommon {
    background: #38a169;
    color: #ffffff;
}
.rarity-rare {
    background: #3182ce;
    color: #ffffff;
}
.rarity-super-rare {
    background: #805ad5;
    color: #ffffff;
}
.rarity-ultra-rare {
    background: #d9a51e;
    color: #FFFFFF;
}
.rarity-promo-rare {
    background: #ec4899;
    color: #ffffff;
}
.rarity-csr {
    background: linear-gradient(135deg, #66a0ea 0%, #8c3fdb 50%, #ce4ecc 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgb(162, 102, 234, 0.6);
}
.rarity-cur {
    background: linear-gradient(135deg, #fff9d9 0%, #e3c312 50%, #df520c 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(255, 131, 0, 0.7);
}
.rarity-cpr {
    background: linear-gradient(135deg, #d5aef0 0%, #e61fc7 50%, #ea3f56 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(245, 87, 146, 0.8);
}

/* Apply text shadow to all rarity badges */
.rarity-common, .rarity-uncommon, .rarity-rare, .rarity-super-rare,
.rarity-ultra-rare, .rarity-promo-rare, .rarity-csr, .rarity-cur, .rarity-cpr {
    text-shadow: 2px 1px 0 #000;
}

/* Type/Class/Element Badges */
.type-badge {
    background: #1e3a5f;
    color: #90cdf4;
    border: 1px solid #2c5282;
}
.class-badge {
    background: #2d3748;
    color: #fc8181;
    border: 1px solid var(--border-color-light);
}
.element-badge {
    background: #234e52;
    color: #81e6d9;
    border: 1px solid #2c7a7b;
}

/* Card Detail Page Styles */
.card-cost-box {
    background: var(--bg-secondary);
    padding: 12px;
    border: 1px solid var(--border-color);
}
.card-cost-label {
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    margin-bottom: 4px;
}
.card-cost-value {
    color: var(--accent-primary);
    font-size: 24px;
    font-weight: 600;
    font-family: var(--font-card-data);
}

.card-stat-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.card-stat-label {
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    text-align: center;
}
.card-stat-pill {
    background: black;
    padding: 0px 10px;
    border: 1px solid #AAAAAA;
    border-radius: 999px;
    color: var(--text-primary);
    font-size: 20px;
    font-weight: 600;
    font-family: var(--font-card-data);
    display: flex;
    align-items: center;
    min-width: 50px;
    justify-content: center;
    line-height: 1.4em;
}

.card-effect-text {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 16px;
    color: var(--text-primary);
    line-height: 1.6;
    font-family: var(--font-card-data);
}

.card-effect-text p {
    margin: 0;
    padding: 0;
}

.card-effect-text p + p {
    margin-top: 0.4em;
}

.card-flavor-text {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 16px;
    color: var(--text-primary);
    font-style: italic;
    line-height: 1.6;
    font-family: var(--font-card-data);
}

/* Effect text formatting */
.effect-bubble-cost {
    display: inline-block;
    background: #E6D24B;
    color: #000;
    padding: 0px 7px;
    border-radius: 999px;
    font-weight: 600;
    line-height: 1.0em;
    font-size: 0.9em;
}

.effect-bubble-inverted {
    display: inline-block;
    background: #1a1a1a;
    color: #fff;
    padding: 0px 7px;
    border-radius: 999px;
    border: 1px solid #fff;
    font-weight: 600;
    line-height: 1.0em;
    font-size: 0.9em;
}

.effect-symbol {
    font-size: 1em;
    margin: 0 1px;
    vertical-align: baseline;
}

/* Effect text icons using SVGs */
.effect-icon {
    display: inline-block;
    width: 0.75em;
    height: 0.75em;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    vertical-align: baseline;
    /* Filter to near-match text color */
    filter: brightness(0) saturate(100%) invert(93%) brightness(104%) contrast(101%);
}

.effect-icon-life {
    background-image: url('/images/icons/official/text_and_stats/heart.svg');
}

.effect-icon-power {
    background-image: url('/images/icons/official/text_and_stats/sword.svg');
}

.effect-icon-external-link {
    background-image: url('/images/icons/noun-external-link-3149642-min.svg');
    width: 1em;
    height: 1em;
}

.effect-rest-symbol {
    font-family: var(--font-ui);
    position: relative;
    top: 2px; /* arrow glyph not vertically aligned with text otherwise */
}

.effect-errata {
    color: #dc2626;
    font-weight: 700;
}

.effect-errata del {
    color: var(--text-muted);
    text-decoration: line-through;
}

/* Reminder text muted color */
.card-effect-text em {
    color: var(--text-muted);
}

.card-info-value {
    color: var(--text-primary);
    font-weight: 500;
    font-family: var(--font-card-data);
}

.card-illustrator-name {
    color: var(--gold-primary);
    font-weight: 500;
    margin-top: 4px;
    font-family: var(--font-card-data);
}

/* Card Textbox with Scooped Corners */
.card-textbox {
    position: relative;
    padding: 20px;
    color: var(--text-primary);
    line-height: 1.2;
    font-family: var(--font-card-data);
}

/* Outer layer: border effect (larger masked shape in border color) */
.card-textbox:before {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--border-color);
    mask:
        radial-gradient(20px at 20px 20px, #0000 calc(98% - 3px), #000 calc(100% - 3px) 98%, #0000) -20px -20px,
        linear-gradient(90deg, #000 6px, #0000 0) -3px 50% / 100% calc(100% - 40px + 3px) repeat-x,
        linear-gradient(#000 6px, #0000 0) 50% -3px / calc(100% - 40px + 3px) 100% repeat-y;
    z-index: -1;
}

/* Inner layer: background fill (smaller masked shape, inset by border width) */
.card-textbox:after {
    content: "";
    position: absolute;
    inset: 1px;
    background: var(--bg-primary);
    mask:
        radial-gradient(18px at 18px 18px, #0000 calc(98% - 3px), #000 calc(100% - 3px) 98%, #0000) -19px -19px,
        linear-gradient(90deg, #000 5px, #0000 0) -2px 50% / 100% calc(100% - 38px + 2px) repeat-x,
        linear-gradient(#000 5px, #0000 0) 50% -2px / calc(100% - 38px + 2px) 100% repeat-y;
    z-index: -1;
}

.card-textbox-effect {
    margin-bottom: 12px;
}

.card-textbox p {
    margin: 4px 4px 10px 4px;
}

.card-textbox-flavor {
    font-style: italic;
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
}

/* Stat Icon Styles */
.stat-icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-right: 6px;
    vertical-align: middle;
}

.stat-icon-speed-fast {
    background: url('/images/icons/official/text_and_stats/thunder.svg') no-repeat center;
    background-size: contain;
    filter: brightness(0) saturate(100%) invert(55%) sepia(48%) saturate(1837%) hue-rotate(316deg) brightness(101%) contrast(96%);
}

.stat-icon-speed-slow {
    background: url('/images/icons/official/text_and_stats/thunder.svg') no-repeat center;
    background-size: contain;
    filter: brightness(0) saturate(100%) invert(61%) sepia(13%) saturate(1072%) hue-rotate(169deg) brightness(88%) contrast(86%);
}

.stat-icon-power {
    background: url('/images/icons/official/text_and_stats/sword.svg') no-repeat center;
    background-size: contain;
    filter: brightness(0) saturate(100%) invert(93%) sepia(8%) saturate(1265%) hue-rotate(359deg) brightness(104%) contrast(101%);
}

.stat-icon-life {
    background: url('/images/icons/official/text_and_stats/heart.svg') no-repeat center;
    background-size: contain;
    filter: brightness(0) saturate(100%) invert(93%) sepia(8%) saturate(1265%) hue-rotate(359deg) brightness(104%) contrast(101%);
}

.stat-icon-durability {
    background: url('/images/icons/official/text_and_stats/shield.svg') no-repeat center;
    background-size: contain;
    filter: brightness(0) saturate(100%) invert(93%) sepia(8%) saturate(1265%) hue-rotate(359deg) brightness(104%) contrast(101%);
}

/* Typeline Styles */
.card-typeline {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
    font-weight: 600;
}

.typeline-icon-circle {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--bg-tertiary);
    border: 2px solid rgba(255, 255, 255, 0.3);
    text-decoration: none;
}

.typeline-icon-circle:hover {
    border-color: var(--accent-primary);
}

.typeline-icon-circle img {
    width: 20px;
    object-fit: contain;
}

.typeline-text {
    flex: 1;
    font-family: var(--font-card-data);
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.typeline-link {
    color: var(--text-primary);
    text-decoration: none;
}

.typeline-link:hover {
    color: var(--accent-primary);
}

.element-display {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 16px;
}

.element-icon {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.element-name {
    font-family: var(--font-card-data);
    font-weight: 600;
    font-size: 16px;
    color: var(--text-primary);
    text-shadow: 2px 1px 0 #000;
}

/* Element color variants - add border color for visual distinction */
.element-display[data-element="Fire"] { border-color: var(--element-fire); }
.element-display[data-element="Water"] { border-color: var(--element-water); }
.element-display[data-element="Wind"] { border-color: var(--element-wind); }
.element-display[data-element="Arcane"] { border-color: var(--element-arcane); }
.element-display[data-element="Luxem"] { border-color: var(--element-luxem); }
.element-display[data-element="Tera"] { border-color: var(--element-tera); }
.element-display[data-element="Crux"] { border-color: var(--element-crux); }
.element-display[data-element="Umbra"] { border-color: var(--element-umbra); }
.element-display[data-element="Astra"] { border-color: var(--element-astra); }
.element-display[data-element="Neos"] { border-color: var(--element-neos); }
.element-display[data-element="Exia"] { border-color: var(--element-exia); }
.element-display[data-element="Exalted"] { border-color: var(--element-exalted); }

/* Cost Display with Background Colors */
.cost-display-new {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 10px 14px;
    border: 2px solid var(--border-color-light);
    border-radius: 16px;
    min-width: 50px;
    position: relative;
}

.cost-display-memory {
    background: linear-gradient(135deg, var(--cost-memory) 0%, var(--cost-memory-dark) 100%);
}

.cost-display-reserve {
    background: linear-gradient(135deg, var(--cost-reserve) 0%, var(--cost-reserve-dark) 100%);
}

.cost-icon {
    width: 36px;
    height: 36px;
    object-fit: contain;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.4;
}

.cost-type-name {
    font-size: 16px;
    font-weight: 600;
    font-family: var(--font-card-data);
    color: var(--text-primary);
    text-shadow: 2px 1px 0 #000;
    z-index: 1;
}

.cost-value-new {
    font-size: 32px;
    font-weight: 700;
    font-family: var(--font-card-data);
    color: var(--text-primary);
    line-height: 1;
    text-shadow: 2px 1px 0 #000;
    z-index: 1;
}

/* Card Grid */
.card-grid {
    display: grid;
    gap: 20px;
    margin-top: 20px;
}

.card-item {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 20px;
}

.card-item:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.card-item h4 {
    margin-bottom: 15px;
    font-size: 18px;
}

.card-item h4 a {
    color: var(--accent-primary);
    text-decoration: none;
    font-family: var(--font-card-title);
    font-weight: 600;
}

.card-item h4 a:hover {
    color: var(--accent-hover);
}

/* Query Explanation Box */
.query-explanation {
    background: linear-gradient(135deg, #2d1b4e 0%, #1a1f2e 100%);
    border: 1px solid var(--accent-primary);
    padding: 16px 20px;
    margin-bottom: 30px;
    color: var(--text-primary);
    font-family: var(--font-code);
    font-size: 13px;
    line-height: 1.5;
}

.query-explanation-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gold-primary);
    font-weight: 600;
    margin-bottom: 6px;
}

.query-explanation-text {
    font-size: 13px;
    line-height: 1.5;
}

/* Query explanation content wrapper */
.query-explanation-content {
    display: block;
}

.query-prefix {
    color: var(--text-muted);
    font-weight: 500;
}

/* Query lines - indented prose style */
.query-line {
    display: block;
    position: relative;
    padding-left: calc(var(--depth, 0) * 1.5em);
    line-height: 1.6;
}

/* Subtle vertical guide lines in the indentation */
.query-guide {
    position: absolute;
    left: calc((var(--depth, 1) - 1) * 1.5em + 0.5em);
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border-color);
    opacity: 0.3;
}

/* Connector keywords (or/and/not) */
.query-conn {
    color: var(--text-muted);
    font-style: italic;
}

/* Parentheses for nested groups */
.query-paren {
    color: var(--text-muted);
    opacity: 0.6;
}

/* Card Detail Layout */
.card-detail-layout {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 30px;
    margin-top: 20px;
}

/* Variant Thumbnail (cropped to show top portion of card) */
.variant-thumbnail {
    width: 150px;
    height: 60px; /* 60px + 16px to extend through bottom padding */
    overflow: hidden;
    flex-shrink: 0;
    border-radius: 6px 6px 0px 0px;
    margin-bottom: -16px;
}

.variant-thumbnail img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    object-position: top center;
}

/* Responsive */
@media (max-width: 768px) {
    .card-detail-layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}
