/* =========================================================
   ELECTRICAL ENGINEERING — PRODUCTION UI SYSTEM
   Prasun Barua
   Modern 2026 High-Performance Edition (Polished Fixes)
   ========================================================= */

/* =========================================================
   1. DESIGN TOKENS
   ========================================================= */

:root {
    /* Brand Colors */
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;
    --primary-soft: #dbeafe;

    /* Text & Foreground */
    --text: #0f172a;
    --text-strong: #020617;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-subtle: #94a3b8;

    /* Surfaces & Backgrounds */
    --background: #ffffff;
    --background-soft: #f8fafc;
    --background-alt: #f1f5f9;
    --surface-elevated: #ffffff;

    /* Borders & Dividers */
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --border-strong: #cbd5e1;

    /* Status Indicators */
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;

    /* Dark Mode Palette */
    --dark: #0f172a;
    --dark-soft: #1e293b;
    --dark-text: #f8fafc;
    --dark-secondary: #cbd5e1;

    /* Border Radius Scale */
    --radius-xs: 6px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 24px;
    --radius-pill: 9999px;

    /* Ultra-Clean Apple/Google Shadows */
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.06), 0 1px 2px -1px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.05), 0 2px 6px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 12px 24px -4px rgba(0, 0, 0, 0.06), 0 4px 12px -2px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 24px 48px -12px rgba(0, 0, 0, 0.12);

    /* Layout Constraints */
    --container: 1200px;
    --reading-width: 68ch;

    /* Motion & Timing */
    --ease-apple: cubic-bezier(0.16, 1, 0.3, 1);
    --transition-fast: 150ms var(--ease-apple);
    --transition: 250ms var(--ease-apple);
    --transition-slow: 350ms var(--ease-apple);

    /* Dimensional Tokens */
    --header-height: 72px;

    /* Apple/Google System Font Stack */
    --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
                 "Inter", "Google Sans", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}


/* =========================================================
   2. HIGH-PERFORMANCE RESET
   ========================================================= */

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

html {
    scroll-behavior: smooth;
    text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
    font-size: 16px;
    font-synthesis: none;
}

body {
    min-height: 100vh;
    font-family: var(--font-sans);
    color: var(--text);
    background-color: var(--background);
    line-height: 1.6;
    letter-spacing: -0.011em;
    font-optical-sizing: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
}

img,
svg,
video,
canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

button,
input,
textarea,
select {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
    background: none;
    border: none;
}

a {
    color: inherit;
    text-decoration: none;
}

ul,
ol {
    list-style-position: inside;
}


/* =========================================================
   3. SELECTION & FOCUS
   ========================================================= */

::selection {
    color: #ffffff;
    background: var(--primary);
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
    border-radius: var(--radius-xs);
}


/* =========================================================
   4. ACCESSIBILITY & MATERIAL SYMBOLS ALIGNMENT FIX
   ========================================================= */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Perfect alignment for Google Material Symbols */
.material-symbols-rounded {
    font-family: "Material Symbols Rounded", sans-serif;
    font-weight: normal;
    font-style: normal;
    font-size: 20px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-feature-settings: "liga";
    -webkit-font-smoothing: antialiased;
    font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
}


/* =========================================================
   5. CONTAINER & HEADER
   ========================================================= */

.container {
    width: min(calc(100% - 48px), var(--container));
    margin-inline: auto;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    transition: background var(--transition);
}

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

.logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.logo-icon {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: #ffffff;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.logo strong {
    display: block;
    color: var(--text-strong);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.logo small {
    display: block;
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    line-height: 1;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.main-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: -0.01em;
    transition: all var(--transition-fast);
}

.main-nav a:hover {
    color: var(--text-strong);
    background: var(--background-soft);
}

.main-nav a.active {
    color: var(--primary);
    background: var(--primary-light);
    font-weight: 600;
}


/* =========================================================
   6. HERO SECTION
   ========================================================= */

.hero {
    position: relative;
    padding: clamp(60px, 8vw, 100px) 0 clamp(50px, 6vw, 80px);
    background: radial-gradient(100% 100% at 50% 0%, rgba(37, 99, 235, 0.04) 0%, transparent 100%);
    overflow: hidden;
}

.hero-content {
    max-width: 880px;
    margin-inline: auto;
    text-align: center;
    position: relative;
    z-index: 2;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    color: var(--primary);
    background: var(--primary-light);
    border: 1px solid var(--primary-soft);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.hero h1 {
    margin-top: 20px;
    color: var(--text-strong);
    font-size: clamp(36px, 5.5vw, 64px);
    line-height: 1.08;
    letter-spacing: -0.035em;
    font-weight: 700;
    text-wrap: balance;
}

.hero h1 span {
    color: var(--primary);
    display: inline-block;
}

.hero p {
    max-width: 640px;
    margin: 20px auto 0;
    color: var(--text-secondary);
    font-size: clamp(16px, 1.8vw, 19px);
    line-height: 1.6;
    letter-spacing: -0.01em;
    text-wrap: pretty;
}


/* =========================================================
   7. GOOGLE-STYLE SEARCH BAR (ALIGNMENT & DESIGN FIX)
   ========================================================= */

.search-box {
    width: min(640px, 100%);
    height: 52px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 32px auto 0;
    padding: 4px 6px 4px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--background);
    box-shadow: var(--shadow-md);
    transition: all var(--transition);
}

.search-box:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--border-strong);
}

.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12), var(--shadow-lg);
}

.search-box > .material-symbols-rounded {
    color: var(--text-muted);
    font-size: 20px;
    flex-shrink: 0;
}

.search-box input {
    flex: 1;
    min-width: 0;
    height: 100%;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-strong);
    font-size: 15px;
    line-height: 1;
}

.search-box input::placeholder {
    color: var(--text-subtle);
}

/* Precision Flex-aligned Search Button */
.search-box button {
    height: 42px;
    padding: 0 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: var(--radius-pill);
    color: #ffffff;
    background: var(--primary);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.01em;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.search-box button .material-symbols-rounded {
    font-size: 18px;
    line-height: 1;
}

.search-box button span:not(.material-symbols-rounded) {
    display: inline-block;
    line-height: 1;
}

.search-box button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

#search-message {
    margin-top: 10px;
    font-size: 13px;
    font-weight: 500;
    color: var(--danger);
    text-align: center;
}


/* =========================================================
   8. ARTICLE METADATA & HEADER FIX (IMAGE 2 ALIGNMENT)
   ========================================================= */

.article-header {
    text-align: center;
    margin-bottom: 48px;
}

.article-header h1 {
    color: var(--text-strong);
    font-size: clamp(32px, 4.5vw, 52px);
    line-height: 1.1;
    letter-spacing: -0.035em;
    font-weight: 700;
}

/* Inline metadata container with flex alignment */
.article-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 24px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

.meta-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1;
}

.meta-item .material-symbols-rounded {
    font-size: 18px;
    color: var(--text-muted);
}


/* =========================================================
   9. CARDS & SECTIONS
   ========================================================= */

.section {
    padding: clamp(60px, 8vw, 96px) 0;
}

.section-alt {
    background: var(--background-soft);
}

.section-heading {
    max-width: 680px;
    margin-bottom: 40px;
}

.section-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.category-grid,
.calculator-grid,
.article-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.category-card,
.calculator-card,
.article-card {
    display: flex;
    flex-direction: column;
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface-elevated);
    box-shadow: var(--shadow-xs);
    transition: all var(--transition);
}

.category-card:hover,
.calculator-card:hover,
.article-card:hover {
    transform: translateY(-3px);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-lg);
}

.category-icon,
.tool-icon,
.icon-box {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--primary);
    background: var(--primary-light);
    margin-bottom: 20px;
}


/* =========================================================
   10. MEDIA QUERIES
   ========================================================= */

@media (max-width: 768px) {
    :root {
        --header-height: 64px;
    }

    .main-nav {
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
    }

    .main-nav::-webkit-scrollbar {
        display: none;
    }

    .container {
        width: min(calc(100% - 32px), var(--container));
    }

    .article-meta {
        gap: 12px;
        font-size: 13px;
    }
}
