/* ==========================================
   THEME & VARIABLES
   ========================================== */
:root {
    --bg:           #0d1117;
    --bg-secondary: #161b22;
    --fg:           #c9d1d9;
    --muted:        #8b949e;
    --accent:       #58a6ff;
    --accent-dim:   #1f6feb33;
    --border:       #30363d;
    --success:      #3fb950;
    --error:        #f85149;
    --font-main:    'Inter', sans-serif;
    --font-code:    'JetBrains Mono', monospace;
}

[data-theme="light"] {
    --bg:           #ffffff;
    --bg-secondary: #f6f8fa;
    --fg:           #24292f;
    --muted:        #57606a;
    --accent:       #0969da;
    --accent-dim:   #ddf4ff;
    --border:       #d0d7de;
}

/* ==========================================
   BASE RESET
   ========================================== */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-main);
    background-color: var(--bg);
    color: var(--fg);
    line-height: 1.6;
    font-size: 16px;
    overflow-x: hidden;
}

/* ==========================================
   3-6-3 LAYOUT
   ========================================== */

/* Full-height row so all three columns stretch */
.layout-row {
    min-height: 100vh;
    align-items: stretch;
}

/* ── COL-3 LEFT: SIDEBAR ── */
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 32px 24px;
    flex-direction: column;
    scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

/* ── COL-6 MIDDLE: MAIN ── */
.main-content {
    padding: 48px 48px;
    max-width: 100%;
    border-right: 1px solid var(--border);
}

/* ── COL-3 RIGHT: LIVE PANEL ── */
.right-panel {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background-color: var(--bg-secondary);
    border-left: 1px solid var(--border);
    padding: 32px 20px;
    flex-direction: column;
    gap: 28px;
    scrollbar-width: none;
}
.right-panel::-webkit-scrollbar { display: none; }

/* ==========================================
   TYPOGRAPHY
   ========================================== */
h1, h2, h3, h4 { color: var(--fg); font-weight: 600; line-height: 1.3; }

h1 { font-size: 2.6rem; margin-bottom: 16px; font-weight: 800; }

h2 {
    font-size: 1.8rem;
    margin-top: 64px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

h3 { font-size: 1.2rem; margin-top: 32px; margin-bottom: 8px; color: var(--accent); }

p { color: var(--muted); margin-bottom: 16px; }

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

section { margin-bottom: 64px; }

/* ==========================================
   SIDEBAR ELEMENTS
   ========================================== */
.logo {
    font-family: var(--font-code);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--fg);
    margin-bottom: 32px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.logo-symbol { color: var(--accent); }

.nav-section { margin-bottom: 24px; }

.nav-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 8px;
    letter-spacing: 0.06em;
}

.nav-link {
    display: block;
    padding: 7px 12px;
    color: var(--fg);
    text-decoration: none;
    font-size: 0.92rem;
    border-radius: 6px;
    transition: all 0.18s ease;
    margin-bottom: 2px;
}
.nav-link:hover,
.nav-link.active {
    background-color: var(--accent-dim);
    color: var(--accent);
    text-decoration: none;
}
.nav-link.active { font-weight: 500; }

.sidebar-footer {
    margin-top: auto;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

/* ==========================================
   CODE BLOCKS
   ========================================== */
.code-block {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 24px;
    overflow: hidden;
}

.code-header {
    background-color: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 8px 16px;
    font-family: var(--font-code);
    font-size: 0.78rem;
    color: var(--muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

pre { padding: 16px; overflow-x: auto; margin: 0; }

code {
    font-family: var(--font-code);
    font-size: 0.875rem;
    color: var(--fg);
    line-height: 1.6;
}

.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--success);
    display: inline-block;
}

/* ==========================================
   UI ELEMENTS
   ========================================== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 100px;
    font-size: 0.78rem;
    color: var(--fg);
    margin-right: 6px;
    margin-bottom: 6px;
}

.badges-container { margin-bottom: 16px; }

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background-color: var(--accent);
    color: #ffffff !important;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    text-decoration: none !important;
    transition: opacity 0.18s;
}
.btn-primary:hover { opacity: 0.88; }

table { width: 100%; border-collapse: collapse; margin-bottom: 24px; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); }
th { font-weight: 600; font-size: 0.82rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
td { font-size: 0.93rem; }
tr:hover { background-color: var(--bg-secondary); }

hr.divider { border: 0; border-top: 1px solid var(--border); margin: 32px 0; }

.credential-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    background-color: var(--bg-secondary);
}

.cert-placeholder {
    background-color: var(--bg);
    border: 1px dashed var(--border);
    border-radius: 6px;
    padding: 32px;
    text-align: center;
    margin-top: 24px;
}

/* ==========================================
   INTERACTIVE CODE SNIPPETS
   ========================================== */
.run-btn {
    background-color: var(--accent-dim);
    color: var(--accent);
    border: 1px solid var(--accent);
    padding: 3px 10px;
    border-radius: 5px;
    font-size: 0.72rem;
    font-family: var(--font-main);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s;
}
.run-btn:hover { background-color: var(--accent); color: var(--bg); }

.run-output {
    background-color: #000;
    color: var(--success);
    border-top: 1px solid var(--border);
    padding: 16px;
    font-family: var(--font-code);
    font-size: 0.875rem;
    white-space: pre-wrap;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ==========================================
   CONTACT FORM: TERMINAL SHELL
   ========================================== */
.form-shell {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    margin-top: 24px;
}

.form-shell-header {
    background-color: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.shell-file-tab {
    font-family: var(--font-code);
    font-size: 0.75rem;
    color: var(--muted);
}

.shell-status {
    font-family: var(--font-code);
    font-size: 0.7rem;
    color: var(--success);
    letter-spacing: 0.04em;
}

#contact-form {
    padding: 24px 24px 20px;
    transition: opacity 0.35s ease;
}

.form-group { margin-bottom: 20px; }

.form-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-code);
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 6px;
}

.prompt-sym { color: var(--success); font-weight: 600; }

.form-group .form-input {
    width: 100%;
    padding: 10px 14px;
    background-color: var(--bg);
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--fg);
    font-family: var(--font-code);
    font-size: 0.875rem;
    transition: border-color 0.18s, box-shadow 0.18s;
    resize: vertical;
}

.form-group .form-input::placeholder { color: var(--muted); opacity: 0.55; }

.form-group .form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(88,166,255,0.1);
}

.form-group .form-input.error { border-color: var(--error); }

.error-text {
    font-family: var(--font-code);
    font-size: 0.75rem;
    color: var(--error);
    margin-top: 4px;
    display: none;
}
.error-text.visible { display: block; }

.char-counter {
    display: block;
    text-align: right;
    font-family: var(--font-code);
    font-size: 0.7rem;
    color: var(--muted);
    margin-top: 4px;
}
.char-counter.warn { color: #f0883e; }

.submit-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    font-family: var(--font-code);
    font-size: 0.82rem;
    padding: 9px 18px;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.18s, color 0.18s, transform 0.1s;
    margin-top: 4px;
}
.submit-btn:hover { background: var(--accent); color: var(--bg); }
.submit-btn:active { transform: scale(0.97); }

.submit-path { color: var(--muted); font-size: 0.75rem; }
.submit-btn:hover .submit-path { color: rgba(13,17,23,0.65); }
.submit-arrow { transition: transform 0.2s; }
.submit-btn:hover .submit-arrow { transform: translateX(3px); }

/* ==========================================
   TERMINAL SUCCESS STATE
   ========================================== */
.terminal-success {
    display: none;
    background: #090d12;
    padding: 28px 24px 24px;
    font-family: var(--font-code);
    font-size: 0.88rem;
}

.ts-line {
    opacity: 0;
    color: var(--fg);
    line-height: 2;
    animation: tsReveal 0.3s ease forwards;
}

.ts-d0 { animation-delay: 0.1s; }
.ts-d1 { animation-delay: 0.55s; }
.ts-d2 { animation-delay: 1.0s; }
.ts-d3 { animation-delay: 1.45s; }
.ts-d4 { animation-delay: 1.9s; }
.ts-d5 { animation-delay: 2.45s; }
.ts-d6 { animation-delay: 2.8s; }
.ts-d7 { animation-delay: 3.15s; }

@keyframes tsReveal {
    from { opacity: 0; transform: translateX(-8px); }
    to   { opacity: 1; transform: translateX(0); }
}

.ts-prompt      { color: var(--success); margin-right: 4px; }
.ts-dim         { color: var(--muted); }
.ts-ok          { color: var(--success); font-weight: 600; }
.ts-blue        { color: #79c0ff; }
.ts-success-line{ color: var(--success); font-weight: 600; }
.ts-dim-line    { color: var(--muted); font-size: 0.78rem; }

.ts-reset-btn {
    background: transparent;
    border: none;
    color: var(--accent);
    font-family: var(--font-code);
    font-size: 0.82rem;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.18s;
}
.ts-reset-btn:hover { color: var(--fg); }

/* ==========================================
   RIGHT PANEL
   ========================================== */
.rp-section { display: flex; flex-direction: column; gap: 12px; }

.rp-title {
    font-family: var(--font-code);
    font-size: 0.68rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.rp-item { display: flex; gap: 10px; align-items: flex-start; }

.rp-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-top: 5px;
    flex-shrink: 0;
}
.rp-dot-green  { background: var(--success); box-shadow: 0 0 6px rgba(63,185,80,0.5); }
.rp-dot-blue   { background: var(--accent);  box-shadow: 0 0 6px rgba(88,166,255,0.4); }
.rp-dot-yellow { background: #e3b341;        box-shadow: 0 0 6px rgba(227,179,65,0.4); }

.rp-label {
    font-size: 0.68rem;
    color: var(--muted);
    font-family: var(--font-code);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.rp-value {
    font-size: 0.8rem;
    color: var(--fg);
    font-family: var(--font-code);
    margin-top: 1px;
}

.rp-meta { font-size: 0.68rem; color: var(--muted); margin-top: 2px; }

.rp-tag-cloud { display: flex; flex-wrap: wrap; gap: 5px; }

.rp-tag {
    font-family: var(--font-code);
    font-size: 0.68rem;
    color: var(--accent);
    border: 1px solid rgba(88,166,255,0.25);
    background: rgba(88,166,255,0.07);
    border-radius: 4px;
    padding: 2px 7px;
}

.rp-avail {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-code);
    font-size: 0.8rem;
    color: var(--success);
}

.rp-avail-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--success);
    flex-shrink: 0;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(63,185,80,0.5); }
    50%       { box-shadow: 0 0 0 5px rgba(63,185,80,0); }
}

.rp-avail-detail { font-family: var(--font-code); font-size: 0.72rem; color: var(--muted); }

.rp-link {
    display: block;
    font-family: var(--font-code);
    font-size: 0.75rem;
    color: var(--accent);
    text-decoration: none;
    padding: 5px 0;
    border-bottom: 1px solid var(--border);
    transition: color 0.18s;
}
.rp-link:hover { color: var(--fg); text-decoration: none; }

/* ==========================================
   MOBILE HEADER
   ========================================== */
.mobile-header {
    position: sticky;
    top: 0;
    background-color: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
}
.mobile-logo { font-weight: 700; font-size: 1.1rem; }

/* ==========================================
   BACK TO TOP
   ========================================== */
.back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 40px; height: 40px;
    background-color: var(--accent);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    z-index: 999;
}
.back-to-top.visible { opacity: 1; pointer-events: auto; }

/* ==========================================
   FOOTER
   ========================================== */
footer {
    padding: 32px 0 16px;
    border-top: 1px solid var(--border);
    margin-top: 32px;
}
footer p { font-size: 0.85rem; color: var(--muted); }

/* ==========================================
   SCROLLBAR
   ========================================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ==========================================
   RESPONSIVE — MOBILE
   ========================================== */
@media (max-width: 991px) {
    .main-content { padding: 24px 20px; border-right: none; }
    h1 { font-size: 2rem; }
    h2 { font-size: 1.5rem; margin-top: 48px; }
    pre { font-size: 0.8rem; white-space: pre-wrap; }
    table { display: block; overflow-x: auto; white-space: nowrap; }
}

/* ── GitHub live commits extras ── */
.rp-dot-dim {
    background: var(--border);
    box-shadow: none;
}

.rp-commit-extra {
    opacity: 0.75;
    transition: opacity 0.2s;
}

.rp-commit-extra:hover { opacity: 1; }

.rp-commit-msg-small {
    font-size: 0.74rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

/* ── Profile avatar ── */
.profile-placeholder {
    display: flex;
    justify-content: center;
    padding: 16px 0 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.avatar-img {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    border: 2px solid var(--border);
    transition: border-color 0.2s;
    object-fit: cover;
}

.avatar-img:hover { border-color: var(--accent); }

/* ==========================================
   PROJECTS GRID
   ========================================== */

.projects-grid {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding-bottom: 16px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    cursor: grab;
}

.projects-grid:active { cursor: grabbing; }

.projects-grid::-webkit-scrollbar {
    height: 4px;
}

.projects-grid::-webkit-scrollbar-track {
    background: var(--bg);
}

.projects-grid::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.project-card-grid {
    flex: 0 0 calc(50% - 10px);
    scroll-snap-align: start;
    min-width: 320px;
}

/* When 3+ projects exist each becomes ~33% */
.projects-grid:has(.project-card-grid:nth-child(3)) .project-card-grid {
    flex: 0 0 calc(33.333% - 14px);
}

.project-inner {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: border-color 0.2s;
}

.project-inner:hover { border-color: var(--accent); }

.project-header h3 {
    margin-top: 0;
    margin-bottom: 8px;
}

.project-preview {
    width: 100%;
    border-radius: 6px;
    border: 1px solid var(--border);
    display: block;
    object-fit: cover;
    height: 180px;
}

.project-footer {
    display: flex;
    gap: 8px;
    margin-top: auto;
    padding-top: 8px;
}

.project-btn {
    flex: 1;
    text-align: center;
    justify-content: center;
    font-size: 0.82rem;
    padding: 8px 12px;
    margin-bottom: 0 !important;
}

.btn-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--fg);
    border-radius: 6px;
    font-size: 0.82rem;
    text-decoration: none;
    transition: border-color 0.18s, color 0.18s;
}

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
    text-decoration: none;
}

@media (max-width: 768px) {
    .project-card-grid {
        flex: 0 0 85vw;
    }
}
