/* Memorial Booklet - Main Styles */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&family=Inter:wght@300;400;500;600&display=swap');

:root {
    --color-ivory: #FFFFF0;
    --color-white: #FFFFFF;
    --color-charcoal: #36454F;
    --color-charcoal-light: #4A5D68;
    --color-gold: #C9A962;
    --color-gold-muted: #B8956E;
    --color-cream: #FDF8F0;
    --color-border: #E8E4DC;
    --font-heading: 'Playfair Display', Georgia, serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-medium: 0 8px 30px rgba(0, 0, 0, 0.12);
    --transition-smooth: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-body);
    background: linear-gradient(135deg, var(--color-cream) 0%, var(--color-ivory) 100%);
    color: var(--color-charcoal);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Header Controls */
.booklet-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 16px 24px;
    background: linear-gradient(to bottom, rgba(253, 248, 240, 0.95), rgba(253, 248, 240, 0));
    pointer-events: none;
}

.booklet-header > * {
    pointer-events: auto;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition-smooth);
    text-decoration: none;
}

.btn-primary {
    background: var(--color-charcoal);
    color: var(--color-white);
}

.btn-primary:hover {
    background: var(--color-charcoal-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-soft);
}

.btn-secondary {
    background: transparent;
    color: var(--color-charcoal);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background: var(--color-white);
    border-color: var(--color-gold);
    color: var(--color-gold-muted);
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    color: var(--color-charcoal);
}

.btn-icon:hover {
    background: var(--color-gold);
    color: var(--color-white);
    border-color: var(--color-gold);
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

/* Booklet Container */
.booklet-container {
    width: 100%;
    height: calc(100vh - 70px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

/* PageFlip Styles */
#booklet {
    max-width: 100%;
    width: 95vw;
    height: 100%;
    box-shadow: var(--shadow-medium);
    border-radius: 4px;
    overflow: hidden;
}

/* Individual Page Styles */
.page {
    width: 100%;
    height: 100%;
    background: var(--color-white);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.page-content {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* Cover Page */
.page-cover {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
}

.page-cover::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
}

.page-cover .page-content {
    position: relative;
    z-index: 1;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.cover-photo {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--color-gold);
    margin-bottom: 30px;
    box-shadow: var(--shadow-soft);
}

.cover-title {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 400;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--color-gold-muted);
    margin-bottom: 16px;
}

.cover-name {
    font-family: var(--font-heading);
    font-size: 42px;
    font-weight: 500;
    color: var(--color-charcoal);
    margin-bottom: 20px;
    line-height: 1.2;
}

.cover-dates {
    font-family: var(--font-body);
    font-size: 16px;
    font-weight: 300;
    color: var(--color-charcoal-light);
    margin-bottom: 30px;
    letter-spacing: 1px;
}

.cover-quote {
    font-family: var(--font-heading);
    font-size: 16px;
    font-style: italic;
    color: var(--color-charcoal-light);
    max-width: 400px;
    line-height: 1.6;
}

/* Biography & Content Pages */
.page-biography .page-content,
.page-lifeStory .page-content,
.page-thankYou .page-content {
    justify-content: flex-start;
    align-items: flex-start;
}

.page-heading {
    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 500;
    color: var(--color-charcoal);
    margin-bottom: 8px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--color-gold);
}

.page-heading-center {
    text-align: center;
    margin-bottom: 30px;
}

.page-heading-center::after {
    content: '';
    display: block;
    width: 60px;
    height: 2px;
    background: var(--color-gold);
    margin: 16px auto 0;
}

.page-text {
    font-size: 15px;
    line-height: 1.8;
    color: var(--color-charcoal-light);
}

.page-text p {
    margin-bottom: 16px;
}

.page-text h2, .page-text h3 {
    font-family: var(--font-heading);
    color: var(--color-charcoal);
    margin: 24px 0 12px;
}

.page-text ul, .page-text ol {
    margin: 16px 0;
    padding-left: 24px;
}

.page-text li {
    margin-bottom: 8px;
}

/* Gallery Page */
.page-gallery .page-content {
    padding: 30px;
}

.gallery-grid {
    display: grid;
    gap: 12px;
    height: 100%;
}

.gallery-grid.single {
    grid-template-columns: 1fr;
}

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

.gallery-grid.three {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
}

.gallery-grid.collage {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(3, 1fr);
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 4px;
    background: var(--color-cream);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gallery-item:hover img {
    transform: scale(1.05);
}

.gallery-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
    color: var(--color-white);
    font-size: 13px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-item:hover .gallery-caption {
    opacity: 1;
}

/* Programme Page */
.page-programme .page-content {
    justify-content: flex-start;
}

.programme-list {
    list-style: none;
}

.programme-item {
    display: flex;
    gap: 20px;
    padding: 20px 0;
    border-bottom: 1px solid var(--color-border);
}

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

.programme-time {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 500;
    color: var(--color-gold-muted);
    min-width: 80px;
}

.programme-details h3 {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 500;
    color: var(--color-charcoal);
    margin-bottom: 6px;
}

.programme-details p {
    font-size: 14px;
    color: var(--color-charcoal-light);
    line-height: 1.5;
}

/* Tribute Page */
.page-tribute .page-content {
    justify-content: flex-start;
}

.tribute-block {
    padding: 24px;
    margin-bottom: 20px;
    background: var(--color-cream);
    border-radius: 8px;
    border-left: 4px solid var(--color-gold);
}

.tribute-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.tribute-photo {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--color-gold);
}

.tribute-info h4 {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 500;
    color: var(--color-charcoal);
}

.tribute-info span {
    font-size: 13px;
    color: var(--color-gold-muted);
}

.tribute-text {
    font-size: 15px;
    line-height: 1.7;
    color: var(--color-charcoal-light);
    font-style: italic;
}

/* Back Cover Page */
.page-backCover {
    background: var(--color-charcoal);
    color: var(--color-white);
}

.page-backCover .page-content {
    justify-content: center;
    align-items: center;
    text-align: center;
}

.back-cover-text {
    font-family: var(--font-heading);
    font-size: 20px;
    font-style: italic;
    color: var(--color-ivory);
    max-width: 400px;
    line-height: 1.6;
}

.back-cover-image {
    max-width: 200px;
    margin-top: 30px;
    opacity: 0.9;
}

/* Loading State */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-cream);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    margin-top: 20px;
    font-family: var(--font-heading);
    font-size: 16px;
    color: var(--color-charcoal-light);
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--color-charcoal-light);
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 14px;
}

/* Fullscreen Mode */
body.fullscreen {
    background: #000;
}

body.fullscreen .booklet-header {
    opacity: 0;
    transition: opacity 0.3s ease;
}

body.fullscreen:hover .booklet-header {
    opacity: 1;
}

/* Responsive Design */
@media (max-width: 768px) {
    .booklet-header {
        padding: 12px 16px;
    }

    .btn {
        padding: 8px 16px;
        font-size: 13px;
    }

    .btn-icon {
        width: 36px;
        height: 36px;
    }

    .booklet-container {
        padding: 70px 10px 10px;
    }

    #booklet {
        height: calc(100vh - 80px);
    }

    .page-content {
        padding: 24px;
    }

    .cover-photo {
        width: 140px;
        height: 140px;
    }

    .cover-title {
        font-size: 12px;
    }

    .cover-name {
        font-size: 28px;
    }

    .cover-quote {
        font-size: 14px;
    }

    .page-heading {
        font-size: 22px;
    }

    .page-text {
        font-size: 14px;
    }

    .gallery-grid.three,
    .gallery-grid.collage {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(3, 1fr);
    }
}

@media (max-width: 480px) {
    .booklet-header {
        padding: 8px 10px;
    }

    .btn span {
        display: none;
    }

    .btn-icon {
        width: 34px;
        height: 34px;
    }

    .booklet-container {
        height: calc(100vh - 70px);
        padding: 5px;
    }

    #booklet {
        width: 95vw;
        height: 100%;
    }

    .page-content {
        padding: 12px;
    }

    .cover-photo {
        width: 100px;
        height: 100px;
        margin-bottom: 16px;
    }

    .cover-name {
        font-size: 22px;
    }
    
    .cover-title {
        font-size: 11px;
    }
    
    .cover-dates {
        font-size: 11px;
    }
    
    .cover-quote {
        font-size: 12px;
    }

    .page-heading {
        font-size: 18px;
        margin-bottom: 12px;
    }
    
    .page-text {
        font-size: 14px;
        line-height: 1.5;
    }
    
    .page-image {
        max-width: 150px;
        margin-bottom: 16px;
    }

    .programme-item {
        flex-direction: column;
        gap: 8px;
    }

    .gallery-grid.two,
    .gallery-grid.three {
        grid-template-columns: 1fr;
    }
    
    .flipbook-nav {
        bottom: 8px;
        padding: 6px 12px;
    }
}

/* Print Styles */
@media print {
    .booklet-header {
        display: none;
    }

    .booklet-container {
        padding: 0;
    }

    #booklet {
        box-shadow: none;
        border-radius: 0;
    }

    .page {
        page-break-after: always;
    }
}

/* PageFlip Internal Styles */
.page__front {
    background: var(--color-white);
}

.page__back {
    background: var(--color-white);
}

/* Hard Page Shadow Effect */
.stf__page-shadow {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* Page Curl Effect Enhancement */
.stf__page_flipped .stf__shadow {
    opacity: 0.3;
}

/* Flipbook Styles */
.flipbook {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--color-cream);
}

.flipbook-pages {
    flex: 1;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.flipbook-page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, transform 0.4s ease;
    transform: translateX(30px);
    overflow-y: auto;
}

.flipbook-page.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    z-index: 1;
}

.flipbook-page.flipping {
    animation: pageFlip 0.5s ease;
}

@keyframes pageFlip {
    0% {
        opacity: 1;
        transform: translateX(0);
    }
    50% {
        opacity: 0.5;
        transform: translateX(-15px);
    }
    100% {
        opacity: 0;
        transform: translateX(-30px);
    }
}

.flipbook-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 16px;
    background: var(--color-white);
    border-top: 1px solid var(--color-border);
}

.flipbook-nav button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--color-border);
    background: var(--color-white);
    color: var(--color-charcoal);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.flipbook-nav button:hover:not(:disabled) {
    background: var(--color-gold);
    border-color: var(--color-gold);
    color: var(--color-white);
}

.flipbook-nav button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.flipbook-nav button svg {
    width: 20px;
    height: 20px;
}

.flipbook-counter {
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--color-charcoal-light);
}

.flipbook-counter .current {
    font-weight: 600;
    color: var(--color-charcoal);
}

/* Toast Animations */
@keyframes slideOut {
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Bottom Toolbar */
.bottom-toolbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--color-white);
    border-top: 1px solid var(--color-cream);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.bottom-toolbar .btn-primary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
}

.bottom-toolbar .btn-primary svg {
    width: 18px;
    height: 18px;
}

.bottom-toolbar .btn-primary span {
    display: inline;
}

.bottom-toolbar .btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Page Images */
.page-image {
    margin: 0 auto 24px;
    max-width: 200px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.page-image img {
    width: 100%;
    height: auto;
    display: block;
}

/* Mobile Bottom Toolbar */
@media (max-width: 480px) {
    .bottom-toolbar {
        padding: 8px 12px;
        gap: 8px;
    }
    
    .bottom-toolbar .btn-primary {
        padding: 10px 16px;
    }
    
    .bottom-toolbar .btn-primary span {
        display: inline;
    }
    
    .bottom-toolbar .btn-icon {
        width: 38px;
        height: 38px;
    }
}

/* Desktop - center toolbar */
@media (min-width: 769px) {
    .bottom-toolbar {
        max-width: 600px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 12px 12px 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    }
}
