/* CSS Reset and Variables */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #f59e0b;
    --background-color: #f8fafc;
    --surface-color: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --transition: all 0.2s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #8b5cf6 100%);
    color: white;
    padding: 2rem 1.5rem;
    text-align: center;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.logo {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.tagline {
    font-size: 1.125rem;
    opacity: 0.9;
    margin-top: 0.5rem;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Emotion Section */
.emotion-section {
    text-align: center;
    margin-bottom: 3rem;
}

.emotion-section h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

.emotion-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    max-width: 900px;
    margin: 0 auto;
}

.emotion-card {
    background: var(--surface-color);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.emotion-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.emotion-card.selected {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
}

.emotion-icon {
    font-size: 2rem;
}

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

.emotion-description {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
}

/* Results Section */
.results-section {
    display: none;
    animation: fadeIn 0.3s ease;
}

.results-section.visible {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.results-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.results-header h2 span {
    color: var(--primary-color);
}

.reset-btn {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.reset-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Font Cards */
.font-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.font-card {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: var(--transition);
}

.font-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.font-card-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.font-card-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.font-category {
    display: inline-block;
    background: var(--background-color);
    color: var(--text-secondary);
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

.font-preview {
    padding: 1.5rem;
    background: var(--background-color);
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.font-sample {
    font-size: 1.5rem;
    text-align: center;
    line-height: 1.4;
}

.font-card-footer {
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.font-traits {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.trait-tag {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
    color: var(--primary-color);
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.view-details-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
}

.view-details-btn:hover {
    background: var(--primary-hover);
}

/* Pairing Section */
.pairing-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.pairing-section h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.pairing-description {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.pairing-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.pairing-card {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.pairing-header {
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05) 0%, rgba(139, 92, 246, 0.05) 100%);
    border-bottom: 1px solid var(--border-color);
}

.pairing-fonts {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
}

.pairing-plus {
    color: var(--text-muted);
    font-weight: 400;
}

.pairing-preview {
    padding: 1.5rem;
}

.pairing-headline {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

.pairing-body {
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.pairing-use-case {
    padding: 0.75rem 1.25rem;
    background: var(--background-color);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.pairing-use-case strong {
    color: var(--text-primary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow-y: auto;
    padding: 2rem 1rem;
}

.modal.visible {
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.modal-content {
    background: var(--surface-color);
    border-radius: var(--radius-xl);
    max-width: 700px;
    width: 100%;
    position: relative;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--background-color);
    color: var(--text-primary);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.modal-body {
    padding: 1.5rem;
}

.preview-section {
    margin-bottom: 2rem;
}

.preview-section h4,
.font-info-section h4,
.character-set h4 {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.preview-controls {
    margin-bottom: 1rem;
}

.preview-controls label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.preview-controls input[type="range"] {
    flex: 1;
    max-width: 200px;
}

.preview-text {
    background: var(--background-color);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    word-break: break-word;
}

.custom-preview {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    resize: vertical;
    min-height: 80px;
}

.custom-preview:focus {
    outline: none;
    border-color: var(--primary-color);
}

.font-info-section {
    margin-bottom: 2rem;
}

.font-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.font-detail-item {
    background: var(--background-color);
    padding: 1rem;
    border-radius: var(--radius-md);
}

.font-detail-item label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.font-detail-item span {
    font-weight: 600;
    font-size: 0.9rem;
}

.character-set {
    margin-bottom: 1rem;
}

.characters {
    background: var(--background-color);
    padding: 1rem;
    border-radius: var(--radius-md);
    font-size: 1.25rem;
    letter-spacing: 0.25em;
    word-break: break-all;
    line-height: 2;
}

/* Footer */
.footer {
    background: var(--surface-color);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem;
    text-align: center;
}

.footer p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.footer a:hover {
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        padding: 1.5rem 1rem;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .tagline {
        font-size: 1rem;
    }

    .main-content {
        padding: 1.5rem 1rem;
    }

    .emotion-section h2 {
        font-size: 1.25rem;
    }

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

    .emotion-card {
        padding: 1rem 0.75rem;
    }

    .emotion-icon {
        font-size: 1.5rem;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .font-cards {
        grid-template-columns: 1fr;
    }

    .pairing-cards {
        grid-template-columns: 1fr;
    }

    .modal {
        padding: 1rem;
    }

    .modal-content {
        border-radius: var(--radius-lg);
    }

    .font-details {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .logo-container {
        flex-direction: column;
        gap: 0.5rem;
    }

    .logo {
        width: 40px;
        height: 40px;
    }

    .header h1 {
        font-size: 1.25rem;
    }

    .emotion-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .emotion-description {
        display: none;
    }

    .font-sample {
        font-size: 1.25rem;
    }

    .pairing-headline {
        font-size: 1.25rem;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Loading State */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
