@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600;700&display=swap");

/* ==================== VARIABLES ==================== */
:root {
    /* Colors */
    --head: #0f172a;
    --txt: #1f2933;
    --txt2: #4b5563;
    --muted: #6b7280;
    --line: #94a3b8;
    --acc: #2563eb;
    --acc-hover: #3b82f6;
    --bg: #f0f2f5;
    --card: #fff;
    --tag-bg: #e5e7eb;
    --hover-bg: #f3f4f6;
    --active-bg: #d1d5db;
    --patent: #5b9608;
    --shadow: rgba(0, 0, 0, 0.1);
    
    /* Sizing */
    --icon-sm: 14px;
    --icon-md: 18px;
    --radius: 6px;
    
    /* Animation */
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --transition: 0.3s ease;
    
    /* Spacing */
    --section-gap: 15px;
    --pad-x: 10px;
    --pad-y: 8px;
}

:root.dark {
    --head: #d5d6d8;
    --txt: #c9cacd;
    --txt2: #a6a8ad;
    --muted: #808288;
    --line: #4c4e56;
    --acc: #60a5fa;
    --acc-hover: #93c5fd;
    --bg: #18191b;
    --card: #202124;
    --tag-bg: #2d2f32;
    --hover-bg: #2d2f32;
    --active-bg: #3e4043;
    --patent: #77bf0a;
    --shadow: rgba(0, 0, 8, 0.4);
}

/* ==================== RESET ==================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ==================== BASE ==================== */
body {
    background: var(--bg);
    color: var(--txt);
    font: 400 13px/1.4 "IBM Plex Mono", monospace;
    -webkit-font-smoothing: antialiased;
    padding: 15px 0;
    transition: background var(--transition), color var(--transition);
}

@media screen and (min-width: 901px) {
    body {
        zoom: 1.1;
    }
}

/* ==================== GLOBAL TRANSITIONS ==================== */
h1,
h2,
h3,
.pronoun,
.meta,
.muted,
.desc,
.acc,
.row strong,
.row>span:not(.meta),
.ranks,
.doi a,
.contacts a,
.contacts .copy-btn,
.gold,
.silver,
.bronze,
[data-lucide],
.tags span,
.qr,
.skill-label,
.skill-items {
    transition: color var(--transition), background var(--transition);
}

.container,
header,
.entry,
.float-btn,
#skills {
    transition: background var(--transition), box-shadow var(--transition);
}

/* ==================== ANIMATIONS ==================== */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(var(--slide-dir, -48px));
    }
    
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    
    to {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==================== ICONS ==================== */
[data-lucide] {
    display: inline-flex;
    vertical-align: middle;
    width: var(--icon-sm);
    height: var(--icon-sm);
    flex-shrink: 0;
}

.contacts [data-lucide],
.ranks [data-lucide] {
    margin: -2px 0;
}

.contacts [data-lucide] {
    color: var(--muted);
}

.row strong [data-lucide] {
    position: relative;
    top: 0.18em;
}

.gold {
    color: #f59e0b;
}

.silver {
    color: #9ca3af;
}

.bronze {
    color: #b45309;
}

:root.dark .bronze {
    color: #d97706;
}

/* ==================== LAYOUT ==================== */
.container {
    width: 210mm;
    min-height: 297mm;
    margin: 0 auto;
    padding: 25px 35px;
    background: var(--card);
    box-shadow: 0 4px 15px var(--shadow);
    animation: slideIn 0.7s var(--ease) forwards;
}

.container:hover {
    box-shadow: 0 8px 25px var(--shadow);
}

/* ==================== HEADER ==================== */
header {
    position: relative;
    margin: calc(-1 * var(--pad-y)) calc(-1 * var(--pad-x)) var(--section-gap);
    padding: var(--pad-y) var(--pad-x) 12px;
    border-bottom: 2px solid var(--line);
    border-radius: var(--radius);
    opacity: 0;
    animation: slideIn 0.6s var(--ease) 0.2s forwards;
}

header:hover {
    background: var(--hover-bg);
}

.name-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

h1 {
    position: relative;
    color: var(--head);
    font-size: 26px;
    font-weight: 700;
    line-height: 1.2;
    padding-bottom: 6px;
}

h1::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 2px;
    background: var(--acc-hover);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.5s var(--ease);
}

header:hover h1::after {
    transform: scaleX(1);
}

.pronoun {
    margin-left: 0.4em;
    color: var(--muted);
    font-size: 0.65em;
    font-weight: 400;
    vertical-align: 0.15em;
}

.qr {
    width: 55px;
    height: 55px;
    padding: 3px;
    flex-shrink: 0;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    image-rendering: pixelated;
}
/* ==================== CONTACTS ==================== */
.contacts {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    row-gap: 10px;
    margin-top: 6px;
}

.contacts a,
.contacts .copy-btn{
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 14px;
    text-decoration: none;
}

.contacts a:hover,
.contacts a:hover [data-lucide] {
    color: var(--acc-hover);
}

.contacts .copy-btn {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
    border-radius: var(--radius);
}

.contacts .copy-btn:hover,
.contacts .copy-btn:hover [data-lucide] {
    color: var(--acc-hover);
}

.contacts .copy-btn:active {
    opacity: 0.7;
}

/* ==================== MAIN ==================== */
main {
    opacity: 0;
    --slide-dir: 48px;
    animation: slideIn 0.6s var(--ease) 0.35s forwards;
}

main section {
    margin-bottom: var(--section-gap);
    opacity: 0;
    animation: slideIn 0.5s var(--ease) calc(0.4s + var(--i, 0) * 0.1s) forwards;
}

main section:last-child {
    margin-bottom: 0;
}

main section:nth-child(odd) {
    --slide-dir: -48px;
}

main section:nth-child(even) {
    --slide-dir: 48px;
}

main section:nth-child(1) {
    --i: 0;
}

main section:nth-child(2) {
    --i: 1;
}

main section:nth-child(3) {
    --i: 2;
}

main section:nth-child(4) {
    --i: 3;
}

/* ==================== HEADINGS ==================== */
h2 {
    margin: 0 0 8px;
    padding-bottom: 2px;
    color: var(--head);
    font-size: 17px;
    font-weight: 700;
    border-bottom: 2px solid var(--line);
}

h3 {
    margin: 10px 0 6px;
    padding: 3px 8px;
    color: var(--txt2);
    font-size: 12px;
    font-weight: 600;
    background: var(--tag-bg);
    border-left: 3px solid var(--acc);
    border-radius: 0 var(--radius) var(--radius) 0;
}

h3:first-of-type {
    margin-top: 6px;
}

/* ==================== ENTRIES ==================== */
.entry {
    position: relative;
    margin: 0 calc(-1 * var(--pad-x)) 8px;
    padding: var(--pad-y) var(--pad-x);
    border-radius: var(--radius);
    font-size: 12px;
}

.entry:hover {
    background: var(--hover-bg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.entry:active {
    background: var(--active-bg);
}

.entry:last-child {
    margin-bottom: 0;
}

.entry> :last-child {
    margin-bottom: 0 !important;
}

.row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
}

.row>span:not(.meta) {
    color: var(--txt2);
}

.entry>.row:first-child {
    position: relative;
    padding-bottom: 2px;
    margin-bottom: 2px;
    min-height: 18px;
}

.entry>.row:first-child::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 2px;
    background: var(--acc-hover);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.4s var(--ease);
}

.entry:hover>.row:first-child::after {
    transform: scaleX(1);
}

.row strong {
    flex: 1;
    color: var(--head);
    font-size: 14px;
    line-height: 1.15;
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
}

.row strong a {
    color: inherit;
    text-decoration: none;
}

.meta {
    flex-shrink: 0;
    color: var(--muted);
    font-weight: 600;
    white-space: nowrap;
}

.muted {
    margin-bottom: 4px;
    color: var(--muted);
    font-weight: bold;
}

.desc {
    margin-bottom: 4px;
    color: var(--txt2);
}

.acc {
    color: var(--acc);
    font-weight: 600;
}

.projects .entry strong {
    color: var(--acc);
}

.entry.patent strong {
    color: var(--patent);
}

/* ==================== RANKS ==================== */
.ranks {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
    padding: 0 15%;
    color: var(--txt2);
}

.ranks span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ==================== DOI ==================== */
.doi {
    margin-top: 2px;
}

.doi a {
    color: var(--acc);
    text-decoration: none;
}

.doi a:hover {
    color: var(--acc-hover);
}

/* ==================== TAGS ==================== */
.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 5px;
}

.tags span {
    padding: 2px 8px;
    color: var(--txt);
    font-size: 11px;
    background: var(--tag-bg);
    border-radius: var(--radius);
    cursor: default;
}

.tags span:hover {
    color: #fff;
    background: #3b82f6;
}

/* ==================== SKILLS ==================== */
#skills {
    margin: 0 calc(-1 * var(--pad-x));
    padding: var(--pad-y) var(--pad-x);
    border-radius: var(--radius);
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    opacity: 0;
    animation: fadeUp 0.5s var(--ease) 0.5s forwards;
}

.skill-category {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    line-height: 1.4;
}

.skill-label {
    flex-shrink: 0;
    padding: 2px 8px;
    color: var(--head);
    font-size: 12px;
    font-weight: 600;
    background: var(--tag-bg);
    border-left: 3px solid var(--acc);
    border-radius: 0 var(--radius) var(--radius) 0;
}

.skill-items {
    color: var(--txt2);
    flex: 1;
}

/* ==================== FOOTER ==================== */
footer {
    display: flex;
    flex-wrap: wrap;
    gap: var(--section-gap) 25px;
    margin-top: var(--section-gap);
    opacity: 0;
    --slide-dir: -48px;
    animation: slideIn 0.5s var(--ease) 0.8s forwards;
}

footer>div {
    flex: 1;
    min-width: 120px;
}

footer h2 {
    margin-bottom: 8px;
}

/* ==================== FLOAT BUTTONS ==================== */
.float-btn {
    position: fixed;
    top: 16px;
    z-index: 100;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card);
    border: none;
    border-radius: 10px;
    box-shadow: 0 2px 5px var(--shadow);
    cursor: pointer;
    opacity: 0;
}

.float-btn [data-lucide] {
    width: var(--icon-md);
    height: var(--icon-md);
    color: var(--muted);
    transition: transform var(--transition), color var(--transition);
}

.float-btn:hover {
    background: var(--hover-bg);
}

.float-btn:hover [data-lucide] {
    transform: rotate(15deg);
}

.float-btn:active {
    background: var(--active-bg);
}

.print-btn {
    left: calc(100% - 35mm + 15px);
    animation: fadeIn 0.4s ease 1s forwards;
}

.theme-btn {
    left: calc(100% - 35mm + 65px);
    animation: fadeIn 0.4s ease 1.1s forwards;
}

.theme-btn .icon-sun,
:root.dark .theme-btn .icon-moon {
    display: none;
}

.theme-btn .icon-moon,
:root.dark .theme-btn .icon-sun {
    display: block;
}

/* ==================== PRINT ==================== */
@media print {
    @page {
        size: A4;
        margin: 15mm 0;
    }

    :root,
    :root.dark {
        --bg: #fff;
        --card: #fff;
        --shadow: none;
        --transition: 0s;
        --head: #0f172a;
        --txt: #1f2933;
        --acc: #2563eb;
    }

    body {
        padding: 0;
    }

    .container {
        width: 210mm;
        padding: 0 40px;
        box-shadow: none;
    }

    /* Prevent Splitting */
    header,
    section,
    .entry,
    .row {
        break-inside: avoid;
    }

    h2,
    h3 {
        break-after: avoid;
    }

    .float-btn,
    h1::after,
    .entry>.row:first-child::after {
        display: none;
    }

    * {
        animation: none !important;
        transition: none !important;
    }

    .tags span,
    h3,
    .skill-label {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ==================== TABLET (601-900px) ==================== */
@media screen and (max-width: 900px) {
    .float-btn {
        top: auto;
        bottom: 16px;
        left: auto;
        animation: fadeIn 0.4s ease 0.6s forwards;
    }
    
    .print-btn {
        right: 68px;
    }
    
    .theme-btn {
        right: 16px;
    }
    
    main,
    main section {
        animation-name: fadeUp;
    }
    
    main {
        animation-delay: 0.2s;
    }
    
    main section:nth-child(1) {
        animation-delay: 0.25s;
    }
    
    main section:nth-child(2) {
        animation-delay: 0.30s;
    }
    
    main section:nth-child(3) {
        animation-delay: 0.35s;
    }
    
    main section:nth-child(4) {
        animation-delay: 0.40s;
    }
}

@media screen and (max-width: 900px) and (min-width: 601px) {
    body {
        padding: 12px;
    }
    
    .container {
        width: 100%;
        min-height: auto;
        padding: 20px 24px;
        border-radius: 8px;
        animation: fadeUp 0.5s ease forwards;
    }
    
    header {
        animation: fadeUp 0.4s ease 0.1s both;
    }
    
    h1 {
        font-size: 24px;
    }
    
    h2 {
        font-size: 16px;
    }
    
    .qr {
        width: 53px;
        height: 53px;
    }
    
    .contacts {
        gap: 10px 16px;
    }
    
    .contacts a,
    .contacts .copy-btn{
        font-size: 13px;
    }
    
    .row strong {
        font-size: 13px;
    }
    
    .ranks {
        padding: 0 10%;
    }
}

/* ==================== MOBILE (max 600px) ==================== */
@media screen and (max-width: 600px) {
    :root {
        --section-gap: 12px;
        --pad-x: 5px;
        --pad-y: 5px;
    }
    
    body {
        padding: 8px;
    }
    
    .container {
        width: 100%;
        min-height: auto;
        padding: 16px 18px;
        border-radius: var(--radius);
        animation: fadeUp 0.5s ease forwards;
    }
    
    header {
        padding-bottom: 10px;
        animation: fadeUp 0.4s ease 0.1s both;
    }
    
    .name-row {
        align-items: flex-start;
    }
    
    h1 {
        font-size: 22px;
        padding-bottom: 0;
    }
    
    .pronoun {
        display: block;
        margin: 2px 0 0;
        font-size: 12px;
    }
    
    .qr {
        width: 58px;
        height: 58px;
        padding: 4px;
    }
    
    .contacts {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px 12px;
        margin-top: 8px;
        justify-items: center;
    }
    
    .contacts a,
    .contacts .copy-btn{
        max-width: 100%;
        font-size: 12px;
        gap: 5px;
    }
    
    .contacts [data-lucide] {
        width: 13px;
        height: 13px;
    }
    
    h2 {
        font-size: 15px;
        margin-bottom: 6px;
    }
    
    h3 {
        font-size: 11px;
        margin: 8px 0 6px;
    }
    
    .row {
        flex-direction: column;
        gap: 2px;
    }
    
    .row strong {
        font-size: 13px;
    }
    
    .row strong [data-lucide] {
        width: 13px;
        height: 13px;
    }
    
    .meta {
        font-size: 11px;
        white-space: normal;
    }
    
    .muted {
        font-size: 11px;
    }
    
    .desc {
        font-size: 12px;
    }
    
    .ranks {
        flex-wrap: wrap;
        gap: 6px 12px;
        padding: 0 5%;
        font-size: 11px;
    }
    
    .ranks [data-lucide] {
        width: 13px;
        height: 13px;
    }
    
    .doi a {
        font-size: 11px;
        word-break: break-all;
    }
    
    .tags span {
        font-size: 11px;
    }
    
    #skills,
    .skill-label {
        font-size: 11px;
    }
    
    footer {
        flex-direction: column;
        gap: var(--section-gap);
        animation: fadeUp 0.4s ease 0.5s both;
    }
    
    footer>div {
        width: 100%;
        min-width: auto;
    }
    
    .float-btn {
        bottom: 12px;
        width: 42px;
        height: 42px;
    }
    
    .float-btn [data-lucide] {
        width: 20px;
        height: 20px;
    }
    
    .print-btn {
        right: 62px;
    }
    
    .theme-btn {
        right: 12px;
    }
}

/* ==================== SMALL MOBILE (max 380px) ==================== */
@media screen and (max-width: 380px) {
    :root {
        --section-gap: 10px;
        --pad-x: 4px;
        --pad-y: 4px;
    }
    
    body {
        padding: 6px;
    }
    
    .container {
        padding: 14px 16px;
    }
    
    h1 {
        font-size: 20px;
    }
    
    h2 {
        font-size: 15px;
    }
    
    .qr {
        width: 52px;
        height: 52px;
    }
    
    .contacts {
        gap: 6px 10px;
    }
    
    .contacts a,
    .contacts .copy-btn{
        font-size: 10px;
        gap: 4px;
    }
    
    .contacts [data-lucide] {
        width: 11px;
        height: 11px;
    }
    
    .row strong {
        font-size: 12px;
    }
    
    .desc {
        font-size: 11px;
    }
    
    .tags span {
        font-size: 10px;
        padding: 2px 6px;
    }
    
    #skills,
    .skill-label {
        font-size: 10px;
    }
    
    .skill-label {
        padding: 2px 6px;
    }
    
    .float-btn {
        width: 40px;
        height: 40px;
    }
    
    .float-btn [data-lucide] {
        width: 18px;
        height: 18px;
    }
    
    .print-btn {
        right: 56px;
    }
    
    .theme-btn {
        right: 10px;
    }
}

/* ==================== TOUCH DEVICES ==================== */
@media (hover: none) and (pointer: coarse) {
    :where(header, .entry, #skills):hover {
        background: transparent;
        box-shadow: none;
    }
    
    .float-btn:hover {
        background: var(--card);
    }
    
    .float-btn:hover [data-lucide] {
        transform: none;
    }
    
    .tags span:hover {
        color: var(--txt);
        background: var(--tag-bg);
    }
    
    .contacts a:hover,
    .contacts a:hover [data-lucide],
    .contacts .copy-btn:hover,
    .contacts .copy-btn:hover [data-lucide] {
        color: var(--muted);
    }
    
    .doi a:hover {
        color: var(--acc);
    }
    
    h1::after,
    .entry>.row:first-child::after {
        display: none;
    }
    
    /* Active States */
    .entry:active,
    #skills:active {
        background: var(--hover-bg);
    }
    
    .tags span:active {
        color: #fff;
        background: #3b82f6;
    }
    
    .float-btn:active {
        background: var(--active-bg);
        transform: scale(0.95);
    }
    
    .contacts a:active,
    .contacts a:active [data-lucide],
    .contacts .copy-btn:active,
    .contacts .copy-btn:active [data-lucide],
    .doi a:active {
        color: var(--acc-hover);
    }
}