/* ===== CSS Variables ===== */
:root {
    --primary-color: #6264a7;
    --accent-color: #8b5cf6;
    --bg-dark: #1f1f1f;
    --bg-darker: #2d2d2d;
    --card-bg: #3a3a3a;
    --card-hover: #424242;
    --text-primary: #ffffff;
    --text-secondary: #b4b4b4;
    --text-muted: #8a8a8a;
    --border-color: #484848;
    --reaction-bg: #2d2d2d;
    --reaction-hover: #424242;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --border-radius: 8px;
    --transition: all 0.2s ease;
    --max-width: 900px;
}

/* ===== Reset & Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-dark);
    min-height: 100vh;
    padding: 20px;
}

/* ===== Header ===== */
header {
    text-align: center;
    padding: 50px 30px;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    margin-bottom: 30px;
    max-width: var(--max-width);
    margin-left: auto;
    margin-right: auto;
    border: 1px solid var(--border-color);
}

.header-emoji {
    display: block;
    width: 60px;
    height: 60px;
    margin: 0 auto 15px;
    object-fit: contain;
}

header h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
    letter-spacing: -0.02em;
}

header .subtitle {
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    color: var(--text-secondary);
    font-weight: 400;
}

/* ===== Main Content ===== */
main {
    max-width: var(--max-width);
    margin: 0 auto;
    width: 100%;
}

/* ===== Intro Section ===== */
#intro {
    background: var(--card-bg);
    padding: 25px 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 30px;
    text-align: center;
    font-size: clamp(1rem, 2vw, 1.125rem);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

/* ===== Memories Section ===== */
#memories {
    margin-bottom: 30px;
}

#memories > h2 {
    text-align: center;
    font-size: clamp(2rem, 4vw, 2.5rem);
    color: var(--text-primary);
    margin-bottom: 30px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* ===== Teams-Style Memory Cards ===== */
.memory {
    display: flex;
    gap: 12px;
    margin-bottom: 25px;
    opacity: 0;
    animation: fadeInUp 0.5s ease forwards;
}

.memory:hover .message-container {
    background: var(--card-hover);
}

/* Profile Image */
.profile-image {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    margin-top: 4px;
    box-shadow: var(--shadow-sm);
    border: 2px solid var(--border-color);
}

/* Message Container */
.message-container {
    flex: 1;
    background: var(--card-bg);
    padding: 16px 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

/* Message Header (Name + Time) */
.message-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 8px;
}

.author-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.message-time {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* Message Content */
.message-content {
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 12px;
}

.message-content p {
    margin-bottom: 12px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content a {
    color: #5b9fd8;
    text-decoration: none;
}

.message-content a:hover {
    text-decoration: underline;
}

/* Message Media */
.message-media {
    margin: 16px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.message-media img,
.message-media video {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    box-shadow: var(--shadow-sm);
}

/* Message Reactions */
.message-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.reaction {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--reaction-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    color: var(--text-primary);
}

.reaction:hover {
    background: var(--reaction-hover);
    border-color: var(--text-muted);
}

.reaction-emoji {
    font-size: 1.125rem;
    line-height: 1;
}

/* Image reactions */
.reaction-emoji img,
img.reaction-emoji {
    width: 20px;
    height: 20px;
    object-fit: contain;
    display: block;
}

.reaction-count {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.add-reaction {
    background: transparent;
    border: 1px dashed var(--border-color);
}

.add-reaction:hover {
    border-color: var(--text-muted);
    background: var(--reaction-bg);
}

.plus-icon {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ===== Footer ===== */
footer {
    text-align: center;
    padding: 40px 30px;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    margin: 30px auto 20px;
    max-width: var(--max-width);
    font-size: clamp(1.125rem, 2.5vw, 1.25rem);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.footer-emoji {
    display: block;
    width: 50px;
    height: 50px;
    margin: 0 auto 15px;
    object-fit: contain;
}

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

/* Stagger animation for memory cards */
.memory:nth-child(1) { animation-delay: 0.1s; }
.memory:nth-child(2) { animation-delay: 0.15s; }
.memory:nth-child(3) { animation-delay: 0.2s; }
.memory:nth-child(4) { animation-delay: 0.25s; }
.memory:nth-child(5) { animation-delay: 0.3s; }
.memory:nth-child(n+6) { animation-delay: 0.35s; }

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    body {
        padding: 15px;
    }

    header,
    #intro,
    footer {
        padding: 30px 20px;
    }

    .message-container {
        padding: 14px 16px;
    }

    .profile-image {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    header,
    #intro,
    footer {
        padding: 25px 15px;
    }

    .memory {
        gap: 8px;
    }

    .profile-image {
        width: 36px;
        height: 36px;
    }

    .message-container {
        padding: 12px 14px;
    }

    .message-header {
        flex-direction: column;
        gap: 4px;
        align-items: flex-start;
    }

    .author-name {
        font-size: 0.9375rem;
    }

    .message-time {
        font-size: 0.8125rem;
    }

    .reaction {
        padding: 5px 10px;
        font-size: 0.875rem;
    }

    .header-emoji,
    .footer-emoji {
        width: 50px;
        height: 50px;
    }
}

/* ===== Accessibility ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== Print Styles ===== */
@media print {
    body {
        background: white;
        color: black;
        padding: 0;
    }

    header,
    #intro,
    .message-container,
    footer {
        background: white;
        color: black;
        box-shadow: none;
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }

    .message-reactions {
        display: none;
    }
}
