/* ─────────────────────────────────────────────────────────
   Mohammed Khaled — personal site
   Design tokens, typography, layout
   ───────────────────────────────────────────────────────── */

:root,
:root[data-theme="dark"] {
  --bg: #0E0E10;
  --bg-2: #111114;
  --fg: #EDEDED;
  --muted: #8A8A8A;
  --accent-1: #FF6B35;
  /* retro orange */
  --accent-2: #4ECDC4;
  /* muted teal */
  --surface: #17171A;
  --border: #262629;
  --scanline: rgba(255, 255, 255, .03);
  --chroma-1: rgba(255, 107, 53, .12);
  --chroma-2: rgba(78, 205, 196, .12);
  --shadow-strong: rgba(0, 0, 0, .8);

  --max: 1120px;
  --pad: clamp(20px, 4vw, 48px);
  --radius: 4px;

  --f-sans: 'Inter', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --f-display: 'Space Grotesk', 'Inter', sans-serif;
  --f-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

  --ease: cubic-bezier(.2, .7, .2, 1);
}

:root[data-theme="retro"] {
  --bg: #FAF9F5;
  /* cream paper */
  --bg-2: #F2F0E8;
  --fg: #1A1814;
  /* warm ink */
  --muted: #6B6557;
  --accent-1: #C2410C;
  /* deeper orange for AA contrast on cream */
  --accent-2: #0F766E;
  /* deeper teal for AA contrast on cream */
  --surface: #F2F0E8;
  --border: #D9D4C5;
  --scanline: rgba(26, 24, 20, .04);
  --chroma-1: rgba(194, 65, 12, .14);
  --chroma-2: rgba(15, 118, 110, .14);
  --shadow-strong: rgba(26, 24, 20, .15);

  color-scheme: light;
}

:root[data-theme="retro"] body {
  background:
    var(--bg) repeating-linear-gradient(0deg,
      transparent 0 2px,
      rgba(26, 24, 20, .018) 2px 3px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--f-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

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

a {
  color: inherit;
  text-decoration: none;
  transition: color .15s var(--ease);
}

a:hover {
  color: var(--accent-1);
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent-1);
  color: #000;
  padding: 10px 14px;
  font-family: var(--f-mono);
  font-size: 13px;
  z-index: 1000;
}

.skip-link:focus {
  left: 12px;
  top: 12px;
}

.mono {
  font-family: var(--f-mono);
  font-feature-settings: 'liga' 0, 'calt' 0;
}

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

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  transition: background .25s var(--ease), border-color .25s var(--ease), backdrop-filter .25s var(--ease);
  border-bottom: 1px solid transparent;
}

.nav[data-state="top"] {
  background: transparent;
}

.nav[data-state="scrolled"] {
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border-bottom-color: var(--border);
}

.nav__inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 14px var(--pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.nav__brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav__mark {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  font-family: var(--f-mono);
  font-weight: 600;
  font-size: 12px;
  color: var(--accent-1);
  letter-spacing: .02em;
  background: var(--surface);
}

.nav__name {
  font-family: var(--f-mono);
  font-size: 13px;
  color: var(--muted);
  letter-spacing: .02em;
}

.nav__links {
  display: flex;
  gap: 24px;
}

.nav__links a {
  font-family: var(--f-mono);
  font-size: 13px;
  color: var(--muted);
}

.nav__links a:hover {
  color: var(--accent-1);
}

.nav__toggle {
  display: none;
  width: 40px;
  height: 40px;
  background: transparent;
  border: 1px solid var(--border);
  padding: 0;
  cursor: pointer;
  position: relative;
}

.nav__right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-toggle {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg);
  cursor: pointer;
  padding: 0;
  transition: color .15s var(--ease), border-color .15s var(--ease), background .15s var(--ease), transform .15s var(--ease);
}

.theme-toggle:hover {
  color: var(--accent-1);
  border-color: var(--accent-1);
  transform: translateY(-1px);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: block;
}

:root[data-theme="retro"] .theme-toggle .icon-sun {
  display: block;
}

.nav__toggle span {
  display: block;
  position: absolute;
  left: 10px;
  right: 10px;
  height: 1px;
  background: var(--fg);
  transition: transform .2s var(--ease), opacity .2s var(--ease), top .2s var(--ease);
}

.nav__toggle span:nth-child(1) {
  top: 14px;
}

.nav__toggle span:nth-child(2) {
  top: 19px;
}

.nav__toggle span:nth-child(3) {
  top: 24px;
}

.nav__toggle[aria-expanded="true"] span:nth-child(1) {
  top: 19px;
  transform: rotate(45deg);
}

.nav__toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.nav__toggle[aria-expanded="true"] span:nth-child(3) {
  top: 19px;
  transform: rotate(-45deg);
}

.menu {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 40;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 80px var(--pad) 40px;
  gap: 28px;
}

.menu[hidden] {
  display: none;
}

.menu__links {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.menu__links a {
  font-family: var(--f-display);
  font-size: clamp(36px, 9vw, 56px);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--fg);
}

.menu__links a:hover {
  color: var(--accent-1);
}

.menu__foot {
  position: absolute;
  left: var(--pad);
  bottom: 32px;
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--muted);
  text-transform: lowercase;
}

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

.hero {
  position: relative;
  min-height: 100svh;
  padding: clamp(120px, 18vh, 180px) var(--pad) clamp(60px, 10vh, 110px);
  overflow: hidden;
  display: flex;
  align-items: center;
}

.hero__scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(to bottom,
      var(--scanline) 0,
      var(--scanline) 1px,
      transparent 1px,
      transparent 3px);
  mix-blend-mode: overlay;
  opacity: .8;
  z-index: 1;
}

.hero__inner {
  position: relative;
  z-index: 2;
  max-width: var(--max);
  margin: 0 auto;
  width: 100%;
}

.hero__label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 24px;
  letter-spacing: 0.02em;
}

.hero__name {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: clamp(50px, 13vw, 100px);
  line-height: 0.92;
  letter-spacing: -0.035em;
  margin: 0 0 28px;
  color: var(--fg);
  /* tiny chroma shadow for CRT feel — ultra-subtle */
  text-shadow:
    -0.01em 0 0 var(--chroma-1),
    0.01em 0 0 var(--chroma-2);
}

.hero__role {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 36px;
  text-transform: lowercase;
  letter-spacing: 0.02em;
}

.hero__tagline {
  font-family: var(--f-mono);
  font-size: clamp(15px, 2vw, 18px);
  color: var(--fg);
  margin: 0 0 44px;
  min-height: 1.6em;
}

.caret {
  display: inline-block;
  color: var(--accent-1);
  margin-left: 1px;
  animation: blink 1s steps(2, start) infinite;
}

@keyframes blink {
  to {
    visibility: hidden;
  }
}

.hero__cta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 56px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--f-mono);
  font-size: 13px;
  padding: 13px 20px;
  border: 1px solid var(--fg);
  background: transparent;
  color: var(--fg);
  text-transform: lowercase;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform .15s var(--ease), background .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease), border-color .15s var(--ease);
  position: relative;
}

.btn:hover {
  color: var(--bg);
  background: var(--accent-1);
  border-color: var(--accent-1);
  box-shadow: 4px 4px 0 0 var(--border);
  transform: translate(-2px, -2px);
}

.btn--primary {
  border-color: var(--accent-1);
  color: var(--accent-1);
}

.btn--primary:hover {
  color: var(--bg);
  background: var(--accent-1);
  border-color: var(--accent-1);
}

.btn--ghost {
  color: var(--fg);
  border-color: var(--border);
}

.btn--ghost:hover {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

.hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  color: var(--muted);
  font-size: 12px;
  text-transform: lowercase;
}

.hero__meta .dot {
  opacity: .6;
}

.hero__meta .status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--fg);
}

.hero__meta .status__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent-2) 25%, transparent);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent-2) 25%, transparent);
  }

  50% {
    box-shadow: 0 0 0 6px color-mix(in oklab, var(--accent-2) 8%, transparent);
  }
}

/* ───────────── SECTIONS ───────────── */

.section {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(80px, 12vh, 140px) var(--pad);
}

.section__label {
  font-size: 12px;
  color: var(--accent-2);
  margin-bottom: 24px;
  letter-spacing: 0.02em;
  text-transform: lowercase;
}

.section__title {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: clamp(36px, 5vw, 56px);
  line-height: 1.02;
  letter-spacing: -0.025em;
  margin: 0 0 48px;
  max-width: 22ch;
  text-wrap: balance;
}

.divider {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--pad);
  color: var(--border);
  font-size: 12px;
  overflow: hidden;
  white-space: nowrap;
  opacity: .7;
  text-align: center;
}

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

.about {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: clamp(32px, 5vw, 80px);
  align-items: start;
}

.about__body p {
  margin: 0 0 18px;
  font-size: 17px;
  color: color-mix(in oklab, var(--fg) 92%, var(--muted));
  max-width: 58ch;
  text-wrap: pretty;
}

.about__body strong {
  color: var(--fg);
  border-bottom: 1px dashed var(--accent-1);
  padding-bottom: 1px;
}

.about__facts {
  display: grid;
  gap: 2px;
  font-size: 12px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.about__facts div {
  display: grid;
  grid-template-columns: 80px 1fr;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.about__facts dt {
  color: var(--muted);
  text-transform: lowercase;
}

.about__facts dd {
  margin: 0;
  color: var(--fg);
  text-transform: lowercase;
}

/* ───────────── TERMINAL / NOW ───────────── */

.terminal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 20px 60px -30px var(--shadow-strong);
}

.terminal__bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 14px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}

:root[data-theme="dark"] .terminal__bar {
  background: #0b0b0d;
}

.terminal__lights {
  display: flex;
  gap: 6px;
}

.terminal__lights span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  border: 1px solid color-mix(in oklab, var(--border) 60%, #000);
}

.terminal__lights span:nth-child(1) {
  background: #3a2420;
}

.terminal__lights span:nth-child(2) {
  background: #3a3520;
}

.terminal__lights span:nth-child(3) {
  background: #1d3330;
}

.terminal__path {
  color: var(--muted);
  font-size: 12px;
  flex: 1;
}

.terminal__meta {
  color: var(--muted);
  font-size: 11px;
}

.terminal__body {
  margin: 0;
  padding: 24px 24px 26px;
  font-size: 13.5px;
  line-height: 1.85;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--fg);
  overflow-x: auto;
}

.t-comment {
  color: var(--muted);
}

.t-key {
  color: var(--accent-2);
}

.t-val {
  color: var(--fg);
  font-weight: 600;
}

.t-dim {
  color: var(--muted);
}

.t-badge {
  display: inline-block;
  width: 1.1em;
}

.t-run {
  color: var(--accent-1);
}

.t-ok {
  color: var(--accent-2);
}

.t-rd {
  color: var(--muted);
}

/* ───────────── SKILLS ───────────── */

.skills {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 32px 48px;
}

.skills__head {
  font-size: 11px;
  color: var(--muted);
  text-transform: lowercase;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 16px;
  letter-spacing: 0.04em;
}

.tags {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  font-family: var(--f-mono);
  font-size: 12.5px;
  padding: 6px 11px;
  border: 1px solid var(--border);
  color: var(--fg);
  background: transparent;
  transition: transform .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
  cursor: default;
}

.tag:hover {
  transform: scale(1.05);
  border-color: var(--accent-2);
  color: var(--accent-2);
}

/* ───────────── PROJECTS ───────────── */

.projects {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.project {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: border-color .2s var(--ease), transform .2s var(--ease), background .2s var(--ease);
}

.project::before {
  content: "→";
  position: absolute;
  top: 22px;
  right: 22px;
  font-family: var(--f-mono);
  font-size: 18px;
  color: var(--accent-2);
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}

.project:hover {
  border-color: var(--accent-2);
  background: color-mix(in oklab, var(--surface) 92%, var(--accent-2));
}

.project:hover::before {
  opacity: 1;
  transform: translateX(0);
}

.project__head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: baseline;
}

.project__idx {
  color: var(--muted);
  font-size: 12px;
}

.project__name {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 22px;
  margin: 0;
  letter-spacing: -0.01em;
}

.project__status {
  font-size: 11px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-transform: lowercase;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  background: var(--muted);
}

.dot--teal {
  background: var(--accent-2);
}

.dot--orange {
  background: var(--accent-1);
}

.dot--muted {
  background: var(--muted);
}

.project__desc {
  margin: 0;
  color: color-mix(in oklab, var(--fg) 88%, var(--muted));
  font-size: 15px;
  text-wrap: pretty;
}

.chips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  font-size: 11px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  color: var(--muted);
  text-transform: lowercase;
}

.project__more summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--accent-2);
  list-style: none;
  text-transform: lowercase;
  width: fit-content;
}

.project__more summary::-webkit-details-marker {
  display: none;
}

.project__more summary:hover {
  color: var(--accent-1);
}

.project__more[open] summary {
  color: var(--accent-1);
}

.project__more p {
  margin: 12px 0 0;
  font-size: 14px;
  color: color-mix(in oklab, var(--fg) 85%, var(--muted));
  text-wrap: pretty;
}

.project__foot {
  margin-top: auto;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
  display: flex;
  gap: 14px;
  padding-top: 14px;
}

.ilink {
  font-size: 12px;
  color: var(--accent-2);
  text-transform: lowercase;
}

.ilink:hover {
  color: var(--accent-1);
}

.ilink--muted {
  color: var(--muted);
  cursor: default;
}

.ilink--muted:hover {
  color: var(--muted);
}

/* ───────────── CERTS ───────────── */

.certs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
  font-size: 13.5px;
}

.certs li {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.certs li:first-child {
  border-top: 1px solid var(--border);
}

.certs__name {
  color: var(--fg);
  flex: 0 0 auto;
}

.certs__sep {
  color: var(--border);
}

.certs__iss {
  color: var(--muted);
}

.certs__yr {
  color: var(--accent-2);
  margin-left: auto;
}

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

.section--contact {
  padding-bottom: clamp(60px, 8vh, 100px);
}

.contact__lede {
  font-size: 17px;
  color: color-mix(in oklab, var(--fg) 90%, var(--muted));
  margin: -24px 0 32px;
  max-width: 50ch;
}

.contact {
  list-style: none;
  margin: 0;
  padding: 0;
}

.contact__row {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 22px 4px;
  border-top: 1px solid var(--border);
  transition: padding-left .2s var(--ease), color .2s var(--ease);
}

.contact li:last-child .contact__row {
  border-bottom: 1px solid var(--border);
}

.contact__k {
  font-size: 11px;
  color: var(--muted);
  text-transform: lowercase;
}

.contact__k {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
}

.contact__k svg {
  display: block;
}

.contact__v {
  font-family: var(--f-display);
  font-weight: 500;
  font-size: clamp(20px, 3vw, 28px);
  letter-spacing: -0.01em;
}

.contact__arrow {
  font-family: var(--f-mono);
  color: var(--muted);
  font-size: 18px;
  transition: transform .2s var(--ease), color .2s var(--ease);
}

.contact__row:hover {
  color: var(--accent-1);
  padding-left: 14px;
}

.contact__row:hover .contact__arrow {
  color: var(--accent-1);
  transform: translateX(4px);
}

/* Button-as-contact-row reset (copy-to-clipboard) */
button.contact__row {
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  font: inherit;
  color: inherit;
  cursor: pointer;
  width: 100%;
  text-align: left;
}

.contact li:last-child button.contact__row {
  border-bottom: 1px solid var(--border);
}

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

.foot {
  border-top: 1px solid var(--border);
  padding: 28px var(--pad);
}

.foot__inner {
  max-width: var(--max);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  font-size: 11px;
  color: var(--muted);
  text-transform: lowercase;
}

.foot__mid {
  opacity: .5;
}

/* ───────────── REVEAL ───────────── */

.reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .4s ease-out, transform .4s ease-out;
  will-change: opacity, transform;
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

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

@media (max-width: 860px) {
  .nav__links {
    display: none;
  }

  .nav__toggle {
    display: inline-block;
  }

  .nav__name {
    display: none;
  }

  .about {
    grid-template-columns: 1fr;
  }

  .projects {
    grid-template-columns: 1fr;
  }

  .contact__row {
    grid-template-columns: 90px 1fr auto;
  }

  .contact__v {
    font-size: 20px;
  }
}

@media (max-width: 480px) {
  .hero__name {
    letter-spacing: -0.04em;
  }

  .btn {
    width: 100%;
    justify-content: space-between;
  }

  .hero__cta {
    gap: 10px;
  }

  .terminal__body {
    padding: 18px 16px 20px;
    font-size: 12.5px;
  }

  .terminal__meta {
    display: none;
  }

  .certs li {
    flex-direction: column;
    gap: 4px;
  }

  .certs__sep {
    display: none;
  }

  .certs__yr {
    margin-left: 0;
  }
}

/* ───────────── REDUCED MOTION ───────────── */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }

  .caret {
    animation: none;
    color: var(--accent-1);
  }

  .reveal {
    opacity: 1;
    transform: none;
  }
}

/* ───────────── PRINT ───────────── */

@media print {

  .nav,
  .menu,
  .foot,
  .hero__scanlines {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }
}