/* =========================================================
   Chalaka Priyashantha | Geospatial Portfolio
   White / black / deep red. IBM Plex Sans + Source Sans 3.
   Edit the tokens below to retheme the whole site.
   ========================================================= */

:root {
  --red: #B4232C;
  --red-dark: #8E1A22;
  --ink: #111111;
  --text: #2b2b2b;
  --muted: #555555;
  --line: #e4e4e4;
  --line-strong: #cfcfcf;
  --bg: #ffffff;

  --font-head: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-body: "Source Sans 3", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;

  --container: 1240px;
  --gutter: clamp(20px, 4vw, 40px);
  --header-h: 72px;
  --section-y: clamp(72px, 9vw, 136px);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 12px);
  -webkit-text-size-adjust: 100%;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;           /* 16px */
  line-height: 1.65;
  font-weight: 400;
  text-align: left;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { display: block; max-width: 100%; height: auto; }
a { color: var(--red); text-underline-offset: 3px; }
a:hover { color: var(--red-dark); }
ul, ol { margin: 0; padding: 0; list-style: none; }
p { margin: 0 0 1em; }
h1, h2, h3, h4 { font-family: var(--font-head); color: var(--ink); font-weight: 500; margin: 0; }
strong { font-weight: 600; color: var(--ink); }

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

.container { width: 100%; max-width: calc(var(--container) + var(--gutter) * 2); margin-inline: auto; padding-inline: var(--gutter); }

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 2px;
  font-family: var(--font-head); text-decoration: none;
}
.skip-link:focus { top: 12px; color: #fff; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color .25s ease;
}
.site-header.is-scrolled { border-bottom-color: var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: var(--header-h); gap: 24px; }

.brand {
  font-family: var(--font-head); font-weight: 500; font-size: 1.125rem;
  letter-spacing: -0.005em; color: var(--ink); text-decoration: none;
}
.brand:hover { color: var(--ink); }

.site-nav ul { display: flex; gap: clamp(20px, 3vw, 40px); }
.site-nav a {
  position: relative; display: inline-block; padding: 8px 0;
  font-family: var(--font-head); font-weight: 400; font-size: 0.9375rem;
  color: var(--ink); text-decoration: none;
}
.site-nav a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 2px; height: 2px;
  background: var(--red); transform: scaleX(0); transform-origin: left; transition: transform .25s ease;
}
.site-nav a:hover::after,
.site-nav a.is-active::after { transform: scaleX(1); }
.site-nav a.is-active { font-weight: 500; }

.nav-toggle { display: none; }

@media (max-width: 760px) {
  :root { --header-h: 64px; }
  .nav-toggle {
    display: inline-flex; align-items: center; gap: 10px;
    min-height: 44px; padding: 0 4px 0 12px; background: none; border: 0; cursor: pointer;
    font-family: var(--font-head); font-size: 0.9375rem; font-weight: 500; color: var(--ink);
  }
  .nav-toggle-bars { position: relative; width: 22px; height: 12px; display: block; }
  .nav-toggle-bars i { position: absolute; left: 0; right: 0; height: 2px; background: var(--ink); transition: transform .25s ease, top .25s ease; }
  .nav-toggle-bars i:first-child { top: 0; }
  .nav-toggle-bars i:last-child { top: 10px; }
  .nav-toggle[aria-expanded="true"] .nav-toggle-bars i:first-child { top: 5px; transform: rotate(45deg); }
  .nav-toggle[aria-expanded="true"] .nav-toggle-bars i:last-child { top: 5px; transform: rotate(-45deg); }

  .site-nav {
    position: absolute; left: 0; right: 0; top: 100%;
    background: #fff; border-bottom: 1px solid var(--line);
    max-height: 0; overflow: hidden; visibility: hidden;
    transition: max-height .3s ease, visibility 0s linear .3s;
  }
  .site-nav.is-open { max-height: 420px; visibility: visible; transition: max-height .3s ease; }
  .site-nav ul { flex-direction: column; gap: 0; padding: 8px var(--gutter) 20px; }
  .site-nav li + li { border-top: 1px solid var(--line); }
  .site-nav a { display: block; padding: 15px 0; font-size: 1.0625rem; }
  .site-nav a::after { display: none; }
  .site-nav a.is-active { color: var(--red); }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 28px;
  font-family: var(--font-head); font-weight: 500; font-size: 0.9375rem; letter-spacing: 0.005em;
  text-decoration: none; cursor: pointer;
  border: 1px solid transparent; border-radius: 2px;
  transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn-ghost:hover { background: var(--ink); color: #fff; }
.btn[disabled] { opacity: .6; cursor: progress; }
.btn-row { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 36px; }

/* ---------- Sections ---------- */
.section { padding-block: var(--section-y); }
.section-tight { padding-block: clamp(48px, 6vw, 80px) var(--section-y); }

.section-head { margin-bottom: clamp(32px, 4vw, 56px); max-width: 720px; }
.section-head h2 {
  font-size: clamp(1.75rem, 1.2rem + 1.8vw, 2.5rem);
  line-height: 1.15; letter-spacing: -0.015em;
}
.section-head h2::before {
  content: ""; display: block; width: 44px; height: 2px; background: var(--red); margin-bottom: 22px;
}
.lede { margin: 18px 0 0; font-size: 1.1875rem; line-height: 1.6; color: var(--muted); }

/* ---------- Hero ---------- */
.hero { padding-block: clamp(40px, 6vw, 88px) clamp(48px, 7vw, 104px); }
.hero-grid {
  display: grid; align-items: center; gap: clamp(32px, 5vw, 80px);
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
}
.hero-copy { padding-top: clamp(0px, 4vw, 56px); }
.hero-role { font-family: var(--font-head); font-weight: 500; font-size: 1.0625rem; color: var(--red); margin: 0 0 20px; }
.hero h1 {
  font-size: clamp(2.5rem, 1.4rem + 3.6vw, 4.25rem);
  line-height: 1.04; letter-spacing: -0.025em; margin-bottom: 18px;
}
.hero-sub { font-family: var(--font-head); font-size: 1.1875rem; color: var(--ink); margin: 0 0 24px; }
.hero-intro { max-width: 34em; font-size: 1.125rem; line-height: 1.7; color: var(--muted); margin: 0; }

.hero-figure { margin: 0; position: relative; }
.hero-figure img { width: 100%; height: auto; border: 1px solid var(--line); }
/* a single restrained accent: a thin red offset frame behind the photo */
.hero-figure::before {
  content: ""; position: absolute; z-index: -1;
  inset: 18px -18px -18px 18px; border: 1px solid var(--red);
}
.hero { overflow-x: clip; }

@keyframes hero-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.hero-copy > * { animation: hero-in .8s cubic-bezier(.2,.7,.2,1) both; }
.hero-copy > *:nth-child(2) { animation-delay: .06s; }
.hero-copy > *:nth-child(3) { animation-delay: .12s; }
.hero-copy > *:nth-child(4) { animation-delay: .18s; }
.hero-copy > *:nth-child(5) { animation-delay: .24s; }
.hero-figure { animation: hero-in 1s cubic-bezier(.2,.7,.2,1) .15s both; }

@media (max-width: 959px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-copy { padding-top: 0; }
  .hero-figure::before { inset: 12px -10px -12px 12px; }
}

/* ---------- Contents list ---------- */
.contents-list { border-top: 1px solid var(--line); }
.contents-list li { border-bottom: 1px solid var(--line); }
.contents-list a {
  display: grid; grid-template-columns: 64px minmax(0, 1.6fr) minmax(0, 1fr);
  align-items: baseline; gap: 8px 24px; padding: 20px 4px;
  text-decoration: none; color: var(--ink);
  transition: background-color .2s ease, padding-left .2s ease;
}
.contents-list a:hover { background: #fafafa; padding-left: 14px; }
.c-num { font-family: var(--font-head); font-weight: 500; color: var(--red); font-size: 1.0625rem; font-variant-numeric: tabular-nums; }
.c-title { font-family: var(--font-head); font-weight: 500; font-size: 1.0625rem; line-height: 1.4; }
.c-sector { color: var(--muted); font-size: 0.9688rem; line-height: 1.45; }
@media (max-width: 760px) {
  .contents-list a { grid-template-columns: 40px 1fr; padding: 18px 0; }
  .contents-list a:hover { padding-left: 0; }
  .c-sector { grid-column: 2; }
}

/* ---------- Generic two-column split ---------- */
.split { display: grid; gap: clamp(32px, 6vw, 96px); grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); align-items: start; }
.split-media { position: sticky; top: calc(var(--header-h) + 24px); }
@media (max-width: 959px) {
  .split { grid-template-columns: 1fr; }
  .split-media { position: static; }
}

.stages { counter-reset: none; border-top: 1px solid var(--line); }
.stages li { display: grid; grid-template-columns: 52px 1fr; gap: 8px 16px; padding: 22px 0; border-bottom: 1px solid var(--line); }
.stage-num { font-family: var(--font-head); font-weight: 500; font-size: 1.5rem; line-height: 1.2; color: var(--red); font-variant-numeric: tabular-nums; }
.stages h3 { font-size: 1.1875rem; line-height: 1.3; margin-bottom: 6px; }
.stages p { margin: 0; color: var(--muted); }

/* ---------- Media + captions ---------- */
.media { margin: 0; }
.zoomable {
  position: relative; display: block; width: 100%; padding: 0; margin: 0;
  background: #fff; border: 1px solid var(--line); border-radius: 0; cursor: zoom-in;
  transition: border-color .2s ease;
}
.zoomable:hover { border-color: var(--ink); }
.zoomable img { width: 100%; height: auto; }
.zoom-badge {
  position: absolute; right: 10px; bottom: 10px;
  display: grid; place-items: center; width: 34px; height: 34px;
  background: rgba(255,255,255,.94); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 2px;
  transition: background-color .2s ease, color .2s ease;
}
.zoom-badge svg { width: 16px; height: 16px; }
.zoomable:hover .zoom-badge { background: var(--red); color: #fff; border-color: var(--red); }
figcaption { margin-top: 12px; font-size: 0.9375rem; line-height: 1.5; color: var(--muted); }

/* ---------- Projects ---------- */
.projects { padding-bottom: clamp(48px, 6vw, 80px); }
.project { padding-block: clamp(48px, 6vw, 88px); border-top: 1px solid var(--line); }
.project:first-of-type { margin-top: 8px; }
.project-grid {
  display: grid; align-items: start;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);   /* 40 / 60 */
  gap: clamp(32px, 6vw, 88px);
}
.project-media { position: sticky; top: calc(var(--header-h) + 24px); }

.project-num { display: flex; align-items: center; gap: 18px; margin-bottom: 18px; }
.project-num span { font-family: var(--font-head); font-weight: 500; font-size: 2.5rem; line-height: 1; color: var(--red); font-variant-numeric: tabular-nums; }
.project-num::after { content: ""; flex: 1; height: 1px; background: var(--line-strong); }

.project h3 { font-size: clamp(1.4rem, 1.1rem + 0.9vw, 1.75rem); line-height: 1.25; letter-spacing: -0.01em; margin-bottom: 26px; overflow-wrap: anywhere; overflow-wrap: break-word; }
.project h4 { font-size: 1rem; font-weight: 600; margin: 30px 0 8px; letter-spacing: 0; }
.project-text p { margin-bottom: 0; }

.facts { margin: 0 0 8px; border-top: 1px solid var(--line); }
.facts > div { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.facts dt { font-family: var(--font-head); font-weight: 500; font-size: 0.9063rem; color: var(--muted); padding-top: 2px; }
.facts dd { margin: 0; color: var(--ink); overflow-wrap: break-word; min-width: 0; }

.ticks li { position: relative; padding: 5px 0 5px 22px; }
.ticks li::before { content: ""; position: absolute; left: 2px; top: 0.95em; width: 8px; height: 2px; background: var(--red); }

.note { max-width: 62em; margin: clamp(24px, 4vw, 48px) 0 0; padding-top: 24px; border-top: 1px solid var(--line); font-size: 0.9375rem; color: var(--muted); }

@media (max-width: 959px) {
  .project-grid { grid-template-columns: 1fr; }
  .project-media { position: static; }
}
@media (max-width: 480px) {
  .facts > div { grid-template-columns: 1fr; gap: 0; padding: 12px 0; }
  .project-num span { font-size: 2.125rem; }
}

/* ---------- Background ---------- */
.background { padding-top: clamp(64px, 8vw, 112px); border-top: 1px solid var(--line); }
.background .section-head { max-width: 920px; margin-bottom: 20px; }
.background .section-head h2 { font-size: clamp(1.375rem, 1rem + 1.6vw, 2.125rem); line-height: 1.2; letter-spacing: -0.005em; }
.subtitle { margin: 16px 0 0; font-family: var(--font-head); font-size: 1.125rem; color: var(--red); }
.intro { max-width: 46em; margin: 0 0 clamp(36px, 5vw, 64px); font-size: 1.125rem; line-height: 1.75; }
.bg-figure { margin-bottom: clamp(36px, 5vw, 64px); }
.bg-pair { display: grid; gap: clamp(20px, 3vw, 40px); grid-template-columns: 1.778fr 0.974fr; align-items: start; }
.bg-pair .media { min-width: 0; }
@media (max-width: 760px) {
  .bg-pair { grid-template-columns: 1fr; gap: 36px; }
}

/* ---------- Contact ---------- */
.contact { border-top: 1px solid var(--line); }
.contact-grid { display: grid; gap: clamp(32px, 6vw, 96px); grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); align-items: start; }
.contact .section-head { margin-bottom: 0; }
.social { display: flex; gap: 12px; margin-top: 32px; }
.social a {
  display: grid; place-items: center; width: 48px; height: 48px;
  color: var(--ink); border: 1px solid var(--line-strong); border-radius: 2px;
  transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}
.social a:hover { background: var(--red); border-color: var(--red); color: #fff; }
.social svg { width: 22px; height: 22px; }

.field { margin-bottom: 22px; }
.field label { display: block; margin-bottom: 8px; font-family: var(--font-head); font-weight: 500; font-size: 0.9375rem; color: var(--ink); }
.field input, .field textarea {
  width: 100%; min-height: 50px; padding: 12px 14px;
  font: inherit; font-size: 1rem; color: var(--ink);
  background: #fff; border: 1px solid var(--line-strong); border-radius: 2px;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.field textarea { min-height: 160px; resize: vertical; line-height: 1.55; }
.field input:hover, .field textarea:hover { border-color: #999; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(180, 35, 44, .18); }
.field.has-error input, .field.has-error textarea { border-color: var(--red); }
.field-error { margin: 6px 0 0; min-height: 0; font-size: 0.9063rem; color: var(--red-dark); }
.field-error:empty { display: none; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 24px; margin-top: 8px; }
.form-status { margin: 0; font-size: 1rem; }
.form-status.is-success { color: #1b6e3a; }
.form-status.is-error { color: var(--red-dark); }
.form-status:empty { display: none; }

@media (max-width: 959px) {
  .contact-grid { grid-template-columns: 1fr; }
  .form-actions .btn { width: 100%; }
}

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding-block: 32px; font-size: 0.9375rem; color: var(--muted); }
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.footer-inner p { margin: 0; }
.site-footer a { color: var(--ink); }

/* ---------- Image viewer ---------- */
.lightbox {
  position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh;
  max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: #fff; color: var(--ink);
}
.lightbox:not([open]) { display: none; }
.lightbox[open] { display: flex; flex-direction: column; }
.lightbox::backdrop { background: rgba(0,0,0,.85); }
.lb-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px clamp(14px, 3vw, 28px); border-bottom: 1px solid var(--line); background: #fff;
}
.lb-caption { margin: 0; font-size: 0.9688rem; line-height: 1.4; color: var(--muted); min-width: 0; }
.lb-actions { display: flex; gap: 10px; flex-shrink: 0; }
.lb-btn {
  min-height: 44px; padding: 0 16px; cursor: pointer;
  font-family: var(--font-head); font-weight: 500; font-size: 0.9063rem; color: var(--ink);
  background: #fff; border: 1px solid var(--line-strong); border-radius: 2px;
  transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}
.lb-btn:hover { border-color: var(--ink); }
.lb-close { background: var(--ink); color: #fff; border-color: var(--ink); }
.lb-close:hover { background: var(--red); border-color: var(--red); color: #fff; }
.lb-btn[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.lb-stage { flex: 1; min-height: 0; overflow: auto; display: grid; place-items: center; padding: clamp(10px, 2vw, 24px); background: #f6f6f6; }
.lb-stage img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; cursor: zoom-in; }
.lb-stage.is-zoomed { display: block; place-items: unset; }
.lb-stage.is-zoomed img { max-width: none; max-height: none; cursor: zoom-out; margin: 0 auto; }
@media (max-width: 600px) {
  .lb-bar { flex-direction: column-reverse; align-items: stretch; gap: 8px; }
  .lb-actions { justify-content: space-between; }
  .lb-actions .lb-btn { flex: 1; }
}
body.lb-open { overflow: hidden; }

/* Print: keep it sensible */
@media print {
  .site-header, .zoom-badge, .btn-row, .form-wrap, .social { display: none; }
  .project-media { position: static; }
}
