@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400..700;1,400..700&family=Outfit:wght@100..900&display=swap');

:root {
    --bg-color: #fdfaf7; /* Warm cream background */
    --text-color: #43392f; /* Dark warm brown text */
    --accent-color: #927352; /* Muted bronze/amber accent */
    --border-color: #ece0d1; /* Soft warm border */
    --secondary-bg: #fffbf8; /* Extra light warm background */
    --font-heading: 'Lora', serif;
    --font-body: 'Outfit', sans-serif;
    --shadow-soft: 0 8px 30px rgba(73, 56, 38, 0.05); /* Softer, warmer shadow */
    --shadow-medium: 0 12px 40px rgba(73, 56, 38, 0.08); /* Warmer medium shadow */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.7; /* Slightly more breathable */
    -webkit-font-smoothing: antialiased;
}

body.page-preload {
    opacity: 0;
}

body.page-loaded {
    opacity: 1;
    transition: opacity 1s ease;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem;
}

main.container {
    max-width: 1700px;
}

/* Header */
.app-header {
    background: var(--bg-color); /* Matches page for a seamless feel */
    padding: 4rem 0 0;
    text-align: left;
}

.app-header .container {
    position: relative;
}

.about-link-btn {
    position: static;
    display: inline-block;
    padding: 0.7rem 1.8rem;
    border: 1px solid var(--accent-color);
    border-radius: 12px;
    background: transparent;
    color: var(--accent-color);
    font-size: 1rem;
    font-family: inherit;
    font-weight: 400;
    text-decoration: none;
    line-height: 1;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.about-link-btn:hover {
    background: var(--accent-color);
    color: #fff;
    box-shadow: var(--shadow-medium);
}

.profile-pic-container {
    margin-bottom: 0;
    display: flex;
    justify-content: center;
    flex-shrink: 0;
}

.header-main {
    display: flex;
    align-items: center;
    gap: 2rem;
    max-width: 900px;
}

.header-copy {
    flex: 1;
}

.profile-pic {
    width: 205px;
    height: 205px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: var(--shadow-soft);
    border: 2px solid #fff;
}

.app-header h1 {
    font-family: var(--font-heading);
    font-size: 3.2rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    margin-bottom: 0.6rem;
    color: var(--text-color);
}

.subtitle {
    font-family: var(--font-body);
    font-weight: 400;
    color: var(--accent-color);
    letter-spacing: 0.01em;
    font-size: 1.05rem;
    margin-bottom: 2.5rem;
    display: flex;
    justify-content: flex-start;
    gap: 1.5rem;
    flex-wrap: wrap;
    opacity: 0.85;
}

.header-description {
    font-family: var(--font-body);
    font-size: 1.05rem;
    color: var(--text-color);
    margin: -1.5rem 0 2rem;
    max-width: 680px;
    opacity: 0.8;
}

.meta-item {
    white-space: nowrap;
}

.meta-separator {
    color: #bdc3c7;
}

.share-btn {
    background: #fff;
    border: 1px solid var(--border-color);
    padding: 0 1.75rem;
    height: 48px;
    border-radius: 999px;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--accent-color);
    cursor: pointer;
    box-shadow: var(--shadow-soft);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 0.7rem;
    position: relative;
    z-index: 10;
}

.share-btn:hover {
    background: #fff;
    border-color: var(--accent-color);
    box-shadow: var(--shadow-medium);
    transform: translateY(-2px);
}

.share-btn::before {
    content: "";
    display: inline-block;
    width: 14px;
    height: 14px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='2.5' stroke='%23927352'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M12 4.5v15m7.5-7.5h-15' /%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0.9;
}

/* Controls Bar (Shuffle, Autoplay, etc.) */
.controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.2rem;
    margin: 0 auto 3.5rem;
    width: 100%;
}

.controls-row .share-btn,
.controls-row .controls-bar {
    margin: 0;
}

.controls-bar {
    display: flex;
    align-items: center;
    gap: 2.1rem;
    padding: 0 1.45rem;
    height: 48px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    width: fit-content;
    box-shadow: var(--shadow-soft);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 10;
}

.controls-bar:hover {
    box-shadow: var(--shadow-medium);
    border-color: var(--accent-color);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.control-label {
    font-size: 0.95rem;
    color: var(--accent-color);
    font-weight: 500;
    opacity: 0.85;
    white-space: nowrap;
}

.next-btn {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    padding: 0.35rem 1rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-family: inherit;
    font-weight: 500;
    color: var(--accent-color);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 0.5rem;
}

.next-btn:hover {
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}

.next-btn:active {
    transform: scale(0.96);
}

.memories-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0 1.4rem;
    margin-bottom: 0.5rem;
    box-shadow: none; /* No shadow = no button feel */
    font-size: 0.88rem;
    color: var(--accent-color);
    font-weight: 400;
    white-space: nowrap;
    z-index: 5;
    animation: badgeFloat 4.2s ease-in-out infinite;
    cursor: default;
    transition: none;
}

.memories-badge .heart-icon {
    font-size: 1.15rem;
    color: #e24d74;
    line-height: 1;
    animation: heartBeat 2.5s infinite ease-in-out;
}

@keyframes badgeFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

@keyframes heartBeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.memories-badge .count {
    font-weight: 600;
    color: var(--text-color);
}

/* The switch - the box around the slider */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
}

/* Hide default HTML checkbox */
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* The slider */
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #f1f3f5;
    transition: .4s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid #e9ecef;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

input:checked + .slider {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
}

input:checked + .slider:before {
    transform: translateX(22px);
    background-color: #fff;
}

/* Rounded sliders */
.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Layout Columns */
.layout-columns {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 1.2rem;
    min-height: 60vh;
}

.refresh-progress-wrap {
    margin-bottom: 0.8rem;
}

.refresh-progress-global {
    margin-bottom: 1.25rem;
}

.refresh-progress-track {
    width: 100%;
    height: 4px;
    background: #edf1f5;
    border-radius: 999px;
    overflow: hidden;
}

.refresh-progress-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #d97706, #92400e); /* Amber/Brown gradient */
    border-radius: inherit;
    transition: width 0.15s linear;
}

/* Image Grid Container */
.slideshow-column {
    position: relative;
    display: block; /* No longer need center alignment */
}

.image-grid-container {
    width: 100%;
    display: block;
    position: relative;
    border-radius: 16px;
    overflow: hidden;
}

.grid-item {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-color);
    box-shadow: none;
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    cursor: pointer;
    width: 100%;
    margin: 0;
}

.grid-item:hover {
    transform: translateY(-5px);
    box-shadow: none;
}

.grid-image {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    border-radius: inherit;
    image-orientation: from-image;
    opacity: 0;
    transform: scale(1.1);
    transition: opacity 1.2s ease, transform 1.2s ease;
}

.grid-image.loaded {
    opacity: 1;
    transform: scale(1);
}

.grid-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 0 0 12px 12px;
    background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
    padding: 2rem 0.75rem 0.75rem;
    color: #fff;
    font-size: 0.8rem;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.4s ease;
    pointer-events: none;
}

.grid-item:hover .grid-caption {
    opacity: 1;
    transform: translateY(0);
}

/* Patch transitions for images */
.grid-patch {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: center;
    gap: 1.2rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 1.5s ease-in-out;
}

.grid-patch.active {
    opacity: 1;
    visibility: visible;
    position: relative;
}

.grid-item.grid-item-wide {
    grid-column: span 2;
}

.grid-item.grid-item-ultrawide {
    grid-column: span 3;
}


/* Text Slideshow */
.memories-column {
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    border-left: 1px solid #e6ebf0;
    padding-left: 1.5rem;
}

.text-slide-container {
    position: relative;
    width: 100%;
    height: 100%; /* Fill column */
}

/* Text patch represents a page/batch of 10 memories */
.text-patch {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    opacity: 0;
    visibility: hidden;
    transition: opacity 1.5s ease-in-out;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.text-patch.active {
    opacity: 1;
    visibility: visible;
    position: relative; /* Take up space in the document flow when active */
}

.memory-item {
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.memory-item:last-child {
    border-bottom: none;
}

.memory-text {
    font-family: var(--font-heading); /* Serif font for stories is more intimate */
    font-style: italic;
    font-size: 1.15rem;
    line-height: 1.8;
    margin-bottom: 1.2rem;
    color: var(--text-color);
    white-space: pre-wrap;
}

.memory-text-short {
    font-size: 1.25rem;
}

.memory-text-medium {
    font-size: 1.1rem;
}

.memory-text-long {
    font-size: 0.98rem;
}

.memory-meta {
    font-size: 0.85rem;
    color: #95a5a6;
    display: flex;
    justify-content: flex-end;
}

.placeholder-msg {
    color: #bdc3c7;
    font-weight: 300;
    letter-spacing: 0.05em;
}

/* Modal Styles */
.modal,
.lightbox-overlay {
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: transparent;
}

.lightbox-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background-color: rgba(0, 0, 0, 0.72);
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.lightbox-overlay.active {
    display: flex;
}

.lightbox-content {
    max-width: min(92vw, 1100px);
    max-height: 92vh;
    width: 100%;
    text-align: center;
}

.lightbox-image {
    max-width: 100%;
    max-height: 82vh;
    width: auto;
    height: auto;
    image-orientation: from-image;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.lightbox-caption {
    margin-top: 0.9rem;
    color: #f7f9fb;
    font-size: 0.95rem;
    line-height: 1.5;
}

.lightbox-close {
    position: absolute;
    top: 0.85rem;
    right: 1.1rem;
    background: transparent;
    border: 0;
    color: #ffffff;
    font-size: 2.2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.2rem 0.45rem;
}

.modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 3rem;
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 600px;
    border-radius: 16px;
    box-shadow: var(--shadow-medium);
    position: relative;
    animation: slideUp 0.4s ease;
}

.close-modal {
    position: absolute;
    top: 1.5rem;
    right: 2rem;
    color: #95a5a6;
    font-size: 2rem;
    font-weight: 300;
    cursor: pointer;
    transition: color 0.3s;
}

.close-modal:hover {
    color: #2c3e50;
}

/* Upload Section within Modal */
.upload-section {
    background: transparent;
}

.tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    background: none;
    border: none;
    padding: 0.75rem 0rem;
    margin-right: 1.5rem;
    font-size: 1.05rem;
    cursor: pointer;
    color: #95a5a6;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
}

.tab-btn.active {
    color: var(--text-color);
    border-bottom: 2px solid var(--accent-color);
    font-weight: 400;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

.input-field {
    width: 100%;
    margin-bottom: 1.5rem;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    background: var(--secondary-bg);
    transition: border-color 0.3s ease;
}

.input-field:focus {
    outline: none;
    border-color: #bdc3c7;
    background: #fff;
}

.textarea {
    min-height: 150px;
    resize: vertical;
}

.input-meta {
    margin-top: -0.9rem;
    margin-bottom: 1.1rem;
}

.char-counter {
    font-size: 0.82rem;
    color: #8b98a3;
    text-align: right;
}

.char-counter.is-limit {
    color: #b45309;
    font-weight: 500;
}

.field-error {
    min-height: 1.5rem;
    margin-top: 0.35rem;
    font-size: 0.82rem;
    color: #c53030; /* Premium ruby red */
    font-weight: 500;
    text-align: right;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.45rem;
    opacity: 0;
    transform: translateY(-4px);
    transition: all 0.35s cubic-bezier(0.23, 1, 0.32, 1);
    pointer-events: none;
}

.field-error:not(:empty) {
    opacity: 1;
    transform: translateY(0);
}

.field-error:not(:empty)::before {
    content: "";
    display: inline-block;
    width: 14px;
    height: 14px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23c53030'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}

.submit-btn {
    background: var(--text-color);
    color: #fff;
    border: none;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 400;
    cursor: pointer;
    width: 100%;
    transition: background 0.3s ease;
}

.submit-btn:hover {
    background: #1a252f;
}

#text-form .submit-btn {
    font-weight: 500;
    letter-spacing: 0.01em;
    box-shadow: 0 6px 16px rgba(28, 41, 51, 0.16);
}

#text-form .submit-btn:hover {
    background: #233240;
    box-shadow: 0 8px 20px rgba(28, 41, 51, 0.22);
}

#text-form .submit-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(35, 50, 64, 0.2), 0 6px 16px rgba(28, 41, 51, 0.16);
}

.heart-burst-particle {
    position: fixed;
    left: 0;
    top: 0;
    font-size: 1.05rem;
    line-height: 1;
    color: #e24d74;
    opacity: 0;
    pointer-events: none;
    user-select: none;
    z-index: 1200;
    text-shadow: 0 4px 12px rgba(226, 77, 116, 0.35);
    transform: translate(-50%, -50%);
    animation: heartBurst 1820ms cubic-bezier(0.2, 0.82, 0.28, 1) forwards;
}

.file-upload {
    border: 2px dashed #dcdde1;
    border-radius: 8px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    margin-bottom: 1.5rem;
    transition: all 0.3s ease;
    background: var(--secondary-bg);
}

.file-upload * {
    cursor: pointer;
}

.file-upload:hover {
    background: #f1f2f6;
    border-color: #bdc3c7;
}

.upload-icon {
    font-size: 2.5rem;
    color: #bdc3c7;
    display: block;
    margin-bottom: 0.5rem;
}

.upload-text {
    font-size: 0.95rem;
    color: #7f8c8d;
}

.app-footer {
    padding: 1rem 0;
    text-align: center;
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: #bdc3c7;
    margin-top: 2rem;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes heartBurst {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.45);
    }
    12% {
        opacity: 1;
    }
    70% {
        opacity: 0.95;
    }
    100% {
        opacity: 0;
        transform: translate(calc(-50% + var(--travel-x, 0px)), calc(-50% + var(--travel-y, 0px))) scale(1.05);
    }
}


.tribute-poem {
    max-width: 600px;
    margin: 0 auto;
    font-style: italic;
    line-height: 1.8;
}

.tribute-poem p {
    margin-bottom: 0.5rem;
}

/* Over Pablo page */
.pablo-page {
    background: #f8fafc;
}

.pablo-content {
    max-width: 760px;
    width: min(760px, calc(100% - 4rem));
    margin: 2rem auto;
    padding: 2rem;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--shadow-soft);
    position: relative;
}

.pablo-back-btn {
    position: static;
    margin-bottom: 1.25rem;
}

.pablo-content h1 {
    font-family: var(--font-heading);
    font-size: 2.8rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

.pablo-content p {
    font-family: var(--font-body);
    font-size: 1.15rem;
    color: var(--text-color);
    line-height: 1.9;
    margin-bottom: 1.5rem;
    opacity: 0.9;
}

@media (max-width: 1200px) {
    main.container { max-width: 1200px; }
    .layout-columns { grid-template-columns: 1.15fr 1fr; gap: 2.5rem; }
    .grid-patch { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
    .grid-item.grid-item-ultrawide { grid-column: span 2; }
}

/* Responsive */
@media (max-width: 800px) {
    .app-header { text-align: center; }
    .header-main { flex-direction: column; gap: 1rem; max-width: none; }
    .header-copy { width: 100%; }
    .profile-pic-container { margin-bottom: 0.75rem; }
    .layout-columns { grid-template-columns: 1fr; gap: 3rem; }
    .memories-column { border-left: none; padding-left: 0; }
    .grid-patch { grid-template-columns: 1fr; gap: 1rem; }
    .grid-item.grid-item-wide,
    .grid-item.grid-item-ultrawide { grid-column: auto; }
    .app-header h1 { font-size: 2.2rem; }
    .subtitle { justify-content: center; }
    .header-description { margin: -0.25rem auto 1.25rem; max-width: 640px; }
    .modal-content { margin: 10% auto; padding: 2rem; }

    .memories-badge {
        display: flex;
        margin: 0 auto 0.5rem;
        width: fit-content;
    }
    .controls-row {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;
        width: 100%;
        gap: 0.75rem;
        margin-bottom: 2rem;
    }
    .controls-bar {
        flex-wrap: nowrap;
        justify-content: flex-start;
        width: fit-content;
        border-radius: 999px;
    }
    .controls-row .share-btn,
    .next-btn {
        margin-left: 0;
    }
    .controls-row .controls-bar,
    .controls-row .share-btn {
        grid-column: auto;
    }
    .controls-row .share-btn {
        justify-self: start;
    }
    .controls-row .controls-bar {
        justify-self: end;
    }
    .controls-row .share-btn {
        width: auto;
    }
    .pablo-content { margin: 1rem auto 2rem; padding: 2rem 1.25rem; }
    .pablo-content h1 { font-size: 1.9rem; }
}

@media (max-width: 600px) {
    .controls-row {
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }
    .controls-bar {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: center;
        gap: 0.6rem 0.75rem;
        width: 100%;
        height: auto;
        padding: 0.75rem 0.85rem;
        border-radius: 16px;
    }
    .controls-bar .control-group {
        justify-content: space-between;
        min-width: 0;
    }
    .controls-bar .control-label {
        font-size: 0.9rem;
    }
    .controls-bar .next-btn {
        grid-column: 1 / -1;
        width: 100%;
        margin-left: 0;
        padding: 0.5rem 0.9rem;
    }
    .controls-row .controls-bar,
    .controls-row .share-btn {
        grid-column: auto;
        justify-self: auto;
    }
    .controls-row .share-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 420px) {
    .controls-bar {
        grid-template-columns: 1fr;
    }
    .controls-bar .next-btn {
        grid-column: auto;
    }
}
