/* ============ Theme tokens ============ */
:root {
    --bg: #f7f8fb;
    --bg-alt: #ffffff;
    --surface: #ffffff;
    --border: #e4e7ef;
    --text: #141a2a;
    --muted: #5d6578;
    --accent: #2f6bff;
    --accent-2: #7b5cff;
    --accent-soft: rgba(47, 107, 255, .1);
    --danger: #d93a3a;
    --ok: #1f9d55;
    --hero-bg: radial-gradient(1200px 500px at 85% -10%, rgba(123, 92, 255, .18), transparent 60%),
               radial-gradient(900px 500px at -10% 20%, rgba(47, 107, 255, .14), transparent 60%);
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
    --radius: 14px;
    --code-bg: #0f1424;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b0f1a;
        --bg-alt: #0f1422;
        --surface: #121829;
        --border: #222a3f;
        --text: #e8ebf3;
        --muted: #9aa3b8;
        --accent: #5b8cff;
        --accent-2: #9a82ff;
        --accent-soft: rgba(91, 140, 255, .14);
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
        --code-bg: #0a0e19;
        color-scheme: dark;
    }
}

/* ============ Base ============ */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
    margin: 0;
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -.02em; }
h1:focus { outline: none; }
p { margin: 0 0 1rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 640px) { .container { padding: 0 24px; } }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; }
.icon { flex-shrink: 0; vertical-align: -3px; }

/* ============ Buttons ============ */
.btn {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .7rem 1.25rem;
    font: inherit; font-weight: 600; font-size: .95rem;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border: 0; border-radius: 10px;
    cursor: pointer;
    text-decoration: none !important;
    transition: transform .15s ease, box-shadow .15s ease, opacity .15s;
    box-shadow: 0 6px 18px rgba(47, 107, 255, .25);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(47, 107, 255, .3); }
.btn-sm { padding: .4rem .8rem; font-size: .85rem; border-radius: 8px; box-shadow: none; }
.btn-ghost {
    color: var(--text); background: transparent;
    border: 1px solid var(--border); box-shadow: none;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); box-shadow: none; }
.btn-ghost.danger:hover { border-color: var(--danger); color: var(--danger); }
.btn-danger { background: var(--danger); box-shadow: none; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; }
.link-btn:hover { color: var(--danger); }

/* ============ Header ============ */
.site-header {
    position: sticky; top: 0; z-index: 50;
    background: color-mix(in srgb, var(--bg) 80%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
}
.nav { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { font-weight: 800; font-size: 1.35rem; color: var(--text); letter-spacing: -.03em; text-decoration: none !important; }
.brand span { color: var(--accent); }
.brand small { font-size: .75rem; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.nav-links { display: flex; align-items: center; gap: 1.5rem; }
.nav-links a:not(.btn) { color: var(--muted); font-weight: 500; font-size: .95rem; }
.nav-links a:not(.btn):hover { color: var(--text); text-decoration: none; }
.nav-toggle, .nav-burger { display: none; }

@media (max-width: 760px) {
    .nav-burger {
        display: flex; align-items: center; justify-content: center;
        width: 40px; height: 40px; cursor: pointer;
    }
    .nav-burger span, .nav-burger span::before, .nav-burger span::after {
        content: ""; display: block; width: 20px; height: 2px; background: var(--text); position: relative;
    }
    .nav-burger span::before { position: absolute; top: -6px; }
    .nav-burger span::after { position: absolute; top: 6px; }
    .nav-links {
        display: none; position: absolute; top: 64px; left: 0; right: 0;
        flex-direction: column; align-items: stretch; gap: 0;
        background: var(--bg-alt); border-bottom: 1px solid var(--border); padding: .5rem 16px 1rem;
    }
    .nav-links a { padding: .6rem 0; }
    .nav-links .btn { justify-content: center; margin-top: .5rem; }
    .nav-toggle:checked ~ .nav-links { display: flex; }
}

/* ============ Hero ============ */
.hero { background: var(--hero-bg); padding: 72px 0 48px; overflow: hidden; }
.hero-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 48px; align-items: center; }
.hero h1 { font-size: clamp(2.1rem, 5vw, 3.4rem); font-weight: 800; margin-bottom: 1rem; }
.accent {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lead { font-size: 1.15rem; color: var(--muted); max-width: 36rem; }
.pill {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .3rem .8rem; margin-bottom: 1.25rem;
    font-size: .85rem; font-weight: 500;
    border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px rgba(31, 157, 85, .2); }
.hero-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1.75rem 0; }
.socials { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; }
.socials a, .socials span { display: inline-flex; align-items: center; gap: .4rem; color: var(--muted); font-size: .92rem; }
.socials a:hover { color: var(--accent); text-decoration: none; }

.hero-visual { position: relative; display: flex; justify-content: flex-end; padding-right: 24px; }
.avatar {
    width: 260px; height: 260px; border-radius: 28px; object-fit: cover;
    box-shadow: var(--shadow); border: 1px solid var(--border);
}
.avatar-initials {
    display: grid; place-items: center;
    font-size: 5.5rem; font-weight: 800; color: #fff; letter-spacing: -.04em;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border: 0;
}
.code-card {
    position: absolute; bottom: -56px; left: -24px;
    background: var(--code-bg); color: #cdd6f4;
    border-radius: 12px; padding: .75rem 1rem 1rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, .25);
    font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .78rem;
    border: 1px solid rgba(255, 255, 255, .06);
}
.code-card pre { margin: 0; font: inherit; line-height: 1.55; }
.code-dots { display: flex; gap: 6px; margin-bottom: .5rem; }
.code-dots i { width: 9px; height: 9px; border-radius: 50%; background: #ff5f57; }
.code-dots i:nth-child(2) { background: #febc2e; }
.code-dots i:nth-child(3) { background: #28c840; }
.code-card .k { color: #c792ea; }
.code-card .t { color: #82aaff; }
.code-card .s { color: #c3e88d; }
.code-card .n { color: #f78c6c; }

@media (max-width: 860px) {
    .hero { padding-top: 48px; }
    .hero-grid { grid-template-columns: 1fr; }
    .hero-visual { justify-content: flex-start; margin-bottom: 32px; }
    .avatar { width: 180px; height: 180px; }
    .avatar-initials { font-size: 4rem; }
    .hero-visual { padding-right: 0; }
    .code-card { left: 150px; bottom: -20px; }
}
@media (max-width: 520px) { .code-card { display: none; } }

/* ============ Stats ============ */
.stats {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
    margin-top: 32px;
}
.stat {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.25rem; box-shadow: var(--shadow);
}
.stat strong { display: block; font-size: 1.9rem; font-weight: 800; letter-spacing: -.03em; }
.stat span { color: var(--muted); font-size: .9rem; }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2, 1fr); } }

/* ============ Sections ============ */
.section { padding: 80px 16px 0; }
@media (min-width: 640px) { .section { padding: 96px 24px 0; } }
.section-head { margin-bottom: 2rem; }
.section-head h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); font-weight: 800; }
.eyebrow {
    display: inline-block; margin-bottom: .5rem;
    font-family: "JetBrains Mono", monospace; font-size: .8rem; color: var(--accent);
    text-transform: uppercase; letter-spacing: .08em;
}
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.5rem; box-shadow: var(--shadow);
}
.card h3 { font-size: 1.1rem; }
.card-title { display: flex; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.card-title .icon { color: var(--accent); }

.about { max-width: 52rem; font-size: 1.08rem; color: var(--muted); }

/* Tags */
.tags { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.tags li {
    padding: .3rem .7rem; font-size: .85rem; font-weight: 500;
    color: var(--accent); background: var(--accent-soft); border-radius: 8px;
}
.tags-sm li { font-size: .78rem; padding: .2rem .55rem; }
.badge {
    display: inline-block; margin-left: .4rem; padding: .05rem .5rem;
    font-size: .75rem; border: 1px solid var(--border); border-radius: 999px;
}

.skills-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.skill-card h3 { margin-bottom: .9rem; }

/* Timeline */
/* Layout: [date column] [gap with rail + dot in the middle] [card] */
.timeline {
    --meta: 170px;
    --gap: 64px;
    --rail: calc(var(--meta) + var(--gap) / 2);
    --dot: 16px;
    --dot-top: 30px;
    list-style: none; padding: 0; margin: 0; position: relative;
}
.timeline::before {
    content: ""; position: absolute; top: var(--dot-top); bottom: 0;
    left: calc(var(--rail) - 1px); width: 2px;
    background: linear-gradient(to bottom, var(--accent), var(--border) 220px);
}
.timeline-item {
    display: grid; grid-template-columns: var(--meta) 1fr; column-gap: var(--gap);
    position: relative; padding-bottom: 28px;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
    content: ""; position: absolute; top: var(--dot-top);
    left: calc(var(--rail) - var(--dot) / 2);
    width: var(--dot); height: var(--dot); box-sizing: border-box; border-radius: 50%;
    background: var(--bg); border: 3px solid var(--accent); z-index: 1;
}
.timeline-item.current::before { background: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); }
.timeline-meta {
    display: flex; flex-direction: column; align-items: flex-end; gap: .3rem;
    text-align: right; padding-top: calc(var(--dot-top) - 6px);
}
.timeline-meta .date { font-weight: 600; font-size: .9rem; line-height: 1.4; }
.duration {
    font-size: .75rem; color: var(--muted);
    padding: .1rem .55rem; border: 1px solid var(--border); border-radius: 999px;
}
.timeline-card { padding: 1.5rem 1.75rem; }
.timeline-head {
    display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem 1.5rem;
    flex-wrap: wrap; padding-bottom: 1rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border);
}
.timeline-card h3 { font-size: 1.15rem; margin: 0 0 .15rem; }
.company { color: var(--accent); font-weight: 600; font-size: .95rem; }
.timeline-where { display: flex; align-items: center; gap: .6rem; color: var(--muted); font-size: .85rem; padding-top: .2rem; }
.timeline-where > span:first-child { display: inline-flex; align-items: center; gap: .3rem; }
.timeline-where .icon { width: 15px; height: 15px; }
.timeline-where .badge { margin: 0; }
.timeline-card .tags { margin-top: 1.1rem; }
.timeline-card .timeline-head + .tags { margin-top: 0; }
.highlights { list-style: none; margin: 0; padding: 0; color: var(--muted); display: grid; gap: .55rem; }
.highlights li { position: relative; padding-left: 1.25rem; line-height: 1.55; }
.highlights li::before {
    content: ""; position: absolute; left: 0; top: .62em;
    width: 7px; height: 7px; border-radius: 2px; background: var(--accent); opacity: .8;
}
@media (max-width: 760px) {
    .timeline { --rail: 7px; --dot-top: 4px; }
    .timeline-item { grid-template-columns: 1fr; row-gap: .75rem; padding-left: 32px; padding-bottom: 24px; }
    .timeline-meta { flex-direction: row; flex-wrap: wrap; align-items: center; gap: .6rem; text-align: left; padding-top: 0; }
    .timeline-card { padding: 1.25rem; }
}

/* Education */
.edu-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.edu-item { display: flex; flex-direction: column; margin-bottom: 1rem; }
.edu-item:last-child { margin-bottom: 0; }
.lang { margin-bottom: 1rem; }
.lang-row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.bar { height: 8px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; margin-top: .4rem; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: inherit; }
@media (max-width: 860px) { .edu-grid { grid-template-columns: 1fr; } }

/* Contact */
.contact-grid { display: grid; grid-template-columns: 1fr 1.3fr; gap: 32px; align-items: start; }
.contact-info p { color: var(--muted); font-size: 1.05rem; }
.contact-list { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: .9rem; }
.contact-list li { display: flex; align-items: center; gap: .75rem; }
.contact-list .icon { color: var(--accent); }
.contact-success h3 { color: var(--ok); }
@media (max-width: 860px) { .contact-grid { grid-template-columns: 1fr; } }

/* ============ Forms ============ */
label { display: flex; flex-direction: column; gap: .35rem; font-weight: 500; font-size: .9rem; margin-bottom: 1rem; }
label.check { flex-direction: row; align-items: center; gap: .5rem; }
.label { display: block; font-weight: 500; font-size: .9rem; margin-bottom: .5rem; }
.hint { font-weight: 400; color: var(--muted); font-size: .8rem; }
input:not([type=checkbox]):not([type=file]), textarea, select {
    width: 100%; padding: .65rem .8rem;
    font: inherit; font-weight: 400; color: var(--text);
    background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 640px) { .field-row { grid-template-columns: 1fr; } }
.invalid { border-color: var(--danger) !important; }
.validation-message { color: var(--danger); font-size: .82rem; font-weight: 400; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.form-actions { display: flex; gap: .75rem; margin-top: .5rem; }

.alert { padding: .75rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-size: .92rem; }
.alert-ok { background: rgba(31, 157, 85, .12); color: var(--ok); }
.alert-error { background: rgba(217, 58, 58, .12); color: var(--danger); }

/* ============ Footer ============ */
.site-footer { margin-top: 96px; padding: 28px 0; border-top: 1px solid var(--border); font-size: .9rem; }
.site-footer .container { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; }

/* ============ Admin ============ */
.admin { display: flex; min-height: 100vh; }
.admin-side {
    width: 240px; flex-shrink: 0; padding: 1.5rem 1rem;
    background: var(--bg-alt); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 1.5rem;
    position: sticky; top: 0; height: 100vh;
}
.admin-side nav { display: flex; flex-direction: column; gap: 2px; }
.admin-side nav a { padding: .55rem .75rem; border-radius: 8px; color: var(--muted); font-weight: 500; font-size: .93rem; }
.admin-side nav a:hover { background: var(--accent-soft); color: var(--text); text-decoration: none; }
.admin-side nav a.active { background: var(--accent-soft); color: var(--accent); }
.admin-side-foot { margin-top: auto; display: flex; flex-direction: column; gap: .75rem; font-size: .88rem; }
.admin-main { flex: 1; min-width: 0; padding: 2rem; max-width: 1100px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.admin-head h1 { font-size: 1.7rem; margin: 0; }
.admin-sub { font-size: 1.15rem; margin: 2rem 0 1rem; }
.form { margin-bottom: 1.5rem; }
.form h2 { font-size: 1.15rem; margin-bottom: 1.25rem; }
.uploads > div { display: flex; flex-direction: column; gap: .5rem; align-items: flex-start; margin-bottom: 1rem; }
.thumb { width: 96px; height: 96px; object-fit: cover; border-radius: 12px; border: 1px solid var(--border); }

.card:has(> .table) { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: .8rem 1rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.table tr:last-child td { border-bottom: 0; }
.table tr.unread td { font-weight: 600; }
.actions { display: flex; gap: .4rem; justify-content: flex-end; white-space: nowrap; }
.confirm { display: inline-flex; gap: .4rem; }

.dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; }
.dash-card { color: var(--text); text-decoration: none !important; transition: border-color .15s; }
.dash-card:hover { border-color: var(--accent); }
.dash-card strong { display: block; font-size: 2rem; font-weight: 800; }
.dash-card span { color: var(--muted); font-size: .9rem; }

.messages { display: grid; gap: 16px; }
.message header { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.message h3 { font-size: 1rem; }
.message.unread { border-left: 4px solid var(--accent); }

.login-wrap { min-height: 100vh; width: 100%; display: grid; place-items: center; padding: 16px; background: var(--hero-bg); }
.admin-main:has(.login-wrap) { padding: 0; max-width: none; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { font-size: 1.5rem; margin-top: 1rem; }
.login-card .btn { width: 100%; justify-content: center; }

@media (max-width: 760px) {
    .admin { flex-direction: column; }
    .admin-side { width: 100%; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--border); gap: 1rem; }
    .admin-side nav { flex-direction: row; flex-wrap: wrap; }
    .admin-side-foot { flex-direction: row; justify-content: space-between; }
    .admin-main { padding: 1.25rem 16px; }
}

/* ============ Blazor defaults ============ */
#blazor-error-ui {
    background: lightyellow; color: #222;
    bottom: 0; left: 0; width: 100%; position: fixed; z-index: 1000;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, .2);
    display: none; padding: .6rem 1.25rem .7rem;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; }
.blazor-error-boundary::after { content: "An error has occurred."; }

/* ============ Privacy policy (standalone page) ============ */
.policy { max-width: 760px; margin: 0 auto; padding: 32px 16px 64px; display: grid; gap: 24px; }
.policy-switch { display: flex; justify-content: center; gap: .5rem; }
.policy-switch a {
    padding: .35rem .9rem; border: 1px solid var(--border); border-radius: 999px;
    color: var(--muted); font-size: .9rem; text-decoration: none;
}
.policy-switch a:hover { color: var(--accent); border-color: var(--accent); }
.policy-doc { padding: 2rem; }
.policy-doc h1 { font-size: 1.8rem; font-weight: 800; margin-bottom: .25rem; }
.policy-doc h2 { font-size: 1.1rem; margin: 1.75rem 0 .5rem; color: var(--accent); }
.policy-doc p { color: var(--muted); }
.policy-doc p:last-child { margin-bottom: 0; }
.policy-meta { font-size: .9rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.policy-doc[dir=rtl] { font-family: "IBM Plex Sans Arabic", "Inter", system-ui, sans-serif; line-height: 1.9; }
.policy-doc[dir=rtl] h1, .policy-doc[dir=rtl] h2 { letter-spacing: 0; }
@media (max-width: 640px) { .policy-doc { padding: 1.4rem; } }
