/* Global reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #fafafa;
    min-height: 100vh;
    padding: 0;
    color: #2c2c2c;
    line-height: 1.6;
}

.container {
    padding: 0;
    max-width: 100%;
}

/* Back link - used on concept, artist, lesson pages */
.back-link {
    position: fixed;
    top: 1rem;
    left: 1rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    color: #666;
    text-decoration: none;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    border: 1px solid rgba(224, 224, 224, 0.5);
    border-radius: 4px;
    z-index: 100;
    transition: background 0.3s ease, color 0.3s ease;
}

.back-link:hover {
    background: rgba(255, 255, 255, 1);
    color: #2c2c2c;
}

/* Fixed header styles - page-title-section, lesson-title-section, header */
.page-title-section,
.lesson-title-section,
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    text-align: center;
    padding: 1rem;
    border-bottom: 1px solid rgba(224, 224, 224, 0.5);
    z-index: 99;
}

.page-title-section,
.lesson-title-section {
    padding-top: 3.5rem;
}

header {
    z-index: 100;
}

.page-title-section h1,
.lesson-title-section h1,
header h1 {
    font-size: 1.2rem;
    font-weight: 300;
    margin-bottom: 0.25rem;
    color: #1a1a1a;
    letter-spacing: 1px;
}

header h1 {
    margin: 0;
}

.breadcrumb,
.time-period {
    color: #888;
    font-size: 0.85rem;
    font-weight: 400;
    font-style: italic;
    letter-spacing: 0.5px;
}

/* Fixed content sections - description, biography */
.description,
.biography {
    position: fixed;
    top: 120px;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(224, 224, 224, 0.5);
    font-size: 0.9rem;
    line-height: 1.6;
    color: #444;
    z-index: 98;
    max-height: 200px;
    overflow-y: auto;
}

/* Section spacing */
.images-section {
    margin-top: 200px;
}

.cards-section {
    margin-top: 120px;
}

/* Desktop: cards-section should not constrain width */
@media (min-width: 769px) {
    .cards-section {
        width: 100%;
        max-width: none;
    }
}

.lessons-section {
    margin-top: 60px;
}

/* Card containers - mobile first */
.images-container,
.cards-container,
.lessons-container {
    display: block;
}

/* Card styles - mobile first (full width single column) */
.artwork-card,
.lesson-card,
.card {
    width: 100vw;
    min-height: auto;
    height: auto;
    margin: 0;
    border: none;
    border-radius: 0;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
}

.artwork-card {
    cursor: pointer;
}

/* Remove link styling from card content */
.artwork-card *,
.lesson-card *,
.card * {
    text-decoration: none;
    color: inherit;
}

.artwork-card:visited *,
.lesson-card:visited *,
.card:visited * {
    color: inherit;
}

.artwork-card:hover *,
.lesson-card:hover *,
.card:hover * {
    text-decoration: none;
    color: inherit;
}

/* Ensure image captions stay white on hover */
.artwork-card:hover .image-caption,
.artwork-card:hover .image-caption *,
.lesson-card:hover .image-caption,
.lesson-card:hover .image-caption *,
.card:hover .image-caption,
.card:hover .image-caption * {
    color: white !important;
    background: rgba(0, 0, 0, 0.8) !important;
}

/* Text panels */
.artwork-card .text-panel,
.lesson-card .text-panel,
.card .text-panel {
    position: relative;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 1.5rem;
    margin: 0;
    max-width: 100%;
    border: none;
    border-top: 1px solid rgba(224, 224, 224, 0.5);
    opacity: 1;
    pointer-events: auto;
}

/* Card typography */
.artwork-card h3,
.lesson-card h2,
.card h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.artwork-card .blurb,
.card .blurb {
    font-size: 0.9rem;
    line-height: 1.5;
}

.lesson-card .time-period {
    font-size: 0.9rem;
    display: block;
    margin-bottom: 0.75rem;
}

.card .lifetime {
    font-size: 0.9rem;
    display: block;
    margin-bottom: 0.75rem;
}

.lesson-card .key-concepts {
    color: #555;
    line-height: 1.3;
    font-size: 0.85rem;
    margin: 0;
    margin-top: 0.5rem;
    padding-left: 0;
    list-style: none;
}

.lesson-card .key-concepts li {
    margin-bottom: 0.15rem;
}

.lesson-card .key-concepts li:last-child {
    margin-bottom: 0;
}

.lesson-card .key-concepts li::before {
    content: '• ';
    color: #999;
    margin-right: 0.3rem;
    font-size: 0.85rem;
}

.artwork-card .title-row,
.lesson-card .title-row,
.card .title-row {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

/* Image captions - shown on all images */
.image-caption {
    position: absolute;
    bottom: 0.5rem;
    left: 0.5rem;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.3rem 0.5rem;
    font-size: 0.7rem;
    line-height: 1.3;
    border-radius: 3px;
    max-width: 85%;
    text-align: left;
    pointer-events: none;
    z-index: 10;
}

.image-caption .title {
    font-weight: 500;
    display: block;
}

.image-caption .artist {
    font-size: 0.65rem;
    opacity: 0.95;
    margin-top: 0.15rem;
    display: block;
}

/* Card placeholder */
.card-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
    background: #f5f5f5;
    color: #999;
    font-size: 1.2rem;
    text-align: center;
    padding: 2rem;
}

.card-placeholder span {
    font-weight: 400;
    letter-spacing: 0.5px;
}

/* Loading and error states */
.loading {
    text-align: center;
    padding: 6rem 2rem;
    color: #888;
    font-size: 1rem;
    font-style: italic;
}

.error {
    background: #fef;
    color: #c44;
    padding: 1.5rem;
    border: 1px solid #ecc;
    border-left: 3px solid #c44;
    text-align: center;
}

/* Mobile styles */
@media (max-width: 768px) {
    /* Ensure containers stay single column on mobile */
    .images-container,
    .cards-container,
    .lessons-container {
        display: block;
    }
    
    .artwork-card,
    .lesson-card,
    .card {
        justify-content: flex-start;
        position: relative;
        background-image: none;
        width: 100vw;
        height: auto;
        min-height: auto;
    }
    
    .artwork-card .image-container,
    .lesson-card .image-container,
    .card .image-container {
        display: block;
        width: 100%;
        height: var(--image-height, 75vw);
        background-size: cover;
        background-position: center;
        background-repeat: no-repeat;
        flex-shrink: 0;
        position: relative;
    }
    
    .artwork-card .text-panel,
    .lesson-card .text-panel,
    .card .text-panel {
        position: relative;
        background: white;
        border-top: 1px solid #e0e0e0;
        padding: 0.75rem 1rem;
        flex-shrink: 0;
        flex-grow: 0;
    }
    
    .artwork-card h3,
    .lesson-card h2,
    .card h3 {
        font-size: 0.85rem;
        margin-bottom: 0;
    }
    
    .artwork-card .title-row,
    .lesson-card .title-row,
    .card .title-row {
        margin-bottom: 0.25rem;
    }
    
    .artwork-card .blurb,
    .card .blurb {
        font-size: 0.75rem;
        line-height: 1.4;
        margin-top: 0.25rem;
    }
    
    .lesson-card .time-period,
    .card .lifetime {
        font-size: 0.7rem;
        margin-bottom: 0.25rem;
    }
    
    .lesson-card .key-concepts {
        font-size: 0.7rem;
        margin-top: 0.25rem;
    }
}

/* Desktop styles */
@media (min-width: 769px) {
    .container {
        max-width: 1400px;
        margin: 0 auto;
        padding: 0;
    }
    
    .page-title-section h1,
    .lesson-title-section h1 {
        font-size: 1.5rem;
    }
    
    .description,
    .biography {
        padding: 1.5rem 2rem;
        font-size: 0.95rem;
        max-width: 1400px;
        margin: 0 auto;
    }
    
    /* Grid layout for lessons on desktop (index page) - uniform heights */
    .lessons-container {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        grid-auto-rows: 1fr;  /* Uniform row heights */
        gap: 1.5rem;
        padding: 1.5rem;
        max-width: 1400px;
        margin: 0 auto;
        align-items: stretch;  /* Cards stretch to fill grid cell */
    }
    
    /* Ensure lesson-card links stretch properly in grid - more specific selector overrides general .lesson-card */
    .lessons-container > .lesson-card {
        display: flex;
        flex-direction: column;
        height: 100%;
        align-self: stretch;
        width: 100%;
    }
    
    /* Ensure text panel fills remaining space in lesson cards */
    .lessons-container > .lesson-card > .text-panel {
        flex-grow: 1;
        display: flex;
        flex-direction: column;
    }
    
    /* Grid layout for cards on desktop - uniform heights */
    .cards-container {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        grid-auto-rows: minmax(min-content, max-content);
        gap: 1.5rem;
        padding: 1.5rem;
        max-width: 1400px;
        margin: 0 auto;
        align-items: start;
    }
    
    /* Cards in grid layout - uniform height on desktop */
    /* Note: More specific selectors (.lessons-container > .lesson-card, .cards-container > .card) override these */
    .artwork-card,
    .lesson-card,
    .card {
        width: 100%;
        max-width: none;
        margin: 0;
        min-height: 0;
        height: 100%;  /* Fill grid cell height */
        background-image: none;
        justify-content: flex-start;
        border-radius: 8px;
        overflow: hidden;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        transition: transform 0.2s ease, box-shadow 0.2s ease;
        display: flex;
        flex-direction: column;
        align-self: stretch;  /* Stretch to fill grid cell */
    }
    
    /* More specific: cards within cards-container also need to stretch */
    .cards-container > .card {
        height: 100%;
        align-self: stretch;
    }
    
    .artwork-card:hover,
    .lesson-card:hover,
    .card:hover {
        transform: translateY(-4px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    
    .artwork-card .image-container,
    .lesson-card .image-container,
    .card .image-container {
        display: block;
        width: 100%;
        height: 300px;
        min-height: 300px;
        max-height: 300px;
        background-size: cover;
        background-position: center;
        background-repeat: no-repeat;
        position: relative;
        flex-shrink: 0;
    }
    
    .artwork-card .text-panel,
    .lesson-card .text-panel,
    .card .text-panel {
        position: relative;
        padding: 1.5rem;
        margin-top: 0;
        flex-grow: 1;  /* Grow to fill remaining space */
        display: flex;
        flex-direction: column;
    }
    
    .artwork-card h3,
    .lesson-card h2,
    .card h3 {
        font-size: 1.25rem;
    }
    
    .image-caption {
        font-size: 0.75rem;
        padding: 0.4rem 0.6rem;
        bottom: 0.75rem;
        left: 0.75rem;
    }
    
    .image-caption .title {
        font-size: 0.75rem;
    }
    
    .image-caption .artist {
        font-size: 0.7rem;
    }
    
    /* Card placeholder on desktop - match image height */
    .card-placeholder {
        min-height: 300px;
        height: 300px;
    }
}
