/* =========================================
   VARIABLES & RESET
   ========================================= */
:root {
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --border: #e2e8f0;
    --text-main: #0f172a;
    --text-muted: #475569;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --radius: 8px;
    --container: 1200px;
    --header-height: 70px;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s;
}

ul {
    list-style: none;
}

button {
    font-family: inherit;
    cursor: pointer;
}

/* =========================================
   UTILITIES
   ========================================= */
.container {
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 20px;
}

.section-header {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 25px;
    display: flex;
    align-items: center;
}

/* =========================================
   HEADER
   ========================================= */
.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    height: var(--header-height);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    gap: 30px;
}

.logo {
    font-weight: 800;
    font-size: 1.4rem;
    color: var(--primary);
    letter-spacing: -0.5px;
    flex-shrink: 0;
}

.header-search {
    flex-grow: 1;
    max-width: 600px;
}

.search-input {
    width: 100%;
    padding: 10px 18px;
    font-size: 0.95rem;
    background-color: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 50px;
    outline: none;
    transition: all 0.2s ease;
    color: var(--text-main);
}

.search-input::placeholder {
    color: #64748b;
}

.search-input:focus {
    background-color: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-main);
    padding: 5px;
    flex-shrink: 0;
}

/* =========================================
   STICKY CATEGORY BAR
   ========================================= */
.category-bar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(5px);
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
    position: sticky;
    top: var(--header-height);
    z-index: 90;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
}

.category-bar ul {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.category-bar ul::-webkit-scrollbar {
    display: none;
}

.category-bar li a {
    display: inline-block;
    padding: 6px 16px;
    background: #f1f5f9;
    color: #334155;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid #e2e8f0;
    transition: all 0.2s;
}

.category-bar li a:hover {
    background: #eff6ff;
    color: var(--primary);
    border-color: #bfdbfe;
}

/* =========================================
   MAIN CONTENT & GRID
   ========================================= */
.main-content {
    padding: 40px 0;
    min-height: 80vh;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 50px;
}

/* Homepage specific large grid to prevent CLS for 30+ items */
#calculators-grid-container {
    min-height: 1500px;
}

@media (max-width: 1024px) {
    #calculators-grid-container {
        min-height: 2000px;
    }
}

@media (max-width: 768px) {
    #calculators-grid-container {
        min-height: 4000px;
    }
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    height: 100%;
}

.card:hover {
    transform: translateY(-3px);
    border-color: #cbd5e1;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
}

.card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-main);
}

.card p {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* =========================================
   FOOTER
   ========================================= */
.footer {
    background: #ffffff;
    border-top: 1px solid var(--border);
    padding: 60px 0 20px;
    margin-top: 60px;
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 40px;
    margin-bottom: 40px;
}

.footer h4 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.footer p,
.footer ul li a {
    color: var(--text-muted);
    font-size: 0.9rem;
    transition: color 0.2s;
}

.footer ul li {
    margin-bottom: 12px;
}

.footer ul li a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.copyright {
    text-align: center;
    color: #64748b;
    font-size: 0.85rem;
    border-top: 1px solid #f1f5f9;
    padding-top: 20px;
}

/* =========================================
   MOBILE MENU
   ========================================= */
.mobile-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 280px;
    height: 100%;
    background: var(--bg-card);
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.1);
    padding: 25px;
    transition: 0.3s ease;
    z-index: 1000;
}

.mobile-menu.active {
    right: 0;
}

.mobile-close {
    background: none;
    border: none;
    font-size: 2rem;
    position: absolute;
    top: 15px;
    right: 20px;
    cursor: pointer;
}

.sidebar-list li {
    margin-bottom: 15px;
}

.sidebar-list a {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
}

/* =========================================
   RESPONSIVE
   ========================================= */
@media (max-width: 768px) {
    .header-inner {
        gap: 10px;
    }

    .logo {
        display: block;
        font-size: 1.1rem;
    }

    .menu-btn {
        display: block;
    }

    .footer-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .main-content {
        padding: 20px 0;
    }
}

/* =========================================
   ARTICLE / PROSE TYPOGRAPHY
   ========================================= */
article {
    max-width: 800px;
    margin: 0 auto;
    font-size: 1.05rem;
    color: #334155;
    line-height: 1.8;
}

article h2 {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-main);
    margin-top: 50px;
    margin-bottom: 20px;
    letter-spacing: -0.5px;
}

article h3 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-main);
    margin-top: 40px;
    margin-bottom: 15px;
}

article h4 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
    margin-top: 30px;
    margin-bottom: 10px;
}

article p {
    margin-bottom: 24px;
}

article ul,
article ol {
    margin-bottom: 24px;
    padding-left: 20px;
}

article ul li,
article ol li {
    margin-bottom: 10px;
    padding-left: 5px;
}

article ul li::marker {
    color: var(--primary);
}

/* Blockquote */
article blockquote {
    background: #f8fafc;
    border-left: 4px solid var(--primary);
    padding: 24px 30px;
    border-radius: 0 8px 8px 0;
    margin: 30px 0;
    font-style: italic;
    color: #475569;
}

/* Formula Box */
.fc-formula-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    padding: 25px;
    margin: 30px 0;
    text-align: center;
}

.fc-formula-box code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
    background: white;
    padding: 5px 12px;
    border-radius: 6px;
    border: 1px solid #dbeafe;
    display: inline-block;
}

/* FAQ Items */
.faq-item {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
    transition: 0.2s;
}

.faq-item:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
}

.faq-question {
    font-weight: 700;
    color: var(--text-main);
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.faq-answer {
    margin-bottom: 0 !important;
    /* Override paragraph margin */
    font-size: 0.95rem;
}

/* Links in article */
article a {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

article a:hover {
    color: var(--primary-hover);
}

/* Homepage Specific Info Section */
.homepage-info {
    margin-top: 80px !important;
    border: none !important;
    padding: 0 !important;
}

.info-content-card {
    background: #fff;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
    line-height: 1.8;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 40px;
    margin-bottom: 40px;
}

.fc-list strong {
    color: var(--text-main);
}