/* ashenwijayaratne.com — one stylesheet, no build step */

@font-face {
  font-family: "Archivo";
  src: url("/assets/fonts/archivo-var.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #fbfcfc;
  --bg-2: #f2f5f7;
  --mat: #ffffff;
  --text: #14181d;
  --muted: #566069;
  --line: #e1e6ea;
  --accent: #1f4fd1;
  --accent-ink: #1a43b3;
  --accent-tint: #eef3fd;
  --on-accent: #ffffff;
  --img-filter: none;
  color-scheme: light;

  --font: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --wrap: 960px;
  --gutter: clamp(20px, 5vw, 40px);
  --s1: 4px;
  --s2: 8px;
  --s3: 16px;
  --s4: 24px;
  --s5: 40px;
  --s6: 72px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121316;
    --bg-2: #1a1c20;
    --mat: #e8eaec;
    --text: #e7e9eb;
    --muted: #a0a6ad;
    --line: #2b2e33;
    --accent: #9db4ff;
    --accent-ink: #b8c8ff;
    --accent-tint: #1b2030;
    --on-accent: #0d1220;
    --img-filter: brightness(0.88);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121316;
  --bg-2: #1a1c20;
  --mat: #e8eaec;
  --text: #e7e9eb;
  --muted: #a0a6ad;
  --line: #2b2e33;
  --accent: #9db4ff;
  --accent-ink: #b8c8ff;
  --accent-tint: #1b2030;
  --on-accent: #0d1220;
  --img-filter: brightness(0.88);
  color-scheme: dark;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: var(--s5);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent); color: var(--on-accent); }

img { max-width: 100%; height: auto; display: block; filter: var(--img-filter); }

a {
  color: var(--accent-ink);
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
}
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

.skip {
  position: absolute;
  left: var(--s3);
  top: -100px;
  background: var(--text);
  color: var(--bg);
  padding: var(--s2) var(--s3);
  z-index: 10;
}
.skip:focus { top: var(--s3); }

h1, h2, h3 { margin: 0; line-height: 1.15; text-wrap: balance; }
h1 {
  font-size: clamp(2rem, 5vw, 3.1rem);
  font-weight: 700;
  font-stretch: 90%;
  letter-spacing: -0.025em;
}
h2 {
  font-size: clamp(1.35rem, 2.4vw, 1.7rem);
  font-weight: 700;
  font-stretch: 92%;
  letter-spacing: -0.015em;
}
h3 { font-size: 1.15rem; line-height: 1.3; font-weight: 650; font-stretch: 94%; }
p { margin: 0 0 var(--s3); max-width: 64ch; }
p:last-child { margin-bottom: 0; }
ul, ol { margin: 0 0 var(--s3); padding-left: 1.25em; max-width: 64ch; }
li { margin-bottom: var(--s2); }
li::marker { color: var(--muted); }
dl, dd { margin: 0; }

.label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.01em;
}

/* ---------- Layout ---------- */

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

.top { border-bottom: 1px solid var(--line); }
.top__in {
  display: grid;
  grid-template-columns: 1fr auto auto;
  grid-template-areas: "brand nav theme";
  align-items: center;
  gap: var(--s4);
  min-height: 68px;
}
.brand {
  grid-area: brand;
  font-weight: 700;
  font-stretch: 90%;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}
.nav { grid-area: nav; display: flex; gap: var(--s4); }
.nav a {
  color: var(--text);
  text-decoration: none;
  padding: 6px 0;
  border-bottom: 2px solid transparent;
}
.nav a:hover { border-color: var(--line); }
.nav a[aria-current="page"] { border-color: var(--accent); }

.theme-toggle {
  grid-area: theme;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.theme-toggle:hover { background: var(--bg-2); }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; }
}
.no-js .theme-toggle { display: none; }

main { padding-bottom: var(--s6); }

.section { padding-top: var(--s6); }
.section > h2 { margin-bottom: var(--s4); }

/* ---------- Buttons ---------- */

.actions { display: flex; flex-wrap: wrap; gap: var(--s3); margin-top: var(--s5); }
.btn {
  display: inline-block;
  padding: 12px 22px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  text-decoration: none;
  border-radius: 6px;
  border: 1.5px solid var(--accent);
}
.btn:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn--ghost { background: transparent; color: var(--accent-ink); }
.btn--ghost:hover { background: var(--accent-tint); color: var(--accent-ink); }

/* ---------- Home ---------- */

.hero { padding: clamp(56px, 12vw, 128px) 0 var(--s4); }
.status {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  margin-bottom: var(--s4);
  padding: 4px 12px;
  background: var(--accent-tint);
  color: var(--accent-ink);
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 999px;
}
.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.hero h1 { max-width: 20ch; }
.hero .lede { margin-top: var(--s4); font-size: 1.2rem; color: var(--muted); max-width: 56ch; }
.facts-line { margin-top: var(--s4); color: var(--muted); font-size: 0.95rem; }

/* Work rows */
.index { list-style: none; margin: 0; padding: 0; max-width: none; }
.index li { margin: 0; border-top: 1px solid var(--line); }
.index li:last-child { border-bottom: 1px solid var(--line); }
.index a {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: var(--s5);
  padding: var(--s4) 0;
  color: var(--text);
  text-decoration: none;
  align-items: center;
}
.index__fig {
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: var(--mat);
  border-radius: 6px;
}
.index__fig img { width: 100%; height: 100%; object-fit: cover; }
.index__fig--none {
  display: grid;
  place-items: center;
  background: var(--bg-2);
  color: var(--muted);
  font-size: 0.9rem;
  padding: var(--s3);
  text-align: center;
}
.index h3 { margin-bottom: var(--s2); }
.index a:hover h3 { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 0.2em; }
.index p { color: var(--muted); }
.index .meta { margin-top: var(--s2); font-size: 0.9rem; }

.more { margin-top: var(--s4); font-weight: 600; }

/* Where I am */
.path {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s5);
}
.path h3 { font-size: 0.9rem; font-weight: 600; color: var(--muted); margin-bottom: var(--s2); }
.path strong { font-weight: 650; }
.path .label { display: block; margin-top: var(--s1); font-size: 0.95rem; line-height: 1.5; }

/* Contact block */
.cta {
  margin-top: var(--s6);
  padding: var(--s5);
  background: var(--accent-tint);
  border-radius: 8px;
}
.cta h2 { margin-bottom: var(--s3); }
.cta .actions { margin-top: var(--s4); }
.cta .links { margin-top: var(--s4); color: var(--muted); font-size: 0.95rem; }

/* ---------- Inner pages ---------- */

.page-title { padding: clamp(40px, 8vw, 88px) 0 var(--s4); }
.page-title p { margin-top: var(--s3); color: var(--muted); font-size: 1.15rem; max-width: 56ch; }

.panel { padding-top: var(--s6); }
.panel__head { margin-bottom: var(--s4); display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); }
.panel__head span.label { display: none; }
.page-title + .panel { padding-top: var(--s5); }

/* Case study header */
.cs-head { padding: clamp(40px, 8vw, 88px) 0 var(--s4); }
.cs-head__main .crumb { margin: 0 0 var(--s4); font-size: 0.875rem; max-width: none; }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--accent-ink); text-decoration: underline; }
.cs-head h1 { font-size: clamp(1.7rem, 3.6vw, 2.4rem); max-width: 36ch; }
.cs-head__main p { margin-top: var(--s4); font-size: 1.2rem; color: var(--muted); max-width: 58ch; }
.cs-head__data {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3) var(--s5);
  margin-top: var(--s5);
  padding-top: var(--s4);
  border-top: 1px solid var(--line);
}
.cell dt { font-size: 0.8125rem; color: var(--muted); }
.cell b { font-weight: 600; }

.cs-figure { margin: var(--s4) 0 0; }
.cs-figure img {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  background: var(--mat);
  border-radius: 6px;
}
.cs-figure figcaption, .gallery figcaption {
  margin-top: var(--s2);
  font-size: 0.875rem;
  color: var(--muted);
}

.cs-body { margin-top: var(--s5); }
.cs-section {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: var(--s5);
  padding: var(--s5) 0;
  border-top: 1px solid var(--line);
}
.cs-section > h2 {
  font-size: 1rem;
  font-weight: 650;
  font-stretch: 100%;
  letter-spacing: 0;
  color: var(--muted);
}
.cs-section h3 { margin: var(--s4) 0 var(--s2); }
.cs-section ol { padding-left: 1.4em; }

.figures {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s4) var(--s3);
  margin-top: var(--s4);
  max-width: 760px;
}
.gallery { margin: 0; }
.gallery img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: var(--mat);
  border-radius: 6px;
}

.gallery--fit img { aspect-ratio: auto; object-fit: contain; max-height: 520px; }
.cs-inline { margin: var(--s4) 0 0; max-width: 560px; }
.cs-inline img { width: 100%; border-radius: 6px; background: var(--mat); max-height: 520px; object-fit: contain; }
.cs-inline figcaption { margin-top: var(--s2); font-size: 0.875rem; color: var(--muted); }
.role__logo { height: 28px; width: auto; margin-bottom: var(--s3); padding: 4px 8px; background: #fff; border-radius: 6px; box-sizing: content-box; }

.result-cells {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s4) var(--s5);
  margin-bottom: var(--s4);
}
.result-cells dt { font-size: 0.8125rem; color: var(--muted); }
.result-cells dd {
  font-size: 1.9rem;
  font-weight: 700;
  font-stretch: 90%;
  line-height: 1.2;
  font-variant-numeric: tabular-nums lining-nums;
}

.draft {
  border: 1.5px dashed var(--accent);
  background: var(--accent-tint);
  color: var(--text);
  padding: var(--s2) var(--s3);
  border-radius: 6px;
  max-width: 64ch;
  font-size: 0.95rem;
}
.draft::before { content: "Draft, to fill in: "; font-weight: 700; color: var(--accent-ink); }

.tag {
  display: inline-block;
  border: 1.5px dashed var(--accent);
  color: var(--accent-ink);
  padding: 0 8px;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: 4px;
}

.cs-nav { margin-top: var(--s6); padding-top: var(--s4); border-top: 1px solid var(--line); }
.cs-nav a { display: block; text-decoration: none; color: var(--text); font-size: 1.3rem; font-weight: 650; }
.cs-nav a:hover { color: var(--accent-ink); }
.cs-nav .label { display: block; font-size: 0.875rem; font-weight: 500; }

/* Experience */
.role {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: var(--s5);
  padding: var(--s4) 0 var(--s5);
  border-top: 1px solid var(--line);
}
.role__when { color: var(--muted); font-size: 0.95rem; }
.role__when b { display: block; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.role__when .label { display: block; }
.role__what h3 { margin-bottom: 2px; }
.role__org { color: var(--muted); margin-bottom: var(--s3); }
.role__what img { margin-top: var(--s3); max-width: 520px; width: 100%; border-radius: 6px; }
.role__what img.role__logo { margin-top: 0; width: auto; max-width: 160px; }
.role__what .result-cells dd { font-size: 1.4rem; }

.tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s5); padding-top: var(--s4); border-top: 1px solid var(--line); }
.tools h3 { font-size: 0.9rem; font-weight: 600; color: var(--muted); margin-bottom: var(--s2); }
.tools ul { list-style: none; padding: 0; margin: 0; }
.tools li { margin-bottom: var(--s2); }
.tools small { display: block; color: var(--muted); font-size: 0.875rem; }

.missed { padding: var(--s6) 0; }

/* Footer */
.foot {
  width: calc(100% - 2 * var(--gutter));
  max-width: calc(var(--wrap) - 2 * var(--gutter));
  margin: 0 auto;
  padding-left: 0;
  padding-right: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--s2) var(--s4);
  padding-top: var(--s4);
  padding-bottom: var(--s5);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}
.foot a { color: var(--muted); display: inline-block; padding: 6px 2px; }

/* ---------- Responsive ---------- */

@media (max-width: 760px) {
  .top__in {
    grid-template-columns: 1fr auto;
    grid-template-areas: "brand theme" "nav nav";
    gap: 0 var(--s3);
    padding-top: var(--s2);
  }
  .nav { padding-bottom: var(--s2); gap: var(--s4); }
  .index a { grid-template-columns: 1fr; gap: var(--s3); }
  .index__fig { aspect-ratio: 16 / 9; }
  .path { grid-template-columns: 1fr; gap: var(--s4); }
  .cs-section, .role { grid-template-columns: 1fr; gap: var(--s2); }
  .cs-section { padding: var(--s4) 0; }
  .tools { grid-template-columns: 1fr; gap: var(--s4); }
  .figures { grid-template-columns: 1fr; }
  .cta { padding: var(--s4) var(--s3); }
}

@media (max-width: 480px) {
  body { font-size: 1rem; }
  .actions .btn { flex: 1 1 100%; text-align: center; }
}

@media (prefers-reduced-motion: no-preference) {
  .btn, .nav a, .theme-toggle { transition: background-color 150ms ease-out, border-color 150ms ease-out; }
}

@media print {
  :root, :root:not([data-theme="light"]), :root[data-theme="dark"] {
    --bg: #fff; --bg-2: #fff; --mat: #fff; --text: #000; --muted: #333;
    --line: #bbb; --accent: #000; --accent-ink: #000; --accent-tint: #fff;
    --on-accent: #fff; --img-filter: none;
  }
  .top, .foot, .cs-nav, .skip, .cta .actions { display: none; }
}
