@import url('https://fonts.googleapis.com/css2?family=Noto+Color+Emoji&display=swap');

:root {
    --bg-color: #ffffff;
    --text-color: #000000;
    --button-bg: #000000;
    --button-text: #ffffff;
    --input-bg: #f5f5f5;
    --thought-bg: #f8f8f8;
}

[data-theme="dark"] {
    --bg-color: #1a1a1a;
    --text-color: #ffffff;
    --button-bg: #ffffff;
    --button-text: #000000;
    --input-bg: #2d2d2d;
    --thought-bg: #252525;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Color Emoji", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    text-align: center;
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid rgba(128, 128, 128, 0.2);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.branding {
    text-align: left;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 0.25rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: linear-gradient(45deg, var(--text-color), rgba(128, 128, 128, 0.8));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.8;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.description {
    font-size: 1rem;
    opacity: 0.7;
    max-width: 600px;
    margin: 0 auto;
}

#darkModeToggle {
    padding: 0.75rem;
    border: none;
    border-radius: 50%;
    background-color: var(--thought-bg);
    color: var(--text-color);
    cursor: pointer;
    transition: transform 0.2s, background-color 0.3s;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#darkModeToggle:hover {
    transform: scale(1.1);
    background-color: var(--input-bg);
}

#darkModeToggle .light-icon {
    display: none;
}

#darkModeToggle .dark-icon {
    display: block;
}

[data-theme="dark"] #darkModeToggle .light-icon {
    display: block;
}

[data-theme="dark"] #darkModeToggle .dark-icon {
    display: none;
}

.input-section {
    margin-bottom: 2rem;
    position: relative;
}

textarea {
    width: 100%;
    height: 100px;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: var(--input-bg);
    color: var(--text-color);
    font-size: 1rem;
    resize: vertical;
}

#submitThought {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 5px;
    background-color: var(--button-bg);
    color: var(--button-text);
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s;
}

#submitThought:hover {
    transform: scale(1.02);
}

.thought-item {
    background-color: var(--thought-bg);
    padding: 1.5rem;
    margin-bottom: 1rem;
    border-radius: 5px;
    animation: fadeIn 0.5s ease-in;
    position: relative;
    overflow: visible;
}

.vote-buttons {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.5rem;
    justify-content: flex-start;
    align-items: center;
}

.vote-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: transform 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.vote-button i {
    font-size: 1.5rem;
    transition: transform 0.2s, color 0.2s;
    display: inline-block;
    font-family: "Font Awesome 6 Free";
    -moz-osx-font-smoothing: grayscale;
    -webkit-font-smoothing: antialiased;
    font-style: normal;
    font-weight: 900;
}

.vote-button[data-vote="up"] i {
    color: #ff4b4b;
    opacity: 0.5;
}

.vote-button[data-vote="down"] i {
    color: #8b4513;
    opacity: 0.5;
}

.vote-button:hover i {
    transform: scale(1.1);
    opacity: 0.8;
}

.vote-button.active i {
    opacity: 1;
    transform: scale(1.1);
}

.vote-button[data-vote="up"].active i {
    color: #ff0000;
}

.vote-button[data-vote="down"].active i {
    color: #663300;
}

.vote-count {
    font-size: 0.9rem;
    opacity: 0.7;
    min-width: 1.5rem;
    text-align: center;
}

.thought-timestamp i {
    font-size: 1rem;
    margin-left: 0.3rem;
    opacity: 0.7;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.loading, .error {
    text-align: center;
    padding: 2rem;
    color: var(--text-color);
    opacity: 0.7;
}

.error {
    color: #ff4444;
}

/* Confetti */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    pointer-events: none;
    z-index: 9999;
    transform: rotate(0deg);
    animation: rotate 1s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Vote animations */
.upvote-animation {
    animation: pulse-green 0.5s ease-out;
}

.downvote-animation {
    animation: pulse-red 0.5s ease-out;
}

.unvote-animation {
    animation: pulse-gray 0.5s ease-out;
}

@keyframes pulse-green {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(0, 255, 0, 0.4); }
    50% { transform: scale(1.02); box-shadow: 0 0 0 10px rgba(0, 255, 0, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(0, 255, 0, 0); }
}

@keyframes pulse-red {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 0, 0, 0.4); }
    50% { transform: scale(1.02); box-shadow: 0 0 0 10px rgba(255, 0, 0, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 0, 0, 0); }
}

@keyframes pulse-gray {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(128, 128, 128, 0.4); }
    50% { transform: scale(1.02); box-shadow: 0 0 0 10px rgba(128, 128, 128, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(128, 128, 128, 0); }
}

/* Message animations */
.error-message,
.success-message {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    border-radius: 4px;
    color: white;
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.error-message {
    background-color: #ff4444;
}

.success-message {
    background-color: #44ff44;
    color: #000;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(128, 128, 128, 0.2);
    font-size: 0.9rem;
    opacity: 0.7;
}

.footer-links {
    margin-top: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.text-button {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.5rem;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.text-button:hover {
    opacity: 1;
}

.separator {
    opacity: 0.5;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

.modal-content {
    background-color: var(--bg-color);
    border-radius: 10px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.3);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal.show .modal-content {
    transform: translateY(0);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(128, 128, 128, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.close-modal {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-color);
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-modal:hover {
    opacity: 1;
}

.modal-body {
    padding: 1.5rem;
}

.modal-body h3 {
    margin: 0 0 1rem 0;
    font-size: 1.2rem;
    font-weight: 600;
}

.modal-body ul {
    list-style: none;
    padding: 0;
    margin: 0 0 2rem 0;
}

.modal-body li {
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-note {
    padding: 1rem;
    background-color: var(--thought-bg);
    border-radius: 5px;
    margin-top: 1.5rem;
    font-style: italic;
    opacity: 0.8;
}

/* Mobile-friendly improvements */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    h1 {
        font-size: 2rem;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .branding {
        text-align: center;
    }

    /* Larger touch targets for mobile */
    #darkModeToggle {
        width: 56px;
        height: 56px;
        font-size: 1.5rem;
    }

    #submitThought {
        padding: 1.2rem;
        font-size: 1.1rem;
        margin-top: 0.5rem;
        /* Add touch feedback */
        -webkit-tap-highlight-color: transparent;
    }

    /* Larger text input on mobile */
    textarea {
        font-size: 1.1rem;
        padding: 1.2rem;
        min-height: 120px;
    }

    /* Improved touch targets for vote buttons */
    .vote-buttons {
        gap: 1.5rem;
        justify-content: center;
        padding: 0.5rem 0;
    }

    .vote-button {
        padding: 0.8rem;
    }

    .vote-button i {
        font-size: 1.8rem;
    }

    .vote-count {
        font-size: 1rem;
    }

    /* Better modal handling on mobile */
    .modal-content {
        width: 95%;
        max-height: 90vh;
        margin: 5vh auto;
        padding: 1.5rem;
    }

    .close-modal {
        padding: 1rem;
        font-size: 1.5rem;
    }

    /* Footer improvements */
    .footer-links {
        gap: 1.5rem;
    }

    .text-button {
        padding: 0.8rem;
        font-size: 1.1rem;
    }

    /* Character counter */
    .char-counter {
        font-size: 0.9rem;
        padding: 0.5rem;
        text-align: right;
    }
}

/* Touch device optimizations */
@media (hover: none) {
    /* Remove hover effects on touch devices */
    #darkModeToggle:hover,
    #submitThought:hover,
    .vote-button:hover,
    .text-button:hover {
        transform: none;
    }

    /* Add active state feedback instead */
    #darkModeToggle:active,
    #submitThought:active,
    .vote-button:active,
    .text-button:active {
        transform: scale(0.95);
        transition: transform 0.1s;
    }
}

/* Prevent text selection on interactive elements */
button, 
.vote-button, 
#darkModeToggle {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Safe area insets for modern mobile devices */
@supports (padding: max(0px)) {
    .container {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}

/* Smooth scrolling for iOS */
html {
    -webkit-overflow-scrolling: touch;
}

/* Remove old icon styles */
.icon {
    display: none;
}

/* Vote message animation */
.vote-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--thought-bg);
    padding: 0.8rem 1.2rem;
    border-radius: 20px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    animation: messagePopup 2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    pointer-events: none;
    z-index: 100;
    text-align: center;
    white-space: nowrap;
}

@keyframes messagePopup {
    0% {
        opacity: 0;
        transform: translate(-50%, -30%);
    }
    20% {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
    80% {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -70%);
    }
}

/* Enhanced vote button animations */
.vote-button:active {
    transform: scale(0.9);
}

@keyframes buttonPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Update emoji styles */
.emoji {
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Android Emoji", sans-serif;
    font-size: 1.5rem;
    line-height: 1;
    vertical-align: middle;
    display: inline-block;
}

/* Dark mode icon styles */
#darkModeToggle i {
    font-size: 1.5rem;
    font-family: "Font Awesome 6 Free";
    -moz-osx-font-smoothing: grayscale;
    -webkit-font-smoothing: antialiased;
    font-style: normal;
    font-weight: 900;
}

.light-icon {
    color: #f1c40f;
}

.dark-icon {
    color: #2c3e50;
}

[data-theme="dark"] .light-icon {
    color: #f1c40f;
}

[data-theme="dark"] .dark-icon {
    color: #f1c40f;
}

.thought-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    font-size: 0.9em;
    color: var(--text-secondary);
}

.thought-timestamp {
    display: flex;
    align-items: center;
}

.time-remaining {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    border-radius: 12px;
    background-color: rgba(128, 128, 128, 0.1);
    font-weight: 500;
}

.time-remaining i {
    font-size: 0.9em;
    margin-right: 2px;
    animation: spin 4s linear infinite;
    display: inline-block;
    font-family: "Font Awesome 6 Free";
    -moz-osx-font-smoothing: grayscale;
    -webkit-font-smoothing: antialiased;
    font-style: normal;
    font-weight: 900;
}

.time-remaining span {
    color: var(--text-color);
}

/* Time remaining color states */
.time-remaining[data-hours="0"] {
    color: #ff4444;
    background-color: rgba(255, 68, 68, 0.1);
}

.time-remaining[data-hours="1"] {
    color: #ff8c00;
    background-color: rgba(255, 140, 0, 0.1);
}

.time-remaining[data-hours="2"] {
    color: #ffd700;
    background-color: rgba(255, 215, 0, 0.1);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.time-ago {
    opacity: 0.8;
}

/* Ensure emoji font fallback */
.emoji, 
.vote-button i,
.time-remaining i {
    font-family: "Font Awesome 6 Free", "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
} 