/* ==========================================================================
   Sachintha Subasinghe – portfolio
   Hand-written, dependency-free. Tokens first, then base, layout, components.
   ========================================================================== */

:root {
    --bg: #faf8f4;
    --bg-alt: #f2efe8;
    --surface: #ffffff;
    --ink: #1c1b19;
    --ink-soft: #57534c;
    --line: #e4dfd5;
    --accent: #1f6f50;
    --accent-ink: #ffffff;
    --accent-hover: #185a41;
    --accent-soft: #e3efe8;
    --danger: #b3261e;
    --focus: #2563eb;

    --font: "Inter", "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgb(28 27 25 / .04), 0 8px 24px rgb(28 27 25 / .06);
    --shadow-lg: 0 2px 4px rgb(28 27 25 / .05), 0 18px 40px rgb(28 27 25 / .10);
    --container: 1120px;
    --gutter: clamp(16px, 4vw, 32px);
    --ease: cubic-bezier(.2, .7, .2, 1);
    --header-h: 68px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #151513;
        --bg-alt: #1c1c19;
        --surface: #22221f;
        --ink: #f2efe8;
        --ink-soft: #b5b0a6;
        --line: #34332e;
        --accent: #3fa57b;
        --accent-ink: #0f1a14;
        --accent-hover: #52b98d;
        --accent-soft: #1f3329;
        --danger: #f2827a;
        --focus: #8ab4ff;
        --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
        --shadow-lg: 0 2px 4px rgb(0 0 0 / .3), 0 18px 40px rgb(0 0 0 / .35);
    }
}

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

html {
    -webkit-text-size-adjust: 100%;
    scroll-padding-top: calc(var(--header-h) + 12px);
}

@media (prefers-reduced-motion: no-preference) {
    html { scroll-behavior: smooth; }
}

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

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
h1, h2, h3, h4 { line-height: 1.15; letter-spacing: -.02em; margin: 0 0 .5em; }
h1 { font-size: clamp(2.1rem, 1.4rem + 3.2vw, 3.6rem); font-weight: 750; letter-spacing: -.035em; }
h2 { font-size: clamp(1.7rem, 1.3rem + 1.6vw, 2.5rem); font-weight: 720; }
h3 { font-size: 1.2rem; font-weight: 650; }
h4 { font-size: .95rem; font-weight: 650; margin-top: 1.4em; }
p { margin: 0 0 1em; }
ul, ol { margin: 0; padding: 0; }

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

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.skip-link {
    position: absolute;
    left: 16px; top: -48px;
    z-index: 100;
    padding: .6rem 1rem;
    background: var(--ink);
    color: var(--bg);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: top .2s;
}
.skip-link:focus { top: 12px; }

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

.icon { width: 1.15em; height: 1.15em; flex: none; }

/* Buttons --------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    min-height: 44px;
    padding: .7rem 1.2rem;
    border: 1px solid transparent;
    border-radius: 999px;
    font: inherit;
    font-size: .975rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease), box-shadow .2s var(--ease);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn .icon { width: 1.1em; height: 1.1em; }

.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 6px 18px rgb(31 111 80 / .25); }

.btn-dark { background: var(--ink); color: var(--bg); }
.btn-dark:hover { opacity: .9; }

.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink); background: var(--surface); }

.btn-link { background: none; color: var(--accent); padding-inline: .4rem; }
.btn-link:hover { text-decoration: underline; transform: none; }

.btn-sm { min-height: 40px; padding: .5rem .95rem; font-size: .9rem; }
.btn-lg { min-height: 52px; padding: .9rem 1.5rem; font-size: 1.025rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: progress; transform: none; }

.btn-ghost .icon { transition: transform .2s var(--ease); }
.btn-ghost:hover .icon { transform: translateX(3px); }

/* Header ---------------------------------------------------------------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(160%) blur(10px);
    -webkit-backdrop-filter: saturate(160%) blur(10px);
    border-bottom: 1px solid transparent;
    transition: border-color .2s;
}
.site-header.is-scrolled { border-bottom-color: var(--line); }

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: var(--header-h);
}

.brand {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .25rem .75rem;
    text-decoration: none;
}
.brand-name { font-weight: 700; letter-spacing: -.01em; }

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .15rem .6rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: .78rem;
    font-weight: 600;
}
.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 0 rgb(34 197 94 / .5);
}
@media (prefers-reduced-motion: no-preference) {
    .status-dot { animation: pulse 2.4s infinite; }
}
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgb(34 197 94 / .5); }
    70% { box-shadow: 0 0 0 7px rgb(34 197 94 / 0); }
    100% { box-shadow: 0 0 0 0 rgb(34 197 94 / 0); }
}

.site-nav { display: flex; align-items: center; gap: 1.75rem; }
.site-nav ul { display: flex; gap: 1.5rem; list-style: none; }
.site-nav ul a {
    position: relative;
    color: var(--ink-soft);
    font-size: .95rem;
    font-weight: 500;
    text-decoration: none;
    transition: color .2s;
}
.site-nav ul a::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: -4px;
    height: 2px;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform .25s var(--ease);
}
.site-nav ul a:hover { color: var(--ink); }
.site-nav ul a:hover::after { transform: scaleX(1); }

.menu-toggle {
    display: none;
    width: 44px; height: 44px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
}
.menu-toggle .icon { width: 22px; height: 22px; }

@media (max-width: 860px) {
    .menu-toggle { display: inline-flex; }
    .site-nav {
        position: absolute;
        top: 100%;
        left: 0; right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        padding: 1rem var(--gutter) 1.5rem;
        background: var(--bg);
        border-bottom: 1px solid var(--line);
        box-shadow: var(--shadow);
        display: none;
    }
    .site-nav.is-open { display: flex; }
    .site-nav ul { flex-direction: column; gap: 0; }
    .site-nav ul a { display: block; padding: .8rem 0; font-size: 1.05rem; color: var(--ink); }
    .site-nav ul a::after { display: none; }
    .site-nav .btn { width: 100%; }
}

@media (max-width: 420px) {
    .status-badge { font-size: .72rem; }
}

/* Hero ------------------------------------------------------------------ */
.hero { padding: clamp(3rem, 7vw, 6rem) 0 clamp(3.5rem, 7vw, 6rem); }

.hero-grid {
    display: grid;
    grid-template-columns: 1.1fr .9fr;
    gap: clamp(2rem, 5vw, 4rem);
    align-items: center;
}

.eyebrow {
    margin-bottom: .9rem;
    color: var(--accent);
    font-size: .82rem;
    font-weight: 650;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.lead {
    max-width: 36ch;
    color: var(--ink-soft);
    font-size: clamp(1.1rem, 1rem + .4vw, 1.3rem);
}
.lead-sm { color: var(--ink-soft); font-size: 1.1rem; }

.hero-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin: 2rem 0 1.75rem; }

.trust-list { display: grid; gap: .5rem; list-style: none; color: var(--ink-soft); font-size: .95rem; }
.trust-list li { display: flex; align-items: center; gap: .55rem; }
.trust-list .icon { color: var(--accent); }

.hero-visual { margin: 0; }
.hero-visual figcaption { margin-top: .85rem; color: var(--ink-soft); font-size: .85rem; text-align: center; }

.browser-frame {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    transform: rotate(1.2deg);
    transition: transform .5s var(--ease);
}
.hero-visual:hover .browser-frame { transform: rotate(0deg) translateY(-4px); }
.browser-bar { display: flex; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.browser-bar span { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }

@media (max-width: 860px) {
    .hero-grid { grid-template-columns: 1fr; }
    .hero-visual { max-width: 560px; }
}

@media (max-width: 480px) {
    .hero-actions .btn { width: 100%; }
}

/* Sections -------------------------------------------------------------- */
.section { padding: clamp(4rem, 8vw, 6.5rem) 0; }
.section-alt { background: var(--bg-alt); }

.section-head { max-width: 640px; margin-bottom: clamp(2rem, 4vw, 3rem); }
.section-sub { color: var(--ink-soft); font-size: 1.075rem; margin: 0; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* Services */
.service-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.25rem;
}
.service-card {
    padding: 1.75rem;
    transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s;
}
.service-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.service-card p { margin: 0; color: var(--ink-soft); }
.service-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px; height: 48px;
    margin-bottom: 1.1rem;
    border-radius: 12px;
    background: var(--accent-soft);
    color: var(--accent);
}
.service-icon .icon { width: 24px; height: 24px; }

/* Work */
.work-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr));
    gap: 1.5rem;
}
.project-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.project-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }

.project-thumb { overflow: hidden; aspect-ratio: 16 / 9; border-bottom: 1px solid var(--line); background: var(--bg-alt); }
.project-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; transition: transform .6s var(--ease); }
.project-card:hover .project-thumb img { transform: scale(1.035); }

.project-body { display: flex; flex: 1; flex-direction: column; padding: 1.4rem 1.5rem 1.5rem; }
.project-body > p { color: var(--ink-soft); font-size: .975rem; }
.project-cat { margin-bottom: .35rem; color: var(--accent); font-size: .78rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; }

.project-outcome {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    padding: .7rem .85rem;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    color: var(--ink) !important;
    font-size: .93rem !important;
    font-weight: 550;
}
.project-outcome .icon { margin-top: .15em; color: var(--accent); }

.tags { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1.25rem; list-style: none; }
.tags li {
    padding: .2rem .6rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--ink-soft);
    font-size: .78rem;
    font-weight: 550;
}

.project-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: auto; }

/* Case study dialog */
.case-dialog {
    width: min(720px, calc(100% - 32px));
    max-height: calc(100dvh - 48px);
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-lg);
}
.case-dialog::backdrop { background: rgb(20 20 18 / .55); backdrop-filter: blur(3px); }
.case-dialog[open] { animation: dialog-in .28s var(--ease); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@media (prefers-reduced-motion: reduce) { .case-dialog[open] { animation: none; } }

.dialog-inner { position: relative; padding: 1.5rem; }
.dialog-inner img { margin-bottom: 1.25rem; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.dialog-inner p { color: var(--ink-soft); }
.dialog-close {
    position: absolute;
    top: .75rem; right: .75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    z-index: 1;
}
.dialog-close:hover { background: var(--bg-alt); }
body.has-dialog { overflow: hidden; }

/* About */
.about-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: clamp(2rem, 5vw, 4rem); align-items: start; }
.about-grid > div > p:not(.eyebrow):not(.lead-sm) { color: var(--ink-soft); }
.process-card { padding: 1.75rem; }
.process { display: grid; gap: 1rem; list-style: none; counter-reset: step; }
.process li { position: relative; padding-left: 2.6rem; color: var(--ink-soft); counter-increment: step; }
.process li strong { color: var(--ink); }
.process li::before {
    content: counter(step);
    position: absolute;
    left: 0; top: -.1rem;
    display: grid;
    place-items: center;
    width: 1.85rem; height: 1.85rem;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: .85rem;
    font-weight: 700;
}
@media (max-width: 860px) { .about-grid { grid-template-columns: 1fr; } }

/* Contact */
.contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(2rem, 5vw, 4rem); align-items: start; }
.contact-intro .btn-block { max-width: 380px; margin-top: .5rem; }
.contact-list { display: grid; gap: .75rem; margin-top: 2rem; list-style: none; }
.contact-list li { display: flex; align-items: center; gap: .7rem; color: var(--ink-soft); }
.contact-list .icon { color: var(--accent); }
.contact-list a { text-decoration: none; overflow-wrap: anywhere; }
.contact-list a:hover { color: var(--ink); text-decoration: underline; }
@media (max-width: 860px) { .contact-grid { grid-template-columns: 1fr; } }

.inquiry-form { padding: clamp(1.4rem, 3vw, 2rem); }
.inquiry-form h3 { margin-bottom: 1.25rem; }
.field { margin-bottom: 1rem; }
.field label { display: block; margin-bottom: .35rem; font-size: .92rem; font-weight: 600; }
.field input,
.field textarea {
    width: 100%;
    padding: .75rem .9rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--ink);
    font: inherit;
    font-size: 1rem;
    transition: border-color .2s, box-shadow .2s;
}
.field textarea { min-height: 120px; resize: vertical; }
.field input:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}
.field input[aria-invalid="true"],
.field textarea[aria-invalid="true"] { border-color: var(--danger); }
.field-error { min-height: 0; margin: .3rem 0 0; color: var(--danger); font-size: .85rem; }
.field-error:empty { display: none; }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.form-status { margin-top: 1rem; font-size: .95rem; }
.form-status:empty { display: none; }
.form-status.is-success { padding: .8rem 1rem; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--ink); }
.form-status.is-error { padding: .8rem 1rem; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--ink); }
.form-wa { margin-top: .75rem; }
.form-wa[hidden] { display: none; }

/* Footer ---------------------------------------------------------------- */
.site-footer { padding: 2rem 0 5.5rem; border-top: 1px solid var(--line); color: var(--ink-soft); font-size: .9rem; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; }
.footer-inner p { margin: 0; }
.footer-inner ul { display: flex; gap: 1.25rem; list-style: none; }
.footer-inner a { text-decoration: none; }
.footer-inner a:hover { color: var(--ink); text-decoration: underline; }

/* Floating WhatsApp ---------------------------------------------------- */
.wa-float {
    position: fixed;
    right: 20px; bottom: 20px;
    z-index: 40;
    display: grid;
    place-items: center;
    width: 56px; height: 56px;
    border-radius: 50%;
    background: #25d366;
    color: #fff;
    box-shadow: 0 8px 24px rgb(0 0 0 / .2);
    transition: transform .2s var(--ease);
}
.wa-float:hover { transform: scale(1.07); }
.wa-float .icon { width: 28px; height: 28px; }

/* Reveal on scroll (only when JS adds .js and motion is allowed) -------- */
@media (prefers-reduced-motion: no-preference) {
    .js .reveal { opacity: 0; transform: translateY(16px); transition: opacity .6s var(--ease), transform .6s var(--ease); }
    .js .reveal.is-visible { opacity: 1; transform: none; }
}
main:focus{outline:none}
