/**
 * Monster Directory - Frontend Styles
 *
 * @package RPG_Monster_Database
 */

/* ==========================================================================
   Monster Archive/Directory
   ========================================================================== */

.rpg-monster-archive {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.rpg-monster-archive .page-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 3px solid #0073aa;
}

.rpg-monster-archive .page-title {
    font-size: 2.5em;
    margin: 0 0 10px 0;
    color: #23282d;
}

.taxonomy-description {
    font-size: 1.1em;
    color: #666;
    margin-top: 10px;
}

/* Filter Controls */
.rpg-monster-filters {
    background: #f7f7f7;
    padding: 20px;
    margin-bottom: 30px;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.monster-filter-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-group label {
    font-weight: 600;
    margin-bottom: 5px;
    color: #23282d;
    font-size: 14px;
}

.filter-group input[type="text"],
.filter-group select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    width: 100%;
}

/* Override for search wrapper */
.search-input-wrapper {
    width: 100%;
}

.filter-group input[type="text"]:focus,
.filter-group select:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 1px #0073aa;
}

.filter-submit {
    display: flex;
    gap: 10px;
}

.filter-submit .button {
    flex: 1;
    padding: 10px 20px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    border: none;
}

.button-primary {
    background: #0073aa;
    color: #fff;
}

.button-primary:hover {
    background: #005177;
}

.button {
    background: #f7f7f7;
    color: #23282d;
    border: 1px solid #ddd;
}

.button:hover {
    background: #e5e5e5;
}

/* Results Info */
.rpg-monster-results-info {
    margin-bottom: 20px;
    padding: 10px 15px;
    background: #fff;
    border-left: 4px solid #0073aa;
}

.results-count {
    margin: 0;
    font-size: 16px;
    color: #555;
}

/* Monster Grid */
.rpg-monster-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

.rpg-monster-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* Desktop hover and mobile touch/active states */
.rpg-monster-card:hover,
.rpg-monster-card:focus-within,
.rpg-monster-card:active {
    transform: translateY(-4px);
    box-shadow: 0px 0px 12px 10px green;
}

/* Ensure touch devices get the effect on tap */
@media (hover: none) and (pointer: coarse) {
    .rpg-monster-card:active {
        transform: translateY(-2px);
        box-shadow: 0px 0px 12px 10px green;
    }
}

.monster-card-image {
    position: relative;
    padding-top: 66.67%; /* 3:2 aspect ratio */
    background: #f0f0f0;
    overflow: hidden;
}

.monster-card-image a {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.monster-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.monster-card-content {
    padding: 20px;
}

.monster-card-title {
    margin: 0 0 10px 0;
    font-size: 1.5em;
    line-height: 1.3;
}

.monster-card-title a {
    color: #23282d;
    text-decoration: none;
}

.monster-card-title a:hover {
    color: #0073aa;
}

.monster-card-meta {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.monster-meta-size {
    display: none;
}

.monster-meta-type {
    display: inline-block;
    padding: 4px 10px;
    background-color: #363636;
    color: #fff;
    font-size: 12px;
    border-radius: 3px;
    font-weight: 600;
    text-transform: uppercase;
}

.monster-meta-type {
    background-color: #363636;
}

.monster-card-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 12px;
    padding: 12px;
    background: #f9f9f9;
    border-radius: 4px;
}

.stat-item {
    font-size: 14px;
    color: #555;
}

.stat-item strong {
    color: #23282d;
}

.monster-card-excerpt {
    font-size: 14px;
    line-height: 1.6;
    color: #000;
    margin-bottom: 15px;
}

.monster-card-footer {
    padding-top: 12px;
    border-top: 1px solid #eee;
}

.button-small {
    display: inline-block;
    padding: 8px 16px;
    font-size: 14px;
    text-decoration: none;
}

/* No Results */
.no-monsters-found {
    text-align: center;
    padding: 60px 20px;
    background: #f7f7f7;
    border-radius: 8px;
}

.no-monsters-found p {
    font-size: 18px;
    color: #666;
    margin: 0;
}

/* Search Input Wrapper */
.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-wrapper input {
    flex: 1;
    padding-right: 40px;
}

.search-spinner {
    position: absolute;
    right: 10px;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0073aa;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 10;
    pointer-events: none;
}

/* Loading Indicator */
.monster-loading {
    text-align: center;
    padding: 40px 30px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    margin: 30px auto;
    max-width: 600px;
    border: 3px solid #dee2e6;
}

/* Scrolling Bars Container */
.monster-loading .spinner {
    width: 100%;
    height: 50px;
    background: #ffffff;
    border-radius: 25px;
    overflow: hidden;
    position: relative;
    margin-bottom: 20px;
    box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.08);
    border: 3px solid #dee2e6;
}

/* Multiple Scrolling Bars */
.monster-loading .spinner::before,
.monster-loading .spinner::after {
    content: '';
    position: absolute;
    top: 0;
    height: 100%;
    width: 60%;
}

.monster-loading .spinner::before {
    left: -60%;
    background: linear-gradient(90deg, 
        transparent 0%,
        #4facfe 20%,
        #00f2fe 50%,
        #4facfe 80%,
        transparent 100%
    );
    animation: scroll-bars 2s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(0, 242, 254, 0.6);
}

.monster-loading .spinner::after {
    left: -60%;
    background: linear-gradient(90deg, 
        transparent 0%,
        #667eea 20%,
        #764ba2 50%,
        #667eea 80%,
        transparent 100%
    );
    animation: scroll-bars 2s ease-in-out 1s infinite;
    box-shadow: 0 0 20px rgba(118, 75, 162, 0.6);
}

@keyframes scroll-bars {
    0% { 
        left: -60%;
        opacity: 0;
    }
    20% {
        opacity: 1;
    }
    80% {
        opacity: 1;
    }
    100% { 
        left: 100%;
        opacity: 0;
    }
}

.monster-loading p {
    margin: 0;
    color: #495057;
    font-weight: 800;
    font-size: 24px;
    letter-spacing: 4px;
    text-transform: uppercase;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    animation: pulse-text 2s ease-in-out infinite;
}

@keyframes pulse-text {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* Dim results during loading */
.rpg-monster-grid.is-loading {
    opacity: 0.6;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Back to Top Button */
.rpg-back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background-color: #0073aa;
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 9999;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    font-size: 24px;
    line-height: 1;
    padding: 0;
}

.rpg-back-to-top:hover {
    background-color: #005a87;
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.rpg-back-to-top .arrow {
    display: block;
    font-weight: bold;
}

/* Load More Button */
#rpg-load-more-monsters {
    padding: 12px 30px;
    font-size: 16px;
    background-color: #0073aa;
    border-color: #0073aa;
}

#rpg-load-more-monsters:hover:not(:disabled) {
    background-color: #005a87;
    border-color: #005a87;
}

#rpg-load-more-monsters:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==========================================================================
   Single Monster Page
   ========================================================================== */

.rpg-monster-single {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

.rpg-monster-entry {
    background: #fff url('paperbackground.jpg') no-repeat center center;
    background-size: cover;
    padding: 30px;
    border-radius: 8px;
}

.rpg-monster-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 3px solid #0073aa;
}

.rpg-monster-title {
    font-size: 2.5em;
    margin: 0 0 15px 0;
    color: #23282d;
}

.rpg-monster-taxonomy-meta {
    display: flex;
    gap: 20px;
    font-size: 16px;
}

.monster-size,
.monster-type {
    color: #555;
}

.monster-size strong,
.monster-type strong {
    color: #23282d;
}

/* Monster Image */
.rpg-monster-image {
    margin-bottom: 30px;
    text-align: center;
}

.rpg-monster-single .rpg-monster-image img {
    max-width: 420px;
    width: 100%;
    height: auto;
    max-height: 560px;
    object-fit: contain;
    margin: 0 auto 1.5rem;
    display: block;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Stats Block */
.rpg-monster-stats-block,
.rpg-monster-saves-block {
    margin-bottom: 30px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #e5e5e5;
}

.rpg-stats-heading {
    margin: 0 0 15px 0;
    font-size: 1.5em;
    color: #0073aa;
}

.rpg-stats-grid,
.rpg-saves-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
}

.rpg-stat-item,
.rpg-save-item {
    display: flex;
    flex-direction: column;
    padding: 12px;
    background: #fff;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.rpg-stat-wide {
    grid-column: span 2;
}

.rpg-stat-label,
.rpg-save-label {
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 700;
    color: #666;
    margin-bottom: 5px;
}

.rpg-stat-value,
.rpg-save-value {
    font-size: 24px;
    font-weight: 700;
    color: #23282d;
}

/* Attributes */
.rpg-monster-attributes-block {
    margin-bottom: 25px;
}

.rpg-attribute-item {
    padding: 10px 0;
    border-bottom: 1px solid #eee;
    font-size: 16px;
    color: #555;
}

.rpg-attribute-item:last-child {
    border-bottom: none;
}

.rpg-attribute-item strong {
    color: #23282d;
    margin-right: 8px;
}

/* About/Description */
.rpg-monster-about {
    margin-bottom: 30px;
    line-height: 1.8;
    color: #000;
}

.rpg-monster-about h2 {
    font-size: 1.8em;
    margin: 0 0 15px 0;
    color: #23282d;
}

/* Special Abilities */
.rpg-monster-special-attack,
.rpg-monster-special-defense {
    margin-bottom: 25px;
    padding: 20px;
    background: #fffbf0;
    border-left: 4px solid #ffb900;
    border-radius: 4px;
}

.rpg-monster-special-attack h2,
.rpg-monster-special-defense h2 {
    margin: 0 0 12px 0;
    font-size: 1.4em;
    color: #23282d;
}

.rpg-special-content {
    line-height: 1.7;
    color: #000;
}

/* Tags */
.rpg-monster-tags {
    margin-bottom: 25px;
}

.rpg-monster-tags h3 {
    font-size: 1.2em;
    margin: 0 0 10px 0;
}

.rpg-tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.rpg-tag {
    display: inline-block;
    padding: 6px 12px;
    background: #0073aa;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    transition: background 0.2s;
}

.rpg-tag:hover {
    background: #005177;
}

/* Navigation */
.rpg-monster-navigation a {
    padding: 8px;
    border-top: 0px solid #eee;
    margin-top: 5px;
    margin-bottom: 5px;
    background-color: #f0f8ff;
}

/* Prev/Next Monster Navigation */
.rpg-monster-prev-next {
    margin: 30px 0;
    padding: 20px 0;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
}

.rpg-monster-prev-next .prev-next-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.rpg-monster-prev-next a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: #363636;
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    transition: background-color 0.2s ease, transform 0.2s ease;
    max-width: 45%;
}

.rpg-monster-prev-next a:hover {
    background: #4a4a4a;
    transform: translateY(-2px);
}

.rpg-monster-prev-next .prev-monster {
    text-align: left;
}

.rpg-monster-prev-next .next-monster {
    text-align: right;
    margin-left: auto;
}

.rpg-monster-prev-next .nav-arrow {
    font-size: 1.4em;
    font-weight: bold;
}

.rpg-monster-prev-next .nav-label {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rpg-monster-prev-next .disabled {
    visibility: hidden;
}

/* Mobile responsive */
@media (max-width: 600px) {
    .rpg-monster-prev-next .prev-next-wrapper {
        flex-direction: column;
        gap: 10px;
    }
    
    .rpg-monster-prev-next a {
        max-width: 100%;
        width: 100%;
        justify-content: center;
    }
    
    .rpg-monster-prev-next .next-monster {
        margin-left: 0;
    }
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 40px;
}

.page-numbers {
    display: inline-block;
    padding: 8px 12px;
    background: #f7f7f7;
    color: #23282d;
    text-decoration: none;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.page-numbers:hover,
.page-numbers.current {
    background: #0073aa;
    color: #fff;
    border-color: #0073aa;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
    .monster-filter-form {
        grid-template-columns: 1fr;
    }

    .rpg-monster-grid {
        grid-template-columns: 1fr;
    }

    .rpg-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .rpg-stat-wide {
        grid-column: span 1;
    }

    .rpg-monster-title {
        font-size: 2em;
    }

    .rpg-monster-taxonomy-meta {
        flex-direction: column;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .rpg-monster-archive,
    .rpg-monster-single {
        padding: 10px;
    }

    .rpg-monster-entry {
        padding: 20px 15px;
    }

    .rpg-monster-title {
        font-size: 1.6em;
    }

    .rpg-stats-grid,
    .rpg-saves-grid {
        grid-template-columns: 1fr;
    }
}
