/* mahen.lk | tokens and contrast values documented in docs/mahen-lk-redesign-spec.md (N.2) */

@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/inter-var-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
/* Metric-matched fallback to limit layout shift while Inter loads */
@font-face {
  font-family: "Inter Fallback";
  src: local("Arial");
  size-adjust: 107.12%;
  ascent-override: 90.44%;
  descent-override: 22.52%;
  line-gap-override: 0%;
}

:root {
  --bg: #FAFAF7;
  --surface: #FFFFFF;
  --ink: #16181C;
  --muted: #4B515A;
  --accent: #0A6670;
  --accent-hover: #084F57;
  --on-accent: #FFFFFF;
  --border-ui: #7A8089;
  --border-subtle: #DADDE1;
  --error: #B3261E;
  --success: #1E6B3A;
  --logo-panel: #FFFFFF;

  --font-sans: "Inter", "Inter Fallback", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;

  --step-0: clamp(1rem, 0.96rem + 0.2vw, 1.125rem);
  --step-1: clamp(1.2rem, 1.1rem + 0.4vw, 1.4rem);
  --step-2: clamp(1.5rem, 1.3rem + 0.9vw, 2rem);
  --step-3: clamp(1.9rem, 1.5rem + 1.8vw, 2.75rem);
  --step-4: clamp(2.1rem, 1.5rem + 2.8vw, 3.5rem);
  --small: 0.875rem;

  --container: 72rem;
  --gutter: clamp(1rem, 4vw, 2rem);
  --section: clamp(3rem, 6vw, 6rem);
  --radius: 0.75rem;
  --header-h: 3.5rem;
  --consent-h: 0px;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1217;
    --surface: #161A21;
    --ink: #E9EBEE;
    --muted: #A7AEB8;
    --accent: #5DD3DE;
    --accent-hover: #8DE3EA;
    --on-accent: #0F1217;
    --border-ui: #6B727C;
    --border-subtle: #262B33;
    --error: #FF8A80;
    --success: #7FD49B;
    --logo-panel: #F3F4F6;
  }
}

/* ---- Base ------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 1rem);
  scroll-padding-bottom: calc(var(--consent-h) + 1rem);
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.6;
  overflow-wrap: break-word;
}
img, svg, picture { display: block; max-width: 100%; height: auto; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: var(--step-3); }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); font-weight: 600; }
p, ul, ol, dl { margin: 0 0 1rem; }
a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--accent-hover); text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
main:focus { outline: none; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.mono { font-family: var(--font-mono); font-size: var(--small); }
.muted { color: var(--muted); }

.container { max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); }
.prose { max-width: 68ch; }
.prose h2 { margin-top: 2.5rem; }
.prose h3 { margin-top: 1.75rem; }
.prose li { margin-bottom: 0.4rem; }

/* ---- Skip link -------------------------------------------------------- */
.skip-link {
  position: absolute; left: 1rem; top: -100%; z-index: 100;
  background: var(--accent); color: var(--on-accent);
  padding: 0.75rem 1rem; border-radius: 0.375rem; font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 0.5rem; color: var(--on-accent); }

/* ---- Buttons ---------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 2.75rem; padding: 0.5rem 1.25rem;
  border: 2px solid transparent; border-radius: 0.5rem;
  font: inherit; font-weight: 600; line-height: 1.2; text-decoration: none; cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); color: var(--on-accent); }
.btn-secondary { background: transparent; color: var(--ink); border-color: var(--border-ui); }
.btn-secondary:hover { border-color: var(--ink); color: var(--ink); }
.btn-small { min-height: 2.75rem; padding: 0.375rem 1rem; font-size: 0.9375rem; }
.btn[aria-disabled="true"] { opacity: 0.7; cursor: progress; }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; }
@media (max-width: 24.99em) {
  .actions .btn { width: 100%; }
}
.link-button {
  background: none; border: 0; padding: 0; font: inherit; color: var(--accent);
  text-decoration: underline; text-underline-offset: 0.18em; cursor: pointer; min-height: 1.5rem;
}
.arrow-link { font-weight: 600; }

/* ---- Header ----------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg); border-bottom: 1px solid var(--border-subtle);
}
.header-inner { display: flex; align-items: center; gap: 0.75rem; min-height: var(--header-h); }
.brand {
  font-weight: 700; color: var(--ink); text-decoration: none; margin-right: auto;
  min-height: 2.75rem; display: inline-flex; align-items: center;
}
.brand:hover { color: var(--ink); }
.site-nav { display: flex; align-items: center; }
.nav-list { display: flex; flex-wrap: wrap; list-style: none; margin: 0; padding: 0; gap: 0.25rem; }
.nav-list a {
  display: inline-flex; align-items: center; min-height: 2.75rem; padding: 0 0.625rem;
  color: var(--ink); text-decoration: none; font-weight: 500;
}
.nav-list a:hover { color: var(--accent); }
.nav-list a[aria-current="page"] { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.4em; }
.nav-contact-narrow { display: none; }
.menu-toggle {
  display: inline-flex; align-items: center; gap: 0.5rem; min-height: 2.75rem; padding: 0 0.75rem;
  background: transparent; color: var(--ink); border: 1px solid var(--border-ui); border-radius: 0.5rem;
  font: inherit; font-weight: 600; cursor: pointer;
}
.menu-toggle[hidden] { display: none; }

/* Without JS the nav simply wraps under the name. With JS, collapse it on narrow screens. */
@media (max-width: 51.99em) {
  .header-inner { flex-wrap: wrap; }
  .js .header-inner { flex-wrap: nowrap; }
  .js .site-nav { order: 3; }
  .js .header-contact { order: 2; }
  .js .nav-list {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; gap: 0; padding: 0.5rem var(--gutter) 1rem;
    background: var(--bg); border-bottom: 1px solid var(--border-ui);
  }
  .js .nav-list.is-open { display: flex; }
  .js .nav-list a { width: 100%; padding: 0 0.25rem; }
}
@media (max-width: 22.49em) {
  .js .header-contact { display: none; }
  .js .nav-contact-narrow { display: block; }
}
@media (min-width: 52em) {
  .menu-toggle { display: none !important; }
}

/* ---- Sections --------------------------------------------------------- */
.section { padding-block: var(--section); border-top: 1px solid var(--border-subtle); }
.section:first-child, .hero + .section { border-top: 0; }
.section-intro { color: var(--muted); max-width: 60ch; margin-bottom: 2rem; }
.section-link { margin-top: 2rem; margin-bottom: 0; }
.eyebrow { font-family: var(--font-mono); font-size: var(--small); color: var(--muted); margin-bottom: 1rem; }
.page-head { padding-block: clamp(2.5rem, 5vw, 4.5rem) 1rem; }
.page-head p { max-width: 62ch; font-size: var(--step-1); line-height: 1.5; color: var(--muted); }

/* ---- Hero ------------------------------------------------------------- */
.hero { padding-block: clamp(2rem, 5vw, 5rem) clamp(2rem, 4vw, 3.5rem); }
.hero-grid { display: grid; gap: 2rem; align-items: center; }
.hero h1 { font-size: var(--step-4); line-height: 1.1; max-width: 18ch; }
.hero-lead { font-size: 1.125rem; max-width: 38rem; }
.hero-portrait { width: min(100%, 14rem); }
.hero-portrait img, .about-portrait img { border-radius: var(--radius); width: 100%; aspect-ratio: 1; object-fit: cover; }
@media (min-width: 25em) { .hero-portrait { width: 16rem; } }
@media (min-width: 52em) {
  .hero-grid { grid-template-columns: 7fr 5fr; gap: 3rem; }
  .hero-portrait { width: 100%; max-width: 24rem; justify-self: end; }
}

/* ---- Proof list ------------------------------------------------------- */
.proof {
  list-style: none; padding: 0; margin: 2.5rem 0 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
  border-top: 1px solid var(--border-subtle);
}
.proof li { padding: 0.875rem 1rem 0.875rem 0; border-bottom: 1px solid var(--border-subtle); font-size: 0.9375rem; color: var(--muted); }
.proof strong { display: block; color: var(--ink); font-size: 1.0625rem; }

/* ---- Cards ------------------------------------------------------------ */
.grid { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--border-subtle); border-radius: var(--radius);
  padding: 1.5rem; display: flex; flex-direction: column;
}
.card > :last-child { margin-bottom: 0; }
.card h3 { margin-bottom: 0.5rem; }
.card .links { margin-top: auto; padding-top: 0.5rem; display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; }
.card .links a { min-height: 1.5rem; display: inline-block; }
.expertise h3 { font-size: 1.1875rem; }

.logo-panel {
  background: var(--logo-panel); border-radius: 0.5rem; height: 5.5rem; margin-bottom: 1.25rem;
  display: flex; align-items: center; justify-content: center; padding: 0.75rem;
}
.logo-panel picture { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.logo-panel img { max-height: 4rem; max-width: 85%; width: auto; height: auto; object-fit: contain; }
.logo-panel--large { height: 11rem; padding: 1.5rem; margin-bottom: 0; }
.logo-panel--large img { max-height: 100%; max-width: 80%; }
.meta { font-family: var(--font-mono); font-size: var(--small); color: var(--muted); margin-bottom: 0.75rem; }

/* ---- Experience lists ------------------------------------------------- */
.roles { list-style: none; padding: 0; margin: 0; }
.roles > li { padding-block: 1.25rem; border-top: 1px solid var(--border-subtle); }
.roles > li:last-child { border-bottom: 1px solid var(--border-subtle); }
.roles h3 { margin-bottom: 0.125rem; font-size: 1.125rem; }
.roles .company { margin-bottom: 0.25rem; font-weight: 500; }
.roles .dates { font-family: var(--font-mono); font-size: var(--small); color: var(--muted); margin-bottom: 0.5rem; }
.roles p:last-child { margin-bottom: 0; }
@media (min-width: 40em) {
  .roles > li { display: grid; grid-template-columns: 11rem 1fr; gap: 1.5rem; }
  .roles .dates { margin: 0.2rem 0 0; }
}

.role-article { padding-block: 2rem; border-top: 1px solid var(--border-subtle); }
.role-article h2 { font-size: var(--step-1); margin-bottom: 0.25rem; }
.role-article .dates { font-family: var(--font-mono); font-size: var(--small); color: var(--muted); margin-bottom: 1rem; }
.role-article .label { font-weight: 600; }

/* ---- Description list (venture facts) ---------------------------------- */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.375rem 1.25rem; margin: 1.25rem 0 1.5rem; }
.facts dt { font-family: var(--font-mono); font-size: var(--small); color: var(--muted); padding-top: 0.15rem; }
.facts dd { margin: 0; }
.venture { padding-block: 2.5rem; border-top: 1px solid var(--border-subtle); }
.venture-head { display: grid; gap: 1.5rem; }
@media (min-width: 52em) {
  .venture-head { grid-template-columns: 1fr 22rem; align-items: start; gap: 2.5rem; }
  .venture-head .logo-panel { order: 2; height: 14rem; }
}
.venture .tagline { font-size: var(--step-1); color: var(--muted); line-height: 1.4; }

/* ---- About preview ---------------------------------------------------- */
.about-grid { display: grid; gap: 2rem; }
.about-portrait { width: min(100%, 14rem); }
@media (min-width: 52em) {
  .about-grid { grid-template-columns: 4fr 8fr; gap: 3rem; align-items: start; }
  .about-portrait { width: 100%; max-width: 20rem; }
}

/* ---- Articles --------------------------------------------------------- */
.breadcrumbs ol { list-style: none; padding: 0; margin: 0 0 1.5rem; display: flex; flex-wrap: wrap; gap: 0.5rem; font-size: var(--small); }
.breadcrumbs li + li::before { content: "/"; margin-right: 0.5rem; color: var(--muted); }
.byline { font-family: var(--font-mono); font-size: var(--small); color: var(--muted); }
.article-body { padding-bottom: var(--section); }
.article-list { list-style: none; padding: 0; margin: 0; }
.article-list > li { padding-block: 1.75rem; border-top: 1px solid var(--border-subtle); max-width: 68ch; }
.article-list h2 { font-size: var(--step-1); margin-bottom: 0.25rem; }
.article-list h2 a { color: var(--ink); text-decoration: none; }
.article-list h2 a:hover { color: var(--accent); text-decoration: underline; }
.topics { display: flex; flex-wrap: wrap; gap: 0.5rem; list-style: none; padding: 0; }
.topics li { font-family: var(--font-mono); font-size: var(--small); border: 1px solid var(--border-ui); border-radius: 999px; padding: 0.25rem 0.75rem; }

/* ---- CTA band --------------------------------------------------------- */
.cta-band { padding-block: var(--section); border-top: 1px solid var(--border-subtle); }
.cta-band p { max-width: 60ch; }

/* ---- Contact + form --------------------------------------------------- */
.contact-grid { display: grid; gap: 2rem; }
@media (min-width: 52em) { .contact-grid { grid-template-columns: 5fr 7fr; gap: 3rem; } }
.form { max-width: 40rem; }
.form-note { font-size: var(--small); color: var(--muted); }
.field { margin-bottom: 1.25rem; }
.field label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
.optional { font-weight: 400; color: var(--muted); }
.hint { font-size: var(--small); color: var(--muted); margin: 0.25rem 0 0; }
.field input, .field textarea {
  display: block; width: 100%; min-height: 2.75rem; padding: 0.625rem 0.75rem;
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border-ui); border-radius: 0.375rem;
}
.field textarea { min-height: 9rem; resize: vertical; }
.field input:focus-visible, .field textarea:focus-visible { outline-offset: 1px; }
.field [aria-invalid="true"] { border: 2px solid var(--error); }
.error-text { color: var(--error); font-size: var(--small); font-weight: 600; margin: 0.25rem 0 0; }
.error-summary { border: 2px solid var(--error); border-radius: 0.5rem; padding: 1rem 1.25rem; margin-bottom: 1.5rem; }
.error-summary h2 { font-size: 1.125rem; color: var(--error); }
.error-summary ul { margin: 0; padding-left: 1.25rem; }
.error-summary a { color: var(--error); font-weight: 600; }
.form-status { margin-top: 1rem; font-weight: 600; }
.form-status.is-error { color: var(--error); }
.form-success { border: 2px solid var(--success); border-radius: 0.5rem; padding: 1.25rem; }
.form-success:focus { outline: 3px solid var(--accent); outline-offset: 2px; }
.form-privacy { font-size: var(--small); color: var(--muted); margin-top: 1rem; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.contact-list { list-style: none; padding: 0; }
.contact-list li { margin-bottom: 0.75rem; }
.contact-list .label { display: block; font-family: var(--font-mono); font-size: var(--small); color: var(--muted); }
.contact-list a { overflow-wrap: anywhere; }

/* ---- Footer ----------------------------------------------------------- */
.site-footer { border-top: 1px solid var(--border-subtle); padding-block: 3rem 2rem; font-size: 0.9375rem; }
.footer-grid { display: grid; gap: 2rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); }
.footer-name { font-weight: 700; margin-bottom: 0.25rem; }
.footer-identity p:last-child { color: var(--muted); }
.footer-heading { font-family: var(--font-mono); font-size: var(--small); font-weight: 500; color: var(--muted); margin-bottom: 0.5rem; letter-spacing: 0; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li a { display: inline-block; padding-block: 0.3rem; color: var(--ink); }
.site-footer li a:hover { color: var(--accent); }
.footer-bottom {
  display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; margin-top: 2.5rem; padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle); color: var(--muted); font-size: var(--small);
}
.footer-bottom p { margin: 0; }
.footer-bottom a { overflow-wrap: anywhere; }

/* ---- Consent banner --------------------------------------------------- */
.consent {
  position: fixed; z-index: 30; left: 1rem; right: 1rem; bottom: 1rem; max-width: 30rem;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border-ui); border-radius: var(--radius);
  padding: 1rem 1.25rem; box-shadow: 0 8px 24px rgb(0 0 0 / 0.18); font-size: 0.9375rem;
}
.consent[hidden] { display: none; }
.consent-title { font-size: 1rem; margin-bottom: 0.25rem; }
.consent-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.5rem; }
.consent-more { margin: 0; font-size: var(--small); }

/* ---- 404 -------------------------------------------------------------- */
.not-found-links { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.75rem 1.5rem; }

/* ---- Forced colors / motion ------------------------------------------- */
@media (forced-colors: active) {
  .btn, .menu-toggle, .card, .consent { border: 2px solid ButtonText; }
  .field [aria-invalid="true"] { border: 3px solid Mark; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

@media print {
  .site-header, .site-footer, .consent, .skip-link { display: none; }
  a { color: inherit; }
}

/* ---- Utilities -------------------------------------------------------- */
.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }

/* ---- FAQ -------------------------------------------------------------- */
.faq dt { font-weight: 600; margin-top: 1.25rem; }
.faq dd { margin: 0.25rem 0 0; }

/* ---- Share + author --------------------------------------------------- */
.share, .author-box { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--border-subtle); }
.share-title { font-family: var(--font-mono); font-size: var(--small); font-weight: 500; color: var(--muted); margin-bottom: 0.75rem; }
.share-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.share-list a, .share-list .link-button {
  display: inline-flex; align-items: center; min-height: 2.75rem; padding: 0 1rem;
  border: 1px solid var(--border-ui); border-radius: 999px; color: var(--ink); text-decoration: none; font-size: 0.9375rem;
}
.share-list a:hover, .share-list .link-button:hover { border-color: var(--accent); color: var(--accent); }
.share-list .link-button[hidden] { display: none; }
.share-status { min-height: 1.5rem; margin-top: 0.5rem; font-size: var(--small); color: var(--success); }
.section-spacer { height: var(--section); }
