/* Item Card Component - Classic D&D Style */

.item-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(139, 90, 43, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(139, 90, 43, 0.06) 0%, transparent 50%),
        linear-gradient(180deg,
            #FDF1DC 0%,
            #F0E6D2 50%,
            #E8DBC5 100%
        );
    color: #1A1A1A;
    border: none;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
    position: relative;
    font-family: var(--qm-font-body);
    font-size: 0.9rem;
    line-height: 1.4;
    overflow: hidden;
}

/* Classic D&D top/bottom decorative bars */
.item-card::before,
.item-card::after {
    content: '';
    display: block;
    height: 5px;
}

.item-card::before {
    background: linear-gradient(90deg,
        #7A200D 0%,
        #E69A28 15%,
        #E69A28 85%,
        #7A200D 100%
    );
}

.item-card::after {
    background: linear-gradient(90deg,
        #7A200D 0%,
        #E69A28 15%,
        #E69A28 85%,
        #7A200D 100%
    );
}

/* Rarity-based top bar colors */
.item-card.rarity-common::before,
.item-card.rarity-common::after {
    background: linear-gradient(90deg, #666 0%, #9e9e9e 15%, #9e9e9e 85%, #666 100%);
}

.item-card.rarity-uncommon::before,
.item-card.rarity-uncommon::after {
    background: linear-gradient(90deg, #2e7d32 0%, #4caf50 15%, #4caf50 85%, #2e7d32 100%);
}

.item-card.rarity-rare::before,
.item-card.rarity-rare::after {
    background: linear-gradient(90deg, #1565c0 0%, #2196f3 15%, #2196f3 85%, #1565c0 100%);
}

.item-card.rarity-very-rare::before,
.item-card.rarity-very-rare::after {
    background: linear-gradient(90deg, #6a1b9a 0%, #9c27b0 15%, #9c27b0 85%, #6a1b9a 100%);
}

.item-card.rarity-legendary::before,
.item-card.rarity-legendary::after {
    background: linear-gradient(90deg, #e65100 0%, #ff9800 15%, #ff9800 85%, #e65100 100%);
}

.item-card.rarity-artifact::before,
.item-card.rarity-artifact::after {
    background: linear-gradient(90deg, #b71c1c 0%, #f44336 15%, #f44336 85%, #b71c1c 100%);
}

/* Edit Toggle */
.item-card__edit-toggle {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    z-index: 10;
    background: rgba(253, 241, 220, 0.9);
    padding: 3px 8px;
    border-radius: 3px;
    border: 1px solid rgba(122, 32, 13, 0.3);
}

.item-card__edit-toggle:hover {
    background: rgba(122, 32, 13, 0.1);
    border-color: rgba(122, 32, 13, 0.5);
}

.item-card__edit-label {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
    user-select: none;
}

.item-card__edit-label input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.item-card__edit-icon {
    display: flex;
    align-items: center;
    color: #7A200D;
    opacity: 0.8;
}

.item-card__edit-text {
    font-size: 0.7rem;
    font-weight: 700;
    color: #7A200D;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.item-card__edit-slider {
    position: relative;
    width: 32px;
    height: 18px;
    background: rgba(122, 32, 13, 0.2);
    border-radius: 9px;
    transition: all 0.3s ease;
    border: 1px solid rgba(122, 32, 13, 0.4);
}

.item-card__edit-slider::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 12px;
    height: 12px;
    background: #FDF1DC;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.item-card__edit-label input:checked + .item-card__edit-slider {
    background: #7A200D;
    border-color: #922610;
}

.item-card__edit-label input:checked + .item-card__edit-slider::before {
    transform: translateX(14px);
    background: #FDF1DC;
}

.item-card--editing .item-card__edit-text {
    color: #922610;
}

.item-card--editing .item-card__edit-icon {
    color: #922610;
    opacity: 1;
}

.item-card__edit-status {
    font-size: 0.65rem;
    color: #7A200D;
    opacity: 0.8;
    white-space: nowrap;
    max-width: 50px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Header */
.item-card__header {
    padding: 0.6rem 0.8rem 0.4rem;
    padding-right: 85px; /* Space for edit toggle */
    background: transparent;
    border-bottom: 2px solid #922610;
    position: relative;
}

.item-card:not([data-editable="true"]) .item-card__header {
    padding-right: 0.8rem; /* No extra padding when not editable */
}

.item-card__title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--qm-space-sm);
}

.item-card__name {
    font-family: var(--qm-font-display);
    font-size: 1.4rem;
    color: #7A200D;
    margin: 0;
    line-height: 1.1;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.item-card__subtitle {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--qm-space-sm);
    margin-top: 0.15rem;
    font-size: 0.85rem;
    font-style: italic;
}

.item-card__type {
    color: #1A1A1A;
}

.item-card__subtype {
    color: #444;
}

.item-card__rarity-badge {
    padding: 2px 8px;
    border-radius: var(--qm-radius-sm);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: white;
    font-style: normal;
}

.item-card__attunement {
    margin-top: 0.2rem;
    font-size: 0.85rem;
    color: #7A200D;
    font-style: italic;
}

/* Image */
.item-card__image {
    width: 100%;
    aspect-ratio: 16/9;
    overflow: hidden;
    background: #E8DBC5;
    border-top: 1px solid rgba(122, 32, 13, 0.2);
    border-bottom: 1px solid rgba(122, 32, 13, 0.2);
}

.item-card__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.item-card:hover .item-card__image img {
    transform: scale(1.02);
}

/* Body */
.item-card__body {
    padding: 0.6rem 0.8rem;
    flex: 1;
}

/* Tapered divider */
.item-card__divider {
    height: 0;
    border: none;
    margin: 0.4rem 0;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 6'%3E%3Cpath d='M0,3 Q100,0 200,3 Q300,6 400,3' stroke='%23922610' stroke-width='2' fill='none'/%3E%3C/svg%3E") no-repeat center;
    background-size: 100% 4px;
    height: 6px;
    opacity: 0.8;
}

.item-card__stats {
    display: flex;
    gap: var(--qm-space-lg);
    margin-bottom: 0.4rem;
    padding: 0.4rem 0;
    border-top: 1px solid rgba(122, 32, 13, 0.3);
    border-bottom: 1px solid rgba(122, 32, 13, 0.3);
}

.item-card__stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.item-card__stat-label {
    font-size: 0.7rem;
    color: #7A200D;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
}

.item-card__stat-value {
    font-family: var(--qm-font-display);
    font-size: 1.1rem;
    color: #1A1A1A;
}

.item-card__weapon-props {
    display: flex;
    flex-wrap: wrap;
    gap: var(--qm-space-xs);
    margin-bottom: 0.5rem;
}

.item-card__weapon-prop {
    padding: 2px 8px;
    background: rgba(122, 32, 13, 0.1);
    border: 1px solid rgba(122, 32, 13, 0.2);
    border-radius: var(--qm-radius-sm);
    font-size: 0.75rem;
    color: #7A200D;
    font-style: italic;
}

.item-card__charges {
    display: flex;
    align-items: center;
    gap: var(--qm-space-sm);
    margin-bottom: 0.5rem;
    padding: 0.4rem 0.6rem;
    background: rgba(122, 32, 13, 0.08);
    border: 1px solid rgba(122, 32, 13, 0.2);
    border-radius: var(--qm-radius-sm);
}

.item-card__charges-label {
    font-weight: 700;
    color: #7A200D;
}

.item-card__charges-value {
    font-family: var(--qm-font-display);
    color: #1A1A1A;
}

.item-card__charges-reset {
    font-size: 0.85rem;
    color: #444;
    font-style: italic;
}

.item-card__section {
    margin-bottom: 0.5rem;
}

.item-card__section:last-child {
    margin-bottom: 0;
}

.item-card__section-title {
    font-family: var(--qm-font-heading);
    font-size: 1rem;
    font-weight: 400;
    color: #7A200D;
    margin: 0.5rem 0 0.25rem;
    border-bottom: 1px solid #7A200D;
    padding-bottom: 0.15rem;
    font-variant: small-caps;
    letter-spacing: 0.05em;
}

.item-card__description {
    color: #444;
    font-style: italic;
    line-height: 1.5;
    margin: 0 0 0.5rem;
}

.item-card__properties {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.item-card__property {
    margin: 0.3rem 0;
    font-size: 0.9rem;
    line-height: 1.4;
    text-indent: -0.6rem;
    padding-left: 0.6rem;
}

.item-card__property-name {
    font-weight: 700;
    font-style: italic;
    color: #1A1A1A;
}

.item-card__property-name::after {
    content: ' ';
}

.item-card__property-desc {
    color: #1A1A1A;
    font-size: 0.9rem;
    line-height: 1.4;
}

.item-card__curse {
    margin: 0.5rem 0;
    padding: 0.5rem 0.6rem;
    background: rgba(139, 0, 0, 0.1);
    border: 1px solid rgba(139, 0, 0, 0.3);
    border-radius: var(--qm-radius-sm);
}

.item-card__curse-label {
    font-weight: 700;
    font-style: italic;
    color: #8B0000;
}

.item-card__curse-desc {
    color: #1A1A1A;
    font-size: 0.9rem;
}

.item-card__lore,
.item-card__history {
    margin-top: 0.5rem;
}

.item-card__lore p,
.item-card__history p {
    color: #444;
    font-size: 0.85rem;
    line-height: 1.5;
    font-style: italic;
    margin: 0;
}

/* Footer */
.item-card__footer {
    padding: 0.4rem 0.8rem;
    background: transparent;
    border-top: 1px solid rgba(122, 32, 13, 0.3);
}

.item-card__meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #666;
}

.item-card__value::before {
    content: '💰 ';
}

.item-card__weight::before {
    content: '⚖️ ';
}


/* Compact variant - for grid/armory listings */
.item-card--compact {
    font-size: 0.8rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.item-card--compact:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.item-card--compact .item-card__header {
    padding: 0.5rem 0.6rem;
}

.item-card--compact .item-card__name {
    font-size: 1rem;
    margin: 0;
}

.item-card--compact .item-card__subtitle {
    font-size: 0.7rem;
    gap: 0.3rem;
}

.item-card--compact .item-card__rarity-badge {
    font-size: 0.6rem;
    padding: 1px 6px;
}

.item-card--compact .item-card__attunement {
    font-size: 0.7rem;
    margin-top: 0.15rem;
}

.item-card--compact .item-card__image {
    aspect-ratio: 16/9;
    max-height: 160px;
    overflow: hidden;
}

.item-card--compact .item-card__image img {
    object-fit: cover;
    width: 100%;
    height: 100%;
}

.item-card--compact .item-card__body {
    padding: 0.4rem 0.6rem;
}

.item-card--compact .item-card__description {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.78rem;
    margin: 0;
}

/* Hide verbose sections in compact mode */
.item-card--compact .item-card__properties,
.item-card--compact .item-card__curse,
.item-card--compact .item-card__charges,
.item-card--compact .item-card__weapon-props,
.item-card--compact .item-card__stats {
    display: none;
}

.item-card--compact .item-card__footer {
    padding: 0.3rem 0.6rem;
    font-size: 0.7rem;
}

.item-card--compact .item-card__meta {
    gap: 0.5rem;
}

/* Editable fields - only active in edit mode */
.item-card.item-card--editing [data-field] {
    transition: all 0.2s ease;
    border-radius: 2px;
    padding: 1px 3px;
    margin: -1px -3px;
    cursor: text;
}

.item-card.item-card--editing [data-field]:hover {
    background: rgba(122, 32, 13, 0.1);
}

.item-card.item-card--editing [data-field]:focus {
    outline: none;
    background: rgba(122, 32, 13, 0.15);
    box-shadow: 0 0 0 2px rgba(122, 32, 13, 0.3);
}

/* Edit mode active */
.item-card.item-card--editing {
    box-shadow: 0 0 0 3px rgba(122, 32, 13, 0.4), 0 0 20px rgba(0, 0, 0, 0.3);
}

.item-card.item-card--editing .item-card__edit-toggle {
    background: rgba(122, 32, 13, 0.15);
    border-color: #7A200D;
}

/* Save controls bar */
.item-card__save-bar {
    display: none;
    padding: 0.5rem 0.8rem;
    background: rgba(122, 32, 13, 0.1);
    border-top: 1px solid rgba(122, 32, 13, 0.2);
    gap: 0.5rem;
    justify-content: flex-end;
    align-items: center;
}

.item-card.item-card--editing .item-card__save-bar {
    display: flex;
}

.item-card.item-card--dirty .item-card__save-bar {
    background: rgba(122, 32, 13, 0.15);
}

.item-card__save-status {
    font-size: 0.75rem;
    color: #7A200D;
    margin-right: auto;
}

/* ========================================
   DARK VARIANT (for dark themed pages)
   ======================================== */

.item-card--dark {
    background:
        linear-gradient(180deg,
            #2A2520 0%,
            #1E1A18 50%,
            #151210 100%
        );
    color: #E8DBC5;
}

.item-card--dark::before,
.item-card--dark::after {
    background: linear-gradient(90deg,
        #4A3728 0%,
        #D4AF37 15%,
        #D4AF37 85%,
        #4A3728 100%
    );
}

.item-card--dark .item-card__header {
    border-bottom-color: #D4AF37;
}

.item-card--dark .item-card__name {
    color: #D4AF37;
}

.item-card--dark .item-card__type,
.item-card--dark .item-card__subtype {
    color: #E8DBC5;
}

.item-card--dark .item-card__attunement {
    color: #D4AF37;
}

.item-card--dark .item-card__stat-label,
.item-card--dark .item-card__charges-label,
.item-card--dark .item-card__section-title {
    color: #D4AF37;
}

.item-card--dark .item-card__section-title {
    border-bottom-color: #D4AF37;
}

.item-card--dark .item-card__stat-value,
.item-card--dark .item-card__charges-value {
    color: #E8DBC5;
}

.item-card--dark .item-card__description,
.item-card--dark .item-card__property-desc,
.item-card--dark .item-card__lore p,
.item-card--dark .item-card__history p {
    color: #C8BBA5;
}

.item-card--dark .item-card__property-name {
    color: #E8DBC5;
}

.item-card--dark .item-card__weapon-prop {
    background: rgba(212, 175, 55, 0.1);
    border-color: rgba(212, 175, 55, 0.3);
    color: #D4AF37;
}

.item-card--dark .item-card__charges {
    background: rgba(212, 175, 55, 0.08);
    border-color: rgba(212, 175, 55, 0.2);
}

.item-card--dark .item-card__curse {
    background: rgba(139, 0, 0, 0.2);
    border-color: rgba(220, 50, 50, 0.4);
}

.item-card--dark .item-card__curse-label {
    color: #FF6B6B;
}

.item-card--dark .item-card__curse-desc {
    color: #E8DBC5;
}

.item-card--dark .item-card__stats {
    border-color: rgba(212, 175, 55, 0.3);
}

.item-card--dark .item-card__footer {
    border-top-color: rgba(212, 175, 55, 0.3);
}

.item-card--dark .item-card__meta {
    color: #A89880;
}

.item-card--dark .item-card__divider {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 6'%3E%3Cpath d='M0,3 Q100,0 200,3 Q300,6 400,3' stroke='%23D4AF37' stroke-width='2' fill='none'/%3E%3C/svg%3E") no-repeat center;
    background-size: 100% 4px;
}

.item-card--dark .item-card__edit-toggle {
    background: rgba(212, 175, 55, 0.1);
    border-color: rgba(212, 175, 55, 0.3);
    color: #D4AF37;
}

.item-card--dark .item-card__edit-toggle:hover {
    background: #D4AF37;
    color: #1A1A1A;
}

.item-card--dark[data-editable="true"] [contenteditable="true"]:hover {
    background: rgba(212, 175, 55, 0.1);
}

.item-card--dark[data-editable="true"] [contenteditable="true"]:focus {
    background: rgba(212, 175, 55, 0.15);
    box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.3);
}

.item-card--dark .item-card__edit-toggle {
    background: rgba(30, 26, 24, 0.95);
    border-color: rgba(212, 175, 55, 0.3);
}

.item-card--dark .item-card__edit-toggle:hover {
    background: rgba(212, 175, 55, 0.1);
    border-color: rgba(212, 175, 55, 0.5);
}

.item-card--dark .item-card__edit-text,
.item-card--dark .item-card__edit-icon,
.item-card--dark .item-card__edit-status {
    color: #D4AF37;
}

.item-card--dark .item-card__edit-slider {
    background: rgba(212, 175, 55, 0.2);
    border-color: rgba(212, 175, 55, 0.4);
}

.item-card--dark .item-card__edit-label input:checked + .item-card__edit-slider {
    background: #D4AF37;
    border-color: #B8973D;
}

.item-card--dark .item-card__save-bar {
    background: rgba(212, 175, 55, 0.05);
    border-top-color: rgba(212, 175, 55, 0.2);
}

.item-card--dark .item-card__save-status {
    color: #D4AF37;
}

/* Responsive */
@media (max-width: 640px) {
    .item-card {
        font-size: 0.85rem;
    }

    .item-card__header {
        padding: 0.5rem 0.6rem 0.3rem;
    }

    .item-card__body {
        padding: 0.5rem 0.6rem;
    }

    .item-card__name {
        font-size: 1.2rem;
    }
}
