/* ==========================================================================
   Shanaka Ramesh Gunasekara — personal research site
   A calm, clean academic layout with a click-to-toggle light/dark theme.
   Type:  Inter (everything) · Roboto Slab (name/headings accent) · JetBrains Mono (labels)
   ========================================================================== */

/* --- 1. Theme tokens ----------------------------------------------------- */

:root {
  --bg:          #ffffff;
  --bg-soft:     #f7f8fa;
  --card:        #ffffff;
  --text:        #1f2328;
  --text-soft:   #5b636c;
  --text-faint:  #8b939c;
  --line:        #e6e8eb;
  --accent:      #0a7d78;
  --accent-soft: #e5f2f1;
  --tag-bg:      #f0f2f4;
  --tag-text:    #414852;
  --shadow:      0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-slab: "Roboto Slab", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --wrap: 1080px;
  --wrap-narrow: 760px;
  --radius: 10px;
}

html[data-theme="dark"] {
  --bg:          #0f1418;
  --bg-soft:     #151b21;
  --card:        #161d24;
  --text:        #e7ebee;
  --text-soft:   #a7b0b8;
  --text-faint:  #737d86;
  --line:        #232c34;
  --accent:      #4fd1c9;
  --accent-soft: #14332f;
  --tag-bg:      #1c242c;
  --tag-text:    #b3bcc4;
  --shadow:      0 1px 2px rgba(0,0,0,.3), 0 1px 3px rgba(0,0,0,.4);
}

/* --- 2. Base ------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 80px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1.02rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}

img { max-width: 100%; display: block; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 1.25rem; }

.skip { position: absolute; left: -9999px; top: 0; background: var(--accent); color: #fff; padding: .6rem 1rem; z-index: 100; }
.skip:focus { left: 0; }

/* --- 3. Typography ------------------------------------------------------- */

h1, h2, h3, h4 { font-family: var(--font-sans); font-weight: 650; line-height: 1.25; margin: 0 0 .5rem; letter-spacing: -0.01em; }

.section-title { font-size: 1.4rem; margin: 0 0 1.25rem; padding-bottom: .5rem; border-bottom: 1px solid var(--line); }
.section-title .ic { font-size: .95em; margin-right: .1em; }
.page-intro h1 .ic { margin-right: .15em; }

.eyebrow { display: none; }          /* not used in this cleaner layout */

p { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }

.lede { font-size: 1.08rem; color: var(--text-soft); }
.mono { font-family: var(--font-mono); font-size: .82rem; }

/* --- 4. Header ----------------------------------------------------------- */

.site-head {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 60px; }

.brand { font-weight: 650; font-size: .98rem; color: var(--text); letter-spacing: -0.01em; display: flex; align-items: center; gap: .55rem; }
.brand:hover { text-decoration: none; }
.brand .mark { width: 20px; height: 20px; flex: none; }
.brand .sub { display: none; }

.nav-wrap { display: flex; align-items: center; gap: .35rem; }

.nav { display: flex; gap: .1rem; align-items: center; }
.nav a { font-size: .9rem; color: var(--text-soft); padding: .4rem .7rem; border-radius: 6px; }
.nav a:hover { color: var(--text); background: var(--bg-soft); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--accent); font-weight: 600; }

/* theme toggle button */
.theme-toggle {
  display: grid; place-items: center;
  width: 36px; height: 36px; padding: 0;
  border: 1px solid var(--line); background: var(--card); color: var(--text-soft);
  border-radius: 8px; cursor: pointer; transition: color .15s, border-color .15s;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-moon { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

.nav-toggle {
  display: none; background: var(--card); border: 1px solid var(--line); color: var(--text);
  font-size: .78rem; padding: .45rem .65rem; border-radius: 8px; cursor: pointer;
}

@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .nav {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--bg); border-bottom: 1px solid var(--line);
    padding: .4rem 1.25rem .8rem; display: none;
  }
  .nav.is-open { display: flex; }
  .nav a { padding: .7rem .2rem; border-radius: 0; border-bottom: 1px solid var(--line); }
}

/* --- 5. Hero (home) ------------------------------------------------------ */

.hero { padding: 3rem 0 2rem; }
.hero-grid { display: grid; grid-template-columns: 1fr 260px; gap: 3rem; align-items: start; }

@media (max-width: 620px) {
  .hero-grid { grid-template-columns: 1fr; gap: 1.5rem; text-align: center; }
  .hero-aside { max-width: 220px; margin: 0 auto; }
  .id-icons { justify-content: center; }
}

.portrait {
  width: 100%; aspect-ratio: 1/1; object-fit: cover;
  border-radius: 50%; border: 1px solid var(--line); background: var(--bg-soft);
}
.portrait-fallback {
  width: 100%; aspect-ratio: 1/1; display: grid; place-items: center;
  border-radius: 50%; border: 1px solid var(--line); background: var(--bg-soft);
  color: var(--text-faint); font-family: var(--font-slab); font-size: 3rem; font-weight: 700;
}

/* skeleton animation below the portrait */
.pose-fig { margin: 1.1rem 0 0; }
.pose-fig svg {
  width: 100%; display: block;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
}
.pose-fig figcaption {
  font-family: var(--font-mono); font-size: .66rem; letter-spacing: .02em;
  color: var(--text-faint); text-align: center; margin-top: .5rem;
}
.pose-fig figcaption b { color: var(--accent); font-weight: 500; }

.hero-name { font-family: var(--font-slab); font-size: 2.15rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; margin: 0 0 .35rem; }
.hero-role { font-size: 1.05rem; color: var(--text); margin: 0 0 .15rem; }
.hero-affil { color: var(--text-soft); margin: 0 0 .35rem; }
.hero-cred { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .04em; color: var(--text-faint); text-transform: uppercase; margin: 0 0 1.1rem; }

.hero-bio { color: var(--text-soft); max-width: 62ch; }
@media (min-width: 620px) {
  .hero-bio { text-align: justify; }
}
.hero-bio p { margin-bottom: .85rem; }
.page-intro .lede { max-width: 68ch; }
.section > .wrap > p.lede, .news, .skillset { max-width: 900px; }

/* icon link row */
.id-icons { display: flex; flex-wrap: wrap; gap: .55rem; margin: 0 0 1.4rem; padding: 0; list-style: none; }
.id-icons a {
  --brand: var(--accent);
  display: grid; place-items: center; width: 40px; height: 40px;
  border: 1px solid var(--line); border-radius: 10px; color: var(--brand);
  background: var(--card); transition: color .15s, border-color .15s, background .15s, transform .1s;
}
.id-icons a:hover {
  color: #fff; background: var(--brand); border-color: var(--brand);
  text-decoration: none; transform: translateY(-2px);
}
.id-icons svg { width: 19px; height: 19px; }
.id-icons .txt { font-family: var(--font-mono); font-size: .7rem; font-weight: 500; letter-spacing: .02em; }
.id-icons a.wide { width: auto; padding: 0 .75rem; gap: .35rem; }

/* brand colours — each icon shows its own colour */
.id-icons a[data-brand="email"]         { --brand: #ea4335; }
.id-icons a[data-brand="googlescholar"] { --brand: #4285f4; }
.id-icons a[data-brand="orcid"]         { --brand: #a6ce39; }
.id-icons a[data-brand="github"]        { --brand: #6e40c9; }
.id-icons a[data-brand="linkedin"]      { --brand: #0a66c2; }
.id-icons a[data-brand="researchgate"]  { --brand: #00ccbb; }
.id-icons a[data-brand="twitter"]       { --brand: #1da1f2; }
.id-icons a[data-brand="cv"]            { --brand: var(--accent); }

/* --- 6. Sections --------------------------------------------------------- */

.section { padding: 2rem 0; }
.section + .section { border-top: 1px solid var(--line); }

/* skills / interests grouped rows (al-folio style) */
.skillset { display: grid; gap: 1.3rem; }
.skill-row h3 { font-size: 1rem; margin-bottom: .55rem; }
.tags { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; margin: 0; padding: 0; }
.tags li {
  font-size: .82rem; color: var(--tag-text); background: var(--tag-bg);
  padding: .3rem .65rem; border-radius: 6px;
  border: 1px solid transparent;
}

/* each skill group gets its own colour family */
.skill-row[data-group="0"] h3 { color: #0a7d78; }
.skill-row[data-group="0"] .tags li { background: rgba(10,125,120,.1);  color: #0a7d78; border-color: rgba(10,125,120,.2); }
.skill-row[data-group="1"] h3 { color: #b4530a; }
.skill-row[data-group="1"] .tags li { background: rgba(180,83,10,.1);  color: #b4530a; border-color: rgba(180,83,10,.2); }
.skill-row[data-group="2"] h3 { color: #6e40c9; }
.skill-row[data-group="2"] .tags li { background: rgba(110,64,201,.1); color: #6e40c9; border-color: rgba(110,64,201,.2); }
.skill-row[data-group="3"] h3 { color: #0a66c2; }
.skill-row[data-group="3"] .tags li { background: rgba(10,102,194,.1); color: #0a66c2; border-color: rgba(10,102,194,.2); }
.skill-row[data-group="4"] h3 { color: #c2185b; }
.skill-row[data-group="4"] .tags li { background: rgba(194,24,91,.1);  color: #c2185b; border-color: rgba(194,24,91,.2); }

html[data-theme="dark"] .skill-row[data-group="0"] h3, html[data-theme="dark"] .skill-row[data-group="0"] .tags li { color: #4fd1c9; background: rgba(79,209,201,.12); border-color: rgba(79,209,201,.25); }
html[data-theme="dark"] .skill-row[data-group="1"] h3, html[data-theme="dark"] .skill-row[data-group="1"] .tags li { color: #f0a35e; background: rgba(240,163,94,.12); border-color: rgba(240,163,94,.25); }
html[data-theme="dark"] .skill-row[data-group="2"] h3, html[data-theme="dark"] .skill-row[data-group="2"] .tags li { color: #b18cf0; background: rgba(177,140,240,.12); border-color: rgba(177,140,240,.25); }
html[data-theme="dark"] .skill-row[data-group="3"] h3, html[data-theme="dark"] .skill-row[data-group="3"] .tags li { color: #6cb2f5; background: rgba(108,178,245,.12); border-color: rgba(108,178,245,.25); }
html[data-theme="dark"] .skill-row[data-group="4"] h3, html[data-theme="dark"] .skill-row[data-group="4"] .tags li { color: #f06fa3; background: rgba(240,111,163,.12); border-color: rgba(240,111,163,.25); }

/* --- 7. News / updates feed --------------------------------------------- */

.news { list-style: none; margin: 0; padding: 0; }
.news li { display: grid; grid-template-columns: 108px 1fr; gap: 1rem; padding: .7rem 0; border-top: 1px solid var(--line); }
.news li:first-child { border-top: 0; }
.news .date { font-family: var(--font-mono); font-size: .74rem; color: var(--text-faint); padding-top: .15rem; }
.news .item { color: var(--text-soft); font-size: .96rem; }
@media (max-width: 560px) {
  .news li { grid-template-columns: 1fr; gap: .1rem; }
}

/* --- 8. Highlights cards ------------------------------------------------- */

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.card { border: 1px solid var(--line); background: var(--card); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.card h3 { font-size: .98rem; margin-bottom: .3rem; }
.card p { font-size: .92rem; color: var(--text-soft); margin: 0; }
.card .stat { font-family: var(--font-slab); font-size: 1.9rem; font-weight: 700; line-height: 1; display: block; margin-bottom: .35rem; color: var(--accent); }

/* --- 9. Timeline (background) ------------------------------------------- */

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline > li { display: grid; grid-template-columns: 140px 1fr; gap: 1.25rem; padding: 1.1rem 0; border-top: 1px solid var(--line); }
.timeline > li:first-child { border-top: 0; padding-top: 0; }
.timeline .when { font-family: var(--font-mono); font-size: .76rem; color: var(--text-faint); padding-top: .15rem; }
.timeline .when.now { color: var(--accent); }
.timeline .when.now::after { content: " •"; }
.timeline h3 { font-size: 1rem; margin-bottom: .15rem; }
.timeline li > div > p { font-size: .94rem; color: var(--text-soft); margin: 0 0 .4rem; }
.timeline li > div > p:last-child { margin-bottom: 0; }
.timeline .where { color: var(--text-soft); font-size: .94rem; }
.timeline ul { margin: .45rem 0 0; padding-left: 1.1rem; font-size: .94rem; color: var(--text-soft); }
.timeline ul li { margin-bottom: .3rem; }
@media (max-width: 600px) { .timeline > li { grid-template-columns: 1fr; gap: .3rem; } }

/* --- 10. Publications (year-grouped visual cards) ----------------------- */

.pub-year { margin-bottom: 1.5rem; }
.year-head {
  font-family: var(--font-slab); font-size: 1.5rem; font-weight: 700;
  color: var(--text); margin: 0 0 1rem;
  padding-bottom: .4rem; border-bottom: 2px solid var(--accent);
  display: inline-block; min-width: 4ch;
}

.pub-cards { list-style: none; margin: 0 0 .5rem; padding: 0; display: grid; gap: 1rem; }

.pub-card {
  display: grid; grid-template-columns: 150px 1fr; gap: 1.2rem; align-items: start;
  border: 1px solid var(--line); background: var(--card); border-radius: var(--radius);
  padding: 1rem 1.15rem; box-shadow: var(--shadow);
}

.pub-thumb {
  width: 150px; aspect-ratio: 4/3; border-radius: 8px; overflow: hidden;
  background: var(--bg-soft); border: 1px solid var(--line);
  display: grid; place-items: center;
}
.pub-thumb img { width: 100%; height: 100%; object-fit: cover; }
.pub-thumb-tag {
  font-family: var(--font-mono); font-size: .72rem; letter-spacing: .04em;
  color: var(--accent); text-align: center; padding: .4rem; line-height: 1.3;
}

.pub-body h3 { font-size: 1.02rem; font-weight: 620; line-height: 1.4; margin: 0 0 .35rem; }
.pub-tag-link {
  font-family: var(--font-mono); font-size: .74rem; font-weight: 500;
  white-space: nowrap; margin-left: .35rem;
}
.pub-body .authors { font-size: .9rem; color: var(--text-soft); margin: 0 0 .25rem; }
.pub-body .authors .me { color: var(--text); font-weight: 650; }
.pub-body .venue { font-size: .86rem; color: var(--text-faint); font-style: italic; margin: 0; }

@media (max-width: 620px) {
  .pub-card { grid-template-columns: 1fr; gap: .8rem; }
  .pub-thumb { width: 100%; max-width: 220px; aspect-ratio: 16/9; }
}

/* --- 11. Research projects ---------------------------------------------- */

.research-layout { display: grid; grid-template-columns: 200px 1fr; gap: 2rem; align-items: start; }
@media (max-width: 860px) { .research-layout { grid-template-columns: 1fr; } .proj-index { position: static !important; display: none; } }

.proj-index { position: sticky; top: 80px; }
.proj-index ol { list-style: none; margin: 0; padding: 0; counter-reset: p; }
.proj-index li { counter-increment: p; }
.proj-index a { display: block; padding: .4rem 0; font-size: .84rem; color: var(--text-soft); line-height: 1.3; border-top: 1px solid var(--line); }
.proj-index li:first-child a { border-top: 0; }
.proj-index a::before { content: counter(p, decimal-leading-zero); font-family: var(--font-mono); font-size: .68rem; color: var(--text-faint); margin-right: .5rem; }
.proj-index a:hover { color: var(--accent); text-decoration: none; }

.project { padding: 0 0 2rem; margin-bottom: 2rem; border-bottom: 1px solid var(--line); }
.project:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.project h2 { font-size: 1.3rem; margin-bottom: .25rem; }
.project .when { font-family: var(--font-mono); font-size: .74rem; color: var(--text-faint); margin: 0 0 1rem; }
.project h4 { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin: 1.1rem 0 .35rem; font-weight: 600; }
.project p { font-size: .96rem; color: var(--text-soft); }
.project .people { font-size: .92rem; color: var(--text-soft); margin: 0; }
.project .people span { display: block; }

.proj-media { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: .8rem; margin: 1.1rem 0 .25rem; }
.proj-media figure { margin: 0; }
.proj-media img { width: 100%; border: 1px solid var(--line); border-radius: 8px; object-fit: cover; }
.proj-media figcaption { font-family: var(--font-mono); font-size: .68rem; color: var(--text-faint); margin-top: .35rem; }

/* --- 12. Awards ---------------------------------------------------------- */

.awards { list-style: none; margin: 0; padding: 0; }
.awards li { padding: .8rem 0 .8rem 1.4rem; border-top: 1px solid var(--line); position: relative; font-size: .96rem; color: var(--text-soft); }
.awards li:first-child { border-top: 0; }
.awards li::before { content: ""; position: absolute; left: 0; top: 1.35rem; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.awards li b, .awards li strong { color: var(--text); font-weight: 650; }

/* --- 13. Contact --------------------------------------------------------- */

.contact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 1.4rem; }
.contact-grid h3 { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin-bottom: .5rem; }
.contact-grid p, .contact-grid a { font-size: .93rem; }
.contact-grid ul { list-style: none; margin: 0; padding: 0; }
.contact-grid li { margin-bottom: .25rem; }

/* --- 14. Page intro (inner pages) --------------------------------------- */
.page-intro { padding: 2.5rem 0 1rem; }
.page-intro h1 { font-family: var(--font-slab); font-size: 1.9rem; font-weight: 700; letter-spacing: -0.02em; }

/* --- 15. Footer ---------------------------------------------------------- */

.site-foot { border-top: 1px solid var(--line); padding: 1.75rem 0 2.25rem; margin-top: 2rem; }
.site-foot .wrap { display: flex; flex-wrap: wrap; gap: .8rem; justify-content: space-between; align-items: center; }
.site-foot p { font-family: var(--font-mono); font-size: .72rem; color: var(--text-faint); margin: 0; }
.foot-links { display: flex; flex-wrap: wrap; gap: .8rem; }
.foot-links a { font-size: .8rem; color: var(--text-soft); }

/* --- 16. Motion ---------------------------------------------------------- */

.js .reveal { opacity: 0; transform: translateY(10px); }
.js .reveal.is-visible { opacity: 1; transform: none; transition: opacity .5s ease, transform .5s ease; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal, .js .reveal.is-visible { opacity: 1; transform: none; transition: none; }
  * { transition-duration: .01ms !important; }
}

/* --- 17. Travel ---------------------------------------------------------- */

.travel-grid { display: grid; gap: 1.5rem; }
.travel-card { border: 1px solid var(--line); background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.travel-photos { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 2px; background: var(--line); }
.travel-photos img { width: 100%; height: 220px; object-fit: cover; display: block; }
.travel-body { padding: 1.1rem 1.25rem; }
.travel-body h3 { font-size: 1.15rem; margin-bottom: .2rem; }
.travel-meta { font-family: var(--font-mono); font-size: .74rem; color: var(--text-faint); margin: 0 0 .6rem; }
.travel-body p { font-size: .95rem; color: var(--text-soft); }

/* --- 18. Blog (tiles) ---------------------------------------------------- */

.blog-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.25rem; }
.blog-tile { border: 1px solid var(--line); background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform .12s ease, box-shadow .12s ease; }
.blog-tile:hover { transform: translateY(-3px); box-shadow: 0 6px 16px rgba(16,24,40,.1); }
.blog-tile-link { display: block; color: inherit; text-decoration: none; height: 100%; }
.blog-tile-link:hover { text-decoration: none; }
.blog-tile-img { aspect-ratio: 16/9; background: var(--bg-soft); overflow: hidden; }
.blog-tile-img img { width: 100%; height: 100%; object-fit: cover; }
.blog-tile-img--blank { display: grid; place-items: center; background: linear-gradient(135deg, var(--accent-soft), var(--bg-soft)); }
.blog-tile-img--blank span { font-family: var(--font-slab); font-size: 2.5rem; font-weight: 700; color: var(--accent); }
.blog-tile-body { padding: 1rem 1.15rem 1.2rem; }
.blog-date { font-family: var(--font-mono); font-size: .72rem; color: var(--text-faint); margin: 0 0 .35rem; }
.blog-tile-body h3 { font-size: 1.08rem; line-height: 1.3; margin-bottom: .45rem; }
.blog-excerpt { font-size: .92rem; color: var(--text-soft); }
.blog-excerpt p { margin: 0; }
.blog-tags { display: flex; flex-wrap: wrap; gap: .35rem; list-style: none; margin: .75rem 0 0; padding: 0; }
.blog-tags li { font-family: var(--font-mono); font-size: .68rem; color: var(--tag-text); background: var(--tag-bg); padding: .2rem .5rem; border-radius: 5px; }

/* --- 19. Empty "coming soon" state -------------------------------------- */

.empty-state { text-align: center; padding: 3.5rem 1rem; max-width: 420px; margin: 0 auto; }
.empty-icon { width: 56px; height: 56px; margin: 0 auto 1.1rem; color: var(--accent); display: grid; place-items: center; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.empty-icon svg { width: 28px; height: 28px; }
.empty-state h3 { font-family: var(--font-slab); font-size: 1.4rem; margin-bottom: .5rem; }
.empty-state p { color: var(--text-soft); font-size: .96rem; }
