:root {
  --bg: #fbf8f6;
  --bg-alt: #f3ede9;
  --card: #ffffff;
  --text: #2a2321;
  --muted: #6e6360;
  --border: #e6dcd7;
  --accent: #9b2213;
  --accent-soft: #f7e3df;
  --accent-text: #ffffff;
  --shadow: 0 1px 2px rgba(60, 20, 10, .05), 0 6px 24px rgba(60, 20, 10, .07);
  --radius: 14px;
  --font-head: "Montserrat", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #161211;
  --bg-alt: #1e1917;
  --card: #231d1b;
  --text: #f1e9e6;
  --muted: #a99c97;
  --border: #3a302d;
  --accent: #ec6b55;
  --accent-soft: #3b211c;
  --accent-text: #1a0f0c;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 28px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 var(--font-body);
  transition: background .3s, color .3s;
}
h1, h2, h3 { font-family: var(--font-head); line-height: 1.15; margin: 0 0 .5em; }
h2 { font-size: clamp(1.6rem, 3vw, 2.1rem); color: var(--accent); letter-spacing: -.01em; }
h3 { font-size: 1.05rem; }
a { color: var(--accent); }
button { font: inherit; cursor: pointer; }

/* NAV */
.nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 1rem;
  padding: .75rem clamp(1rem, 4vw, 3rem);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav-logo { display: inline-flex; line-height: 0; border-radius: 8px; }
.logo-mark { display: block; transition: transform .2s; }
.logo-hex { fill: var(--accent); }
.logo-n { fill: var(--accent-text); }
.nav-logo:hover .logo-mark { transform: rotate(-8deg) scale(1.05); }
@media (prefers-reduced-motion: reduce) { .nav-logo:hover .logo-mark { transform: none; } }
.nav-links { display: flex; gap: 1.4rem; margin-left: auto; }
.nav-links a { color: var(--muted); text-decoration: none; font-weight: 500; font-size: .95rem; }
.nav-links a:hover, .nav-links a.active { color: var(--accent); }
.icon-btn {
  background: none; border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; width: 38px; height: 38px; display: grid; place-items: center;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
[data-theme="light"] .moon, [data-theme="dark"] .sun { display: none; }
@media (max-width: 760px) { .nav-links { display: none; } .icon-btn#theme-toggle { margin-left: auto; } }

/* LAYOUT */
main { padding: 0 clamp(1rem, 4vw, 3rem); }
.section { max-width: 1080px; margin: 0 auto; padding: 4.5rem 0 1rem; }
.lead { font-size: 1.12rem; color: var(--muted); max-width: 760px; }
.hint { color: var(--muted); margin-top: -.5rem; }

/* HERO */
/* Profile photo: a hexagon like the logo, accent-tinted until hovered, focused or tapped. */
.avatar-wrap {
  --size: clamp(130px, 24vw, 176px);
  --hex: polygon(50% 3%, 90.7% 26.5%, 90.7% 73.5%, 50% 97%, 9.3% 73.5%, 9.3% 26.5%);
  position: relative; width: var(--size); height: var(--size);
  margin: 0 auto 1.6rem; outline: none; cursor: pointer;
  filter: drop-shadow(0 8px 18px rgba(60, 20, 10, .18));
}
.avatar-wrap::before {            /* offset hexagon outline behind the photo */
  content: ""; position: absolute; inset: 0; background: var(--accent);
  -webkit-mask: var(--hex-outline) center / 100% 100% no-repeat;
          mask: var(--hex-outline) center / 100% 100% no-repeat;
  transform: translate(12px, 10px); transition: transform .3s ease;
}
.avatar-wrap::after {             /* accent shade over the photo */
  content: ""; position: absolute; inset: 0; clip-path: var(--hex);
  background: var(--accent); mix-blend-mode: multiply; opacity: .55;
  transition: opacity .3s ease; pointer-events: none;
}
.avatar {
  position: relative; display: block; width: 100%; height: 100%;
  object-fit: cover; clip-path: var(--hex);
  filter: grayscale(100%) contrast(1.05); transition: filter .3s ease;
}
.avatar-wrap:hover::after, .avatar-wrap:focus-visible::after, .avatar-wrap:active::after { opacity: 0; }
.avatar-wrap:hover .avatar, .avatar-wrap:focus-visible .avatar, .avatar-wrap:active .avatar { filter: none; }
.avatar-wrap:hover::before, .avatar-wrap:focus-visible::before { transform: translate(6px, 5px); }
[data-theme="dark"] .avatar-wrap::after { mix-blend-mode: screen; opacity: .35; }
[data-theme="dark"] .avatar-wrap { filter: drop-shadow(0 8px 20px rgba(0, 0, 0, .45)); }
:root {
  --hex-outline: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpolygon points='50,3 90.7,26.5 90.7,73.5 50,97 9.3,73.5 9.3,26.5' fill='none' stroke='black' stroke-width='2.2' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* Intro: hexagon outline draws, fills, the N appears, then the logo shrinks away. */
.intro-loader { display: none; }
html.intro { overflow: hidden; }
html.intro .intro-loader {
  display: grid; place-items: center; position: fixed; inset: 0; z-index: 1000;
  background: var(--bg); animation: intro-out .45s ease 2.05s forwards;
}
.intro-hex-line {
  fill: none; stroke: var(--accent); stroke-width: 4; stroke-linejoin: round;
  stroke-dasharray: 100; stroke-dashoffset: 100;
  animation: intro-draw 1.1s ease-in-out .2s forwards;
}
.intro-hex-fill { fill: var(--accent); opacity: 0; animation: intro-fade .35s ease 1.25s forwards; }
.intro-n { fill: var(--accent-text); opacity: 0; transform-origin: 50% 50%; animation: intro-pop .35s ease 1.45s forwards; }
.intro-mark { overflow: visible; animation: intro-shrink .4s ease-in 1.9s forwards; }
@keyframes intro-draw { to { stroke-dashoffset: 0; } }
@keyframes intro-fade { to { opacity: 1; } }
@keyframes intro-pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: scale(1); } }
@keyframes intro-shrink { to { transform: scale(.25); opacity: 0; } }
@keyframes intro-out { to { opacity: 0; visibility: hidden; } }
@media (prefers-reduced-motion: reduce) {
  .avatar, .avatar-wrap::before, .avatar-wrap::after { transition: none; }
  html.intro .intro-loader { display: none; }
  html.intro { overflow: auto; }
}
.hero { min-height: 78vh; display: grid; place-items: center; text-align: center; position: relative; }
.hero::before {
  content: ""; position: absolute; inset: 10% 15%; z-index: -1;
  background: radial-gradient(closest-side, var(--accent-soft), transparent);
  filter: blur(20px);
}
.eyebrow { color: var(--accent); font-weight: 600; letter-spacing: .1em; text-transform: uppercase; margin: 0; }
.hero h1 { font-size: clamp(2.4rem, 7vw, 4.6rem); font-weight: 800; letter-spacing: -.02em; margin: .2em 0; }
.hero-title { font-size: 1.25rem; color: var(--muted); margin: 0; }
.dot { color: var(--accent); }
.typed-line { font: 600 1.15rem var(--font-head); min-height: 1.8em; color: var(--text); margin: 1.2rem 0 2rem; }
.caret { color: var(--accent); animation: blink 1s steps(1) infinite; margin-left: 2px; }
@keyframes blink { 50% { opacity: 0; } }
.hero-cta { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: center; }

.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .75rem 1.25rem; border-radius: 999px;
  border: 1.5px solid var(--border); background: var(--card); color: var(--text);
  text-decoration: none; font-weight: 600; transition: transform .15s, border-color .15s, background .15s;
}
.btn:hover { transform: translateY(-2px); border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.ghost { background: transparent; }

/* STATS */
.stats {
  max-width: 1080px; margin: 0 auto; display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem;
}
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.4rem; box-shadow: var(--shadow); }
.stat-num { font: 800 2.4rem var(--font-head); color: var(--accent); }
.stat-label { color: var(--muted); font-size: .95rem; }

/* SKILLS */
.skill-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.4rem 2rem; margin-top: 1.5rem; }
.skill-group h3 { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip {
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  padding: .35rem .8rem; border-radius: 999px; font-size: .9rem; transition: all .15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.skill-result { margin-top: 1.2rem; padding: .8rem 1rem; border-radius: 10px; background: var(--accent-soft); }
.link-btn { background: none; border: none; color: var(--accent); padding: 0; font-weight: 600; }
.link-btn:hover { text-decoration: underline; }

/* TIMELINE */
.timeline { list-style: none; padding: 0; margin: 1.5rem 0 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 9px; top: 12px; bottom: 12px; width: 2px; background: var(--border); }
.job { position: relative; margin-bottom: .8rem; transition: opacity .25s; }
.job-head {
  width: 100%; display: grid; grid-template-columns: 20px 1fr auto 20px; align-items: center; gap: 1rem;
  background: none; border: none; color: inherit; text-align: left; padding: .6rem 0;
}
.job-dot { width: 20px; height: 20px; border-radius: 50%; background: var(--bg); border: 3px solid var(--accent); z-index: 1; }
.job-main { display: flex; align-items: center; gap: .9rem; min-width: 0; }
.job-text { display: flex; flex-direction: column; min-width: 0; }
.job-logo {
  flex: 0 0 auto; width: 80px; height: 40px; border-radius: 8px; overflow: hidden;
  background: #fff; border: 1px solid var(--border); display: grid; place-items: center;
}
.job-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.job-role { font: 700 1.1rem var(--font-head); }
.job-company { color: var(--muted); }
.job-dates { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.chev { color: var(--muted); transition: transform .2s; font-size: 1.2rem; }
.job-head[aria-expanded="true"] .chev { transform: rotate(180deg); }
.job-head:hover .job-role { color: var(--accent); }
.job-body { margin-left: 36px; padding: .2rem 1.2rem 1rem; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.job-body ul { padding-left: 1.1rem; }
.job-body li { margin: .35rem 0; }
.job-site { display: inline-block; margin-top: .8rem; font-weight: 600; text-decoration: none; }
.job-site:hover { text-decoration: underline; }
@media (max-width: 600px) {
  .job-head { grid-template-columns: 20px 1fr 20px; }
  .job-logo { width: 64px; height: 32px; }
  .job-dates { grid-column: 2; grid-row: 2; }
  .job-body { margin-left: 0; }
}

.tags { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .6rem; }
.tag { font-size: .78rem; padding: .15rem .55rem; border-radius: 6px; background: var(--bg-alt); color: var(--muted); }
.tag.hit { background: var(--accent); color: var(--accent-text); }

/* skill filter dimming */
.dim { opacity: .3; }

/* PROJECTS */
.tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin: 1rem 0 1.5rem; }
.tab { border: 1px solid var(--border); background: transparent; color: var(--muted); padding: .4rem 1rem; border-radius: 999px; font-weight: 600; }
.tab.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.project-grid, .highlight-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1.1rem; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.3rem; box-shadow: var(--shadow); transition: transform .2s, opacity .25s, border-color .2s;
}
.project { display: flex; flex-direction: column; }
.project:hover { transform: translateY(-4px); border-color: var(--accent); }
.project p { color: var(--muted); flex: 1; }
.project .ask-about { align-self: flex-start; margin-top: .9rem; font-size: .9rem; }
.project.hidden-cat { display: none; }
.badge { align-self: flex-start; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: .2rem .6rem; border-radius: 6px; margin-bottom: .7rem; background: var(--accent-soft); color: var(--accent); }
.highlight-grid ul { padding-left: 1.1rem; margin: 0; color: var(--muted); }
.highlight-grid li { margin: .4rem 0; }
.highlight-grid h3 { color: var(--accent); }

/* CONTACT */
.contact { text-align: center; padding-bottom: 5rem; }
.contact .lead { margin: 0 auto 1.5rem; }
.contact-row { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: center; }
.copied { color: var(--accent); font-weight: 600; }
.footer { text-align: center; color: var(--muted); padding: 2rem 1rem 6rem; border-top: 1px solid var(--border); font-size: .9rem; }

/* REVEAL ON SCROLL */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .7s ease, transform .7s ease; }
.reveal.visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}

/* CHAT */
.chat-fab {
  position: fixed; right: 1.4rem; bottom: calc(1.4rem + env(safe-area-inset-bottom, 0px)); z-index: 60;
  width: 60px; height: 60px; border-radius: 50%; border: none;
  background: var(--accent); color: var(--accent-text); box-shadow: 0 8px 24px rgba(155, 34, 19, .35);
  display: grid; place-items: center; transition: transform .2s;
}
.chat-fab:hover { transform: scale(1.08); }
.chat-fab::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid var(--accent); animation: pulse 2.4s ease-out infinite;
}
.chat-fab.seen::after { display: none; }
@keyframes pulse { 0% { opacity: .8; transform: scale(1); } 100% { opacity: 0; transform: scale(1.4); } }

.chat {
  position: fixed; right: 1.4rem; bottom: calc(6rem + env(safe-area-inset-bottom, 0px)); z-index: 70;
  width: min(390px, calc(100vw - 2rem)); height: min(580px, calc(100vh - 8rem));
  display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25); overflow: hidden;
  animation: pop .2s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1rem; background: var(--accent); color: var(--accent-text); }
.chat-head small { display: block; opacity: .85; font-size: .78rem; }
.chat-head .icon-btn { border-color: transparent; color: inherit; }
.chat-log { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .7rem; }
.msg { max-width: 88%; padding: .6rem .9rem; border-radius: 14px; font-size: .94rem; line-height: 1.5; overflow-wrap: anywhere; }
.msg p { margin: 0 0 .5em; } .msg p:last-child { margin: 0; }
.msg ul { margin: .3em 0; padding-left: 1.1rem; }
.msg.bot { background: var(--bg-alt); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.user { background: var(--accent); color: var(--accent-text); align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.error { background: transparent; border: 1px dashed var(--accent); color: var(--accent); }
.typing span { display: inline-block; width: 7px; height: 7px; margin: 0 2px; border-radius: 50%; background: var(--muted); animation: bounce 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; } .typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: none; opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }
.suggestions { display: flex; flex-wrap: wrap; gap: .4rem; }
.suggest { border: 1px solid var(--accent); color: var(--accent); background: transparent; border-radius: 999px; padding: .3rem .75rem; font-size: .83rem; }
.suggest:hover { background: var(--accent-soft); }
.chat-form { display: flex; gap: .5rem; padding: .75rem; border-top: 1px solid var(--border); }
.chat-form input {
  flex: 1; border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 999px; padding: .65rem 1rem; font: inherit; outline: none;
}
.chat-form input:focus { border-color: var(--accent); }
.send { width: 42px; border-radius: 50%; border: none; background: var(--accent); color: var(--accent-text); }
.send:disabled { opacity: .5; cursor: default; }
@media (max-width: 480px) {
  .chat { right: .5rem; left: .5rem; width: auto; bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px)); }
}

/* WRITING / BLOG */
.post-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1.1rem; }
.post-card { display: flex; flex-direction: column; color: var(--text); text-decoration: none; }
.post-card:hover { transform: translateY(-4px); border-color: var(--accent); }
.post-card h3 { margin-top: .2rem; }
.post-summary { color: var(--muted); flex: 1; margin: 0; }
.post-meta { color: var(--muted); font-size: .85rem; margin: 0; }
.post-more { color: var(--accent); font-weight: 600; font-size: .9rem; margin-top: .9rem; }
.see-all { margin-top: 1.5rem; }
.nav-links-always { display: flex !important; }
.blog-head { padding-bottom: 0; }
.blog-title { font-size: clamp(2rem, 5vw, 2.8rem); color: var(--accent); }
.blog-list-section { padding-top: 2rem; padding-bottom: 4rem; }
.post { max-width: 720px; padding-bottom: 4rem; }
.post-back { text-decoration: none; font-weight: 600; font-size: .92rem; }
.post-header { margin: 1.5rem 0 2rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--border); }
.post-header h1 { font-size: clamp(1.8rem, 4.5vw, 2.5rem); }
.post-body { font-size: 1.06rem; line-height: 1.75; overflow-wrap: anywhere; }
.post-body h2 { font-size: 1.45rem; margin-top: 2.2rem; }
.post-body h3 { margin-top: 1.6rem; }
.post-body li { margin: .35rem 0; }
.post-body blockquote { margin: 1.5rem 0; padding: .8rem 1.2rem; border-left: 4px solid var(--accent); background: var(--bg-alt); border-radius: 0 10px 10px 0; }
.post-body blockquote p { margin: .4rem 0; }
.post-body code { background: var(--bg-alt); padding: .1rem .35rem; border-radius: 5px; font-size: .92em; }
.post-body pre { background: var(--bg-alt); padding: 1rem; border-radius: 10px; overflow-x: auto; }
.post-body pre code { background: none; padding: 0; }
.post-body img { max-width: 100%; border-radius: 10px; }
.post-body table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; }
.post-body th, .post-body td { border: 1px solid var(--border); padding: .5rem .75rem; text-align: left; }
.post-footer { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
