/* Inner pages: paper, ink and orange.
   Home page (.home): one glass hub over a photo. Portrait panel on the left,
   cut by a curved edge, with the page links on the right. */

:root {
  --bg: #f4efe6;
  --bg-tint: #ebe4d6;
  --surface: #fbf8f2;
  --ink: #1d1a16;
  --ink-soft: #5b554b;
  --line: #d9d0bf;
  --accent: #e8431f;
  --accent-text: #c93414;
  --accent-ink: #ffffff;
  --accent-soft: #fbd9cf;
  --lime: #d7f171;

  --glass: rgba(255, 255, 255, .5);
  --glass-2: rgba(255, 255, 255, .72);
  --glass-line: rgba(255, 255, 255, .85);
  --glass-edge: rgba(29, 26, 22, .12);
  --glass-shadow: 0 34px 80px -34px rgba(90, 40, 15, .55);
  --scrim: rgba(255, 255, 255, .06);

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --radius: 18px;
  --wrap: 1120px;
  --nav-h: 78px;
  --rim: linear-gradient(160deg, var(--accent), #ffb347 55%, var(--lime));
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15130f;
    --bg-tint: #1c1915;
    --surface: #211e19;
    --ink: #f2ece0;
    --ink-soft: #a9a193;
    --line: #36312a;
    --accent: #ff6b45;
    --accent-text: #ff8b6b;
    --accent-ink: #1a0d08;
    --accent-soft: #3a211a;
    --glass: rgba(34, 27, 22, .46);
    --glass-2: rgba(60, 49, 40, .6);
    --glass-line: rgba(255, 255, 255, .15);
    --glass-edge: rgba(255, 255, 255, .1);
    --glass-shadow: 0 34px 80px -34px rgba(0, 0, 0, .85);
    --scrim: rgba(10, 8, 6, .42);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15130f;
  --bg-tint: #1c1915;
  --surface: #211e19;
  --ink: #f2ece0;
  --ink-soft: #a9a193;
  --line: #36312a;
  --accent: #ff6b45;
  --accent-text: #ff8b6b;
  --accent-ink: #1a0d08;
  --accent-soft: #3a211a;
  --glass: rgba(34, 27, 22, .46);
  --glass-2: rgba(60, 49, 40, .6);
  --glass-line: rgba(255, 255, 255, .15);
  --glass-edge: rgba(255, 255, 255, .1);
  --glass-shadow: 0 34px 80px -34px rgba(0, 0, 0, .85);
  --scrim: rgba(10, 8, 6, .42);
  color-scheme: dark;
}

/* ---------- Base ---------- */
@view-transition { navigation: auto; }
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 12px); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 17px; line-height: 1.65; overflow-x: hidden; transition: background .3s, color .3s; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.12; margin: 0; letter-spacing: -0.015em; text-wrap: balance; }
p { margin: 0 0 1em; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
[hidden] { display: none !important; }

.wrap { width: min(var(--wrap), 100%); margin-inline: auto; padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); }
.mono { font-family: var(--mono); }
.label { font-family: var(--mono); font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-soft); margin: 0 0 .8rem; }
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: 13px 22px; border-radius: 999px; font-weight: 600; font-size: .97rem; text-decoration: none; border: 1.5px solid var(--ink); background: transparent; color: var(--ink); transition: transform .2s, background .2s, color .2s, box-shadow .2s; }
.btn:hover { transform: translateY(-2px); }
.btn-primary { background: var(--ink); color: var(--bg); box-shadow: 4px 4px 0 var(--accent); }
.btn-primary:hover { box-shadow: 6px 6px 0 var(--accent); }
.btn-ghost:hover { background: var(--ink); color: var(--bg); }
.text-link { color: var(--accent-text); font-weight: 600; text-decoration: none; border-bottom: 1.5px solid currentColor; padding-bottom: 1px; }
.text-link:hover { color: var(--ink); }
.text-btn { background: none; border: 0; padding: 0; color: var(--accent-text); font-weight: 600; text-decoration: underline; text-underline-offset: 4px; }

.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; transition: transform .2s, border-color .2s; }
.icon-btn:hover { border-color: var(--ink); transform: translateY(-1px); }
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: block; }
  :root:not([data-theme="light"]) .i-moon { display: none; }
}

/* ---------- Nav (inner pages) ---------- */
.nav { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 50; padding: 12px 0 0; }
.nav-row { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 58px; padding: 0 9px 0 14px; border-radius: 999px; background: color-mix(in srgb, var(--surface) 78%, transparent); -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4); border: 1px solid var(--line); box-shadow: 0 14px 34px -22px rgba(70, 35, 12, .45); transition: box-shadow .25s; }
.nav.scrolled .nav-row { box-shadow: 0 18px 38px -20px rgba(70, 35, 12, .55); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; white-space: nowrap; }
.brand-mark { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-family: var(--serif); font-weight: 700; font-size: 1.1rem; }
.brand-mark img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.nav-links { display: flex; align-items: center; gap: 2px; }
.nav-links a { text-decoration: none; font-size: .9rem; font-weight: 500; padding: 8px 12px; border-radius: 999px; color: var(--ink-soft); transition: background .2s, color .2s; white-space: nowrap; }
.nav-links a:hover { color: var(--ink); background: var(--bg-tint); }
.nav-links a[aria-current="page"] { color: var(--ink); background: var(--bg-tint); box-shadow: inset 0 0 0 1px var(--line); }
.nav-links .nav-cta { background: var(--ink); color: var(--bg); margin-left: 4px; }
.nav-links .nav-cta:hover { background: var(--accent); color: var(--accent-ink); }
.nav-links .nav-cta[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }
.nav-actions { display: flex; align-items: center; gap: 8px; }
.menu-btn { display: none; position: relative; }
.menu-btn span { position: absolute; left: 11px; right: 11px; height: 2px; background: var(--ink); border-radius: 2px; transition: transform .25s, top .25s; }
.menu-btn span:nth-child(1) { top: 15px; }
.menu-btn span:nth-child(2) { top: 23px; }
.menu-btn[aria-expanded="true"] span:nth-child(1) { top: 19px; transform: rotate(45deg); }
.menu-btn[aria-expanded="true"] span:nth-child(2) { top: 19px; transform: rotate(-45deg); }

/* ---------- Sections and page heads ---------- */
.section { padding: clamp(32px, 5vw, 64px) 0; }
.section-tint { background: var(--bg-tint); }
.section-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 8px 24px; margin-bottom: 1.6rem; }
.section-head h2 { font-size: clamp(1.7rem, 3.6vw, 2.4rem); }
.page-head { position: relative; overflow: hidden; padding: clamp(36px, 6vw, 72px) 0 clamp(4px, 1vw, 12px); }
.page-head > .wrap { position: relative; z-index: 1; }
.page-head::before, .page-head::after { content: ""; position: absolute; border-radius: 50%; pointer-events: none; -webkit-mask-image: linear-gradient(to bottom, #000 40%, transparent 92%); mask-image: linear-gradient(to bottom, #000 40%, transparent 92%); }
.page-head::before { width: 440px; height: 440px; right: -150px; top: -190px; border: 7px solid transparent; background: linear-gradient(var(--bg), var(--bg)) padding-box, var(--rim) border-box; opacity: .55; }
.page-head::after { width: 640px; height: 640px; right: -270px; top: -300px; border: 1.5px solid var(--line); }
.page-head h1 { font-size: clamp(2.4rem, 6vw, 4.2rem); margin-bottom: 1rem; }
.page-head h1 .scribble { position: relative; white-space: nowrap; color: var(--accent-text); font-style: italic; }
.page-head h1 .scribble svg { position: absolute; left: 0; bottom: -.14em; width: 100%; height: .28em; overflow: visible; }
.page-head h1 .scribble path { fill: none; stroke: var(--accent); stroke-width: 3.5; stroke-linecap: round; stroke-dasharray: 340; stroke-dashoffset: 340; animation: draw 1.1s .4s ease forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.lede { max-width: 40em; color: var(--ink-soft); font-size: 1.08rem; margin: 0; }
.crumb { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: .82rem; text-decoration: none; color: var(--ink-soft); margin-bottom: 1.2rem; }
.crumb:hover { color: var(--accent-text); }

/* ---------- Controls: toggles + search ---------- */
.controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 18px; margin: 1.8rem 0 1.4rem; }
.toggles { display: flex; flex-wrap: wrap; gap: 8px; }
.tog { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 999px; border: 1.5px solid var(--line); background: transparent; font-weight: 500; font-size: .92rem; transition: background .2s, color .2s, border-color .2s; }
.tog .n { font-family: var(--mono); font-size: .74rem; color: var(--ink-soft); }
.tog:hover { border-color: var(--ink); }
.tog.is-active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tog.is-active .n { color: color-mix(in srgb, var(--bg) 70%, transparent); }
.toggles.mini { padding: 4px; border: 1.5px solid var(--line); border-radius: 999px; background: var(--surface); gap: 2px; }
.toggles.mini .tog { border-color: transparent; padding: 7px 16px; }
.toggles.mini .tog:hover { border-color: transparent; background: var(--bg-tint); }
.toggles.mini .tog.is-active { background: var(--ink); }
.search { position: relative; flex: 1 1 240px; max-width: 360px; }
.search svg { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--ink-soft); pointer-events: none; }
.search input { width: 100%; padding: 11px 16px 11px 43px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); }
.search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.result-note { font-family: var(--mono); font-size: .78rem; color: var(--ink-soft); margin: 0 0 1rem; }
.empty-state { padding: 34px 26px; border: 1.5px dashed var(--line); border-radius: var(--radius); text-align: center; color: var(--ink-soft); }
.empty-state h3 { font-size: 1.25rem; color: var(--ink); margin-bottom: .4rem; }
.empty-state p { margin: 0 auto; max-width: 30em; font-size: .97rem; }
.empty-state .btn { margin-top: 1rem; }
.badge { display: inline-block; font-family: var(--mono); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); }

/* ---------- Works ---------- */
.cats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.cat { display: flex; flex-direction: column; gap: 8px; padding: 28px; min-height: 270px; text-decoration: none; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); transition: transform .25s, border-color .25s, box-shadow .25s; }
.cat:hover { transform: translateY(-4px); border-color: var(--ink); box-shadow: 6px 6px 0 var(--accent); }
.cat:nth-child(2):hover { box-shadow: 6px 6px 0 var(--lime); }
.cat h3 { font-size: 1.55rem; }
.cat p { color: var(--ink-soft); font-size: .97rem; margin: 0; }
.cat-count { font-family: var(--mono); font-size: .76rem; color: var(--accent-text); text-transform: uppercase; letter-spacing: .1em; }
.cat-list { margin-top: auto; padding-top: 14px; display: grid; gap: 4px; font-size: .92rem; }
.cat-list li { display: flex; gap: 8px; }
.cat-list li::before { content: ""; flex: none; width: 8px; height: 2px; background: var(--accent); margin-top: .8em; }
.cat-go { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: .93rem; color: var(--accent-text); margin-top: 12px; }
.cat:hover .cat-go svg { transform: translateX(4px); }
.cat-go svg { transition: transform .25s; }
.proj-results { display: grid; gap: 12px; margin-top: 1.4rem; }
.proj { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 18px; padding: 18px 22px; text-decoration: none; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); transition: border-color .2s, transform .2s; }
.proj:hover { border-color: var(--ink); transform: translateY(-2px); }
.proj b { font-family: var(--serif); font-size: 1.15rem; font-weight: 600; }
.proj span { font-family: var(--mono); font-size: .78rem; color: var(--ink-soft); }

.work-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; margin-top: 1.8rem; }
.card { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 28px; display: flex; flex-direction: column; transition: transform .25s, border-color .25s, box-shadow .25s; }
.card:hover { transform: translateY(-4px); border-color: var(--ink); box-shadow: 6px 6px 0 var(--accent); }
.card-feature { grid-column: 1 / -1; padding: 34px; background: var(--ink); color: var(--bg); border-color: var(--ink); }
.card-feature:hover { box-shadow: 6px 6px 0 var(--lime); }
.card-kind { font-family: var(--mono); font-size: .76rem; color: var(--accent-text); text-transform: uppercase; letter-spacing: .1em; margin-bottom: .8rem; }
.card-feature .card-kind { color: var(--lime); }
.card h3 { font-size: 1.4rem; margin-bottom: .7rem; }
.card-feature h3 { font-size: clamp(1.6rem, 3vw, 2.2rem); max-width: 18em; }
.card p { font-size: .98rem; color: var(--ink-soft); }
.card-feature p { color: color-mix(in srgb, var(--bg) 84%, transparent); max-width: 42em; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: .6rem; }
.tags li { font-family: var(--mono); font-size: .74rem; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink-soft); }
.card-feature .tags li { color: color-mix(in srgb, var(--bg) 72%, transparent); border-color: color-mix(in srgb, var(--bg) 30%, transparent); }
.card .text-link { margin-top: 14px; width: fit-content; font-size: .93rem; }
.card-feature .text-link { color: var(--lime); }
.card:target { outline: 3px solid var(--accent); outline-offset: 4px; }

/* ---------- About ---------- */
.about-top { display: grid; grid-template-columns: 300px 1fr; gap: clamp(32px, 6vw, 80px); align-items: center; }
.portrait { position: relative; aspect-ratio: 3 / 4; max-width: 300px; width: 100%; margin-inline: auto; border: 1.5px solid var(--ink); border-radius: var(--radius); overflow: hidden; background: var(--surface); box-shadow: 8px 8px 0 var(--lime); transform: rotate(1.2deg); display: grid; place-items: center; }
:root[data-theme="dark"] .portrait { box-shadow: 8px 8px 0 #4a5a1a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .portrait { box-shadow: 8px 8px 0 #4a5a1a; } }
.portrait img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center top; }
.avatar-fb { font-family: var(--serif); font-size: clamp(3.4rem, 9vw, 5.4rem); font-weight: 600; color: var(--accent-text); letter-spacing: -0.03em; }
.summary p.big { font-family: var(--serif); font-size: clamp(1.4rem, 2.6vw, 1.9rem); line-height: 1.3; max-width: 28em; margin-bottom: 1rem; }
.summary p { color: var(--ink-soft); font-size: 1.08rem; max-width: 38em; }
.summary .btns { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 1.6rem; }
.summary .quick { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 1.6rem; font-size: .93rem; color: var(--ink-soft); }
.summary .quick b { color: var(--ink); font-weight: 600; }

.interests { display: flex; flex-wrap: wrap; gap: 10px; }
.interests li { padding: 10px 20px; border-radius: 999px; background: var(--surface); border: 1.5px solid var(--line); font-weight: 500; transition: background .2s, color .2s, transform .2s, border-color .2s; }
.interests li:hover { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); transform: translateY(-2px) rotate(-1.5deg); }
.edu { display: grid; grid-template-columns: 170px 1fr; gap: 12px 24px; padding: 28px; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); }
.edu .when { font-family: var(--mono); font-size: .82rem; color: var(--accent-text); padding-top: 6px; }
.edu h3 { font-size: 1.4rem; margin-bottom: .3rem; }
.edu p { margin: 0; color: var(--ink-soft); }
.edu p + p { margin-top: .5rem; font-size: .96rem; }
.skills { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.skill { padding: 24px; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); }
.skill h3 { font-size: 1.2rem; margin-bottom: .4rem; }
.skill p { margin: 0; font-size: .95rem; color: var(--ink-soft); }
.langs { margin-top: 1.2rem; font-size: .95rem; color: var(--ink-soft); }
.langs b { color: var(--ink); }
.tool-groups { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px 28px; }
.tool-group { padding: 22px 0; border-top: 1.5px solid var(--ink); }
.tool-group h3 { font-size: 1.15rem; margin-bottom: 14px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pills li { padding: 6px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: .9rem; transition: background .2s, color .2s, transform .2s; }
.pills li:hover { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); transform: translateY(-2px) rotate(-1.5deg); }

/* ---------- Experience ---------- */
.timeline { border-left: 2px solid var(--ink); margin-left: 6px; }
.timeline > li { display: grid; grid-template-columns: 190px 1fr; gap: 24px; padding: 0 0 30px 30px; position: relative; }
.timeline > li::before { content: ""; position: absolute; left: -9px; top: 6px; width: 16px; height: 16px; border-radius: 50%; background: var(--bg); border: 2px solid var(--ink); }
.timeline > li.now::before { background: var(--accent); }
.when { font-size: .82rem; color: var(--ink-soft); padding-top: 6px; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
details summary { list-style: none; cursor: pointer; display: flex; flex-direction: column; gap: 2px; padding-right: 38px; position: relative; }
details summary::-webkit-details-marker { display: none; }
details summary::after { content: "+"; position: absolute; right: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; font-size: 1.1rem; line-height: 1; }
details[open] summary::after { content: "–"; background: var(--ink); color: var(--bg); border-color: var(--ink); }
.role { font-family: var(--serif); font-weight: 600; font-size: 1.3rem; line-height: 1.2; }
.org { color: var(--ink-soft); font-size: .95rem; }
.timeline details ul { margin-top: 14px; }
.timeline details li { position: relative; padding-left: 20px; margin-bottom: .6em; color: var(--ink-soft); font-size: .98rem; }
.timeline details li::before { content: ""; position: absolute; left: 0; top: .72em; width: 8px; height: 2px; background: var(--accent); }
.tools-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 1rem; }
.tools-row .result-note { margin: 0; }

/* ---------- Publications ---------- */
.strip { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 2rem; background: var(--surface); border: 1.5px solid var(--ink); border-radius: var(--radius); overflow: hidden; }
.strip li { padding: 18px 22px; border-right: 1px solid var(--line); }
.strip li:last-child { border-right: 0; }
.strip .mono { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-soft); margin-bottom: .3rem; }
.strip strong { font-family: var(--serif); font-size: clamp(1.5rem, 2.6vw, 2rem); line-height: 1.1; display: block; }
.strip small { display: block; color: var(--ink-soft); font-size: .84rem; margin-top: .25rem; line-height: 1.35; }
.papers { display: grid; gap: 18px; }
.paper { display: grid; grid-template-columns: 92px 1fr; gap: 20px; padding: 28px; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); transition: transform .25s, border-color .25s, box-shadow .25s; }
.paper:hover { transform: translateY(-3px); border-color: var(--ink); box-shadow: 6px 6px 0 var(--accent); }
.paper-year { font-family: var(--mono); font-size: 1.5rem; color: var(--accent-text); margin: 0; }
.paper h3 { font-size: 1.3rem; margin-bottom: .5rem; }
.paper-meta { color: var(--ink-soft); font-size: .93rem; margin-bottom: .6rem; }
.paper-sum { color: var(--ink-soft); font-size: .97rem; margin-bottom: .8rem; }

/* ---------- Certifications ---------- */
.certs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.cert { padding: 22px; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); transition: transform .25s, border-color .25s, box-shadow .25s; }
.cert:hover { transform: translateY(-3px); border-color: var(--ink); box-shadow: 5px 5px 0 var(--lime); }
.cert h3 { font-size: 1.15rem; }
.cert-by { color: var(--ink-soft); font-size: .93rem; margin: 0; }
.cert-date { margin: auto 0 0; padding-top: 8px; font-family: var(--mono); font-size: .78rem; color: var(--accent-text); }

/* ---------- Activity ---------- */
.posts { display: grid; gap: 16px; }
.post { display: grid; grid-template-columns: 150px 1fr; gap: 12px 24px; padding: 24px 26px; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); transition: transform .25s, border-color .25s, box-shadow .25s; }
.post:hover { transform: translateY(-3px); border-color: var(--ink); box-shadow: 6px 6px 0 var(--accent); }
.post-side { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.post-date { font-family: var(--mono); font-size: .8rem; color: var(--ink-soft); }
.post h3 { font-size: 1.25rem; margin-bottom: .4rem; }
.post p { margin: 0 0 .6rem; color: var(--ink-soft); font-size: .97rem; }
.post .text-link { font-size: .93rem; }

/* ---------- Contact ---------- */
.contact-grid { display: grid; grid-template-columns: 1fr 1.05fr; gap: 20px; align-items: start; margin-top: 1.8rem; }
.contact-card { padding: 32px; border-radius: var(--radius); }
.contact-info { background: var(--ink); color: var(--bg); }
.contact-info h2 { font-size: 1.7rem; margin-bottom: .8rem; }
.contact-info p { color: color-mix(in srgb, var(--bg) 78%, transparent); }
.contact-lines { margin: 1.4rem 0 0; display: grid; gap: 10px; }
.contact-lines li { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.contact-lines .mono { font-size: .76rem; text-transform: uppercase; letter-spacing: .1em; color: color-mix(in srgb, var(--bg) 62%, transparent); min-width: 78px; }
.contact-info .text-link { color: var(--lime); }
.contact-btns { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 1.6rem; }
.contact-info .btn { border-color: var(--bg); color: var(--bg); }
.contact-info .btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); box-shadow: 4px 4px 0 var(--lime); }
.contact-info .btn-ghost:hover { background: var(--bg); color: var(--ink); }
.form-card { background: var(--surface); border: 1.5px solid var(--line); }
.form { display: grid; gap: 16px; }
.form h2 { font-size: 1.6rem; }
.field { display: grid; gap: 6px; }
.field label { font-size: .88rem; font-weight: 600; }
.field input, .field select, .field textarea { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--bg); }
.field textarea { min-height: 130px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.form-note { font-size: .86rem; color: var(--ink-soft); margin: 0; }

/* ---------- Footer & floaters ---------- */
.footer { padding: 26px 0 30px; border-top: 1px solid var(--line); margin-top: 48px; text-align: center; font-size: .9rem; color: var(--ink-soft); }
.footer p { margin: 0; }
.to-top { position: fixed; right: max(18px, env(safe-area-inset-right, 0px)); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); width: 46px; height: 46px; border-radius: 50%; border: 1.5px solid var(--ink); background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; z-index: 40; opacity: 0; transform: translateY(14px); pointer-events: none; transition: opacity .25s, transform .25s; }
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: var(--accent); z-index: 60; }
.reveal { transition: opacity .7s ease, transform .7s ease; }
.reveal.pre { opacity: .35; transform: translateY(16px); }
main { animation: pagein .5s ease both; }
@keyframes pagein { from { opacity: 0; transform: translateY(8px); } }

/* =====================================================
   HOME: glass hub over a photo
   ===================================================== */
.home { position: relative; min-height: 100vh; display: flex; flex-direction: column; justify-content: center; }
.home main { animation: none; }
.home .bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; background: var(--bg); }
.home .bg-photo { position: absolute; inset: 0; background: url("background.jpg") center / cover no-repeat; }
.home .bg-photo::after { content: ""; position: absolute; inset: 0; background: var(--scrim); }

.home-theme { position: fixed; top: calc(16px + env(safe-area-inset-top, 0px)); right: max(16px, env(safe-area-inset-right, 0px)); z-index: 50; border-radius: 50%; background: var(--glass-2); border-color: var(--glass-line); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.glass { background: var(--glass); -webkit-backdrop-filter: blur(22px) saturate(1.6); backdrop-filter: blur(22px) saturate(1.6); border: 1px solid var(--glass-line); box-shadow: var(--glass-shadow), inset 0 1px 0 rgba(255, 255, 255, .28); }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .glass { background: var(--glass-2); } }

.hub-wrap { width: min(1120px, 100%); margin-inline: auto; padding: clamp(60px, 7vw, 84px) max(16px, env(safe-area-inset-left, 0px)) 14px; padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.hub { position: relative; display: grid; grid-template-columns: 41% 1fr; min-height: 590px; border-radius: 38px; overflow: hidden; }

/* Portrait panel: the right edge is a smooth ellipse, with a gradient rim following it */
.hub-photo { position: relative; min-height: 100%; }
.hub-photo .rim, .hub-photo .pic { position: absolute; top: 0; bottom: 0; left: 0; clip-path: ellipse(100% 110% at 0% 50%); }
.hub-photo .rim { right: 0; background: linear-gradient(160deg, var(--accent), #ffb347 55%, var(--lime)); }
.hub-photo .pic { right: 7px; background: var(--glass-2); display: grid; place-items: center; overflow: hidden; }
.hub-photo .pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 18%; }
.hub-photo .avatar-fb { font-size: clamp(4rem, 8vw, 6.5rem); }
.photo-tag { position: absolute; left: 22px; bottom: 22px; z-index: 2; padding: 7px 16px; border-radius: 999px; font-family: var(--mono); font-size: .76rem; white-space: nowrap; }

.hub-main { display: flex; flex-direction: column; justify-content: center; min-width: 0; padding: clamp(26px, 3.4vw, 42px) clamp(22px, 3.4vw, 44px) clamp(26px, 3.4vw, 38px) clamp(22px, 3vw, 40px); }
.status { display: inline-flex; align-items: center; gap: 10px; align-self: flex-start; max-width: 100%; padding: 7px 8px 7px 14px; margin-bottom: 1.1rem; border-radius: 999px; text-decoration: none; font-size: .86rem; background: var(--glass-2); border: 1px solid var(--glass-line); transition: transform .2s; }
.status:hover { transform: translateY(-2px); }
.status .go { background: var(--ink); color: var(--bg); padding: 4px 12px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: #3fbf5f; box-shadow: 0 0 0 0 rgba(63, 191, 95, .6); animation: pulse 2.2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 9px rgba(63, 191, 95, 0); } 100% { box-shadow: 0 0 0 0 rgba(63, 191, 95, 0); } }
.hub-name { font-size: clamp(2.5rem, 5.4vw, 4.5rem); line-height: 1; letter-spacing: -0.025em; }
.hub-name em { display: block; font-style: italic; background: linear-gradient(95deg, var(--accent), #ff9a3c); -webkit-background-clip: text; background-clip: text; color: transparent; padding-bottom: .08em; }
.hub-say { font-family: var(--serif); font-size: clamp(1.05rem, 1.8vw, 1.3rem); line-height: 1.3; margin: .9rem 0 .9rem; max-width: 24em; }
.hub-roles { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 1.4rem; }
.hub-roles li { padding: 5px 13px; border-radius: 999px; font-size: .84rem; background: var(--glass-2); border: 1px solid var(--glass-line); }
.hub-links { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 1.2rem; }
.hub-link { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px 10px 16px; border-radius: 16px; text-decoration: none; background: var(--glass-2); border: 1px solid var(--glass-line); transition: transform .2s, border-color .2s, background .2s; }
.hub-link b { display: block; font-weight: 600; font-size: .98rem; line-height: 1.3; }
.hub-link small { display: block; color: var(--ink-soft); font-size: .78rem; line-height: 1.3; }
.hub-link i { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: var(--bg); display: grid; place-items: center; transition: transform .25s, background .25s; }
.hub-link:hover { transform: translateY(-2px); border-color: var(--accent); }
.hub-link:hover i { background: var(--accent); color: var(--accent-ink); transform: translateX(3px); }
.hub-link.cv { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.hub-link.cv small { color: color-mix(in srgb, var(--accent-ink) 78%, transparent); }
.hub-link.cv i { background: var(--accent-ink); color: var(--accent); }
.hub-social { display: flex; gap: 10px; }
.hub-social a { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--glass-2); border: 1px solid var(--glass-line); text-decoration: none; transition: transform .25s, background .25s, color .25s; }
.hub-social a:hover { transform: translateY(-3px); background: var(--accent); color: var(--accent-ink); }
.home-foot { text-align: center; font-size: .86rem; color: var(--ink); padding: 10px 16px 26px; }
.home-foot p { margin: 0; display: inline-block; padding: 5px 16px; border-radius: 999px; background: var(--glass); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }

/* ---------- v6 additions ---------- */

/* Back-to-home button at the top left of every inner page */
.page-top { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 1.4rem; }
.btn-home, .page-top .crumb { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; margin: 0; border-radius: 999px; font-family: var(--sans); font-size: .9rem; font-weight: 600; text-decoration: none; transition: background .2s, color .2s, border-color .2s, transform .2s; }
.btn-home { background: var(--ink); color: var(--bg); border: 1.5px solid var(--ink); }
.btn-home:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); transform: translateX(-2px); }
.page-top .crumb { background: var(--surface); color: var(--ink); border: 1.5px solid var(--line); }
.page-top .crumb:hover { border-color: var(--ink); color: var(--ink); transform: translateX(-2px); }

/* About: skills and the education card react like the project cards */
.skill { transition: transform .25s, border-color .25s, box-shadow .25s; }
.skill:hover { transform: translateY(-4px); border-color: var(--ink); box-shadow: 6px 6px 0 var(--accent); }
a.edu { text-decoration: none; color: inherit; transition: transform .25s, border-color .25s, box-shadow .25s; }
a.edu:hover { transform: translateY(-4px); border-color: var(--ink); box-shadow: 6px 6px 0 var(--accent); }
.edu-go { display: inline-flex; align-items: center; gap: 8px; margin-top: .9rem; font-weight: 600; font-size: .93rem; color: var(--accent-text); }
a.edu:hover .edu-go svg { transform: translateX(4px); }
.edu-go svg { transition: transform .25s; }

/* Publications: keywords on each paper */
.paper .tags { margin: 0 0 .9rem; padding-top: 0; }

/* Certifications: whole card opens the certificate */
.cert { position: relative; }
.cert-link { font-size: .93rem; width: fit-content; }
.cert-link::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.cert.has-link { cursor: pointer; }

/* Experience: cards that open a details panel */
.xp-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.xp-card { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 26px; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); cursor: pointer; transition: transform .25s, border-color .25s, box-shadow .25s; }
.xp-card:hover { transform: translateY(-4px); border-color: var(--ink); box-shadow: 6px 6px 0 var(--accent); }
.xp-card.now { border-color: var(--ink); }
.xp-top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; margin-bottom: .5rem; }
.xp-when { font-size: .78rem; color: var(--ink-soft); }
.xp-now { font-family: var(--mono); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink); display: inline-flex; align-items: center; gap: 6px; }
.xp-now::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #3fbf5f; }
.xp-card h3 { font-size: 1.3rem; line-height: 1.2; }
.xp-open { background: none; border: 0; padding: 0; margin: 0; font: inherit; color: inherit; text-align: left; letter-spacing: inherit; cursor: pointer; }
.xp-open::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.xp-open:focus-visible { outline: none; }
.xp-open:focus-visible::after { outline: 3px solid var(--accent); outline-offset: 3px; }
.xp-org { color: var(--ink-soft); font-size: .95rem; margin: 0; }
.xp-teaser { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; color: var(--ink-soft); font-size: .96rem; margin: .5rem 0 1rem; }
.xp-more { margin-top: auto; display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: .92rem; color: var(--accent-text); }
.xp-more svg { transition: transform .25s; }
.xp-card:hover .xp-more svg { transform: translateX(4px); }
.xp-detail { display: none; }

.xp-dialog { border: 1.5px solid var(--ink); border-radius: var(--radius); background: var(--surface); color: var(--ink); padding: 0; width: min(680px, calc(100% - 32px)); max-height: min(86vh, 760px); box-shadow: 8px 8px 0 var(--accent); }
.xp-dialog::backdrop { background: rgba(20, 15, 10, .55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.xp-dialog-in { position: relative; padding: 30px 30px 28px; }
.xp-close { position: absolute; top: 16px; right: 16px; width: 38px; height: 38px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--bg); font-size: 1.3rem; line-height: 1; display: grid; place-items: center; }
.xp-close:hover { border-color: var(--ink); }
.xp-dmeta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: .9rem; padding-right: 48px; }
.xp-dialog h2 { font-size: 1.7rem; margin-bottom: .3rem; padding-right: 44px; }
.xp-dorg { color: var(--ink-soft); margin: 0 0 1.2rem; }
.xp-dlist li { position: relative; padding-left: 20px; margin-bottom: .75em; color: var(--ink-soft); }
.xp-dlist li::before { content: ""; position: absolute; left: 0; top: .72em; width: 8px; height: 2px; background: var(--accent); }
html:has(dialog[open]) { overflow: hidden; }

/* Landing on a card from a link elsewhere */
.is-target { outline: 3px solid var(--accent); outline-offset: 4px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .menu-btn { display: grid; }
  .nav-links { position: absolute; left: 0; right: 0; top: calc(100% + 6px); flex-direction: column; align-items: stretch; gap: 4px; background: var(--bg); padding: 12px; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 18px 40px -20px rgba(0, 0, 0, .35); transform: translateY(-8px); opacity: 0; visibility: hidden; transition: all .25s; }
  .nav-links.open { transform: none; opacity: 1; visibility: visible; }
  .nav-links a { padding: 13px 16px; font-size: 1.02rem; }
  .nav-links .nav-cta { margin: 6px 0 0; text-align: center; }
}
@media (max-width: 900px) {
  .cats, .skills, .tool-groups, .certs { grid-template-columns: repeat(2, 1fr); }
  .about-top { grid-template-columns: 1fr; }
  .portrait { max-width: 260px; }
  .strip { grid-template-columns: repeat(2, 1fr); }
  .strip li:nth-child(2) { border-right: 0; }
  .strip li:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .contact-grid { grid-template-columns: 1fr; }
  .timeline > li { grid-template-columns: 1fr; gap: 4px; }
  .when { padding-top: 0; flex-direction: row; align-items: center; gap: 12px; }

  .hub { grid-template-columns: 1fr; min-height: 0; border-radius: 30px; }
  .hub-photo { height: 300px; min-height: 0; }
  .hub-photo .rim, .hub-photo .pic { left: 0; right: 0; top: 0; clip-path: ellipse(110% 100% at 50% 0%); }
  .hub-photo .rim { bottom: 0; }
  .hub-photo .pic { bottom: 7px; right: 0; }
  .hub-photo .pic img { object-position: center 20%; }
  .photo-tag { left: 50%; transform: translateX(-50%); bottom: 26px; }
  .hub-main { padding-top: 12px; }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  .page-head::before { width: 300px; height: 300px; right: -130px; top: -150px; }
  .page-head::after { width: 440px; height: 440px; right: -220px; top: -230px; }
  .brand-name { display: none; }
  .cats, .skills, .tool-groups, .certs, .work-grid { grid-template-columns: 1fr; }
  .card-feature { padding: 26px; }
  .paper, .edu, .post { grid-template-columns: 1fr; gap: 6px; }
  .post-side { flex-direction: row; align-items: center; gap: 12px; }
  .controls { flex-direction: column; align-items: stretch; }
  .search { max-width: none; flex: none; width: 100%; }
  .toggles.mini { align-self: flex-start; border-radius: 22px; }
  .toggles.mini .tog { padding: 7px 13px; font-size: .88rem; }
  .page-head h1 .scribble { white-space: normal; }
  .hub-links { grid-template-columns: 1fr; }
  .status { font-size: .8rem; }
}
@media (max-width: 420px) {
  .strip { grid-template-columns: 1fr; }
  .strip li { border-right: 0 !important; border-bottom: 1px solid var(--line); }
  .strip li:last-child { border-bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal.pre { opacity: 1; transform: none; }
  .page-head h1 .scribble path { stroke-dashoffset: 0; }
}
@media print { .nav, .to-top, .progress, .home .bg, .controls, .home-theme { display: none; } }

@media (max-width: 760px) {
  .xp-grid { grid-template-columns: 1fr; }
  .xp-dialog-in { padding: 24px 22px 22px; }
}
