/* ==========================================================================
   Muhammad Ibrahim Awan - shared styles (index.html, projects.html)
   Mobile first. Dark ground, periwinkle accent.
   ========================================================================== */

:root {
    --bg:      #07090F;
    --bg-1:    #0B0E17;
    --bg-2:    #111522;
    --bg-3:    #181D2C;

    --ac:      #5E6AD2;
    --ac-hi:   #828FFF;
    --ac-soft: rgba(110, 122, 230, 0.12);
    --ac-line: rgba(130, 143, 255, 0.38);

    --tx:      #F3F4F6;
    --tx-2:    #A8AFBB;
    --tx-3:    #808897;
    --line:    rgba(255, 255, 255, 0.08);
    --line-2:  rgba(255, 255, 255, 0.15);
    --bad:     #FF8A8A;

    --shell:   1200px;
    --gut:     20px;
    --nav-h:   64px;
    --r:       14px;

    --ease-o:  cubic-bezier(.16, 1, .3, 1);
    --ease-io: cubic-bezier(.65, 0, .35, 1);

    --z-nav: 50; --z-toast: 60;

    color-scheme: dark;
}

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

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 12px); }

body {
    background:
        radial-gradient(1000px 560px at 12% -12%, rgba(76, 96, 214, .14), transparent 62%),
        radial-gradient(900px 520px at -10% 38%, rgba(60, 110, 220, .07), transparent 60%),
        var(--bg);
    color: var(--tx-2);
    font-family: 'Host Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 1.0625rem;
    line-height: 1.6;
    letter-spacing: -0.005em;
    overflow-x: clip;
    min-height: 100dvh;
}

h1, h2, h3, h4 { color: var(--tx); font-weight: 600; letter-spacing: -0.03em; line-height: 1.08; text-wrap: balance; }
p { text-wrap: pretty; }
a { color: inherit; }
img, svg { display: block; max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }

::selection { background: var(--ac); color: #fff; }
:focus-visible { outline: 2px solid var(--ac-hi); outline-offset: 3px; border-radius: 8px; }
::placeholder { color: var(--tx-3); opacity: 1; }
html { scrollbar-color: var(--bg-3) var(--bg); }
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 10px; border: 2px solid var(--bg); }

.skip { position: absolute; left: 16px; top: -80px; z-index: 99; background: var(--ac); color: #fff; padding: .6rem 1rem; border-radius: 10px; text-decoration: none; font-weight: 500; }
.skip:focus { top: 12px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

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

.sec { padding-block: clamp(4.5rem, 11vw, 8.5rem); }
.sec__t { font-size: clamp(2rem, 6.4vw, 3.25rem); max-width: 22ch; }
.sec__p { margin-top: 1rem; max-width: 52ch; color: var(--tx-2); }
.sec__head { margin-bottom: clamp(2.25rem, 5vw, 3.5rem); }

/* ---------- icons (Tabler outline, masked so they take currentColor) ---------- */
.ic { display: inline-block; width: 1.15em; height: 1.15em; flex: none; background: currentColor;
      -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }
.i-arrow  { --i: url(https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/arrow-right.svg); }
.i-out    { --i: url(https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/arrow-up-right.svg); }
.i-prev   { --i: url(https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/chevron-left.svg); }
.i-next   { --i: url(https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/chevron-right.svg); }
.i-check  { --i: url(https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/circle-check.svg); }
.i-copy   { --i: url(https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/copy.svg); }
.i-mail   { --i: url(https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/mail.svg); }
.i-map    { --i: url(https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/sitemap.svg); }
.i-db     { --i: url(https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/database.svg); }
.i-cloud  { --i: url(https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/cloud-upload.svg); }
.i-robot  { --i: url(https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/robot.svg); }
.i-li     { --i: url(https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/brand-linkedin.svg); }
.i-lock   { --i: url(https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/lock.svg); }
.i-gh     { --i: url(https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/brand-github.svg); }

/* ---------- buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
    min-height: 48px; padding: .7rem 1.35rem; border-radius: 999px;
    border: 1px solid var(--line-2); background: transparent; color: var(--tx);
    font-size: .98rem; font-weight: 500; letter-spacing: -0.01em; text-decoration: none; white-space: nowrap;
    cursor: pointer;
    transition: background-color .18s var(--ease-o), border-color .18s var(--ease-o), transform .12s var(--ease-o);
}
.btn:hover { border-color: rgba(255, 255, 255, .32); background: rgba(255, 255, 255, .04); }
.btn:active { transform: scale(.97); }
.btn .ic { transition: transform .2s var(--ease-o); }
.btn:hover .i-arrow { transform: translateX(3px); }
.btn:hover .i-out { transform: translate(2px, -2px); }
.btn--pri { background: var(--ac); border-color: transparent; color: #fff; box-shadow: 0 6px 16px -8px rgba(0, 0, 0, .7), inset 0 1px 0 rgba(255, 255, 255, .16); }
.btn--pri:hover { background: #4F5BC4; border-color: transparent; }
.btn--sm { min-height: 40px; padding: .45rem 1rem; font-size: .9rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.link { display: inline-flex; align-items: center; gap: .4rem; color: var(--ac-hi); text-decoration: none; font-weight: 500; }
.link:hover { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }

/* ---------- nav ---------- */
.nav { position: sticky; top: 0; z-index: var(--z-nav); height: var(--nav-h);
       background: rgba(8, 9, 10, .82); backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%);
       border-bottom: 1px solid transparent; transition: border-color .25s var(--ease-o); }
.nav.is-scrolled { border-bottom-color: var(--line); }
.nav__in { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.nav__name { color: var(--tx); font-weight: 600; letter-spacing: -0.02em; text-decoration: none; font-size: 1rem; white-space: nowrap; }
.nav__links { display: none; gap: 1.75rem; list-style: none; }
.nav__links a { color: var(--tx-2); text-decoration: none; font-size: .94rem; transition: color .15s; }
.nav__links a:hover, .nav__links a[aria-current="page"] { color: var(--tx); }
.nav__r { display: flex; align-items: center; gap: 1.75rem; }

/* ---------- tags ---------- */
.tags { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; }
.tags li { font-family: 'Martian Mono', ui-monospace, monospace; font-size: .68rem; color: var(--tx-2);
           padding: .28rem .6rem; border-radius: 6px; background: rgba(255, 255, 255, .045); border: 1px solid var(--line); }

/* ---------- architecture diagrams ---------- */
.dg { width: 100%; height: auto; font-family: 'Host Grotesk', sans-serif; }
.dg .n     { fill: #15161B; stroke: rgba(255, 255, 255, .14); stroke-width: 1; }
.dg .n-ac  { fill: rgba(110, 122, 230, .16); stroke: rgba(130, 143, 255, .5); stroke-width: 1; }
.dg .n-ok  { fill: rgba(130, 143, 255, .08); stroke: rgba(130, 143, 255, .32); stroke-width: 1; stroke-dasharray: 0; }
.dg .t     { fill: #F3F4F6; font-size: 10px; font-weight: 600; letter-spacing: -.025em; }
.dg .s     { fill: #A3AAB6; font-size: 7.6px; letter-spacing: -.015em; }
.dg .lbl   { fill: #828FFF; font-size: 8.5px; font-weight: 500; letter-spacing: .02em; }
.dg .ln    { stroke: rgba(255, 255, 255, .22); stroke-width: 1; fill: none; }
.dg .ln-ac { stroke: rgba(130, 143, 255, .6); stroke-width: 1.2; fill: none; }
.dg .ln-d  { stroke: rgba(255, 255, 255, .18); stroke-width: 1; fill: none; stroke-dasharray: 3 3; }
.dg .bnd   { fill: none; stroke: rgba(130, 143, 255, .35); stroke-width: 1; stroke-dasharray: 4 4; }

/* ---------- case studies (shared by home + projects) ---------- */
.case { background: linear-gradient(180deg, rgba(94, 106, 210, .05), transparent 40%), var(--bg-1); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; display: grid; grid-template-rows: auto 1fr;
        transition: transform .35s var(--ease-o), border-color .35s var(--ease-o), box-shadow .35s var(--ease-o); }
@media (hover: hover) {
    .case:hover { transform: translateY(-4px); border-color: rgba(130, 143, 255, .28); box-shadow: 0 24px 48px -28px rgba(0, 0, 0, .9); }
}
/* diagrams draw themselves once their card scrolls in (paths get pathLength=1 from JS) */
.js .dg-draw path.ln, .js .dg-draw path.ln-ac { stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset .9s var(--ease-io); transition-delay: calc(var(--i, 0) * 70ms + 250ms); }
.js .dg-draw rect, .js .dg-draw text { opacity: 0; transition: opacity .5s var(--ease-o); transition-delay: calc(var(--i, 0) * 45ms + 120ms); }
.js .is-in .dg-draw path.ln, .js .is-in .dg-draw path.ln-ac { stroke-dashoffset: 0; }
.js .is-in .dg-draw rect, .js .is-in .dg-draw text { opacity: 1; }
.case__fig { background: radial-gradient(120% 90% at 30% 0%, rgba(94, 106, 210, .10), transparent 60%), var(--bg); border-bottom: 1px solid var(--line); padding: clamp(1rem, 3vw, 1.75rem); display: grid; place-items: center; }
.case__fig .dg { max-width: 480px; }
.case > * { min-width: 0; }
.case__scroll { width: 100%; display: grid; place-items: center; }
.case__swipe { display: none; }
@media (max-width: 639px) {
    /* phones: keep diagram type legible, let the figure scroll sideways instead of shrinking */
    .case__fig { display: block; place-items: normal; padding-inline: 0; }
    .case__scroll { display: block; place-items: normal; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; padding-inline: 1rem;
        -webkit-mask: linear-gradient(to right, #000 78%, transparent); mask: linear-gradient(to right, #000 78%, transparent); }
    .case__scroll::-webkit-scrollbar { display: none; }
    .case__scroll.is-end { -webkit-mask: none; mask: none; }
    .case__fig .dg { width: 600px; max-width: none; }
    .case__swipe { display: flex; align-items: center; gap: .35rem; margin: .6rem 1rem 0; font-size: .8rem; color: var(--tx-3); }
}
.case__body { padding: clamp(1.4rem, 4vw, 2.25rem); display: flex; flex-direction: column; gap: 1.4rem; }
.case__t { font-size: clamp(1.4rem, 4.2vw, 1.85rem); }
.case__k { color: var(--tx-2); margin-top: .45rem; font-size: 1rem; }
.pbr { display: grid; gap: 1.1rem; }
.pbr dt { color: var(--ac-hi); font-size: .82rem; font-weight: 500; margin-bottom: .2rem; }
.pbr dd { color: var(--tx-2); font-size: .98rem; line-height: 1.6; }
.pbr dd b { color: var(--tx); font-weight: 500; }
.case__foot { margin-top: auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; padding-top: 1.2rem; border-top: 1px solid var(--line); }

/* confidential client work: no repo, no diagram */
.case--conf { grid-template-rows: 1fr; background: linear-gradient(160deg, rgba(72, 98, 214, .09), transparent 55%), var(--bg-1); }
.badge { display: inline-flex; align-items: center; gap: .35rem; margin-bottom: .9rem; padding: .25rem .65rem; border-radius: 999px;
         font-size: .76rem; font-weight: 500; color: var(--ac-hi); background: var(--ac-soft); border: 1px solid var(--ac-line); }
.badge .ic { width: .9rem; height: .9rem; }
.case__nda { font-size: .86rem; color: var(--tx-3); }

/* ---------- footer ---------- */
.foot { border-top: 1px solid var(--line); padding-block: 2rem calc(2rem + env(safe-area-inset-bottom)); }
.foot__in { display: flex; flex-direction: column; gap: 1.25rem; }
.foot p { font-size: .9rem; color: var(--tx-3); }
.foot__links { display: grid; grid-template-columns: repeat(2, max-content); gap: 0 2rem; list-style: none; }
.foot__links a { display: inline-flex; align-items: center; gap: .45rem; color: var(--tx-2); text-decoration: none; font-size: .92rem; min-height: 44px; }
.foot__links a:hover { color: var(--tx); }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: var(--z-toast);
         transform: translate(-50%, 8px); opacity: 0; pointer-events: none;
         background: var(--bg-3); color: var(--tx); border: 1px solid var(--line-2); border-radius: 999px; padding: .6rem 1.1rem; font-size: .9rem;
         box-shadow: 0 12px 32px -12px rgba(0, 0, 0, .8);
         transition: opacity .2s var(--ease-o), transform .2s var(--ease-o); }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- reveal on scroll (only hidden once JS confirms it can reveal) ---------- */
.js .rise { opacity: 0; transform: translateY(14px); filter: blur(4px);
            transition: opacity .7s var(--ease-o), transform .7s var(--ease-o), filter .7s var(--ease-o);
            transition-delay: calc(var(--d, 0) * 70ms); }
.js .rise.is-in { opacity: 1; transform: none; filter: none; }

/* ---------- breakpoints ---------- */
@media (min-width: 640px) {
    :root { --gut: 28px; }
}
@media (min-width: 900px) {
    :root { --gut: 40px; --nav-h: 68px; }
    body { font-size: 1.125rem; }
    .nav__links { display: flex; }
    .foot__in { flex-direction: row; align-items: center; justify-content: space-between; }
    .foot__links { display: flex; gap: .5rem 1.4rem; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; transition-delay: 0s !important; }
    .js .rise { opacity: 1; transform: none; filter: none; }
    .js .dg-draw path.ln, .js .dg-draw path.ln-ac { stroke-dashoffset: 0; }
    .js .dg-draw rect, .js .dg-draw text { opacity: 1; }
    .case:hover { transform: none; }
}
