/**
 * Quote Showcase Component - Theme Integration
 *
 * Professional quote display system with responsive grid layouts,
 * multiple visual styles, and complete design system integration.
 *
 * Moved from plugin to theme for unified styling architecture.
 */

.qm-quote-showcase {
    /* Component-specific custom properties (can be overridden) */
    --columns-mobile: var(--qm-grid-columns-mobile, 1);
    --columns-tablet: var(--qm-grid-columns-tablet, 2);
    --columns-desktop: var(--qm-grid-columns-desktop, 3);
    --gap-size: var(--qm-gap-default, 20px);
    --border-radius: var(--qm-border-radius-lg, 12px);
    /* HYBRID COLOR SYSTEM: Block overrides + Color Manager defaults */
    --bg-color: var(--block-bg-color, var(--qm-background-base));
    --text-color: var(--block-text-color, var(--qm-text-primary));
    --accent-color: var(--block-accent-color, var(--qm-accent-color));
    --border-color: var(--block-border-color, var(--qm-border-light));
    --shadow-color: var(--block-shadow-color, var(--qm-shadow-soft));

    /* Additional styling from Color Manager */
    --quote-color: var(--qm-quote-text, var(--text-color));
    --author-color: var(--qm-quote-author, var(--text-color));
    --character-color: var(--accent-color);
    --quote-font-size: var(--qm-text-base, 1rem);
    --shadow: var(--qm-shadow);
    --hover-shadow: var(--qm-hover-shadow);
    --transition: var(--qm-transition, all 0.3s ease);
    --custom-font-size: var(--qm-text-base, 16px);
    --font-weight: var(--qm-font-normal, 400);
    --line-height: var(--qm-leading-relaxed, 1.6);
    --letter-spacing: var(--qm-tracking-normal, 0);
    --padding-top: var(--qm-space-lg, 20px);
    --padding-right: var(--qm-space-lg, 20px);
    --padding-bottom: var(--qm-space-lg, 20px);
    --padding-left: var(--qm-space-lg, 20px);
    --margin-top: 0px;
    --margin-right: 0px;
    --margin-bottom: var(--qm-space-lg, 20px);
    --margin-left: 0px;
    --box-shadow: var(--shadow);
    --hover-effect: lift;

    margin: var(--margin-top) var(--margin-right) var(--margin-bottom) var(--margin-left);
    background-color: var(--bg-color);
    border-radius: var(--border-radius);
    border: var(--border-color) != transparent ? 1px solid var(--border-color) : none;
}

.qm-quote-showcase-title {
    font-size: var(--qm-text-2xl, 1.75rem);
    font-weight: var(--qm-font-bold, 700);
    margin: 0 0 var(--qm-space-xl, 2rem) 0;
    text-align: center;
    color: var(--quote-color);
}

/* === RESPONSIVE GRID SYSTEM === */
/* Core responsive 3→2→1 layout from perfect configuration analysis */

.qm-quotes-grid {
    display: grid;
    gap: var(--gap-size);
    grid-template-columns: repeat(var(--columns-mobile), 1fr);
}

/* CRITICAL: Bulletproof responsive breakpoints with !important */
/* These !important declarations are REQUIRED to override theme conflicts */
@media (max-width: 639px) {
    .qm-quote-showcase .qm-quotes-grid {
        grid-template-columns: 1fr !important;  /* 1 column mobile */
    }
}

@media (min-width: 640px) and (max-width: 899px) {
    .qm-quote-showcase .qm-quotes-grid {
        grid-template-columns: 1fr 1fr !important;  /* 2 columns tablet */
    }
}

@media (min-width: 900px) {
    .qm-quote-showcase .qm-quotes-grid {
        grid-template-columns: 1fr 1fr 1fr !important;  /* 3 columns desktop */
    }
}

/* === QUOTE CARD COMPONENTS === */

.qm-quote-item {
    background: var(--qm-bg-primary, #ffffff);
    border-radius: var(--border-radius);
    padding: var(--padding-top) var(--padding-right) var(--padding-bottom) var(--padding-left);
    transition: var(--transition);
    box-shadow: var(--box-shadow);
    position: relative;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--qm-border-light, rgba(0,0,0,0.05));
    font-size: var(--custom-font-size);
    font-weight: var(--font-weight);
    line-height: var(--line-height);
    letter-spacing: var(--letter-spacing);
}

/* Character Avatar */
.qm-quote-avatar {
    width: var(--qm-character-avatar-size, 48px);
    height: var(--qm-character-avatar-size, 48px);
    border-radius: var(--qm-border-radius-full, 50%);
    overflow: hidden;
    margin-bottom: var(--qm-space-md, 1rem);
    flex-shrink: 0;
    border: var(--qm-character-avatar-border, 2px) solid var(--character-color);
}

.qm-quote-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.qm-quote-avatar a {
    display: block;
    width: 100%;
    height: 100%;
}

/* Quote Text */
.qm-quote-text {
    font-size: var(--quote-font-size);
    line-height: var(--qm-leading-relaxed, 1.6);
    margin: 0 0 var(--qm-space-md, 1rem) 0;
    color: var(--quote-color);
    flex: 1;
    position: relative;
}

/* Quote Author */
.qm-quote-author {
    font-size: var(--qm-text-sm, 0.875rem);
    color: var(--author-color);
    font-weight: var(--qm-font-semibold, 600);
    font-style: normal;
    margin-top: auto;
}

.qm-quote-author a {
    color: var(--character-color);
    text-decoration: none;
    transition: var(--transition);
}

.qm-quote-author a:hover {
    text-decoration: underline;
}

/* Quote Source */
.qm-quote-source {
    font-size: var(--qm-text-xs, 0.75rem);
    color: #999;
    margin-top: var(--qm-space-sm, 0.5rem);
    opacity: 0.8;
    text-align: center;
}

.qm-quote-source a {
    color: inherit;
    text-decoration: none;
}

.qm-quote-source a:hover {
    text-decoration: underline;
}

/* === ENHANCED STYLING VARIATIONS === */

/* Shadow Intensity Variations */
.qm-shadow-none {
    --box-shadow: var(--qm-shadow-none, none);
}

.qm-shadow-light {
    --box-shadow: var(--qm-shadow-sm, 0 1px 3px rgba(0,0,0,0.12));
}

.qm-shadow-medium {
    --box-shadow: var(--qm-shadow-md, 0 4px 6px rgba(0,0,0,0.12));
}

.qm-shadow-strong {
    --box-shadow: var(--qm-shadow-lg, 0 10px 15px rgba(0,0,0,0.12));
}

/* Font Weight Variations */
.qm-weight-normal {
    --font-weight: var(--qm-font-normal, 400);
}

.qm-weight-medium {
    --font-weight: var(--qm-font-medium, 500);
}

.qm-weight-semibold {
    --font-weight: var(--qm-font-semibold, 600);
}

.qm-weight-bold {
    --font-weight: var(--qm-font-bold, 700);
}

/* Letter Spacing Variations */
.qm-spacing-tight {
    --letter-spacing: var(--qm-tracking-tight, -0.025em);
}

.qm-spacing-normal {
    --letter-spacing: var(--qm-tracking-normal, 0);
}

.qm-spacing-wide {
    --letter-spacing: var(--qm-tracking-wide, 0.025em);
}

.qm-spacing-wider {
    --letter-spacing: var(--qm-tracking-wider, 0.05em);
}

/* Enhanced Styling Override for Quote Text */
.qm-enhanced-styling .qm-quote-text {
    font-size: var(--custom-font-size);
    font-weight: var(--font-weight);
    line-height: var(--line-height);
    letter-spacing: var(--letter-spacing);
}

.qm-enhanced-styling .qm-quote-author {
    color: var(--author-color);
    font-weight: var(--font-weight);
}

.qm-enhanced-styling .qm-quote-avatar {
    border-color: var(--accent-color, var(--character-color));
}

.qm-enhanced-styling .qm-character-link {
    color: var(--accent-color, var(--character-color));
}

/* === HOVER EFFECTS === */

.qm-hover-lift .qm-quote-item:hover {
    transform: translateY(-3px);
    box-shadow: var(--hover-shadow);
}

.qm-hover-glow .qm-quote-item:hover {
    box-shadow: 0 0 20px var(--accent-color, #007cba), var(--box-shadow);
}

.qm-hover-scale .qm-quote-item:hover {
    transform: scale(1.02);
    box-shadow: var(--hover-shadow);
}

.qm-hover-none .qm-quote-item:hover {
    transform: none;
    box-shadow: var(--box-shadow);
}

/* === VISUAL STYLES === */

/* Modern Style (default) */
.qm-style-modern .qm-quote-text {
    font-weight: var(--qm-font-normal, 400);
    position: relative;
}

/* Classic Style */
.qm-style-classic .qm-quote-text {
    font-style: italic;
    position: relative;
}

.qm-style-classic .qm-quote-text::before {
    content: '"';
    font-size: 3rem;
    color: var(--character-color);
    position: absolute;
    left: -1rem;
    top: -0.5rem;
    opacity: 0.3;
    font-family: var(--qm-font-serif, Georgia, serif);
}

.qm-style-classic .qm-quote-text::after {
    content: '"';
    font-size: 3rem;
    color: var(--character-color);
    position: absolute;
    right: -0.5rem;
    bottom: -1rem;
    opacity: 0.3;
    font-family: var(--qm-font-serif, Georgia, serif);
}

/* Minimal Style */
.qm-style-minimal .qm-quote-item {
    background: transparent;
    box-shadow: none;
    border: none;
    border-left: 4px solid var(--character-color);
    border-radius: 0;
    padding: var(--qm-space-md, 1rem) var(--qm-space-lg, 1.5rem);
}

.qm-style-minimal .qm-quote-item:hover {
    transform: none;
    background: rgba(0,0,0,0.02);
}

.qm-style-minimal .qm-quote-avatar {
    display: none;
}

/* Bubble Style */
.qm-style-bubble .qm-quote-item {
    position: relative;
    background: var(--character-color);
    color: white;
    border-radius: var(--qm-border-radius-xl, 1.5rem);
}

.qm-style-bubble .qm-quote-item::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 2rem;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid var(--character-color);
}

.qm-style-bubble .qm-quote-text {
    color: white;
}

.qm-style-bubble .qm-quote-author {
    color: rgba(255,255,255,0.9);
}

.qm-style-bubble .qm-quote-author a {
    color: white;
}

/* === LAYOUT VARIATIONS === */

/* Grid Layout - Explicit Declaration */
.qm-layout-grid .qm-quotes-grid {
    display: grid !important;
}

/* List Layout */
.qm-layout-list .qm-quotes-grid {
    display: block;
    max-width: 800px;
    margin: 0 auto;
}

.qm-layout-list .qm-quote-item {
    margin-bottom: var(--gap-size);
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: var(--qm-space-md, 1rem);
}

.qm-layout-list .qm-quote-avatar {
    margin-bottom: 0;
    flex-shrink: 0;
}

/* Carousel Layout */
.qm-layout-carousel .qm-quotes-grid {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: var(--gap-size);
    padding-bottom: var(--qm-space-md, 1rem);
}

.qm-layout-carousel .qm-quote-item {
    flex: 0 0 320px;
    scroll-snap-align: start;
}

.qm-layout-carousel .qm-quotes-grid::-webkit-scrollbar {
    height: 8px;
}

.qm-layout-carousel .qm-quotes-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.qm-layout-carousel .qm-quotes-grid::-webkit-scrollbar-thumb {
    background: var(--character-color);
    border-radius: 4px;
}

/* Masonry Layout */
.qm-layout-masonry .qm-quotes-grid {
    display: block;
    columns: var(--columns-mobile);
    column-gap: var(--gap-size);
}

@media (min-width: 640px) {
    .qm-layout-masonry .qm-quotes-grid {
        columns: var(--columns-tablet);
    }
}

@media (min-width: 900px) {
    .qm-layout-masonry .qm-quotes-grid {
        columns: var(--columns-desktop);
    }
}

.qm-layout-masonry .qm-quote-item {
    break-inside: avoid;
    margin-bottom: var(--gap-size);
    display: inline-block;
    width: 100%;
}

/* === SPACING VARIATIONS === */
.qm-spacing-compact {
    --gap-size: var(--qm-gap-compact, 15px);
}

.qm-spacing-wide {
    --gap-size: var(--qm-gap-wide, 30px);
}

.qm-spacing-extra-wide {
    --gap-size: var(--qm-gap-extra-wide, 40px);
}

/* === FONT SIZE VARIATIONS === */
.qm-font-small {
    --quote-font-size: var(--qm-text-sm, 0.9rem);
}

.qm-font-large {
    --quote-font-size: var(--qm-text-lg, 1.125rem);
}

.qm-font-extra-large {
    --quote-font-size: var(--qm-text-xl, 1.25rem);
}

/* === SQUARE STYLE - LEGACY SLIDER INSPIRED === */
.qm-quote-showcase.qm-style-square .qm-quote-item {
    aspect-ratio: 1/1;
    position: relative;
    background-size: cover;
    background-position: center;
    border-radius: var(--qm-border-radius-lg, 12px);
    overflow: hidden;
    border: none;
    box-shadow: var(--qm-shadow-lg, 0 4px 16px rgba(0,0,0,0.15));
    transition: var(--qm-transition, transform 0.3s ease);
}

.qm-quote-showcase.qm-style-square .qm-quote-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--qm-hover-shadow-lg, 0 8px 24px rgba(0,0,0,0.2));
}

/* Lighter overlay for better background visibility */
.qm-quote-showcase.qm-style-square .qm-quote-item::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(0,0,0,0.2), rgba(0,0,0,0.4));
    z-index: 1;
}

.qm-quote-showcase.qm-style-square .qm-quote-content {
    position: absolute;
    inset: 20px;
    bottom: 60px;
    z-index: 2;
    display: flex;
    flex-direction: column;
    text-align: center;
    height: calc(100% - 80px);
}

/* Character avatar at top - completely round */
.qm-quote-showcase.qm-style-square .qm-character-avatar {
    width: var(--qm-character-avatar-size-lg, 80px);
    height: var(--qm-character-avatar-size-lg, 80px);
    border-radius: var(--qm-border-radius-full, 50%) !important;
    border: 3px solid white;
    margin: 0 auto;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    display: block;
}

/* Quote text styling - bold and centered */
.qm-quote-showcase.qm-style-square .qm-quote-text {
    color: white;
    font-style: italic;
    font-size: var(--qm-text-base, 1rem);
    font-weight: var(--qm-font-bold, bold);
    line-height: var(--qm-leading-normal, 1.4);
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin: 15px 0 15px 0;
    overflow: hidden;
    max-height: calc(100% - 140px);
}

/* Author label - positioned above source */
.qm-quote-showcase.qm-style-square .qm-quote-author {
    background: rgba(0,0,0,0.95);
    color: white;
    padding: 4px 8px;
    border-radius: var(--qm-border-radius, 8px);
    font-size: var(--qm-text-xs, 0.75rem);
    font-weight: var(--qm-font-medium, 500);
    align-self: center;
    text-shadow: none;
    max-width: fit-content;
    border: 2px solid white;
    margin-top: auto;
    margin-bottom: 8px;
}

.qm-quote-showcase.qm-style-square .qm-quote-author a {
    color: white;
    text-decoration: none;
}

/* Source post in black bar at bottom */
.qm-quote-showcase.qm-style-square .qm-quote-source {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 8px 15px;
    font-size: var(--qm-text-sm, 0.8rem);
    text-align: center;
    z-index: 3;
    border-bottom-left-radius: var(--qm-border-radius-lg, 12px);
    border-bottom-right-radius: var(--qm-border-radius-lg, 12px);
}

.qm-quote-showcase.qm-style-square .qm-quote-source a {
    color: white;
    text-decoration: none;
    font-weight: var(--qm-font-medium, 500);
}

.qm-quote-showcase.qm-style-square .qm-quote-source a:hover {
    text-decoration: underline;
}

/* === ANIMATIONS === */
.qm-animate .qm-quote-item {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.6s ease forwards;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.qm-animate .qm-quote-item[data-animate-delay] {
    animation-delay: calc(var(--animate-delay, 0) * 1ms);
}

/* Live Refresh State */
.qm-quote-showcase.qm-refreshing {
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.qm-quote-showcase.qm-refreshing .qm-quotes-grid {
    pointer-events: none;
}

/* Empty State */
.qm-quote-showcase-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: var(--qm-space-2xl, 3rem) var(--qm-space-md, 1rem);
    color: var(--qm-text-muted, #666);
    font-style: italic;
}

/* === BADGE POSITIONING === */
/* Ensure corner badges are properly positioned on quote items */
.qm-quote-item .qm-badge--corner {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
}

/* Square style badge positioning adjustment */
.qm-quote-showcase.qm-style-square .qm-quote-item .qm-badge--corner {
    top: 12px;
    right: 12px;
    z-index: 20; /* Higher z-index to appear above overlay */
}

/* === RESPONSIVE ADJUSTMENTS === */
@media (max-width: 639px) {
    .qm-quote-item {
        padding: var(--qm-quote-card-padding-mobile, 1rem);
    }

    .qm-layout-carousel .qm-quote-item {
        flex: 0 0 280px;
    }

    .qm-layout-list .qm-quote-item {
        flex-direction: column;
    }

    .qm-layout-list .qm-quote-avatar {
        margin-bottom: var(--qm-space-md, 1rem);
    }

    /* Square style mobile adjustments */
    .qm-quote-showcase.qm-style-square .qm-character-avatar {
        width: 60px;
        height: 60px;
    }

    .qm-quote-showcase.qm-style-square .qm-quote-text {
        font-size: var(--qm-text-sm, 0.9rem);
        max-height: calc(100% - 120px);
    }

    .qm-quote-showcase.qm-style-square .qm-quote-content {
        inset: 15px;
        bottom: 50px;
        height: calc(100% - 65px);
    }

    .qm-quote-showcase.qm-style-square .qm-quote-source {
        padding: 6px 12px;
        font-size: var(--qm-text-xs, 0.75rem);
    }

    .qm-quote-showcase.qm-style-square .qm-quote-author {
        font-size: 0.7rem;
        padding: 3px 6px;
        margin-bottom: 6px;
    }
}

/* === HIGH CONTRAST MODE === */
@media (prefers-contrast: high) {
    .qm-quote-item {
        border-width: 2px;
        border-color: var(--qm-border-color, #000);
    }

    .qm-quote-author {
        color: var(--qm-text-primary, #000);
    }
}

/* === REDUCED MOTION === */
@media (prefers-reduced-motion: reduce) {
    .qm-quote-item,
    .qm-quote-author a {
        transition: none;
    }

    .qm-quote-item:hover {
        transform: none;
    }

    .qm-animate .qm-quote-item {
        animation: none;
        opacity: 1;
        transform: none;
    }

    .qm-quote-showcase.qm-refreshing {
        transition: none;
    }
}