/* ============================================================
   ahmed-masud.github.io — main stylesheet
   Themes: moody (default) | dark | light | access
   ============================================================ */

/* ── VARIABLES / THEMES ──────────────────────────────────── */

:root {
  --serif: 'EB Garamond', Georgia, serif;
  --sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono:  'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
}

[data-theme="moody"] {
  --bg:          #0F0D14;
  --bg2:         #171420;
  --bg3:         #1E1A28;
  --fg:          #DDD8F0;
  --mid:         #8A84A8;
  --faint:       #3A3650;
  --accent:      #7C6FCD;
  --gold:        #C8A96E;
  --rule:        #2A2438;
  --card-bg:     #171420;
  --card-border: #2A2438;
}

[data-theme="dark"] {
  --bg:          #0A0A0F;
  --bg2:         #0F0F17;
  --bg3:         #14141E;
  --fg:          #E8E6DF;
  --mid:         #8A8799;
  --faint:       #3D3C4A;
  --accent:      #4A90D9;
  --gold:        #D4A847;
  --rule:        #1E1D2A;
  --card-bg:     #0F0F17;
  --card-border: #1E1D2A;
}

[data-theme="light"] {
  --bg:          #F8F7F4;
  --bg2:         #F2F0EB;
  --bg3:         #ECEAE3;
  --fg:          #0F0F1A;
  --mid:         #5A5870;
  --faint:       #B0AEBF;
  --accent:      #1A5FA8;
  --gold:        #B07820;
  --rule:        #DDDBD3;
  --card-bg:     #FFFFFF;
  --card-border: #E0DED8;
}

/* High-contrast accessibility theme — WCAG AA+ */
[data-theme="access"] {
  --bg:          #FFFFFF;
  --bg2:         #F5F5F5;
  --bg3:         #EBEBEB;
  --fg:          #000000;
  --mid:         #1A1A1A;
  --faint:       #595959;
  --accent:      #0047AB;
  --gold:        #7A4F00;
  --rule:        #767676;
  --card-bg:     #FFFFFF;
  --card-border: #767676;
}


/* ── RESET & BASE ────────────────────────────────────────── */

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--fg);
  font-size: 15px;
  line-height: 1.7;
  font-weight: 400;
  transition: background 0.2s, color 0.2s;
}

[data-theme="access"] body {
  font-size: 17px;
  line-height: 1.9;
}

img, svg { display: block; max-width: 100%; }

/* ── ACCESSIBILITY UTILITIES ─────────────────────────────── */

.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;
}

.skip-link {
  position: absolute;
  top: -100px; left: 1rem;
  background: var(--accent);
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 3px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  z-index: 9999;
  transition: top 0.15s;
}
.skip-link:focus { top: 1rem; }

#theme-announce {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

/* ── FOCUS RINGS (keyboard nav) ──────────────────────────── */

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


/* ── THEME BAR ────────────────────────────────────────────── */

.theme-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 3rem;
  background: var(--bg2);
  border-bottom: 0.5px solid var(--rule);
}

.theme-bar-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}
[data-theme="access"] .theme-bar-label { font-size: 12px; }

.theme-btn {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.3rem 0.75rem;
  border-radius: 2px;
  cursor: pointer;
  border: 0.5px solid var(--rule);
  background: transparent;
  color: var(--mid);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.theme-btn:hover { border-color: var(--mid); color: var(--fg); }
.theme-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.theme-btn.access-btn[aria-pressed="true"] {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--bg);
}
[data-theme="access"] .theme-btn {
  font-size: 13px;
  padding: 0.45rem 1rem;
  border-width: 2px;
}

/* ── NAV ─────────────────────────────────────────────────── */

header nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 3rem;
  border-bottom: 0.5px solid var(--rule);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-logo {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--fg);
  text-decoration: none;
  font-style: italic;
}

.nav-links {
  display: flex;
  gap: 2rem;
  list-style: none;
}

.nav-links a {
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mid);
  text-decoration: none;
  transition: color 0.15s;
}
.nav-links a:hover { color: var(--fg); }
[data-theme="access"] .nav-links a { font-size: 14px; text-decoration: underline; }


/* ── HERO ────────────────────────────────────────────────── */

.hero {
  padding: 6rem 3rem 5rem;
  max-width: 900px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 5rem;
  align-items: start;
}

.hero-theorem {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--gold);
  letter-spacing: 0.06em;
  margin-bottom: 2rem;
}
[data-theme="access"] .hero-theorem { font-size: 14px; }

.hero h1 {
  font-family: var(--serif);
  font-size: 3.8rem;
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--fg);
  margin-bottom: 1.5rem;
}
.hero h1 em { font-style: italic; color: var(--accent); }
[data-theme="access"] .hero h1 { font-size: 3rem; }

.hero-sub {
  font-size: 0.95rem;
  color: var(--mid);
  line-height: 1.9;
  max-width: 420px;
  margin-bottom: 2.5rem;
  font-weight: 300;
}
[data-theme="access"] .hero-sub { font-size: 17px; color: var(--fg); font-weight: 400; }

.hero-ctas { display: flex; gap: 0.75rem; flex-wrap: wrap; }

.btn {
  display: inline-block;
  padding: 0.65rem 1.4rem;
  border-radius: 2px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  transition: all 0.18s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { opacity: 0.85; }
.btn-ghost { border: 0.5px solid var(--faint); color: var(--mid); }
.btn-ghost:hover { border-color: var(--mid); color: var(--fg); }
[data-theme="access"] .btn { font-size: 14px; padding: 0.8rem 1.6rem; }
[data-theme="access"] .btn-ghost { border: 2px solid var(--fg); color: var(--fg); }

/* Axioms sidebar */
.axioms { border-left: 1px solid var(--gold); padding-left: 1.5rem; }

.axioms-heading {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 1.25rem;
  opacity: 0.8;
}
[data-theme="access"] .axioms-heading { font-size: 12px; opacity: 1; }

.axiom { margin-bottom: 1.5rem; }
.axiom:last-child { margin-bottom: 0; }

.axiom-num {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--faint);
  display: block;
  margin-bottom: 4px;
  letter-spacing: 0.06em;
}
[data-theme="access"] .axiom-num { font-size: 12px; color: var(--mid); }

.axiom-text {
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--mid);
  font-style: italic;
}
[data-theme="access"] .axiom-text { color: var(--fg); }


/* ── SECTION SCAFFOLDING ─────────────────────────────────── */

.rule {
  border: none;
  border-top: 0.5px solid var(--rule);
  margin: 0;
}
[data-theme="access"] .rule { border-top: 2px solid var(--rule); }

.section {
  padding: 5rem 3rem;
  max-width: 900px;
  margin: 0 auto;
}

.section-header {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.section-num {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--faint);
  letter-spacing: 0.08em;
  flex-shrink: 0;
}
[data-theme="access"] .section-num { font-size: 13px; color: var(--mid); }

.section-title {
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--fg);
}

/* ── ABOUT ───────────────────────────────────────────────── */

.about-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
}

.about-prose p {
  font-size: 0.9rem;
  color: var(--mid);
  line-height: 1.95;
  margin-bottom: 1rem;
  font-weight: 300;
}
.about-prose p:last-child { margin-bottom: 0; }
[data-theme="access"] .about-prose p { color: var(--fg); font-size: 17px; }

.stack-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 0.65rem;
  margin-top: 1.25rem;
}
.stack-label:first-child { margin-top: 0; }

.stack-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.25rem;
  list-style: none;
}

.stack-tag {
  font-size: 10px;
  padding: 0.2rem 0.55rem;
  border: 0.5px solid var(--card-border);
  color: var(--mid);
  border-radius: 2px;
  font-family: var(--mono);
  background: var(--bg2);
}
[data-theme="access"] .stack-tag { font-size: 13px; border-width: 1.5px; }


/* ── SAF.AI ──────────────────────────────────────────────── */

.safai-hero {
  background: var(--bg2);
  border: 0.5px solid var(--card-border);
  border-radius: 4px;
  padding: 3rem;
  position: relative;
  overflow: hidden;
}
.safai-hero::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}
.safai-hero::after {
  content: '∑';
  position: absolute;
  right: 1.5rem;
  bottom: -2rem;
  font-family: var(--serif);
  font-size: 16rem;
  color: var(--rule);
  line-height: 1;
  pointer-events: none;
}
[data-theme="access"] .safai-hero::after { display: none; }

.safai-eyebrow {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.25rem;
}
[data-theme="access"] .safai-eyebrow { font-size: 13px; }

.safai-hero h3 {
  font-family: var(--serif);
  font-size: 2.4rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--fg);
  margin-bottom: 0.75rem;
  line-height: 1.1;
}

.safai-hero p {
  font-size: 0.875rem;
  color: var(--mid);
  line-height: 1.9;
  max-width: 500px;
  margin-bottom: 2rem;
  font-weight: 300;
}
[data-theme="access"] .safai-hero p { color: var(--fg); font-size: 17px; }

.safai-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--rule);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 2rem;
}
.metric { background: var(--bg3); padding: 1.25rem 1rem; }
.metric dt {
  font-size: 9px;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}
[data-theme="access"] .metric dt { font-size: 12px; color: var(--mid); }
.metric dd {
  font-family: var(--mono);
  font-size: 1.3rem;
  font-weight: 300;
  color: var(--fg);
  letter-spacing: -0.02em;
}

.orch-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 0.75rem;
}
.orch-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
  list-style: none;
}
.orch-list li {
  font-size: 10px;
  font-family: var(--mono);
  padding: 0.25rem 0.65rem;
  border: 0.5px solid var(--faint);
  color: var(--mid);
  border-radius: 2px;
  background: var(--bg);
}
[data-theme="access"] .orch-list li { font-size: 13px; border-width: 1.5px; }

.safai-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  text-decoration: none;
  border: 0.5px solid var(--accent);
  padding: 0.6rem 1.25rem;
  border-radius: 2px;
  transition: opacity 0.15s;
}
.safai-link-btn:hover { opacity: 0.8; }
[data-theme="access"] .safai-link-btn { font-size: 14px; border-width: 2px; text-decoration: underline; }


/* ── WORK TIMELINE ───────────────────────────────────────── */

.work-timeline { display: flex; flex-direction: column; list-style: none; }

.work-item {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 2.5rem;
  padding: 2rem 0;
  border-bottom: 0.5px solid var(--rule);
}
.work-item:first-child { border-top: 0.5px solid var(--rule); }

.work-years {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--faint);
  padding-top: 3px;
  line-height: 1.6;
}
[data-theme="access"] .work-years { font-size: 13px; color: var(--mid); }

.work-role {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.3rem;
}
[data-theme="access"] .work-role { font-size: 13px; }

.work-company {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--fg);
  margin-bottom: 0.5rem;
}

.work-desc {
  font-size: 0.85rem;
  color: var(--mid);
  line-height: 1.85;
  font-weight: 300;
}
[data-theme="access"] .work-desc { color: var(--fg); font-size: 17px; }

/* ── PATENTS & RECOGNITION ───────────────────────────────── */

.patent-card {
  background: var(--card-bg);
  border: 0.5px solid var(--card-border);
  border-radius: 4px;
  padding: 2rem;
  margin-bottom: 1.5rem;
  position: relative;
  overflow: hidden;
}
.patent-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 2px;
  background: var(--gold);
}

.patent-id {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.75rem;
  padding-left: 1rem;
}
[data-theme="access"] .patent-id { font-size: 12px; }

.patent-title {
  font-family: var(--serif);
  font-size: 1.4rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--fg);
  margin-bottom: 0.75rem;
  padding-left: 1rem;
}

.patent-desc {
  font-size: 0.85rem;
  color: var(--mid);
  line-height: 1.9;
  font-weight: 300;
  padding-left: 1rem;
}
[data-theme="access"] .patent-desc { color: var(--fg); font-size: 17px; }

.awards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.award-card {
  padding: 1.5rem;
  border: 0.5px solid var(--card-border);
  border-radius: 4px;
  background: var(--card-bg);
}
[data-theme="access"] .award-card { border-width: 2px; }

.award-year {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--faint);
  margin-bottom: 0.5rem;
  letter-spacing: 0.06em;
}
[data-theme="access"] .award-year { font-size: 13px; color: var(--mid); }

.award-title {
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 500;
  color: var(--fg);
  margin-bottom: 0.4rem;
}

.award-desc { font-size: 11px; color: var(--mid); line-height: 1.75; font-weight: 300; }
[data-theme="access"] .award-desc { font-size: 15px; color: var(--fg); }


/* ── WRITING ─────────────────────────────────────────────── */

.post-list { display: flex; flex-direction: column; list-style: none; }

.post-item {
  display: grid;
  grid-template-columns: 60px 1fr 90px;
  gap: 1.5rem;
  align-items: baseline;
  padding: 1.25rem 0;
  border-bottom: 0.5px solid var(--rule);
}
.post-item:first-child { border-top: 0.5px solid var(--rule); }

.post-num {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--faint);
  letter-spacing: 0.06em;
}
[data-theme="access"] .post-num { font-size: 13px; color: var(--mid); }

.post-title {
  font-family: var(--serif);
  font-size: 1rem;
  color: var(--fg);
  text-decoration: none;
  transition: color 0.15s;
}
.post-title:hover { color: var(--accent); }
[data-theme="access"] .post-title { text-decoration: underline; }

.post-date {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--faint);
  text-align: right;
  letter-spacing: 0.04em;
}
[data-theme="access"] .post-date { font-size: 13px; color: var(--mid); }

/* ── CONTACT ─────────────────────────────────────────────── */

.contact-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.contact-group {
  padding: 1.25rem;
  border: 0.5px solid var(--card-border);
  border-radius: 4px;
  background: var(--card-bg);
}
[data-theme="access"] .contact-group { border-width: 2px; }

.contact-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  display: block;
  margin-bottom: 0.4rem;
}
[data-theme="access"] .contact-label { font-size: 12px; color: var(--mid); }

.contact-val {
  font-family: var(--serif);
  font-size: 1rem;
  color: var(--fg);
  text-decoration: none;
  display: block;
  transition: color 0.15s;
}
a.contact-val:hover { color: var(--accent); }
[data-theme="access"] a.contact-val { text-decoration: underline; }

/* ── FOOTER ──────────────────────────────────────────────── */

footer {
  border-top: 0.5px solid var(--rule);
  padding: 1.75rem 3rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 900px;
  margin: 0 auto;
}

footer p, footer a, .footer-seq {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--faint);
  letter-spacing: 0.06em;
  text-decoration: none;
}
footer a:hover { color: var(--mid); }
.footer-seq { color: var(--rule); letter-spacing: 0.08em; }
[data-theme="access"] footer p,
[data-theme="access"] footer a { font-size: 13px; }
[data-theme="access"] footer a { text-decoration: underline; }

/* ── RESPONSIVE ──────────────────────────────────────────── */

@media (max-width: 720px) {
  .hero { grid-template-columns: 1fr; gap: 3rem; padding: 4rem 1.5rem 3rem; }
  .hero h1 { font-size: 2.8rem; }
  .about-body { grid-template-columns: 1fr; gap: 2rem; }
  .contact-body { grid-template-columns: 1fr; }
  .awards-grid { grid-template-columns: 1fr; }
  .safai-metrics { grid-template-columns: 1fr; gap: 0; }
  .work-item { grid-template-columns: 1fr; gap: 0.5rem; }
  .post-item { grid-template-columns: 1fr; gap: 0.25rem; }
  .post-date { text-align: left; }
  header nav { padding: 1rem 1.5rem; flex-wrap: wrap; gap: 1rem; }
  .section { padding: 3rem 1.5rem; }
  .theme-bar { padding: 0.6rem 1.5rem; flex-wrap: wrap; }
  footer { padding: 1.5rem; flex-direction: column; gap: 0.75rem; text-align: center; }
}

@media (max-width: 480px) {
  .nav-links { display: none; }
}

