/* 
    Calculomates - Premium Soft Design System
    A modern, sleek aesthetic for math education.
*/

:root {
    /* Colors */
    --primary: #4b89f5;
    --primary-dark: #3b79e5;
    --secondary: #9f5cf5;
    --accent: #10b981;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    
    /* Shadows */
    --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-soft: 0 20px 25px -5px rgba(75, 137, 245, 0.1), 0 8px 10px -6px rgba(75, 137, 245, 0.1);
    
    /* Transitions */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Montserrat', system-ui, -apple-system, sans-serif;
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Glassmorphism Header */
header {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.logo {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.logo span {
    color: var(--secondary);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    list-style: none;
    margin: 0 1rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-main);
    font-weight: 500;
    transition: var(--transition);
    font-size: 0.85rem;
    white-space: nowrap;
}

.nav-links a:hover {
    color: var(--primary);
}

/* Dropdown */
.dropdown {
    position: relative;
}

.dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    white-space: nowrap;
    flex-wrap: nowrap;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    padding: 1rem;
    display: none;
    flex-direction: column;
    gap: 0.5rem;
    /* Remove margin-top to avoid the hover gap */
    margin-top: 0; 
    z-index: 100;
}

/* Add a transparent bridge so the hover doesn't break if there's a visual gap */
.dropdown-menu::before {
    content: '';
    position: absolute;
    top: -15px;
    left: 0;
    width: 100%;
    height: 15px;
    background: transparent;
}

.dropdown:hover > .dropdown-menu,
.dropdown.active > .dropdown-menu {
    display: flex;
}

.dropdown-menu a {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    white-space: nowrap;
}

.dropdown-menu a:hover {
    background: rgba(75, 137, 245, 0.05);
}

/* Multi-level Dropdown Support */
.dropdown-menu .dropdown {
    width: 100%;
}

.dropdown-menu .dropdown-toggle {
    justify-content: space-between;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    width: 100%;
}

.dropdown-menu .dropdown-toggle:hover {
    background: rgba(75, 137, 245, 0.05);
    color: var(--primary);
}

.dropdown-menu .dropdown-menu {
    top: -0.5rem;
    left: 100%;
    margin-top: 0;
    margin-left: 0.25rem;
}

/* Hero Section */
.hero {
    padding: 5rem 0;
    text-align: center;
    background: radial-gradient(circle at top right, rgba(75, 137, 245, 0.05), transparent),
                radial-gradient(circle at bottom left, rgba(159, 92, 245, 0.05), transparent);
}

.hero h1 {
    font-size: 3.5rem;
    line-height: 1.1;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero p {
    font-size: 1.25rem;
    color: var(--text-muted);
    max-width: 700px;
    margin: 0 auto 2.5rem;
}

/* Grid Layout */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    padding: 2rem 0;
}

/* Premium Soft Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1.5rem;
    padding: 2rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-soft);
    border-color: rgba(75, 137, 245, 0.3);
}

.card-icon {
    width: 56px;
    height: 56px;
    background: rgba(75, 137, 245, 0.1);
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    color: var(--primary);
    font-size: 1.5rem;
}

.card h3 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

.card p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
    cursor: pointer;
    border: none;
}

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

.btn-primary:hover {
    background-color: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(75, 137, 245, 0.4);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
}

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

/* Footer */
footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 4rem 0 2rem;
    margin-top: 5rem;
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 4rem;
    margin-bottom: 3rem;
}

.footer-logo {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    color: var(--text-main);
}

.footer-logo span {
    color: var(--primary);
}

.footer-links h4 {
    margin-bottom: 1.5rem;
    font-size: 1rem;
}

.footer-links ul {
    list-style: none;
}

.footer-links li {
    margin-bottom: 0.75rem;
}

.footer-links a {
    text-decoration: none;
    color: var(--text-muted);
    transition: var(--transition);
}

.footer-links a:hover {
    color: var(--primary);
}

.footer-bottom {
    border-top: 1px solid var(--border);
    padding-top: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-control {
    width: 100%;
    padding: 1rem 1.25rem;
    background-color: #f8fafc;
    border: 2px solid #f1f5f9;
    border-radius: 1rem;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-main);
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    background-color: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(75, 137, 245, 0.1);
}

.form-control::placeholder {
    color: #cbd5e1;
}

.form-error {
    color: #ef4444;
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

/* Favorite Button */
.fav-btn {
    background: none !important;
    border: none !important;
    color: #d1d5db;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    outline: none;
    -webkit-text-fill-color: initial !important;
}
.fav-btn i {
    font-size: 2.2rem;
    -webkit-text-fill-color: initial !important;
}
.fav-btn:hover {
    color: #ffb4b4;
    transform: scale(1.1);
}
.fav-btn.is-fav-active {
    color: #ff0000 !important;
}
.fav-btn.is-fav-active:hover {
    color: #dc2626 !important;
}

@media (max-width: 768px) {
    .hero h1 {
        font-size: 2.5rem;
    }
    .footer-grid {
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
    }
}
