/* Theme Isolation: Reset inherited CSS custom properties */
.memorial-theme-sunrise,
.memorial-theme-zenith,
.memorial-theme-dawn,
.memorial-theme-night {

    --bg-primary: initial;
    --bg-secondary: initial;
    --bg-card: initial;
    --text-primary: initial;
    --text-secondary: initial;
    --text-muted: initial;
    --border-color: initial;
    --shadow-color: initial;
    --navbar-bg: initial;
    --navbar-text: initial;
    
    background: initial;
    color: initial;
}

.preview-home-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #4b6cb7, #182848);
    color: white;
    padding: 0.875rem 1.25rem;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 6px 20px rgba(75, 108, 183, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.preview-home-btn:hover {
    background: linear-gradient(135deg, #5a7bc8, #243759);
    box-shadow: 0 8px 25px rgba(75, 108, 183, 0.4);
}

.preview-home-btn i {
    font-size: 1rem;
}

.memorial-page-container {
    min-height: 100vh;
    position: relative;
    overflow: hidden;
    font-family: 'Inter', sans-serif;
}

body {
    padding-top: 0 !important;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

body.iframe-mode {
    padding-top: 0 !important;
    margin-top: 0 !important;
}

body.iframe-mode .site-navbar,
body.iframe-mode .site-footer {
    display: none !important;
}

body::-webkit-scrollbar {
    display: none;
}

html {
    scrollbar-width: none; 
    -ms-overflow-style: none;
}

html::-webkit-scrollbar {
    display: none;
}

.memorial-page-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0.3;
    z-index: 0;
}

.memorial-main-content {
    top: 20px;
    max-width: 1440px;
    margin: 0 auto;
    margin-bottom: 120px;
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.memorial-header-container {
    flex-shrink: 0;
    padding: 2rem 2rem 1rem 2rem;
}

.memorial-header-section {
    width: min(520px, 90%);
    margin: 0 auto;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.315), rgba(255, 255, 255, 0.85));
    backdrop-filter: blur(50px);
    border-radius: 16px;
    padding: 2.5rem 2rem;
    text-align: center;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.memorial-main-photo {
    width: 400px;
    height: 400px;
    border-radius: 50%;
    margin: 0 auto 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
    border: 3px solid rgba(255, 255, 255, 0.8);
    overflow: hidden;
}

.memorial-main-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.memorial-name {
    font-family: 'Playfair Display', serif;
    font-size: 2.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.memorial-dates {
    font-size: 1.25rem;
    font-weight: 400;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.memorial-subtitle {
    font-size: 1rem;
    font-weight: 500;
    font-style: italic;
    letter-spacing: 0.02em;
    margin-bottom: 0;
    opacity: 0.8;
    line-height: 1.4;
}

.memorial-content-container {
    flex: 1;
    padding: 1rem 2rem 2rem 2rem;
}


.memorial-single-flow-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.memorial-content-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 2.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.memorial-section-header {
    color: white;
    text-align: center;
    padding: 1rem;
    margin: -2.5rem -2.5rem 2rem -2.5rem;
    border-radius: 16px 16px 0 0;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.memorial-pictures-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
    padding: 0;
}

.memorial-pictures-grid:first-child {
    margin-top: 0;
}

.memorial-picture-item {
    aspect-ratio: 4/3;
    background: #f5f5f5;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.memorial-picture-item:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.memorial-picture-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.memorial-text-content {
    font-size: 1rem;
    line-height: 1.7;
    text-align: justify;
    margin: 2rem 0;
    padding: 0;
}

.memorial-text-content:last-child {
    margin-bottom: 0;
}

.memorial-text-content p {
    margin-bottom: 1rem;
}

.memorial-quote-section {
    border-left: 4px solid;
    padding: 2rem 1.5rem;
    margin: 3rem 0;
    border-radius: 0 12px 12px 0;
    font-style: italic;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    text-align: center;
}

.memorial-quote-text {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.memorial-quote-attribution {
    font-size: 0.9rem;
    opacity: 0.8;
}

.memorial-videos-section {
    margin: 3rem 0 2rem 0;
    padding: 2rem 0;
    border-top: 2px solid rgba(0, 0, 0, 0.1);
    text-align: center;
}

.memorial-section-title {
    margin-bottom: 2rem;
}

.memorial-section-title h3 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-family: 'Playfair Display', serif;
}

.memorial-section-title p {
    color: rgba(0, 0, 0, 0.7);
    font-size: 1rem;
    font-style: italic;
}

.memorial-videos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
    padding: 0;
}

.memorial-video-item {
    position: relative;
    aspect-ratio: 16/9; 
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.memorial-video-item.portrait {
    aspect-ratio: 9/16; 
    max-width: 280px; 
    justify-self: center; 
}

.memorial-video-item.square {
    aspect-ratio: 1/1; 
    max-width: 350px; 
    justify-self: center;
}

.memorial-video-item.landscape {
    grid-column: 1 / -1; 
    aspect-ratio: 16/9; 
    max-width: 100%; 
    margin: 0 auto;
}

.memorial-video-item:hover {
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.25);
    transform: translateY(-2px);
}

.memorial-video-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    background: #000;
}

.video-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 3rem;
    opacity: 0.8;
    cursor: pointer;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    transition: opacity 0.3s ease;
}

.memorial-video-item:hover .video-overlay {
    opacity: 1;
}

.memorial-video-item video:not([controls])::-webkit-media-controls {
    display: none;
}

@media (max-width: 1024px) and (min-width: 769px) {
    .memorial-videos-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 1.5rem;
    }
    
    .memorial-video-item.portrait {
        max-width: 250px;
    }
    
    .memorial-video-item.landscape {
        grid-column: 1 / -1;
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .memorial-videos-grid {
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }
    
    .memorial-section-title h3 {
        font-size: 1.5rem;
    }
    
    .memorial-video-item.portrait {
        max-width: none; 
        width: 100%;
    }
    
    .memorial-video-item.landscape {
        grid-column: 1 / -1;
        max-width: 100%;
    }
    
    .memorial-video-item.square {
        max-width: none;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .memorial-videos-grid {
        grid-template-columns: 1fr; 
        gap: 1rem;
    }
    
    .memorial-video-item.portrait,
    .memorial-video-item.landscape,
    .memorial-video-item.square {
        grid-column: 1;
        max-width: 100%;
        width: 100%;
    }
}

.memorial-theme-sunrise {
    background-image: url('/img/bg_sunrise.webp');
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-size: cover;
}

.memorial-theme-sunrise .memorial-header-section {
    background: #ffffff49;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.158);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.377);
}

.memorial-theme-sunrise .memorial-main-photo {
    background: #d63031;
}

.memorial-theme-sunrise .memorial-name {
    color: #0000009c;
}

.memorial-theme-sunrise .memorial-header-section .memorial-subtitle {
    color: #0000009c;
}

.memorial-theme-sunrise .memorial-dates {
    color: #0000009c;
}

.memorial-theme-sunrise .memorial-section-header {
    background: #e17055;
}

.memorial-theme-sunrise .memorial-text-section .memorial-section-header {
    background: #00b894;
}

.memorial-theme-sunrise .memorial-quote-section {
    background: rgba(252, 252, 252, 0.1);
    border-left-color: #ff91002f;
    color: #ffffff;
}

.memorial-theme-sunrise .memorial-single-flow-content {
    background: #ffffff49;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.158);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.377);
}

.memorial-theme-sunrise .memorial-text-content {
    color: #111111d8;
}

.memorial-theme-zenith {
    background-image: url('/img/bg_zenith.webp');
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-size: cover;
}

.memorial-theme-zenith .memorial-main-photo {
    background: #6c5ce7;
}

.memorial-theme-zenith .memorial-name {
    color: #2d3436;
}

.memorial-theme-zenith .memorial-dates {
    color: #636e72;
}

.memorial-theme-zenith .memorial-header-section {
    background: #ffffff63;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.26);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.377);    
}

.memorial-theme-zenith .memorial-single-flow-content {
    background: #ffffff63;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.26);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.377);
}

.memorial-theme-zenith .memorial-section-header {
    background: #a29bfe;
}

.memorial-theme-zenith .memorial-text-section .memorial-section-header {
    background: #fd79a8;
}

.memorial-theme-zenith .memorial-quote-section {
    background: rgba(32, 32, 32, 0.1);
    border-left-color: #e2e2e288;
    color: #383838;
    text-shadow: #ffffff28 0px 0px 2px;
}

.memorial-theme-zenith .memorial-text-content {
    color: #1a1a1a;
}

.memorial-theme-dawn {
    background-image: url('/img/bg_dawn.webp');
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-size: cover;
}

.memorial-theme-dawn .memorial-main-photo {
    background: #1a237e;
}

.memorial-theme-dawn .memorial-name {
    color: #2c3e50;
}

.memorial-theme-dawn .memorial-dates {
    color: #7f8c8d;
}

.memorial-theme-dawn .memorial-section-header {
    background: #00bcd4;
}

.memorial-theme-dawn .memorial-header-section {
    background: #ffffff63;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.26);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.377);    
}

.memorial-theme-dawn .memorial-text-section .memorial-section-header {
    background: #4caf50;
}

.memorial-theme-dawn .memorial-single-flow-content {
    background: #ffffff63;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.26);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.377);
}

.memorial-theme-dawn .memorial-quote-section {
    background: rgba(49, 6, 66, 0.1);
    border-left-color: #d1d1d1a8;
    color: #ffffff98;
}

.memorial-theme-dawn .memorial-text-content {
    color: #222222;
}

.memorial-theme-night {
    background-image: url('/img/bg_night.webp');
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-size: cover;
}

.memorial-theme-night .memorial-header-section,
.memorial-theme-night .memorial-content-section {
    background: #1d1d1d52;
    backdrop-filter: blur(20px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.377);
    border: 1px solid rgba(255, 255, 255, 0.123);
}

.memorial-theme-night .memorial-main-photo {
    background: #ffffff1a;
    border: 5px solid rgba(255, 255, 255, 0.089);
}

.memorial-theme-night .memorial-subtitle {
    color: #ffffffc5;
}

.memorial-theme-night .memorial-name {
    color: #ecf0f1;
}

.memorial-theme-night .memorial-dates {
    color: #bdc3c7;
}

.memorial-theme-night .memorial-section-header {
    background: #3498db;
}

.memorial-theme-night .memorial-text-section .memorial-section-header {
    background: #27ae60;
}

.memorial-theme-night .memorial-quote-section {
    background: rgba(0, 22, 94, 0.123);
    border-left-color: #0d284baf;
    color: #e0e0e0e7;
}

.memorial-theme-night .memorial-single-flow-content {
    background: #1d1d1d52;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.123);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.377);
}

.memorial-theme-night .memorial-text-content {
    color: #ebebeba8;
}

.memorial-theme-night .memorial-text-content h2 {
    color: #ffffffd2;
}

@media (max-width: 1660px) {
    .memorial-main-content {
        max-width: 1280px;
    }
}

@media (max-width: 1280px) {
    .memorial-main-content {
        max-width: 900px;
    }
}

@media (max-width: 768px) {
    .memorial-header-container,
    .memorial-content-container {
        padding: 1rem;
    }

    .memorial-header-section,
    .memorial-content-section {
        padding: 2rem 1.5rem;
    }
}

.memorial-home-button {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: none; 
}

.memorial-home-button .home-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.memorial-home-button .home-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.memorial-home-button .home-btn:active {
    transform: translateY(0);
}

.memorial-home-button .home-btn i {
    font-size: 1rem;
}

@media (max-width: 768px) {
    .memorial-home-button {
        bottom: 15px;
    }
    
    .memorial-home-button .home-btn {
        padding: 10px 20px;
        font-size: 0.85rem;
    }
    
    .memorial-home-button .home-btn i {
        font-size: 0.9rem;
    }
}

@media (max-width: 680px) {
    .memorial-header-section {
        width: 100%;
        max-width: 100%;
        margin: 0;
    }

    .memorial-main-photo {
        width: 160px;
        height: 160px;
    }

    .memorial-name {
        font-size: 2rem;
    }

    .memorial-dates {
        font-size: 1.125rem;
    }

    .memorial-pictures-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 0.75rem;
    }

    .memorial-section-header {
        margin: -2rem -1.5rem 1.5rem -1.5rem;
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    .memorial-header-section,
    .memorial-content-section {
        padding: 1.5rem 1rem;
    }

    .memorial-main-photo {
        width: 140px;
        height: 140px;
    }

    .memorial-name {
        font-size: 1.75rem;
    }

    .memorial-pictures-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }

    .memorial-section-header {
        margin: -1.5rem -1rem 1rem -1rem;
    }
}

.memorial-content-section {
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Mobile performance optimizations - fix background scroll lag */
@media (max-width: 768px) {
    .memorial-theme-sunrise,
    .memorial-theme-zenith,
    .memorial-theme-dawn,
    .memorial-theme-night {
        background-attachment: scroll;
    }
    
    .memorial-theme-sunrise::before,
    .memorial-theme-zenith::before,
    .memorial-theme-dawn::before,
    .memorial-theme-night::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: -1;
        background-size: cover;
        background-position: center;
        background-repeat: no-repeat;
        will-change: transform;
        transform: translateZ(0);
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }
    
    .memorial-theme-sunrise::before {
        background-image: url('/img/bg_sunrise.webp');
    }
    
    .memorial-theme-zenith::before {
        background-image: url('/img/bg_zenith.webp');
    }
    
    .memorial-theme-dawn::before {
        background-image: url('/img/bg_dawn.webp');
    }
    
    .memorial-theme-night::before {
        background-image: url('/img/bg_night.webp');
    }
    
    .memorial-page-container {
        -webkit-overflow-scrolling: touch;
        overflow-y: auto;
    }
    
    .memorial-header-section,
    .memorial-single-flow-content {
        will-change: auto;
        transform: translateZ(0);
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }
}