/* =============================================================
   Bilal Khizar - portfolio
   Design intent: editorial, calm, finance-credible. Serif display
   for gravitas, clean sans for body, a monospace "instrument" face
   for figures and nominal codes, one restrained bronze accent, and
   a single bold signature: the dark "categorise a transaction" panel.
   Optimised for fast first paint and 30-second trust.
   ============================================================= */

:root {
  /* Palette - warm paper, ink, ledger-navy, bronze accent,
     plus a disciplined double-entry pair (Dr rust / Cr green). */
  --paper:       #FBFAF7;
  --paper-2:     #F1EDE4;
  --ink:         #15171C;
  --ink-soft:    #565963;
  --navy:        #0E2A47;
  --navy-deep:   #0A1F36;
  --accent:      #9A6B2F;
  --accent-deep: #7B5424;
  --line:        #E6E1D5;
  --line-strong: #D9D2C2;
  --dr:          #A23B2A; /* debit  - cost   */
  --cr:          #2F7D52; /* credit - outcome */

  --maxw: 64rem;
  --pad: clamp(1.25rem, 5vw, 3rem);

  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;
  --font-sans:  "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono:  ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.05);
  --shadow-lift: 0 2px 4px rgba(16, 24, 40, 0.05), 0 18px 40px rgba(16, 24, 40, 0.10);

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.6;
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { line-height: 1.12; color: var(--navy); margin: 0; font-weight: 500; }
p { margin: 0; }
a { color: var(--accent-deep); text-decoration: none; }
a:hover { color: var(--accent); }

.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--pad); }

/* tabular figures wherever numbers carry meaning */
.proof-strip strong, .work-metrics strong, .stat-num, .demo-amount, .demo-code {
  font-variant-numeric: tabular-nums;
}

/* ---------- Accessibility helpers ---------- */
.skip-link {
  position: absolute; left: 0; top: -100%;
  background: var(--navy); color: #fff; padding: 0.6rem 1rem; z-index: 100;
  border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { top: 0; color: #fff; }

/* visually hidden but available to screen readers */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

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

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(251, 250, 247, 0.85);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}
.site-header.is-scrolled {
  border-bottom-color: var(--line);
  box-shadow: 0 1px 0 rgba(16, 24, 40, 0.02), 0 6px 18px rgba(16, 24, 40, 0.05);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 4rem;
}
.brand { display: flex; align-items: baseline; gap: 0.6rem; color: var(--navy); }
.brand-name { font-family: var(--font-serif); font-size: 1.2rem; font-weight: 600; }
.brand-role {
  font-family: var(--font-mono);
  font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent-deep); font-weight: 600;
}

.nav-list { display: flex; align-items: center; gap: 1.6rem; list-style: none; margin: 0; padding: 0; }
.nav-list a { color: var(--ink-soft); font-weight: 500; font-size: 0.95rem; }
.nav-list a:hover { color: var(--navy); }
.nav-cta {
  background: var(--navy); color: #fff !important; padding: 0.5rem 1rem;
  border-radius: 8px; font-weight: 600;
  transition: background 0.15s ease, transform 0.12s ease;
}
.nav-cta:hover { background: #14365b; }
.nav-cta:active { transform: translateY(1px); }

.nav-toggle { display: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.8rem 1.4rem; border-radius: 9px; font-weight: 600; font-size: 0.98rem;
  border: 1px solid transparent; cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--navy); color: #fff; box-shadow: 0 1px 2px rgba(10, 31, 54, 0.25); }
.btn-primary:hover { background: #14365b; color: #fff; box-shadow: 0 6px 18px rgba(10, 31, 54, 0.22); }
.btn-ghost { background: transparent; color: var(--navy); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-deep); background: #fff; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding: clamp(3.5rem, 9vw, 6.5rem) 0 clamp(2.5rem, 6vw, 4rem);
  overflow: hidden;
}
/* Ambient signature: faint ledger columns + warm wash, behind the type. */
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    radial-gradient(120% 90% at 85% -10%, rgba(154, 107, 47, 0.10) 0%, transparent 55%),
    repeating-linear-gradient(90deg, rgba(14, 42, 71, 0.035) 0 1px, transparent 1px 7.5rem);
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 55%, transparent 100%);
          mask-image: linear-gradient(180deg, #000 0%, #000 55%, transparent 100%);
}
.hero .wrap { position: relative; z-index: 1; }
.hero-grid { display: grid; grid-template-columns: 1fr; gap: clamp(1.75rem, 5vw, 3rem); align-items: center; }
@media (min-width: 46rem) {
  .hero-grid { grid-template-columns: minmax(0, 1fr) auto; }
}
.hero-portrait { margin: 0; }
.hero-photo {
  display: block;
  width: clamp(132px, 20vw, 200px); height: auto; aspect-ratio: 1 / 1;
  object-fit: cover; border-radius: 18px;
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lift);
}
.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--accent-deep); font-weight: 600; margin-bottom: 1.1rem;
}
.hero-heading {
  font-family: var(--font-serif);
  font-size: clamp(2.05rem, 1.2rem + 3.6vw, 3.85rem);
  font-weight: 500; letter-spacing: -0.012em; max-width: 18ch;
  overflow-wrap: break-word;
}
.hero-sub {
  margin-top: 1.4rem; max-width: 56ch;
  font-size: clamp(1.05rem, 1rem + 0.4vw, 1.2rem); color: var(--ink-soft);
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-top: 2rem; }

.proof-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1.4rem 1.6rem; list-style: none; margin: 3rem 0 0; padding: 1.8rem 0 0;
  border-top: 1px solid var(--line);
}
.proof-strip li { display: flex; flex-direction: column; gap: 0.25rem; }
.stat-num {
  font-family: var(--font-serif);
  font-size: clamp(1.6rem, 1.3rem + 1vw, 2.1rem);
  font-weight: 600; color: var(--navy); line-height: 1;
}
.stat-label { font-size: 0.86rem; color: var(--ink-soft); }

/* ---------- Sections ---------- */
main { counter-reset: section; }
.section { padding: clamp(3.5rem, 8vw, 6rem) 0; counter-increment: section; }
.section-tint { background: var(--paper-2); } /* tonal shift only - no hard hairline, for continuous scroll */
.section-head { max-width: 52ch; margin-bottom: clamp(2rem, 4vw, 3rem); }
.section-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.74rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--accent-deep); font-weight: 600; margin-bottom: 0.7rem;
}
/* ledger-style folio numbering - a running rhythm down the page (01 / , 02 / , ...) */
.section-eyebrow::before {
  content: counter(section, decimal-leading-zero) " / ";
  color: var(--accent);
}
.section-heading { font-family: var(--font-serif); font-size: clamp(1.75rem, 1.3rem + 1.8vw, 2.4rem); }
.section-lead { margin-top: 0.9rem; color: var(--ink-soft); font-size: 1.05rem; }
.section-lead a { font-weight: 600; }

/* ---------- Services ---------- */
.services-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1.1rem; list-style: none; margin: 0; padding: 0;
}
.service-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.5rem 1.5rem 1.6rem;
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease), border-color 0.18s var(--ease);
}
.service-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.service-card h3 {
  font-family: var(--font-sans); font-size: 1.08rem; font-weight: 600;
  color: var(--navy); margin-bottom: 0.55rem;
}
.service-card p { color: var(--ink-soft); font-size: 0.96rem; }

/* ---------- Selected work ---------- */
.work-list { display: grid; gap: 1.1rem; }
.work-card {
  position: relative; overflow: hidden;
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  padding: clamp(1.5rem, 3vw, 2.2rem); box-shadow: var(--shadow);
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
/* the accent rule grows on hover - structural, not decorative: it marks the "spine" of each entry */
.work-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent); transform: scaleY(0.4); transform-origin: top;
  transition: transform 0.28s var(--ease);
}
.work-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.work-card:hover::before { transform: scaleY(1); }
.work-kicker {
  font-family: var(--font-mono);
  font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent-deep); font-weight: 600; margin-bottom: 0.6rem;
}
.work-title { font-family: var(--font-serif); font-size: clamp(1.4rem, 1.2rem + 1vw, 1.8rem); font-weight: 600; }
.work-body { margin-top: 0.9rem; color: var(--ink-soft); max-width: 70ch; }
.work-metrics {
  display: flex; flex-wrap: wrap; gap: 0.5rem 0.6rem; list-style: none;
  margin: 1.2rem 0 0; padding: 0;
}
.work-metrics li {
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 0.32rem 0.8rem; font-size: 0.84rem; color: var(--ink-soft);
}
.work-metrics strong { color: var(--navy); font-weight: 700; }
.work-links { display: flex; gap: 1.2rem; margin-top: 1.1rem; font-weight: 600; }
.work-links a { position: relative; }
.work-links a::after {
  content: "\2197"; margin-left: 0.25rem; font-size: 0.85em; color: var(--accent);
  display: inline-block; transition: transform 0.15s ease;
}
.work-links a:hover::after { transform: translate(2px, -2px); }
.work-footnote {
  margin-top: 1.6rem; color: var(--ink-soft); font-size: 0.95rem; max-width: 74ch;
}
.work-footnote strong { color: var(--navy); }

/* ---------- Signature: Categorise a transaction (the one bold moment) ---------- */
/* demo now sits at the end (before Contact); tinted so the plain/tint/plain rhythm holds. Dark panel still pops on paper-2. */
.demo { background: var(--paper-2); }
.demo-card {
  /* local palette: this panel inverts to the "ledger terminal" */
  --d-line: rgba(244, 234, 213, 0.16);
  position: relative; overflow: hidden;
  margin-top: 0.5rem;
  background:
    radial-gradient(130% 120% at 100% 0%, rgba(154, 107, 47, 0.18) 0%, transparent 55%),
    linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: #EFEBE2;
  border: 1px solid var(--navy-deep);
  border-radius: 14px;
  padding: clamp(1.5rem, 3.5vw, 2.5rem);
  box-shadow: var(--shadow-lift);
}
.demo-card::before { /* faint ledger columns inside the panel */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0.5;
  background-image: repeating-linear-gradient(90deg, rgba(244, 234, 213, 0.04) 0 1px, transparent 1px 6rem);
}
.demo-card > * { position: relative; }
.demo-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: rgba(239, 235, 226, 0.6); margin-bottom: 1.1rem;
}
.demo-score { color: var(--accent); font-weight: 600; }
.demo-narrative { font-family: var(--font-serif); font-size: clamp(1.2rem, 1rem + 1vw, 1.55rem); color: #fff; }
.demo-amount { font-family: var(--font-mono); color: var(--accent); margin-top: 0.35rem; font-size: 0.95rem; }
.demo-prompt {
  margin-top: 1.2rem; font-size: 0.82rem; letter-spacing: 0.04em; text-transform: uppercase;
  font-family: var(--font-mono); color: rgba(239, 235, 226, 0.7);
}
.demo-options {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem;
  list-style: none; margin: 0.7rem 0 0; padding: 0;
}
.demo-option {
  display: flex; align-items: baseline; gap: 0.6rem; width: 100%; text-align: left;
  font-family: var(--font-mono); font-size: 0.92rem; color: #EFEBE2;
  background: rgba(244, 234, 213, 0.05); border: 1px solid var(--d-line);
  border-radius: 8px; padding: 0.7rem 0.85rem; cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}
.demo-option:hover:not(:disabled) { border-color: var(--accent); background: rgba(154, 107, 47, 0.12); }
.demo-option:active:not(:disabled) { transform: translateY(1px); }
.demo-option:disabled { cursor: default; }
.demo-code { color: var(--accent); font-weight: 600; }
.demo-option.is-correct {
  border-color: var(--cr); background: rgba(47, 125, 82, 0.22); color: #EAF6EE;
}
.demo-option.is-correct .demo-code { color: #A8E0BF; }
.demo-option.is-wrong {
  border-color: var(--dr); background: rgba(162, 59, 42, 0.22); color: #F7E2DE;
}
.demo-option.is-wrong .demo-code { color: #F0B4A8; }
.demo-option.is-muted { opacity: 0.45; }
.demo-mark { margin-left: auto; font-weight: 700; }
.demo-reasoning {
  margin-top: 1.1rem; font-family: var(--font-serif); font-style: italic;
  color: rgba(239, 235, 226, 0.92); font-size: 0.98rem; line-height: 1.55;
  padding-left: 0.9rem; border-left: 2px solid var(--accent);
}
.demo-reasoning b { font-style: normal; color: var(--accent); font-family: var(--font-mono); font-size: 0.82rem; letter-spacing: 0.04em; text-transform: uppercase; }
.demo-foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 0.8rem 1.2rem; margin-top: 1.4rem;
}
.demo-next {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-family: var(--font-mono); font-size: 0.86rem; font-weight: 600;
  color: var(--navy); background: #EFEBE2; border: 1px solid #EFEBE2;
  border-radius: 8px; padding: 0.55rem 1rem; cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease;
}
.demo-next:hover { box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25); }
.demo-next:active { transform: translateY(1px); }
.demo-link { font-family: var(--font-mono); font-size: 0.82rem; color: rgba(239, 235, 226, 0.75); }
.demo-link a { color: var(--accent); font-weight: 600; }
.demo-link a:hover { color: #C99A5C; }

/* ---------- About ---------- */
.about-wrap { display: grid; gap: 1.5rem; }
.about-body { display: grid; gap: 1.1rem; max-width: 64ch; }
.about-body p { color: var(--ink); font-size: 1.08rem; }
.about-body p + p { color: var(--ink-soft); }

/* ---------- Contact ---------- */
.contact-wrap { max-width: 56ch; }
.contact-lead { margin-top: 0.9rem; color: var(--ink-soft); font-size: 1.08rem; }
.contact-actions { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-top: 1.8rem; }
.contact-direct { margin-top: 1.4rem; color: var(--ink-soft); font-size: 0.95rem; }
.contact-direct a { font-family: var(--font-mono); font-size: 0.92rem; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 2.5rem 0; background: var(--paper-2); }
.footer-inner { display: grid; gap: 0.5rem; }
.footer-name { font-family: var(--font-serif); font-weight: 600; color: var(--navy); font-size: 1.1rem; }
.footer-tag { color: var(--ink-soft); font-size: 0.92rem; }
.footer-links { display: flex; flex-wrap: wrap; gap: 1.2rem; list-style: none; margin: 0.6rem 0 0; padding: 0; }
.footer-links a { color: var(--ink-soft); font-weight: 500; font-size: 0.92rem; }
.footer-links a:hover { color: var(--accent-deep); }
.footer-copy { color: var(--ink-soft); font-size: 0.85rem; margin-top: 0.6rem; font-family: var(--font-mono); }

/* ---------- Reveal on scroll (progressive enhancement) ---------- */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity 0.6s var(--ease), transform 0.6s var(--ease); }
.reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .service-card, .work-card, .btn, .nav-cta, .demo-option, .demo-next { transition: none; }
  .work-card::before { transition: none; transform: scaleY(1); }
}

/* ---------- Mobile ---------- */
@media (max-width: 38rem) {
  .demo-options { grid-template-columns: 1fr; }

  .nav-toggle {
    display: inline-flex; flex-direction: column; gap: 5px; justify-content: center;
    width: 2.5rem; height: 2.5rem; background: transparent; border: 1px solid var(--line);
    border-radius: 8px; cursor: pointer;
  }
  .nav-toggle-bar { display: block; width: 1.1rem; height: 2px; background: var(--navy); margin-inline: auto; transition: transform 0.2s ease, opacity 0.2s ease; }
  .nav-toggle[aria-expanded="true"] .nav-toggle-bar:first-child { transform: translateY(3.5px) rotate(45deg); }
  .nav-toggle[aria-expanded="true"] .nav-toggle-bar:last-child { transform: translateY(-3.5px) rotate(-45deg); }

  .nav-list {
    position: absolute; top: 4rem; right: var(--pad); left: var(--pad);
    flex-direction: column; align-items: stretch; gap: 0.4rem;
    background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 0.8rem; box-shadow: var(--shadow);
    display: none;
  }
  .nav-list.is-open { display: flex; }
  .nav-list a { padding: 0.6rem 0.5rem; }
  .nav-cta { text-align: center; }
}
