/* ---------- Tokens ---------- */
:root {
    --bg: #ffffff;
    --bg-alt: #f5f5f7;
    --tile: #f5f5f7;
    --tile-2: #e8e8ed;
    --text: #1d1d1f;
    --text-2: #6e6e73;
    --hair: rgba(0, 0, 0, 0.12);
    --accent: #0071e3;
    --accent-text: #0066cc;
    --glass: rgba(255, 255, 255, 0.72);
    --glass-border: rgba(0, 0, 0, 0.08);
    --lift: 0 18px 40px rgba(0, 0, 0, 0.08);
    --g1: linear-gradient(100deg, #e8501c, #c2185b);
    --g2: linear-gradient(100deg, #0071e3, #6e3ff3);
    --g3: linear-gradient(100deg, #0a8f5b, #00798a);
    --g4: linear-gradient(100deg, #8e3ad6, #c2185b);
    --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Inter, "Helvetica Neue", Arial, sans-serif;
}
:root[data-theme="dark"], .on-dark {
    --bg: #000000;
    --bg-alt: #161617;
    --tile: #1c1c1e;
    --tile-2: #2c2c2e;
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --hair: rgba(255, 255, 255, 0.16);
    --accent-text: #2997ff;
    --glass: rgba(22, 22, 23, 0.72);
    --glass-border: rgba(255, 255, 255, 0.1);
    --lift: 0 18px 40px rgba(0, 0, 0, 0.5);
    --g1: linear-gradient(100deg, #ff7a45, #ff4f8b);
    --g2: linear-gradient(100deg, #2997ff, #a07bff);
    --g3: linear-gradient(100deg, #30d158, #40c8e0);
    --g4: linear-gradient(100deg, #bf5af2, #ff4f8b);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #000000;
        --bg-alt: #161617;
        --tile: #1c1c1e;
        --tile-2: #2c2c2e;
        --text: #f5f5f7;
        --text-2: #a1a1a6;
        --hair: rgba(255, 255, 255, 0.16);
        --accent-text: #2997ff;
        --glass: rgba(22, 22, 23, 0.72);
        --glass-border: rgba(255, 255, 255, 0.1);
        --lift: 0 18px 40px rgba(0, 0, 0, 0.5);
        --g1: linear-gradient(100deg, #ff7a45, #ff4f8b);
        --g2: linear-gradient(100deg, #2997ff, #a07bff);
        --g3: linear-gradient(100deg, #30d158, #40c8e0);
        --g4: linear-gradient(100deg, #bf5af2, #ff4f8b);
    }
}
@media (prefers-contrast: more) {
    :root, :root[data-theme="dark"], .on-dark { --hair: currentColor; }
    :root:not([data-theme="dark"]) { --text-2: #3a3a3c; }
    :root[data-theme="dark"], .on-dark { --text-2: #d1d1d6; }
    .tile { outline: 1px solid var(--text); }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
body {
    font-family: var(--font);
    font-size: 17px;
    line-height: 1.47;
    letter-spacing: -0.01em;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}
body:has(dialog[open]) { overflow: hidden; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
ul { list-style: none; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.wrap { max-width: 1024px; margin: 0 auto; padding: 0 22px; }
.on-dark { background: var(--bg); color: var(--text); }
.muted { color: var(--text-2); }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 12px; z-index: 100; background: var(--bg); padding: 8px 14px; border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Glass nav (functional layer only) ---------- */
.nav {
    position: sticky; top: 0; z-index: 50;
    background: var(--glass);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    backdrop-filter: blur(24px) saturate(1.4);
    border-bottom: 1px solid var(--glass-border);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .nav { background: var(--bg); } }
@media (prefers-reduced-transparency: reduce) { .nav { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; } }
@media (prefers-contrast: more) { .nav { background: var(--bg); border-bottom-color: var(--text); } }
.nav-inner { max-width: 1024px; margin: 0 auto; padding: 0 22px; height: 52px; display: flex; align-items: center; gap: 24px; }
.brand { font-weight: 600; font-size: 19px; color: var(--text); letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.nav nav { margin-left: auto; }
.nav ul { display: flex; gap: 28px; }
.nav ul a { color: var(--text); font-size: 14px; opacity: 0.85; display: inline-flex; align-items: center; min-height: 44px; }
.nav ul a:hover { opacity: 1; text-decoration: none; }
.icon-btn {
    width: 44px; height: 44px; border: 0; background: transparent; color: var(--text);
    font-size: 18px; cursor: pointer; border-radius: 50%; flex: none;
}
.icon-btn:hover { background: var(--hair); }
.menu-btn { display: none; }

/* ---------- Buttons ---------- */
.actions { display: flex; flex-wrap: wrap; gap: 14px 28px; align-items: center; }
.center { justify-content: center; }
.btn {
    display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
    padding: 0 24px; border-radius: 980px; background: var(--accent); color: #fff;
    font-size: 17px; font-weight: 500; border: 0; cursor: pointer;
}
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.link {
    display: inline-flex; align-items: center; gap: 4px; min-height: 44px;
    color: var(--accent-text); font-size: 17px; background: none; border: 0; cursor: pointer; font-family: inherit;
}

/* ---------- Gradient figures (signature) ---------- */
.fig { font-weight: 700; letter-spacing: -0.03em; line-height: 1; color: var(--text); }
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
    .fig { -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
    .fig.g1 { background-image: var(--g1); }
    .fig.g2 { background-image: var(--g2); }
    .fig.g3 { background-image: var(--g3); }
    .fig.g4 { background-image: var(--g4); }
}
@media (prefers-contrast: more) { .fig { background: none !important; -webkit-text-fill-color: currentColor; } }
.fig .unit { font-size: 0.4em; font-weight: 500; letter-spacing: 0; color: var(--text-2); -webkit-text-fill-color: currentColor; }

/* ---------- Story: hero ---------- */
.hero { text-align: center; padding: clamp(88px, 14vw, 160px) 0 clamp(72px, 10vw, 120px); }
.hero .eyebrow { font-size: clamp(19px, 2.2vw, 24px); font-weight: 600; margin-bottom: 14px; }
.hero h1 { font-size: clamp(48px, 8.4vw, 96px); line-height: 1.04; letter-spacing: -0.035em; font-weight: 700; }
.hero .tagline { font-size: clamp(19px, 2.2vw, 24px); color: var(--text-2); margin: 22px auto 0; max-width: 720px; }
.hero .pitch { color: var(--text-2); max-width: 620px; margin: 18px auto 36px; }

/* ---------- Section headings ---------- */
.section-head { padding-block: clamp(80px, 11vw, 130px) clamp(48px, 6vw, 72px); }
.section-title { font-size: clamp(40px, 6vw, 64px); letter-spacing: -0.03em; line-height: 1.06; font-weight: 700; }
.section-sub { color: var(--text-2); font-size: clamp(19px, 2.2vw, 24px); margin-top: 12px; max-width: 680px; }

/* ---------- Work index: featured project tiles ---------- */
#work .section-head { padding-top: 0; }
.work-index { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: clamp(32px, 5vw, 48px); }
.tile.index-card { min-height: 250px; }
.index-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; }
.index-card.g1::before { background: var(--g1); }
.index-card.g2::before { background: var(--g2); }
.index-card.g3::before { background: var(--g3); }
.index-card.g4::before { background: var(--g4); }

/* ---------- Bento body ---------- */
.bento {
    max-width: 1024px; margin: 0 auto; padding: 0 22px clamp(80px, 10vw, 120px);
    display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: minmax(210px, auto);
    grid-auto-flow: dense; gap: 16px;
}
.tile {
    position: relative; background: var(--tile); border-radius: 28px; padding: 28px;
    display: flex; flex-direction: column; overflow: hidden; isolation: isolate;
    transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1), box-shadow 0.35s ease;
}
.w2 { grid-column: span 2; }
.w4 { grid-column: span 4; }
.h2 { grid-row: span 2; }
.tile .kicker { font-size: 14px; font-weight: 600; color: var(--text-2); }
.tile h2, .tile h3 { letter-spacing: -0.02em; line-height: 1.15; }
.tile h3 { font-size: 24px; margin-top: 6px; }
.tile .grow { margin-top: auto; }
.tile .fig { font-size: 40px; padding-top: 20px; }
.tile .fig-label { font-size: 15px; color: var(--text-2); margin-top: 6px; }

/* Openable tiles: the whole tile opens the sheet. */
.tile.openable { cursor: pointer; }
.tile.openable:hover { transform: translateY(-4px); box-shadow: var(--lift); }
.tile.openable .fig-label { padding-right: 44px; }
.tile-open {
    position: absolute; right: 20px; bottom: 20px; width: 36px; height: 36px; border-radius: 50%;
    border: 0; background: var(--tile-2); color: var(--text); font-size: 22px; line-height: 1; cursor: pointer;
    display: grid; place-items: center; transition: transform 0.3s ease;
}
.tile-open:focus-visible { outline: none; }
.tile.openable:has(.tile-open:focus-visible) { outline: 3px solid var(--accent); outline-offset: 3px; }
.tile.openable:hover .tile-open { transform: rotate(90deg); }

/* Experience tile */
.xp h3 { font-size: clamp(26px, 3vw, 34px); }
.xp-list { margin-top: 20px; }
.xp-list li { display: flex; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid var(--hair); }
.xp-list b { font-weight: 600; display: block; }
.xp-list span { color: var(--text-2); font-size: 15px; white-space: nowrap; }
.xp-list li:last-child { padding-right: 44px; }
.path { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 16px; font-size: 13px; }
.path span { padding: 5px 11px; border-radius: 980px; background: var(--tile-2); }
.path span:last-child { background: var(--accent); color: #fff; }
.path i { font-style: normal; color: var(--text-2); }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.chip { font-size: 14px; padding: 6px 13px; border-radius: 980px; background: var(--tile-2); }

/* Education & certs */
.edu .fig { font-size: 52px; white-space: nowrap; }
.certs { margin-top: 10px; }
.certs li { padding: 9px 0; border-top: 1px solid var(--hair); font-size: 15px; display: flex; gap: 10px; }
.certs li:first-child { border-top: 0; }
.certs li::before { content: "✓"; color: var(--accent-text); font-weight: 700; }

/* Contact */
.contact { padding: clamp(36px, 6vw, 64px); flex-direction: row; align-items: center; justify-content: space-between; gap: 32px; flex-wrap: wrap; }
.contact h2 { font-size: clamp(36px, 5vw, 56px); letter-spacing: -0.035em; line-height: 1.05; }
.contact p { color: var(--text-2); margin-top: 12px; max-width: 520px; }
.status { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; color: var(--text-2); margin-bottom: 14px; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #30d158; box-shadow: 0 0 0 4px rgba(48, 209, 88, 0.2); }

footer { padding: 28px 0 40px; font-size: 12px; color: var(--text-2); }
footer .wrap { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-top: 1px solid var(--hair); padding-top: 18px; }

/* ---------- Sheet ---------- */
dialog.sheet {
    border: 0; padding: 0; margin: auto; color: var(--text); background: var(--bg);
    width: min(680px, calc(100% - 32px)); max-width: 100%; max-height: min(86vh, 880px);
    border-radius: 28px; overflow: auto; overscroll-behavior: contain;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.35);
}
dialog.sheet::backdrop { background: rgba(0, 0, 0, 0.35); }
dialog.sheet[open] { animation: pop 0.38s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes pop { from { opacity: 0; transform: translateY(24px) scale(0.97); } }
@keyframes slide-up { from { transform: translateY(100%); } }
.sheet-head {
    position: sticky; top: 0; z-index: 2; display: flex; justify-content: flex-end; padding: 10px 12px;
    background: var(--glass);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    backdrop-filter: blur(24px) saturate(1.4);
}
@media (prefers-reduced-transparency: reduce) { .sheet-head { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; } }
@media (prefers-contrast: more) { .sheet-head { background: var(--bg); border-bottom: 1px solid var(--text); } }
.sheet-head .icon-btn { background: var(--tile); font-size: 16px; }
.grabber { display: none; }
.sheet-body { padding: 0 40px 44px; }
.sheet-body .kicker { font-size: 15px; font-weight: 600; color: var(--text-2); }
.sheet-body h2 { font-size: clamp(30px, 4vw, 40px); letter-spacing: -0.03em; line-height: 1.1; margin-top: 4px; }
.sheet-body .fig { font-size: clamp(64px, 10vw, 96px); margin-top: 28px; }
.sheet-body .fig-label { font-weight: 600; margin-top: 8px; }
.sheet-body .lead { font-size: 21px; color: var(--text-2); margin-top: 24px; }
.sheet-body .chip { background: var(--tile); }
.plain { margin-top: 24px; padding: 18px 20px; border-radius: 16px; background: var(--tile); color: var(--text-2); font-style: italic; }
.sheet-section { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--hair); }
.sheet-section h3 { font-size: 21px; letter-spacing: -0.015em; }
.sheet-section .meta { color: var(--text-2); font-size: 15px; }
.role { margin-top: 16px; }
.role h4 { font-size: 17px; }
.role h4 span { font-weight: 400; color: var(--text-2); }
.role li { position: relative; padding-left: 18px; color: var(--text-2); margin-top: 8px; }
.role li::before { content: ""; position: absolute; left: 2px; top: 0.7em; width: 6px; height: 6px; border-radius: 50%; background: var(--text-2); }

/* ---------- Details: shown in the sheet with JS, listed in full without it ---------- */
.js .details { display: none; }
.details .sheet-body { padding: 48px 0; border-top: 1px solid var(--hair); }
html:not(.js) [data-open], html:not(.js) .nav-actions { display: none; }

/* ---------- Motion ---------- */
:where(.js) .reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.2, 0.7, 0.2, 1); }
:where(.js) .reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    :where(.js) .reveal { opacity: 1; transform: none; transition: none; }
    .tile, .tile-open { transition: none; }
    .tile.openable:hover, .tile.openable:hover .tile-open { transform: none; }
    dialog.sheet[open] { animation: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1068px) {
    .bento, .work-index { grid-template-columns: repeat(2, 1fr); }
    .w4 { grid-column: span 2; }
}
@media (max-width: 734px) {
    .menu-btn { display: inline-block; }
    .nav ul {
        display: none; position: absolute; top: 52px; left: 0; right: 0;
        flex-direction: column; gap: 0; padding: 8px 22px 16px;
        background: var(--bg); border-bottom: 1px solid var(--hair);
    }
    .nav ul.open { display: flex; }
    .nav ul a { font-size: 21px; width: 100%; border-bottom: 1px solid var(--hair); min-height: 52px; }
    .actions .btn { width: 100%; }

    .bento { grid-template-columns: 1fr; grid-auto-rows: auto; gap: 12px; }
    .work-index { grid-template-columns: 1fr; gap: 12px; }
    .tile.index-card { min-height: 180px; }
    .w2, .w4 { grid-column: span 1; }
    .h2 { grid-row: span 1; }
    .tile { padding: 24px; min-height: 180px; }
    .xp-list li { flex-direction: column; gap: 2px; }
    .contact { flex-direction: column; align-items: flex-start; }

    dialog.sheet { width: 100%; margin: auto 0 0; max-height: 92vh; border-radius: 28px 28px 0 0; }
    dialog.sheet[open] { animation-name: slide-up; }
    .sheet-head { justify-content: space-between; align-items: center; }
    .grabber { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--hair); margin-left: calc(50% - 32px); }
    .sheet-body { padding: 0 24px 36px; }
}
