/* Grid */
.mmcd-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 325px));
    gap: 24px;
    padding: 20px 0;
    justify-content: center;
}

@media (max-width: 1400px) {
    .mmcd-grid {
        grid-template-columns: repeat(3, minmax(0, 325px));
    }
}

@media (max-width: 1050px) {
    .mmcd-grid {
        grid-template-columns: repeat(2, minmax(0, 325px));
    }
}

@media (max-width: 700px) {
    .mmcd-grid {
        grid-template-columns: minmax(0, 325px);
    }
}

/* Card */
.mmcd-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s ease;
    max-width: 325px;
}

/* Centrar tarjeta individual (single) */
.single-mm_catalog .mmcd-card {
    margin: 0 auto;
}

/* Hide author/byline injected by theme */
.mmcd-card .byline,
.mmcd-card .author,
.mmcd-card .post-author,
.mmcd-card .entry-author,
.mmcd-card .meta-author,
.mmcd-card [class*="author"],
.mmcd-card [rel="author"],
.mmcd-grid .byline,
.mmcd-grid .author,
.mmcd-grid .post-author,
.mmcd-grid .entry-author,
.mmcd-grid [class*="author"],
.single-mm_catalog .byline,
.single-mm_catalog .author,
.single-mm_catalog .post-author,
.single-mm_catalog .entry-author,
.single-mm_catalog .meta-author,
.single-mm_catalog [class*="author"],
.single-mm_catalog [rel="author"],
.single-mm_catalog .entry-meta,
.single-mm_catalog .post-meta,
.single-mm_catalog .wp-block-post-author,
.single-mm_catalog .wp-block-post-date,
.single-mm_catalog .posted-by,
.single-mm_catalog .meta {
    display: none !important;
}

.mmcd-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

/* Imagen normal (sin 3D) */
.mmcd-card-image {
    aspect-ratio: 210 / 297; /* Proporcion A4 */
    max-height: 460px;
    overflow: hidden;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mmcd-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

/* Efecto libro 3D */
.mmcd-card-image-3d {
    background: linear-gradient(135deg, #e8e8e8 0%, #d5d5d5 100%);
    perspective: 1200px;
    padding: 35px;
    box-sizing: border-box;
    overflow: visible;
    display: flex;
    justify-content: center;
    align-items: center;
}

.mmcd-card-image-3d .mmcd-book {
    --book-angle: 25deg; /* valor por defecto horizontal */
    --book-angle-v: 5deg; /* valor por defecto vertical */
    position: relative;
    transform-style: preserve-3d;
    transform: rotateY(var(--book-angle)) rotateX(var(--book-angle-v));
    transition: transform 0.4s ease;
    width: calc(100% - 30px);
    height: calc(100% - 10px);
}

.mmcd-card:hover .mmcd-card-image-3d .mmcd-book {
    transform: rotateY(calc(var(--book-angle) - 8deg)) rotateX(calc(var(--book-angle-v) - 2deg));
}

/* Portada del libro 3D */
.mmcd-card-image-3d .mmcd-book-cover {
    position: relative;
    width: 100%;
    height: 100%;
    background: #fff;
    border-radius: 0 4px 4px 0;
    overflow: hidden;
    box-shadow:
        10px 10px 30px rgba(0, 0, 0, 0.4),
        2px 2px 8px rgba(0, 0, 0, 0.2);
}

.mmcd-card-image-3d .mmcd-book-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

/* Lomo del libro con titulo */
.mmcd-card-image-3d .mmcd-book-spine {
    position: absolute;
    left: 0;
    top: 0;
    width: 35px;
    height: 100%;
    background: linear-gradient(90deg,
        #1a1a1a 0%,
        #3d3d3d 15%,
        #2d2d2d 50%,
        #3d3d3d 85%,
        #1a1a1a 100%);
    transform: translateX(-100%) rotateY(-90deg);
    transform-origin: right center;
    border-radius: 4px 0 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

.mmcd-card-image-3d .mmcd-book-spine-title {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    color: #c0c0c0;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 90%;
    padding: 10px 0;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* Paginas del libro (borde izquierdo) */
.mmcd-card-image-3d .mmcd-book-pages {
    position: absolute;
    right: 0;
    top: 1%;
    width: 12px;
    height: 98%;
    background: linear-gradient(90deg,
        #fff 0%,
        #f0f0f0 10%,
        #fff 20%,
        #e8e8e8 30%,
        #fff 40%,
        #f5f5f5 50%,
        #fff 60%,
        #eee 70%,
        #fff 80%,
        #f0f0f0 90%,
        #e5e5e5 100%);
    transform: translateX(100%) rotateY(90deg);
    transform-origin: left center;
    border-radius: 0 2px 2px 0;
}

/* Sombra inferior del libro */
.mmcd-card-image-3d .mmcd-book::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 10%;
    width: 80%;
    height: 20px;
    background: radial-gradient(ellipse at center, rgba(0,0,0,0.3) 0%, transparent 70%);
    transform: rotateX(90deg);
}

.mmcd-card-no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    color: #ccc;
}

.mmcd-card-image-3d .mmcd-book-cover .mmcd-card-no-image {
    background: linear-gradient(145deg, #f0f0f0 0%, #ddd 100%);
    color: #999;
}

.mmcd-card-no-image .dashicons {
    font-size: 60px;
    width: 60px;
    height: 60px;
}

/* Category Archive */
.mmcd-category-archive {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.mmcd-category-title {
    margin: 0 0 10px;
    font-size: 32px;
    color: #333;
}

.mmcd-category-description {
    margin: 0 0 30px;
    font-size: 16px;
    color: #666;
    line-height: 1.6;
}

.mmcd-card-content {
    padding: 16px;
}

.mmcd-card-title {
    margin: 0 0 8px;
    font-size: 18px;
    color: #333;
}

.mmcd-card-description {
    margin: 0 0 16px;
    font-size: 14px;
    color: #666;
    line-height: 1.5;
}

.mmcd-download-btn {
    display: inline-block;
    width: 100%;
    padding: 12px 24px;
    background: #000;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s ease;
}

.mmcd-download-btn:hover {
    background: #333;
}

.mmcd-download-btn:disabled {
    background: #999;
    cursor: not-allowed;
}

.mmcd-submit-btn {
    display: inline-block;
    width: 100%;
    padding: 12px 24px;
    background: #000;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s ease;
}

.mmcd-submit-btn:hover {
    background: #333;
}

.mmcd-submit-btn:disabled {
    background: #999;
    cursor: not-allowed;
}

.mmcd-no-pdf {
    display: inline-block;
    padding: 10px 24px;
    color: #999;
    font-size: 14px;
    font-style: italic;
}

/* Modal */
.mmcd-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: mmcdFadeIn 0.2s ease;
}

@keyframes mmcdFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.mmcd-modal {
    background: #fff;
    border-radius: 8px;
    padding: 32px;
    width: 90%;
    max-width: 440px;
    position: relative;
    animation: mmcdSlideIn 0.25s ease;
}

@keyframes mmcdSlideIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.mmcd-modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 28px;
    color: #666;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.mmcd-modal-close:hover {
    color: #333;
}

.mmcd-modal-title {
    margin: 0 0 20px;
    font-size: 20px;
    color: #333;
    padding-right: 30px;
}

/* Form */
.mmcd-field {
    margin-bottom: 16px;
}

.mmcd-field label {
    display: block;
    margin-bottom: 4px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.mmcd-field input,
.mmcd-field select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

.mmcd-field input:focus,
.mmcd-field select:focus {
    border-color: #000;
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

.mmcd-field input.mmcd-input-error,
.mmcd-field select.mmcd-input-error {
    border-color: #dc3232;
}

.mmcd-error {
    display: block;
    color: #dc3232;
    font-size: 12px;
    margin-top: 4px;
    min-height: 16px;
}

.mmcd-message {
    padding: 10px 14px;
    border-radius: 4px;
    font-size: 14px;
    margin-top: 8px;
}

.mmcd-message.mmcd-success {
    background: #e8f5e9;
    color: #2e7d32;
}

.mmcd-message.mmcd-error-msg {
    background: #fbe9e7;
    color: #c62828;
}
