/* ============================================
   Valentine Puzzle Experience - Styles
   ============================================ */

/* --- CSS Variables / Design Tokens --- */
:root {
    --bg-main: #FDF8F5;
    --bg-card: #FFFFFF;
    --color-primary: #C9A9A6;
    --color-secondary: #A8B5C4;
    --color-accent: #E8C4C4;
    --color-highlight: #D4827D;
    --color-text: #4A4A4A;
    --color-text-light: #7A7A7A;
    --color-success: #8BAF8B;
    
    --font-display: 'Cormorant Garamond', serif;
    --font-body: 'Nunito Sans', sans-serif;
    --font-accent: 'Italiana', serif;
    
    --transition-smooth: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--bg-main);
    color: var(--color-text);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

/* --- Loading Screen --- */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-main);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.5s ease;
}

.loading-heart {
    font-size: 3rem;
    color: var(--color-highlight);
    animation: pulse 1s ease-in-out infinite;
}

/* --- Section Layout --- */
.section {
    min-height: 100vh;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    opacity: 0;
    transition: opacity var(--transition-smooth);
}

.section.active {
    display: flex;
    opacity: 1;
}

.container {
    max-width: 600px;
    width: 100%;
    text-align: center;
    padding: 2rem;
}

/* --- Typography --- */
.prelude {
    font-family: var(--font-body);
    font-size: 0.875rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--color-text-light);
    margin-bottom: 1rem;
    opacity: 0;
    animation: fadeInUp 0.8s ease forwards;
    animation-delay: 0.2s;
}

.title {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 8vw, 4rem);
    font-weight: 400;
    color: var(--color-text);
    margin-bottom: 1rem;
    opacity: 0;
    animation: fadeInUp 0.8s ease forwards;
    animation-delay: 0.4s;
}

.subtitle {
    font-family: var(--font-body);
    font-size: 1.125rem;
    font-weight: 300;
    color: var(--color-text-light);
    margin-bottom: 3rem;
    opacity: 0;
    animation: fadeInUp 0.8s ease forwards;
    animation-delay: 0.6s;
}

.section-label {
    font-family: var(--font-body);
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--color-primary);
    margin-bottom: 0.5rem;
}

h2 {
    font-family: var(--font-display);
    font-size: clamp(1.75rem, 5vw, 2.5rem);
    font-weight: 400;
    margin-bottom: 0.75rem;
}

.hint-text {
    font-size: 0.9rem;
    color: var(--color-text-light);
    margin-bottom: 2rem;
}

/* --- Buttons --- */
.btn {
    font-family: var(--font-body);
    font-size: 1rem;
    padding: 0.875rem 2.5rem;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all var(--transition-smooth);
    opacity: 0;
    animation: fadeInUp 0.8s ease forwards;
    animation-delay: 0.8s;
}

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

.btn.primary:hover {
    background: #c06b66;
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(212, 130, 125, 0.3);
}

.btn.secondary {
    background: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-primary);
    padding: 0.625rem 1.5rem;
    font-size: 0.875rem;
}

.btn.secondary:hover {
    background: var(--color-accent);
    border-color: var(--color-accent);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- Puzzle 1: Mini Crossword --- */
.crossword-container {
    max-width: 700px;
}

.crossword-layout {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    justify-content: center;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.crossword-grid {
    display: grid;
    gap: 2px;
    background: var(--color-text);
    padding: 2px;
    border-radius: 4px;
}

.crossword-cell {
    width: 44px;
    height: 44px;
    position: relative;
    background: var(--bg-card);
}

.crossword-cell.blocked {
    background: var(--color-text);
}

.crossword-cell input {
    width: 100%;
    height: 100%;
    border: none;
    text-align: center;
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 500;
    text-transform: uppercase;
    background: transparent;
    color: var(--color-text);
    caret-color: var(--color-highlight);
}

.crossword-cell input:focus {
    outline: none;
    background: rgba(212, 130, 125, 0.1);
}

.crossword-cell.correct input {
    background: rgba(139, 175, 139, 0.2);
    color: var(--color-success);
}

.crossword-cell.incorrect input {
    background: rgba(212, 130, 125, 0.2);
}

.crossword-cell .cell-number {
    position: absolute;
    top: 2px;
    left: 3px;
    font-size: 0.6rem;
    font-weight: 500;
    color: var(--color-text-light);
    pointer-events: none;
}

.crossword-clues {
    text-align: left;
    min-width: 200px;
    max-width: 280px;
}

.clue-section {
    margin-bottom: 1.5rem;
}

.clue-section h4 {
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-primary);
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--color-accent);
}

.clue {
    font-size: 0.9rem;
    color: var(--color-text);
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.clue:hover {
    background: rgba(200, 169, 166, 0.1);
}

.clue.active {
    background: rgba(212, 130, 125, 0.1);
}

.clue-number {
    font-weight: 600;
    color: var(--color-highlight);
    margin-right: 0.5rem;
}

.puzzle-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
}

.puzzle-controls .btn {
    opacity: 1;
    animation: none;
}

@media (max-width: 600px) {
    .crossword-layout {
        flex-direction: column;
        align-items: center;
    }
    
    .crossword-cell {
        width: 38px;
        height: 38px;
    }
    
    .crossword-cell input {
        font-size: 1.25rem;
    }
    
    .crossword-clues {
        max-width: 100%;
    }
}

/* --- Puzzle 2: Connections --- */
.connections-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin: 2rem 0;
}

@media (max-width: 500px) {
    .connections-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.connection-tile {
    padding: 1rem 0.5rem;
    font-family: var(--font-body);
    font-size: 0.85rem;
    background: var(--bg-card);
    border: 2px solid var(--color-secondary);
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-smooth);
    user-select: none;
}

.connection-tile:hover {
    border-color: var(--color-primary);
}

.connection-tile.selected {
    background: var(--color-accent);
    border-color: var(--color-highlight);
    transform: scale(1.02);
}

.connection-tile.found {
    opacity: 0.5;
    cursor: not-allowed;
}

.found-groups {
    margin-top: 1.5rem;
}

.found-group {
    background: var(--color-success);
    color: white;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    animation: fadeInUp 0.5s ease;
}

.found-group-title {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.found-group-items {
    font-size: 0.875rem;
    opacity: 0.9;
}

/* --- Success Message --- */
.success-message {
    margin-top: 2rem;
    padding: 2rem;
    background: linear-gradient(135deg, rgba(232, 196, 196, 0.2), rgba(200, 169, 166, 0.1));
    border-radius: 16px;
    animation: fadeInUp 0.6s ease;
}

.success-message.hidden {
    display: none;
}

.success-text {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-style: italic;
    color: var(--color-highlight);
    margin-bottom: 0.5rem;
}

.story-beat {
    font-size: 1rem;
    color: var(--color-text-light);
    margin-bottom: 1.5rem;
}

.success-message .btn {
    opacity: 1;
    animation: none;
}

/* --- Timeline Journey --- */
.timeline-section {
    display: none;
    flex-direction: column;
    padding: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.timeline-section.active {
    display: flex;
}

.timeline-container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 4rem 2rem 6rem;
}

.timeline-year {
    margin-bottom: 4rem;
    opacity: 0;
    transform: translateY(40px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.timeline-year.visible {
    opacity: 1;
    transform: translateY(0);
}

.year-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.year-number {
    font-family: var(--font-display);
    font-size: clamp(3rem, 10vw, 5rem);
    font-weight: 400;
    color: var(--color-highlight);
    line-height: 1;
}

.year-title {
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 300;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--color-text-light);
}

.year-title.title-only {
    font-family: var(--font-display);
    font-size: clamp(2rem, 6vw, 3rem);
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--color-highlight);
}

.timeline-photos {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem;
}

.timeline-photo {
    flex: 0 1 calc(33.333% - 1rem);
    min-width: 200px;
    max-width: 280px;
    position: relative;
    opacity: 0;
    transform: translateY(30px) scale(0.95);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.timeline-photo.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.timeline-photo img {
    width: 100%;
    aspect-ratio: 4/5;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    transition: all 0.4s ease;
}

.timeline-photo:hover img {
    transform: translateY(-4px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}

.timeline-photo-caption {
    margin-top: 0.75rem;
    font-family: var(--font-display);
    font-size: 1rem;
    font-style: italic;
    color: var(--color-text);
    text-align: center;
}

.timeline-progress {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 4px;
    background: rgba(200, 169, 166, 0.2);
    z-index: 50;
}

.timeline-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-highlight));
    transition: width 0.1s ease;
}

.timeline-continue {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 60;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.timeline-continue.visible {
    opacity: 1;
}

/* Story Intro Page */
.story-intro-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    text-align: center;
    padding: 2rem;
}

.story-intro-text {
    font-family: var(--font-body);
    font-size: 1.25rem;
    line-height: 2;
    color: var(--color-text);
    max-width: 650px;
    margin: 0 auto 3rem;
    font-style: italic;
}

#story-intro-continue {
    margin-top: 2rem;
}

/* Timeline ending message */
.timeline-end {
    text-align: center;
    padding: 4rem 2rem;
    opacity: 0;
    transform: translateY(40px);
    transition: all 0.8s ease;
}

.timeline-end.visible {
    opacity: 1;
    transform: translateY(0);
}

.timeline-end-text {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    font-style: italic;
    color: var(--color-text);
    margin-bottom: 2rem;
}

@media (max-width: 600px) {
    .timeline-container {
        padding: 3rem 1.5rem 5rem;
    }
    
    .timeline-photos {
        gap: 1.25rem;
    }
    
    .timeline-photo {
        flex: 0 1 100%;
        max-width: 100%;
    }
    
    .year-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
}

/* --- Message Section --- */
.message-container {
    max-width: 700px;
}

.message-lines {
    text-align: left;
    margin-bottom: 3rem;
}

.message-line {
    font-family: var(--font-display);
    font-size: clamp(1.25rem, 4vw, 1.75rem);
    line-height: 1.8;
    margin-bottom: 1rem;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.6s ease;
}

.message-line.visible {
    opacity: 1;
    transform: translateY(0);
}

#message-continue {
    opacity: 0;
    transition: opacity 0.5s ease;
}

#message-continue.visible {
    opacity: 1;
}

#message-continue.hidden {
    display: inline-block;
}

/* --- The Ask --- */
.ask-container {
    padding: 3rem 2rem;
}

.ask-title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 7vw, 3.5rem);
    font-weight: 400;
    margin-bottom: 3rem;
    opacity: 0;
    animation: fadeInUp 0.8s ease forwards;
    animation-delay: 0.3s;
}

.ask-buttons {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.ask-btn {
    font-size: 1.25rem;
    padding: 1rem 3rem;
    background: var(--color-highlight);
    color: white;
    opacity: 0;
    animation: fadeInUp 0.8s ease forwards, pulse 2s ease-in-out infinite;
    animation-delay: 0.6s, 1.4s;
}

.ask-btn:hover {
    background: #c06b66;
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 6px 25px rgba(212, 130, 125, 0.4);
}

/* --- Celebration --- */
.celebration-container {
    position: relative;
    padding: 3rem 2rem;
}

.celebration-title {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 10vw, 5rem);
    font-weight: 400;
    color: var(--color-highlight);
    margin-bottom: 1rem;
    opacity: 0;
    animation: fadeInUp 0.8s ease forwards;
    animation-delay: 0.5s;
}

.celebration-lines {
    margin-top: 2.5rem;
}

.celebration-line {
    font-size: 1.35rem;
    color: var(--color-text-light);
    margin-bottom: 1.5rem;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.6s ease;
}

.celebration-line.visible {
    opacity: 1;
    transform: translateY(0);
}

.celebration-video-btn {
    margin-top: 4rem;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.8s ease;
}

.celebration-video-btn.visible {
    opacity: 1;
    transform: translateY(0);
}

.hearts-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 100;
}

.heart {
    position: absolute;
    font-size: 1.5rem;
    animation: floatUp 4s ease-out forwards;
}

/* --- Animations --- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-8px); }
    80% { transform: translateX(8px); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

@keyframes floatUp {
    0% {
        opacity: 1;
        transform: translateY(100vh) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translateY(-20vh) rotate(720deg);
    }
}

/* --- Navigation Panel (bottom-right) --- */
.dev-nav {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    font-family: var(--font-body);
}

.dev-nav-toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dev-nav-arrow {
    font-size: 1rem;
    color: var(--color-highlight);
    animation: jumpArrow 1s ease-in-out infinite;
    opacity: 0.9;
}

@keyframes jumpArrow {
    0%, 100% {
        transform: translateX(0);
        opacity: 0.6;
    }
    50% {
        transform: translateX(6px);
        opacity: 1;
    }
}

.dev-nav.open .dev-nav-arrow {
    display: none;
}

.dev-nav-toggle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-highlight), var(--color-primary));
    color: white;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(212, 130, 125, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.dev-nav-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(212, 130, 125, 0.5);
}

.dev-nav-panel {
    position: absolute;
    bottom: 60px;
    right: 0;
    background: white;
    border-radius: 12px;
    padding: 0.75rem;
    min-width: 180px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.25s ease;
}

.dev-nav.open .dev-nav-panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dev-nav-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-text-light);
    padding: 0.25rem 0.5rem;
    margin-bottom: 0.25rem;
}

.dev-nav-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.75rem;
    border: none;
    background: transparent;
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--color-text);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.dev-nav-btn:hover {
    background: var(--color-accent);
}

.dev-nav-btn.active {
    background: var(--color-primary);
    color: white;
}

.dev-nav-divider {
    border: none;
    border-top: 1px solid #eee;
    margin: 0.5rem 0;
}

.dev-nav-restart {
    color: var(--color-highlight);
}

/* --- Utilities --- */
.hidden {
    display: none !important;
}

/* --- Responsive --- */
@media (max-width: 480px) {
    .container {
        padding: 1.5rem 1rem;
    }
    
    .letter-tile, .answer-slot {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }
    
    .memory-grid {
        gap: 0.75rem;
    }
    
    .memory-back p {
        font-size: 0.8rem;
    }
    
    .ask-buttons {
        flex-direction: column;
        align-items: center;
    }
}
