/* Main HTML Tarot Styles - Compact Version */
body {
    font-family: Georgia, serif;
    margin: 0;
    padding: 15px; /* Reduced from 20px */
    line-height: 1.6;
    background-color: #fafafa;
}

/* Card Layout Structure - Tighter spacing */
.card-page {
    max-width: 800px;
    margin: 0 auto;
    padding: 15px; /* Reduced from 20px */
}

.card-title {
    font-size: 2.5em;
    font-weight: bold;
    text-align: center;
    margin-bottom: 20px; /* Reduced from 30px */
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* New layout: Upper section with image and narrative, Lower section with description */
.card-content-wrapper {
    display: flex;
    flex-direction: column;
    gap: 20px; /* Reduced from 30px */
    margin-bottom: 20px; /* Reduced from 30px */
}

.card-upper {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 20px; /* Reduced from 30px */
    /* Fix for overflow issues */
    min-width: 0;
    overflow: hidden;
}

.card-lower {
    width: 100%;
    clear: both; /* Ensure it flows below the grid */
    margin-top: 20px; /* Space from content above */
    border-top: 2px solid #333; /* HR separator line */
    padding-top: 20px; /* Space below the line */
}

.card-image-container {
    border: 3px solid #333;
    padding: 10px;
    background: white;
    height: 600px; /* Reduced from 700px */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.card-image-container:hover {
    transform: scale(1.02);
}

.card-image {
    width: auto;
    height: 580px; /* Reduced from 680px */
    min-height: 580px;
    object-fit: contain;
}

/* Modal styles */
.image-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    cursor: pointer;
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1001;
}

.modal-close:hover {
    opacity: 0.7;
}

/* Card content sections - compact spacing */
.card-details {
    padding: 15px; /* Reduced from 20px */
    font-size: 0.85em;
    line-height: 1.5;
    /* Fix for long text overflow */
    min-width: 0;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

/* Narrative section styling - compact */
.card-narrative {
    margin-bottom: 17px; /* Reduced from 25px */
}

.card-narrative h3 {
    font-size: 1.2em;
    margin-bottom: 7px; /* Reduced from 10px */
    text-decoration: underline;
}

.narrative-text {
    font-style: italic;
    font-size: 1.1em; /* Back to original size */
    line-height: 1.65;
    margin: 10px 0; /* Reduced from 15px */
    padding: 15px; /* Reduced from 20px */
    background: #f9f9f9;
    color: #444;
    min-height: 60px;
    /* Fix for long text overflow */
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
    box-sizing: border-box;
}

/* Description section - compact spacing */
.card-description {
    margin-top: 15px; /* Reduced from 20px */
    padding-top: 15px; /* Reduced from 20px */
    border-top: 1px solid #ddd;
}

.card-description h3 {
    font-size: 1.2em;
    margin-bottom: 7px; /* Reduced from 10px */
    text-decoration: underline;
}

.card-description p {
    line-height: 1.5;
    margin-bottom: 5px; /* Reduced from 8px */
    font-size: 0.9em;
}

/* First paragraph in description (summary) gets emphasis */
.card-description p:first-of-type {
    font-size: 1em;
    font-weight: 500;
    margin-bottom: 10px; /* Reduced from 15px */
    color: #2c3e50;
}

.card-notes {
    border-top: 2px solid #333;
    padding-top: 10px; /* Reduced from 15px */
    margin-top: 15px; /* Reduced from 20px */
}

.notes-layout {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
    /* Firefox flexbox fixes */
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

.notes-left {
    flex: 1 1 auto;
    text-align: left;
    /* Firefox flexbox fixes */
    -moz-flex: 1 1 auto;
    min-width: 0;
}

.notes-right {
    flex: 0 0 auto;
    text-align: right;
    margin-left: auto;
    /* Firefox flexbox fixes */
    -moz-flex: 0 0 auto;
    align-self: flex-end;
    justify-self: flex-end;
}

.card-notes h3 {
    font-size: 1.1em;
    margin-bottom: 7px; /* Reduced from 10px */
}

.note-icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    background: #333;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
}

.note-link {
    color: #333;
    text-decoration: none;
    margin-right: 15px;
}

.note-link:hover {
    text-decoration: underline;
}

/* Navigation styles - compact */
.nav-container {
    text-align: center;
    margin: 20px 0; /* Reduced from 30px */
}

.nav-button {
    display: inline-block;
    padding: 10px 20px;
    margin: 0 10px;
    background: #333;
    color: white;
    text-decoration: none;
    border-radius: 5px;
}

.nav-button:hover {
    background: #555;
}

/* Interactive elements - compact */
.interactive-container {
    text-align: center;
    margin: 20px 0; /* Reduced from 30px */
}

.draw-button {
    padding: 15px 30px;
    font-size: 1.2em;
    background: #4a4a4a;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin: 10px;
}

.draw-button:hover {
    background: #666;
}

/* Debug and testing elements */
.debug-info {
    background: #ffe6e6;
    padding: 15px;
    margin: 10px 0;
    border-radius: 5px;
    font-family: monospace;
    font-size: 0.9em;
}

.narrative-selector {
    margin: 7px 0; /* Reduced from 10px */
    text-align: center;
}

.narrative-btn {
    padding: 8px 15px;
    margin: 0 5px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.9em;
}

.narrative-btn.active {
    background: #2c3e50;
}

/* Responsive design - compact */
@media (max-width: 768px) {
    .card-upper {
        grid-template-columns: 1fr;
        gap: 15px; /* Reduced from 20px */
    }
    
    .card-title {
        font-size: 2em;
    }
    
    .card-image-container {
        height: 400px;
    }
    
    .card-details {
        font-size: 0.9em;
    }
    
    .modal-content {
        max-width: 95vw;
        max-height: 85vh;
    }
    
    .modal-close {
        top: 10px;
        right: 15px;
        font-size: 30px;
    }
}

/* Additional HTML-specific styles - compact */
.main-nav {
    background: #333;
    padding: 12px; /* Reduced from 15px */
    margin-bottom: 20px; /* Reduced from 30px */
    text-align: center;
}

.main-nav a {
    color: white;
    text-decoration: none;
    margin: 0 15px;
    padding: 5px 10px;
    border-radius: 3px;
}

.main-nav a:hover {
    background: #555;
}

/* Backwards compatibility with existing card structure */
.card-content {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 20px; /* Reduced from 30px */
    margin-bottom: 20px; /* Reduced from 30px */
}

@media (max-width: 768px) {
    .card-content {
        grid-template-columns: 1fr;
        gap: 15px; /* Reduced from 20px */
    }
}