/* ══════════════════════════════════════════════
   ✦ CV — Lục Trung Hiếu ✦
   Cửa sổ nổi bật/tắt + kéo qua lại · Fluent (Win 11)
   Nền động dễ thương-ngầu: blob mờ, lưới, tinh tú
   ══════════════════════════════════════════════ */

/* ---------- Palette: SÁNG ---------- */
:root {
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI Variable', 'Segoe UI', Roboto, 'Noto Sans', sans-serif;
    --mono: 'Cascadia Code', 'Consolas', ui-monospace, monospace;

    --bg: #eef0f3;
    --blob-a: rgba(0, 0, 0, 0.10);
    --blob-b: rgba(0, 0, 0, 0.06);
    --gridc: rgba(0, 0, 0, 0.035);
    --spark: #9a9aa2;

    --mica: rgba(255, 255, 255, 0.86);
    --mica-2: rgba(255, 255, 255, 0.74);
    --bar: rgba(255, 255, 255, 0.6);
    --sub: rgba(0, 0, 0, 0.03);
    --sub-strong: rgba(0, 0, 0, 0.055);
    --line: rgba(0, 0, 0, 0.08);
    --line-2: rgba(0, 0, 0, 0.14);

    --ink: #1a1a1c;
    --ink-2: #55555c;
    --ink-3: #8a8a92;

    --accent: #1a1a1c;
    --accent-ink: #ffffff;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-hi: 0 2px 6px rgba(0, 0, 0, 0.1), 0 18px 46px rgba(0, 0, 0, 0.16);
    --radius: 10px;
}

/* ---------- Palette: TỐI ---------- */
body.dark {
    --bg: #151619;
    --blob-a: rgba(255, 255, 255, 0.09);
    --blob-b: rgba(255, 255, 255, 0.05);
    --gridc: rgba(255, 255, 255, 0.04);
    --spark: #6e6e78;

    --mica: rgba(36, 37, 41, 0.9);
    --mica-2: rgba(46, 47, 51, 0.78);
    --bar: rgba(255, 255, 255, 0.05);
    --sub: rgba(255, 255, 255, 0.04);
    --sub-strong: rgba(255, 255, 255, 0.07);
    --line: rgba(255, 255, 255, 0.1);
    --line-2: rgba(255, 255, 255, 0.16);

    --ink: #f2f2f4;
    --ink-2: #b6b6bd;
    --ink-3: #85858d;

    --accent: #f2f2f4;
    --accent-ink: #151619;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.45);
    --shadow-hi: 0 2px 8px rgba(0, 0, 0, 0.5), 0 22px 54px rgba(0, 0, 0, 0.62);
}

/* ---------- Reset & base ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    color: var(--ink);
    line-height: 1.65;
    min-height: 100vh;
    background-color: var(--bg);
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s, color 0.3s;
}

::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }

/* ════════ NỀN ĐỘNG ════════ */
.bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }

.blob {
    position: absolute;
    border-radius: 50%;
    /* Gradient đã mềm sẵn — bỏ filter blur(70px) để đỡ tốn GPU */
    background-repeat: no-repeat;
    will-change: transform;
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
}
.b1 {
    width: 46vw; height: 46vw; top: -12vw; left: -8vw;
    background: radial-gradient(circle at 50% 50%, var(--blob-a), transparent 70%);
    animation: drift1 24s ease-in-out infinite alternate;
}
.b2 {
    width: 40vw; height: 40vw; top: 8vh; right: -10vw;
    background: radial-gradient(circle at 50% 50%, var(--blob-b), transparent 70%);
    animation: drift2 30s ease-in-out infinite alternate;
}
.b3 {
    width: 52vw; height: 52vw; bottom: -22vw; left: 22vw;
    background: radial-gradient(circle at 50% 50%, var(--blob-b), transparent 70%);
    animation: drift3 34s ease-in-out infinite alternate;
}
@keyframes drift1 { from { transform: translate(0, 0) scale(1); } to { transform: translate(6vw, 5vh) scale(1.12); } }
@keyframes drift2 { from { transform: translate(0, 0) scale(1.05); } to { transform: translate(-7vw, 6vh) scale(1); } }
@keyframes drift3 { from { transform: translate(0, 0) scale(1); } to { transform: translate(4vw, -6vh) scale(1.1); } }

.grid-overlay {
    position: absolute; inset: 0;
    background-image:
        linear-gradient(var(--gridc) 1px, transparent 1px),
        linear-gradient(90deg, var(--gridc) 1px, transparent 1px);
    background-size: 46px 46px;
    -webkit-mask-image: radial-gradient(circle at 50% 28%, #000 0%, transparent 72%);
    mask-image: radial-gradient(circle at 50% 28%, #000 0%, transparent 72%);
}

.spark {
    position: absolute;
    bottom: -40px;
    font-size: 14px;
    color: var(--spark);
    opacity: 0;
    will-change: transform, opacity;
    animation-name: floatUp;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}
@keyframes floatUp {
    0% { transform: translateY(0) rotate(0deg); opacity: 0; }
    12% { opacity: 0.55; }
    88% { opacity: 0.4; }
    100% { transform: translateY(-112vh) rotate(200deg); opacity: 0; }
}

/* Lúc kéo cửa sổ: tạm dừng nền động để kéo mượt */
body.dragging .blob { animation-play-state: paused; }
body.dragging .spark { display: none; }
body.dragging .window { transition: none; animation: none; }

/* ════════ KHUNG ỨNG DỤNG ════════ */
.app { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 22px 22px 48px; }

/* ════════ THANH ĐỊNH DANH ════════ */
.appbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    margin-bottom: 16px;
    background: var(--mica);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
    backdrop-filter: blur(18px) saturate(150%);
    position: sticky;
    top: 14px;
    z-index: 60;
}

.identity { display: flex; align-items: center; gap: 14px; min-width: 0; }
.id-avatar {
    width: 52px;
    height: 52px;
    flex: 0 0 auto;
    border-radius: 50%;
    padding: 2px;
    background: var(--accent);
    box-shadow: var(--shadow);
}
.id-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    filter: grayscale(1);
    transition: filter 0.4s;
}
.appbar:hover .id-avatar img { filter: grayscale(0); }

.id-text { min-width: 0; }
.id-name {
    font-size: 1.22rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    position: relative;
    cursor: pointer;
}
.id-role {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ink-2);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* glitch tên */
.id-name.glitch::before,
.id-name.glitch::after {
    content: attr(data-text);
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.id-name.glitch::before { color: var(--ink-3); transform: translateX(-2px); clip-path: inset(0 0 55% 0); animation: glitchA 0.4s steps(2) 2; }
.id-name.glitch::after { color: var(--ink-2); transform: translateX(2px); clip-path: inset(55% 0 0 0); animation: glitchB 0.4s steps(2) 2; }
@keyframes glitchA { 0% { transform: translate(-3px, 1px); } 50% { transform: translate(2px, -1px); } 100% { transform: translate(0); } }
@keyframes glitchB { 0% { transform: translate(3px, -1px); } 50% { transform: translate(-2px, 1px); } 100% { transform: translate(0); } }

.appbar-actions { margin-left: auto; display: flex; gap: 6px; }
.icon-btn {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    font-size: 16px;
    color: var(--ink-2);
    background: var(--sub);
    border: 1px solid transparent;
    border-radius: 9px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, transform 0.15s;
}
.icon-btn span { filter: grayscale(1); transition: filter 0.2s; }
.icon-btn:hover { background: var(--sub-strong); color: var(--ink); }
.icon-btn:hover span { filter: grayscale(0); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.icon-btn[aria-pressed="true"] span { filter: grayscale(0); }

/* ════════ THANH BẬT/TẮT ════════ */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 15px;
    font: 600 13px var(--font);
    color: var(--ink-2);
    background: var(--mica-2);
    border: 1px solid var(--line);
    border-radius: 999px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.12s;
}
.chip .ico { font-size: 15px; filter: grayscale(1); transition: filter 0.2s; }
.chip:hover { background: var(--sub-strong); color: var(--ink); }
.chip:active { transform: scale(0.96); }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; box-shadow: var(--shadow); }
.chip[aria-pressed="true"] .ico { filter: grayscale(0); }

/* ════════ SÂN CỬA SỔ ════════ */
/* Không-JS: xếp dọc bình thường */
.canvas { display: flex; flex-direction: column; gap: 16px; }

/* Có-JS: sân định vị tự do, cửa sổ nổi kéo được */
html.js .canvas { display: block; position: relative; min-height: 70vh; }
html.js .canvas .window { position: absolute; left: 0; top: 0; }

/* ════════ CỬA SỔ ════════ */
.window {
    display: flex;
    flex-direction: column;
    background: var(--mica);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: box-shadow 0.25s;
    animation: winIn 0.28s ease-out;
}
@keyframes winIn { from { opacity: 0; } to { opacity: 1; } }
.window:hover { box-shadow: var(--shadow-hi); }
.window.front { box-shadow: var(--shadow-hi); }
.window.closed { display: none; }
.window.dragging { transition: none; animation: none; will-change: transform; }
/* Khi bấm "sắp xếp lại": cửa sổ trượt về vị trí mới */
.window.arranging { transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s; }

html.js .canvas .window.max { left: 0 !important; width: 100% !important; transform: none !important; }

.win-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 40px;
    padding-left: 14px;
    background: var(--bar);
    border-bottom: 1px solid var(--line);
    user-select: none;
}
html.js .win-bar { cursor: grab; touch-action: none; }
html.js .window.dragging .win-bar { cursor: grabbing; }
html:not(.js) .win-ctrls, .win-bar.no-drag { cursor: default; }

.win-ico { font-size: 15px; filter: grayscale(1); }
.win-name {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.win-ctrls { align-self: stretch; display: flex; }
.win-btn {
    width: 44px;
    display: grid;
    place-items: center;
    font: 500 13px/1 var(--font);
    color: var(--ink-2);
    background: transparent;
    border: 0;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.win-btn:hover { background: var(--sub-strong); color: var(--ink); }
.win-btn:active { background: var(--sub-strong); }
.win-btn.close:hover { background: var(--accent); color: var(--accent-ink); }

.win-body {
    flex: 1;
    padding: 16px 18px 18px;
    font-size: 0.9rem;
    max-height: 62vh;
    overflow: auto;
    overscroll-behavior: contain;
}
.window.max .win-body { max-height: none; }

/* thu nhỏ */
.window.min .win-body { display: none; }
.window.min .win-bar { border-bottom: 0; }

/* scrollbar mảnh kiểu Fluent */
.win-body::-webkit-scrollbar { width: 10px; height: 10px; }
.win-body::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
.win-body::-webkit-scrollbar-thumb:hover { background: var(--ink-3); background-clip: content-box; }

/* ════════ NỘI DUNG ════════ */
.panel-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--ink-3);
    margin: 20px 0 10px;
    padding-bottom: 7px;
    border-bottom: 1px solid var(--line);
}
.win-body > .panel-title:first-child { margin-top: 0; }

.win-body p { margin-bottom: 10px; color: var(--ink-2); }
.win-body strong { color: var(--ink); font-weight: 700; }
.muted { color: var(--ink-3); font-size: 0.85rem; }

/* fun facts */
.fun-facts { list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.fun-facts li {
    padding: 8px 11px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ink-2);
    background: var(--sub);
    border: 1px solid var(--line);
    border-radius: 8px;
}

/* skills */
.skills-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.skill-tag {
    position: relative;
    padding: 6px 13px;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--ink);
    background: var(--sub);
    border: 1px solid var(--line);
    border-radius: 999px;
    cursor: default;
    transition: background 0.15s, border-color 0.15s;
}
.skill-tag:hover { background: var(--sub-strong); border-color: var(--line-2); }
.skill-tag::after {
    content: attr(data-level) '%';
    position: absolute;
    left: 50%;
    top: -30px;
    transform: translateX(-50%) scale(0.8);
    opacity: 0;
    background: var(--accent);
    color: var(--accent-ink);
    font: 600 11px var(--mono);
    padding: 3px 9px;
    border-radius: 6px;
    white-space: nowrap;
    transition: opacity 0.15s, transform 0.15s;
    z-index: 5;
}
.skill-tag:hover::after { opacity: 1; transform: translateX(-50%) scale(1); }

/* timeline */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.timeline-item { position: relative; margin-bottom: 16px; }
.timeline-item:last-child { margin-bottom: 0; }
.timeline-marker { position: absolute; left: -22px; top: 6px; width: 14px; height: 14px; border-radius: 50%; background: var(--bg); border: 2px solid var(--ink); }
.timeline-content { background: var(--sub); border: 1px solid var(--line); border-radius: 9px; padding: 13px 15px; }
.timeline-header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; }
.job-title { font-size: 0.98rem; font-weight: 700; letter-spacing: -0.01em; }
.job-company { font-size: 0.78rem; font-weight: 600; color: var(--ink-2); }
.job-meta { display: flex; flex-wrap: wrap; gap: 14px; font-size: 0.73rem; color: var(--ink-3); margin: 4px 0 8px; }
.job-duties { padding-left: 17px; font-size: 0.83rem; color: var(--ink-2); margin-bottom: 10px; }
.job-duties li { margin-bottom: 3px; }
.job-duties li::marker { color: var(--ink-3); }
.tech-stack { display: flex; flex-wrap: wrap; gap: 5px; }
.tech-badge { font-size: 0.68rem; font-weight: 600; color: var(--ink-2); background: var(--sub-strong); border-radius: 6px; padding: 3px 10px; }

/* projects */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 13px; }
.project-card {
    background: var(--sub);
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.project-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-2); }
.project-media { height: 84px; display: grid; place-items: center; background: var(--sub-strong); border-bottom: 1px solid var(--line); }
.project-placeholder { font-size: 2.2rem; filter: grayscale(1); transition: filter 0.2s, transform 0.3s; }
.project-card:hover .project-placeholder { filter: grayscale(0); transform: scale(1.15) rotate(-5deg); }
.project-content { padding: 11px 13px; }
.project-badge { display: inline-block; font-size: 9px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-ink); background: var(--accent); border-radius: 5px; padding: 2px 8px; margin-bottom: 7px; }
.project-title { font-size: 0.98rem; font-weight: 700; margin-bottom: 4px; letter-spacing: -0.01em; }
.project-desc { font-size: 0.78rem; color: var(--ink-2); margin-bottom: 9px; }
.project-tech { display: flex; flex-wrap: wrap; gap: 5px; }
.project-tech span { font-size: 0.66rem; font-weight: 600; color: var(--ink-2); border: 1px solid var(--line); border-radius: 5px; padding: 2px 8px; }

/* education */
.education-grid { display: grid; gap: 10px; }
.edu-card { display: flex; gap: 12px; background: var(--sub); border: 1px solid var(--line); border-radius: 9px; padding: 13px 15px; }
.edu-icon { font-size: 1.7rem; filter: grayscale(1); transition: filter 0.25s; }
.edu-card:hover .edu-icon { filter: grayscale(0); }
.edu-content h3 { font-size: 0.92rem; font-weight: 700; letter-spacing: -0.01em; }
.edu-school { font-size: 0.78rem; font-weight: 600; color: var(--ink-2); }
.edu-date { font-family: var(--mono); font-size: 0.66rem; color: var(--ink-3); margin-top: 3px; }
.edu-detail { font-size: 0.76rem; color: var(--ink-2); margin-top: 4px; }

/* achievements */
.achievements-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.achievement-card { text-align: center; background: var(--sub); border: 1px solid var(--line); border-radius: 9px; padding: 14px 12px; transition: transform 0.2s, border-color 0.2s; }
.achievement-card:hover { transform: translateY(-2px); border-color: var(--line-2); }
.achievement-icon { font-size: 1.7rem; margin-bottom: 6px; filter: grayscale(1); transition: filter 0.25s; }
.achievement-card:hover .achievement-icon { filter: grayscale(0); }
.achievement-card h4 { font-size: 0.85rem; font-weight: 700; margin-bottom: 3px; }
.achievement-card p { font-size: 0.74rem; color: var(--ink-2); margin: 0; }

/* contact */
.contact-list { list-style: none; margin-bottom: 16px; }
.contact-list li { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 0.85rem; }
.ci { filter: grayscale(1); }
.contact-list a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line-2); }
.contact-list a:hover { border-bottom-color: var(--ink); }

.lang-item { margin-bottom: 10px; }
.lang-name { font-size: 0.78rem; font-weight: 600; }
.lang-bar { height: 7px; margin-top: 5px; background: var(--sub-strong); border-radius: 999px; overflow: hidden; }
.lang-fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width 1s cubic-bezier(0.16, 1, 0.3, 1); }

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 10px 18px;
    font: 600 13px var(--font);
    color: var(--accent-ink);
    background: var(--accent);
    border-radius: 9px;
    text-decoration: none;
    box-shadow: var(--shadow);
    transition: transform 0.15s, opacity 0.15s;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { transform: scale(0.97); }

/* ════════ FOOTER ════════ */
.foot { text-align: center; margin-top: 30px; color: var(--ink-3); font-size: 0.8rem; }
.foot code { font-family: var(--mono); font-size: 0.74rem; background: var(--sub-strong); border-radius: 5px; padding: 2px 7px; }
.foot-kawa { margin-top: 6px; font-family: 'Comic Neue', cursive; font-style: italic; }

/* ════════ MOBILE = CV XẾP DỌC ════════ */
@media (max-width: 760px) {
    .app { padding: 14px 14px 40px; }
    .appbar { position: static; padding: 13px 15px; gap: 12px; }
    .id-avatar { width: 46px; height: 46px; }
    .id-name { font-size: 1.08rem; }
    .icon-btn { width: 38px; height: 38px; }
    .toolbar { gap: 7px; }
    .chip { padding: 7px 13px; font-size: 12.5px; }
    html.js .canvas { min-height: 0; }
    html.js .canvas .window { position: static; transform: none !important; }
    html.js .canvas .window.max { left: auto !important; width: auto !important; }
    html.js .win-bar { cursor: default; }
    .win-body, .window.max .win-body { max-height: none; }
    .bg .b3 { display: none; }
}

/* ════════ IN ════════ */
@media print {
    body { background: #fff; }
    .bg { display: none !important; }
    .app { max-width: none; padding: 0; }
    .appbar { position: static; box-shadow: none; border: none; padding: 0 0 10px; border-bottom: 2px solid #000; border-radius: 0; backdrop-filter: none; }
    .appbar-actions, .toolbar { display: none !important; }
    .canvas { display: block !important; }
    html.js .canvas .window, .window {
        position: static !important;
        left: auto !important; top: auto !important;
        transform: none !important;
        width: auto !important;
        display: block !important;
        box-shadow: none;
        border: 1px solid #bbb;
        border-radius: 0;
        margin-bottom: 14px;
        break-inside: avoid;
        page-break-inside: avoid;
        animation: none;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
        background: #fff;
    }
    .window.min .win-body { display: block !important; }
    .win-bar { background: #f0f0f0; }
    .win-ctrls { display: none; }
    .win-body { max-height: none !important; overflow: visible !important; }
    .id-name.glitch::before, .id-name.glitch::after { display: none; }
    * { filter: grayscale(1) !important; box-shadow: none !important; }
}

/* ════════ GIẢM CHUYỂN ĐỘNG ════════ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    .blob, .spark { animation: none !important; }
}
