/* =========================================
   1. SETUP & VARIABLES
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&family=Inter:wght@400;500;700;800&display=swap');

:root {
    /* LIGHT MODE */
    --bg-body: #e2e8f0;       
    --bg-card: #ffffff;       
    
    --text-main: #0f172a;     /* Deep Navy */
    --text-muted: #475569;    /* Slate */
    
    --accent: #2563eb;        /* Royal Blue */
    --border: #cbd5e1;        /* Defined Grey Borders */
    
    /* TERMINAL */
    --term-bg: #1e293b;       
    --term-text: #f1f5f9;
    --term-accent: #38bdf8;
    --term-success: #4ade80;

    /* DIMENSIONS */
    --radius: 6px;            
    --border-width: 1px;      
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* DARK MODE */
body.dark-mode {
    --bg-body: #0f172a;       /* Slate 900 */
    --bg-card: #1e293b;       /* Slate 800 */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #60a5fa;
    --border: #334155;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
}

/* =========================================
   2. GLOBAL RESET & PERFORMANCE
   ========================================= */
* { box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    /* REMOVED TRANSITION: Instant snap fixes the "Lag/Low FPS" issue */
}

/* Tech Font */
code, pre, .sub-info, #demo-summary, input, select, button, .code-header {
    font-family: 'Fira Code', monospace;
    font-weight: 500;
}

h1, h2, h3 {
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-main);
    margin-bottom: 0.5em;
}

a { 
    color: var(--accent); 
    text-decoration: none; 
    font-weight: 600; 
}
a:hover { text-decoration: underline; }

.code-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
    width: 100%;
}

/* =========================================
   3. HEADER
   ========================================= */
header {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2.5rem;
    margin-bottom: 4rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

header > div {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    align-items: start;
}

header h1 { 
    font-size: 3rem; 
    line-height: 1.1; 
    margin: 0; 
    text-transform: uppercase;
}

header p { 
    font-family: 'Fira Code', monospace;
    color: var(--text-muted); 
    font-size: 1rem;
    margin-top: 0.5rem;
    font-weight: 600;
}

#theme-toggle {
    grid-column: 2;
    grid-row: 1;
    background: var(--bg-body);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-family: 'Fira Code', monospace;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    /* Removed transition for instant feel */
}

#theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}

nav { 
    display: flex; 
    gap: 1.5rem; 
    font-size: 1.75rem; 
    margin-top: 0.5rem;
}

@media (max-width: 640px) {
    header > div { grid-template-columns: 1fr; }
    header h1 { font-size: 2.25rem; }
    #theme-toggle {
        grid-column: 1;
        grid-row: 2;
        justify-self: start;
        margin-top: 0.5rem;
    }
}

/* =========================================
   4. SECTIONS & TITLES
   ========================================= */
section { margin-bottom: 5rem; }

section h2 {
    font-size: 1.5rem;
    text-transform: uppercase;
    background: transparent; 
    color: var(--text-main);
    padding: 0;
    margin-bottom: 1.5rem;
    border-bottom: 3px solid var(--accent);
    display: inline-block;
}

/* =========================================
   5. CARD GRIDS (Fixed Education Width)
   ========================================= */

/* MULTI-COLUMN GRIDS: Projects, History, Skills, References */
#projects, #employment-history, #skills .grid-container, #references .grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); 
    gap: 2rem;
}

/* SINGLE-COLUMN LAYOUT: Education & Summary 
   This ensures the card always fills 100% of the space. */
#education, #professional-summary {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Header Spanning for Grids */
#projects h2, #employment-history h2, #skills h2, #references h2 {
    grid-column: 1 / -1;
    width: 100%;
    margin-bottom: 1.5rem;
}

/* UNIFIED CARD STYLING */
article, 
.reference-item, 
#skills div,
#professional-summary p {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    height: 100%;
    width: 100%; /* Ensures expansion */
}

/* Blue Spine */
article::before, 
.reference-item::before, 
#skills div::before, 
#professional-summary p::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    background: var(--accent);
}

/* Hover Effects - Kept simple and performant */
article:hover, .reference-item:hover, #skills div:hover, #professional-summary p:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
    /* No shadow transition to keep it fast */
}

/* Card Typography */
article h3, .reference-item h3, #skills h3 {
    margin-top: 0;
    font-size: 1.25rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
}

.sub-info {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 1.25rem;
    display: block;
}

article ul, #skills ul {
    padding-left: 1.25rem;
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-muted);
}

article li, #skills li { margin-bottom: 0.5rem; }

/* References Specifics */
#references p { margin-bottom: 2rem; color: var(--text-muted); }
#references .reference-item p { margin: 0.5rem 0; color: var(--text-muted); }
#references .reference-item strong { color: var(--text-main); }

/* =========================================
   6. TERMINAL DEMO
   ========================================= */
#api-demo {
    background: var(--term-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    color: var(--term-text);
}

#api-demo h2 {
    color: var(--term-accent);
    border: none;
    margin-top: 0;
    font-family: 'Fira Code', monospace;
    text-transform: none;
    background: transparent;
    padding: 0;
}

#api-demo .sub-info {
    color: #cbd5e1;
    font-weight: 400;
    border-bottom: 1px solid #334155;
    padding-bottom: 1.5rem;
    margin-bottom: 2rem;
    text-transform: none;
    line-height: 1.7;
}

#api-demo .grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

#demo-text, #demo-mode {
    background: #0f172a;
    border: 1px solid #334155;
    color: #fff;
    padding: 1rem;
    border-radius: var(--radius);
    font-size: 1rem;
    width: 100%;
}

#demo-send {
    background: var(--term-accent);
    color: #0f172a;
    font-weight: 700;
    text-transform: uppercase;
    padding: 1rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    width: 100%;
}

#demo-send:hover { filter: brightness(1.1); }

.summary-panel--dark {
    background: #020617;
    border-left: 4px solid var(--term-success);
    color: var(--term-success);
    padding: 1rem;
    margin-top: 2rem;
    font-size: 0.9rem;
    
    /* FORCE WRAPPING FIX */
    white-space: pre-wrap;       /* Respects line breaks from your code */
    word-break: break-all;       /* Forces the long string to break at any character */
    overflow-wrap: anywhere;     /* The strongest wrapping property available */
    max-width: 100%;             /* Ensures it never exceeds the card width */
    overflow: hidden;            /* Emergency cutoff if all else fails */
    box-sizing: border-box;      /* Includes padding in width calculation */
}

@media (min-width: 640px) {
    #api-demo .grid {
        grid-template-columns: 1fr auto auto;
        align-items: end;
    }
    #demo-send { width: auto; }
}

/* =========================================
   7. SOURCE CODE
   ========================================= */
.code-window {
    margin-top: 2rem;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: var(--radius);
    width: 100%;
}

.code-header {
    background: #161b22;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid #30363d;
    font-size: 0.8rem;
    color: #8b949e;
    display: flex;
    justify-content: space-between;
}

.code-content {
    padding: 1rem;
    overflow-x: auto;
    max-height: 400px;
    font-size: 0.85rem;
    color: #e6edf3;
    font-family: 'Fira Code', monospace;
}
.code-content pre { margin: 0; }

/* =========================================
   8. FOOTER
   ========================================= */
footer {
    text-align: center;
    margin-top: 6rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}
