/* ============================================
   SAMEER AHMED — Portfolio
   "System Monitor" Dark Theme
   Inter + JetBrains Mono
   ============================================ */

/* --- 1. CSS VARIABLES --- */
:root {
    --bg:         #0d1117;
    --bg-surface: #161b22;
    --bg-raised:  #1c2128;
    --text:       #c9d1d9;
    --text-bright:#e6edf3;
    --text-dim:   #484f58;
    --accent:     #58a6ff;
    --green:      #3fb950;
    --purple:     #bc8cff;
    --red:        #ff7b72;
    --cyan:       #79c0ff;
    --orange:     #d29922;
    --yellow:     #e3b341;
    --border:     #21262d;
    --border-hl:  #30363d;
    --font-body:  'Inter', system-ui, -apple-system, sans-serif;
    --font-mono:  'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;
    --max-w:      820px;
}

/* Light Mode Support (respects system preference) */
@media (prefers-color-scheme: light) {
    :root {
        --bg:         #ffffff;
        --bg-surface: #f6f8fa;
        --bg-raised:  #ffffff;
        --text:       #24292f;
        --text-bright:#1f2328;
        --text-dim:   #656d76;
        --accent:     #0969da;
        --green:      #1a7f37;
        --purple:     #8250df;
        --red:        #cf222e;
        --cyan:       #0969da;
        --orange:     #bc4c00;
        --yellow:     #bf8700;
        --border:     #d0d7de;
        --border-hl:  #afb8c1;
    }
    
    .noscript {
        background: #cf222e !important;
        color: #ffffff !important;
    }
}

/* --- 2. RESET --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

::selection {
    background: rgba(88, 166, 255, 0.25);
    color: var(--text-bright);
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    scroll-padding-top: 2rem; /* Offset for anchor links */
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.7;
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 3rem 2rem;
    text-align: left;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation; /* Prevent double-tap zoom on mobile */
}

/* --- 3. SCROLLBAR --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hl); }

/* --- 4. TYPOGRAPHY --- */
a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.15s;
}
a:hover { color: var(--text-bright); }

h1 {
    font-family: var(--font-mono);
    color: var(--text-bright);
    font-size: 2.6rem;
    font-weight: 700;
    letter-spacing: -1.5px;
    line-height: 1.1;
    margin-bottom: 0.4rem;
}

h2 {
    font-family: var(--font-mono);
    color: var(--purple);
    font-size: 1rem;
    font-weight: 600;
    margin-top: 4rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--border);
    text-transform: lowercase;
    letter-spacing: 0.5px;
}
h2::before {
    content: "~/";
    opacity: 0.35;
    margin-right: 6px;
    font-weight: 400;
}

h3 {
    font-family: var(--font-mono);
    color: var(--text-bright);
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.15rem;
}

section {
    width: 100%;
}

strong { color: var(--text-bright); font-weight: 600; }
code {
    font-family: var(--font-mono);
    color: var(--cyan);
    font-size: 0.9em;
}

/* --- 5. HEADER / HERO --- */
header {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
}

.hero-badge {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--green);
    background: rgba(63, 185, 80, 0.1);
    border: 1px solid rgba(63, 185, 80, 0.25);
    padding: 3px 12px;
    border-radius: 4px;
    margin-bottom: 1rem;
    letter-spacing: 0.5px;
}

.tagline {
    font-size: 1.05rem;
    color: var(--text);
    margin-bottom: 1.5rem;
    max-width: 560px;
    line-height: 1.6;
}

.meta-block {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1.8rem;
    color: var(--text-dim);
    align-items: flex-start;
}
.meta-block span {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}

.copy-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s;
    margin-left: 4px;
}

.copy-btn:hover {
    background: var(--bg-raised);
    border-color: var(--border-hl);
    color: var(--accent);
}

.copy-btn:active {
    transform: scale(0.95);
}
.meta-key {
    display: inline-block;
    min-width: 38px;
    color: var(--purple);
    font-weight: 500;
}
.meta-block a {
    color: var(--accent);
    font-size: 0.8rem;
}

.hero-actions {
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
    align-items: flex-start;
}

.btn {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 8px 18px;
    border-radius: 6px;
    border: 1px solid transparent;
    transition: all 0.15s;
    display: inline-block;
}
.btn-primary {
    color: #fff;
    background: rgba(63, 185, 80, 0.15);
    border-color: rgba(63, 185, 80, 0.35);
}
.btn-primary:hover {
    background: rgba(63, 185, 80, 0.25);
    border-color: var(--green);
    color: #fff;
}
.btn-secondary {
    color: var(--text);
    background: var(--bg-surface);
    border-color: var(--border);
}
.btn-secondary:hover {
    border-color: var(--border-hl);
    color: var(--text-bright);
}

/* --- 6. CASE STUDY CARDS --- */
.case-study {
    border: 1px solid var(--border);
    background: var(--bg-surface);
    border-radius: 8px;
    padding: 1.8rem;
    margin-bottom: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    content-visibility: auto; /* Performance: render only visible cards */
    contain-intrinsic-size: auto 600px; /* Estimate height for layout stability */
}
.case-study:hover {
    border-color: var(--border-hl);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
}

.case-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.5rem;
}

.role-badge {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--accent);
    background: rgba(121, 192, 255, 0.08);
    padding: 0.25rem 0.65rem;
    border-radius: 4px;
    border: 1px solid rgba(121, 192, 255, 0.2);
    font-weight: 500;
    letter-spacing: 0.02em;
}

.source-link {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-dim) !important;
    transition: color 0.15s;
    white-space: nowrap;
}
.source-link:hover { color: var(--accent) !important; }

.tag-row {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-bottom: 0.4rem;
}

.tag {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 3px;
    background: rgba(88, 166, 255, 0.08);
    color: var(--accent);
    border: 1px solid rgba(88, 166, 255, 0.15);
}

.highlights {
    list-style: none;
    padding: 0;
    margin-top: 0.2rem;
}
.highlights li {
    position: relative;
    padding-left: 1.3rem;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    line-height: 1.65;
    color: var(--text);
}
.highlights li::before {
    content: "▸";
    position: absolute;
    left: 0;
    color: var(--green);
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

/* --- 7. ARCHITECTURE DIAGRAMS (SVG IMAGES) --- */
.arch-diagram {
    width: 100%;
    height: auto;
    max-width: 100%;
    border-radius: 0;
    margin-bottom: 1rem;
    display: block;
    border: none;
    background: transparent;
}

section > .arch-diagram {
    margin-top: 0;
}

/* Text Content Blocks */
.text-content {
    margin-bottom: 1.5rem;
    color: var(--text);
}

.text-content h3 {
    color: var(--text-bright);
    font-size: 1.1rem;
    margin-bottom: 0.3rem;
}

.text-content h4 {
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 1rem;
    margin-bottom: 0.3rem;
}

.text-content p {
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 0.5rem;
}

.meta-text {
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 0.8rem !important;
}

.skill-group {
    margin-bottom: 0.8rem;
}

/* Terminal Hint */
.terminal-hint {
    color: var(--text-dim);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    font-style: italic;
}

.terminal-hint code {
    background: var(--bg-surface);
    color: var(--accent);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-style: normal;
}

/* --- 8. (Experience section is now SVG — no text CSS needed) --- */

/* --- 9. (Skills section is now SVG — no text CSS needed) --- */

/* --- 10. (Education section is now SVG — no text CSS needed) --- */

/* --- 11. TERMINAL --- */
.terminal-container {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #010409;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.terminal-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--bg-raised);
    border-bottom: 1px solid var(--border);
}

.terminal-dots { display: flex; gap: 6px; }

.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot.red    { background: #ff5f56; }
.dot.yellow { background: #ffbd2e; }
.dot.green  { background: #27c93f; }

.terminal-title {
    font-family: var(--font-mono);
    color: var(--text-dim);
    font-size: 0.72rem;
    margin-left: 8px;
}

.terminal-window {
    min-height: 100px;
    max-height: 320px;
    overflow-y: auto;
    padding: 1rem 1.2rem;
    cursor: text;
}

.output-line {
    font-family: var(--font-mono);
    margin-bottom: 4px;
    white-space: pre-wrap;
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--text);
}

.input-line {
    font-family: var(--font-mono);
    display: flex;
    align-items: center;
    padding: 0.5rem 1.2rem 1rem;
    font-size: 0.82rem;
}

.prompt-user  { color: var(--green); font-weight: 600; }
.prompt-separator { color: var(--text-dim); margin: 0 1px; }
.prompt-path  { color: var(--accent); }
.prompt-dollar { color: var(--text-dim); margin: 0 8px 0 4px; }

#terminal-input {
    background: transparent;
    border: none;
    color: var(--text-bright);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    flex-grow: 1;
    outline: none;
    caret-color: var(--purple);
    max-width: 100%;
    width: 100%;
}

/* --- 12. FOOTER --- */
footer {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-dim);
}
.footer-sub {
    margin-top: 0.3rem;
    opacity: 0.5;
}

/* --- 13. RESPONSIVE (MOBILE-FIRST) --- */
@media (max-width: 640px) {
    body {
        padding: 1.5rem 1rem;
        font-size: 14px;
    }
    h1 { font-size: 1.9rem; }
    .case-header {
        flex-direction: column;
        gap: 0.25rem;
    }
    .hero-actions {
        flex-direction: column;
    }
    .btn { text-align: center; }
    .meta-block { font-size: 0.75rem; }
    
    /* Terminal Mobile Fixes */
    .terminal-window {
        max-height: 240px;
        padding: 0.8rem;
        font-size: 0.75rem;
    }
    
    .output-line {
        font-size: 0.75rem;
        word-break: break-word;
    }
    
    .input-line {
        padding: 0.5rem 0.8rem 0.8rem;
        font-size: 0.75rem;
        flex-wrap: wrap;
    }
    
    .prompt-user,
    .prompt-separator,
    .prompt-path,
    .prompt-dollar {
        font-size: 0.75rem;
    }
    
    #terminal-input {
        font-size: 0.75rem;
        min-width: 0;
        width: 100%;
    }
    
    .terminal-header {
        padding: 8px 10px;
    }
    
    .terminal-title {
        font-size: 0.65rem;
    }
    
    #back-to-top {
        bottom: 1rem;
        right: 1rem;
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
    }
}

@media (max-width: 400px) {
    h1 { font-size: 1.6rem; }
    .case-study {
        padding: 1.2rem;
    }
    
    /* Extra small screens - terminal adjustments */
    .terminal-window {
        padding: 0.6rem;
        font-size: 0.7rem;
    }
    
    .output-line,
    .input-line,
    #terminal-input {
        font-size: 0.7rem;
    }
}

/* === ACCESSIBILITY ENHANCEMENTS === */

/* Skip Navigation Link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--bg-raised);
    color: var(--accent);
    padding: 8px 16px;
    text-decoration: none;
    z-index: 100;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 500;
}
.skip-link:focus {
    top: 10px;
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
}

/* Keyboard Focus Indicators */
a:focus-visible, 
button:focus-visible, 
input:focus-visible,
.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Touch Target Size (Mobile) */
@media (max-width: 768px) {
    .btn, .source-link {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    .terminal-dots .dot {
        width: 16px;
        height: 16px;
    }
}

/* Reduced Motion Preference */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* External Link Indicators */
a[target="_blank"]::after {
    content: " ↗";
    font-size: 0.75em;
    opacity: 0.5;
    display: inline-block;
    margin-left: 2px;
}

.source-link::after,
a[href^="mailto"]::after {
    content: "";
    margin-left: 0;
}

/* Back to Top Button */
#back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    color: var(--accent);
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, transform 0.2s, background 0.2s;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

#back-to-top:hover {
    background: var(--bg-surface);
    border-color: var(--accent);
    transform: translateY(-2px);
}

#back-to-top:active {
    transform: translateY(0);
}

#back-to-top.show {
    opacity: 1;
    visibility: visible;
}

/* Offline Banner */
.offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--red);
    color: #fff;
    padding: 0.75rem;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.offline-banner.show {
    transform: translateY(0);
}

@supports (backdrop-filter: blur(10px)) {
    #back-to-top {
        background: rgba(22, 27, 34, 0.8);
        backdrop-filter: blur(10px);
    }
}

@media (prefers-color-scheme: light) {
    #back-to-top {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }
    
    @supports (backdrop-filter: blur(10px)) {
        #back-to-top {
            background: rgba(255, 255, 255, 0.9);
        }
    }
}

/* === PRINT STYLES === */
@media print {
    @page {
        margin: 1.5cm;
    }
    
    body {
        background: white;
        color: black;
        font-size: 11pt;
        line-height: 1.5;
        padding: 0;
    }
    
    /* Hide interactive/non-essential elements */
    .terminal-container,
    .terminal-hint,
    .skip-link,
    .hero-actions,
    footer,
    .source-link {
        display: none !important;
    }
    
    /* Optimize for print */
    h1 { font-size: 24pt; color: black; page-break-after: avoid; }
    h2 { font-size: 14pt; color: black; page-break-after: avoid; margin-top: 1.5em; }
    h3 { font-size: 12pt; color: black; page-break-after: avoid; }
    
    .case-study {
        page-break-inside: avoid;
        border: 1px solid #333;
        padding: 1em;
        margin-bottom: 1em;
    }
    
    .arch-diagram {
        max-height: 200px;
        page-break-inside: avoid;
    }
    
    a {
        color: black;
        text-decoration: underline;
    }
    
    /* Show URLs after links */
    .meta-block a[href^="http"]:after,
    header a[href^="mailto"]:after {
        content: " (" attr(href) ")";
        font-size: 9pt;
        color: #666;
    }
    
    .tag {
        border: 1px solid #666;
        color: black;
        background: white;
    }
    
    /* Ensure good contrast */
    .hero-badge,
    .role-badge,
    .meta-key {
        color: black;
        border: 1px solid black;
    }
}
