/* ══════════════════════════════════════════════
   RESET & TOKENS
   ══════════════════════════════════════════════ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #f8f5f0;
  --bg-alt: #f0ece4;
  --surface: #eae6dc;
  --ink: #1a1816;
  --ink-2: #44403a;
  --ink-3: #857e74;
  --accent: #2a4a3e;
  --accent-lt: #3d6b5c;
  --accent-bg: rgba(42, 74, 62, .06);
  --rule: #d4cfc6;
  --rule-lt: #e4e0d8;
  --serif: 'EB Garamond', Georgia, 'Times New Roman', serif;
  --mono: 'DM Mono', 'Courier New', Consolas, monospace;
  --ease: cubic-bezier(.25, .46, .45, .94);
  --radius: 3px;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.78;
  min-height: 100vh;
}

::selection {
  background: rgba(42, 74, 62, .15);
  color: var(--ink);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color .2s var(--ease), border-color .2s var(--ease);
}

a:hover {
  color: var(--accent-lt);
}

/* ══════════════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════════════ */
.page {
  max-width: 740px;
  margin: 0 auto;
  padding: 0 2rem;
}

/* ══════════════════════════════════════════════
   HEADER
   ══════════════════════════════════════════════ */
header {
  padding: 4.5rem 0 2.5rem;
  border-bottom: 1px solid var(--rule);
}

.header-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2rem;
  align-items: center;
}

.name {
  font-size: clamp(2rem, 5vw, 2.8rem);
  font-weight: 500;
  letter-spacing: -.02em;
  line-height: 1.15;
  color: var(--ink);
}

.title-line {
  font-family: var(--mono);
  font-size: .75rem;
  font-weight: 300;
  color: var(--ink-3);
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-top: .65rem;
}

.title-line .sep {
  margin: 0 .5em;
  opacity: .35;
}

.quick-links {
  margin-top: 1rem;
  display: flex;
  gap: 1.2rem;
  flex-wrap: wrap;
}

.quick-links a {
  font-family: var(--mono);
  font-size: .68rem;
  font-weight: 400;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-3);
  border-bottom: 1px solid transparent;
  padding-bottom: 1px;
  transition: color .2s var(--ease), border-color .2s var(--ease);
}

.quick-links a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.avatar {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--rule);
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .08);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  transition: transform .4s var(--ease);
}

.avatar:hover img {
  transform: scale(1.05);
}

/* ══════════════════════════════════════════════
   NAV
   ══════════════════════════════════════════════ */
nav {
  padding: .85rem 0;
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  background: rgba(248, 245, 240, .92);
}

nav ul {
  list-style: none;
  display: flex;
  gap: 1.6rem;
  flex-wrap: wrap;
}

nav a {
  font-family: var(--mono);
  font-size: .7rem;
  font-weight: 400;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
  text-decoration: none;
  padding: .2rem 0;
  border-bottom: 1.5px solid transparent;
  transition: color .2s var(--ease), border-color .2s var(--ease);
}

nav a:hover,
nav a.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ══════════════════════════════════════════════
   SECTIONS
   ══════════════════════════════════════════════ */
section {
  padding: 3rem 0;
  border-bottom: 1px solid var(--rule-lt);
}

section:last-of-type {
  border-bottom: none;
}

.section-label {
  font-family: var(--mono);
  font-size: .66rem;
  font-weight: 300;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 1.4rem;
  display: flex;
  align-items: center;
  gap: .6rem;
}

.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--rule-lt);
}

/* ══════════════════════════════════════════════
   ABOUT
   ══════════════════════════════════════════════ */
#about p {
  color: var(--ink-2);
  max-width: 640px;
}

#about p+p {
  margin-top: 1rem;
}

.affil-block {
  margin-top: 1.8rem;
  padding: 1.1rem 1.3rem;
  background: var(--accent-bg);
  border-left: 2px solid var(--accent);
  font-size: .88rem;
  color: var(--ink-2);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.affil-block strong {
  color: var(--ink);
  font-weight: 500;
}

/* ══════════════════════════════════════════════
   RESEARCH INTERESTS
   ══════════════════════════════════════════════ */
#research .topics {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  margin-bottom: 1.5rem;
}

.tag {
  font-family: var(--mono);
  font-size: .7rem;
  letter-spacing: .05em;
  padding: .3rem .8rem;
  border: 1px solid var(--rule);
  color: var(--ink-2);
  border-radius: 2px;
  transition: border-color .25s var(--ease), color .25s var(--ease), background .25s var(--ease);
  cursor: default;
}

.tag:hover {
  border-color: var(--accent-lt);
  color: var(--accent);
  background: var(--accent-bg);
}

#research p {
  color: var(--ink-2);
  font-size: .97rem;
  max-width: 640px;
}

/* ══════════════════════════════════════════════
   PUBLICATIONS
   ══════════════════════════════════════════════ */
.pub-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1.8rem;
}

.pub {
  padding-bottom: 1.8rem;
  border-bottom: 1px dashed var(--rule-lt);
  transition: transform .2s var(--ease);
}

.pub:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.pub:hover {
  transform: translateX(4px);
}

.pub-title {
  font-size: 1.04rem;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.4;
}

.pub-authors {
  font-size: .84rem;
  color: var(--ink-3);
  margin-top: .25rem;
}

.pub-authors em {
  color: var(--accent);
  font-style: normal;
  font-weight: 500;
}

.pub-venue {
  font-family: var(--mono);
  font-size: .7rem;
  letter-spacing: .05em;
  color: var(--accent-lt);
  margin-top: .35rem;
}

.pub-links {
  margin-top: .5rem;
  display: flex;
  gap: 1rem;
}

.pub-links a {
  font-family: var(--mono);
  font-size: .66rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-3);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color .2s var(--ease), border-color .2s var(--ease);
}

.pub-links a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ══════════════════════════════════════════════
   PROJECTS
   ══════════════════════════════════════════════ */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.project-card {
  padding: 1.2rem 1.4rem;
  background: var(--bg-alt);
  border: 1px solid var(--rule-lt);
  border-radius: var(--radius);
  transition: border-color .25s var(--ease), transform .2s var(--ease), box-shadow .25s var(--ease);
  display: flex;
  flex-direction: column;
}

.project-card:hover {
  border-color: var(--accent-lt);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(42, 74, 62, .06);
}

.project-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: .8rem;
  margin-bottom: .5rem;
}

.project-name {
  font-size: .98rem;
  font-weight: 500;
  color: var(--ink);
}

.project-name a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color .2s var(--ease), border-color .2s var(--ease);
}

.project-name a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.project-lang {
  font-family: var(--mono);
  font-size: .62rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-3);
  white-space: nowrap;
  padding: .15rem .5rem;
  border: 1px solid var(--rule);
  border-radius: 2px;
  flex-shrink: 0;
}

.project-desc {
  font-size: .86rem;
  color: var(--ink-3);
  line-height: 1.55;
  flex: 1;
}

.project-meta {
  margin-top: .8rem;
  display: flex;
  gap: .8rem;
  align-items: center;
}

.project-meta a {
  font-family: var(--mono);
  font-size: .62rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-3);
  border-bottom: 1px solid transparent;
}

.project-meta a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.project-stars {
  font-family: var(--mono);
  font-size: .62rem;
  color: var(--ink-3);
  letter-spacing: .04em;
}

/* ══════════════════════════════════════════════
   WRITING / CTF
   ══════════════════════════════════════════════ */
.writing-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.writing-item {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: .6rem 0;
  border-bottom: 1px dotted var(--rule-lt);
  transition: transform .2s var(--ease);
}

.writing-item:last-child {
  border-bottom: none;
}

.writing-item:hover {
  transform: translateX(4px);
}

.writing-platform {
  font-family: var(--mono);
  font-size: .62rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent-lt);
  white-space: nowrap;
  min-width: 90px;
}

.writing-title a {
  font-size: .94rem;
  color: var(--ink-2);
  border-bottom: 1px solid transparent;
}

.writing-title a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ══════════════════════════════════════════════
   EDUCATION
   ══════════════════════════════════════════════ */
.edu-item {
  margin-bottom: 1.4rem;
}

.edu-item:last-child {
  margin-bottom: 0;
}

.edu-degree {
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink);
}

.edu-institution {
  font-size: .9rem;
  color: var(--ink-2);
}

.edu-year {
  font-family: var(--mono);
  font-size: .7rem;
  color: var(--ink-3);
  letter-spacing: .06em;
  margin-top: .15rem;
}

/* ══════════════════════════════════════════════
   NEWS
   ══════════════════════════════════════════════ */
.news-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}

.news-item {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: .45rem 0;
  border-bottom: 1px dotted var(--rule-lt);
  transition: transform .2s var(--ease);
}

.news-item:last-child {
  border-bottom: none;
}

.news-item:hover {
  transform: translateX(4px);
}

.news-date {
  font-family: var(--mono);
  font-size: .64rem;
  letter-spacing: .06em;
  color: var(--accent-lt);
  white-space: nowrap;
  min-width: 80px;
}

.news-text {
  font-size: .92rem;
  color: var(--ink-2);
  line-height: 1.5;
}

.news-text a {
  border-bottom: 1px solid var(--rule-lt);
}

.news-text a:hover {
  border-bottom-color: var(--accent);
}

/* ══════════════════════════════════════════════
   CONTACT
   ══════════════════════════════════════════════ */
.contact-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .5rem 1.6rem;
  align-items: baseline;
  font-size: .92rem;
}

.contact-key {
  font-family: var(--mono);
  font-size: .66rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.contact-val a {
  color: var(--ink-2);
  text-decoration: none;
  border-bottom: 1px solid var(--rule-lt);
  transition: color .2s var(--ease), border-color .2s var(--ease);
}

.contact-val a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ══════════════════════════════════════════════
   FOOTER
   ══════════════════════════════════════════════ */
footer {
  padding: 2.5rem 0 3.5rem;
  font-family: var(--mono);
  font-size: .65rem;
  letter-spacing: .06em;
  color: var(--ink-3);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .6rem;
  border-top: 1px solid var(--rule-lt);
}

/* ══════════════════════════════════════════════
   ANIMATIONS
   ══════════════════════════════════════════════ */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

header {
  animation: fadeUp .6s var(--ease) both;
}

nav {
  animation: fadeUp .5s .06s var(--ease) both;
}

.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .55s var(--ease), transform .55s var(--ease);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

.reveal-children>* {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .4s var(--ease), transform .4s var(--ease);
}

.reveal-children.visible>* {
  opacity: 1;
  transform: translateY(0);
}

.reveal-children.visible>*:nth-child(1) { transition-delay: 0s; }
.reveal-children.visible>*:nth-child(2) { transition-delay: .06s; }
.reveal-children.visible>*:nth-child(3) { transition-delay: .12s; }
.reveal-children.visible>*:nth-child(4) { transition-delay: .18s; }
.reveal-children.visible>*:nth-child(5) { transition-delay: .24s; }
.reveal-children.visible>*:nth-child(6) { transition-delay: .30s; }
.reveal-children.visible>*:nth-child(7) { transition-delay: .36s; }
.reveal-children.visible>*:nth-child(8) { transition-delay: .42s; }

/* ══════════════════════════════════════════════
   BACK-TO-TOP
   ══════════════════════════════════════════════ */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .3s var(--ease), transform .3s var(--ease);
  z-index: 200;
  font-size: .8rem;
  box-shadow: 0 2px 10px rgba(42, 74, 62, .2);
}

.back-to-top.show {
  opacity: 1;
  transform: translateY(0);
}

.back-to-top:hover {
  background: var(--accent-lt);
  transform: translateY(-2px);
}

/* ══════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════ */
@media (max-width: 600px) {
  body { font-size: 16px; }
  .page { padding: 0 1.25rem; }
  header { padding: 2.5rem 0 2rem; }
  .header-grid { grid-template-columns: 1fr; gap: 1.2rem; }
  .avatar { width: 80px; height: 80px; order: -1; }
  nav ul { gap: 1rem; }
  .project-grid { grid-template-columns: 1fr; }
  .contact-grid { grid-template-columns: 1fr; }
  .contact-key { margin-top: .7rem; }
  .writing-item { flex-direction: column; gap: .2rem; }
  .news-item { flex-direction: column; gap: .2rem; }
  footer { flex-direction: column; }
}

@media (max-width: 380px) {
  .quick-links { gap: .8rem; }
}
