/* ==========================================================
   Youssef Cherkaoui — personal site
   Mobile-first. Themes are driven by custom properties.
   ========================================================== */

:root {
  --bg: #f7f5f0;
  --bg-alt: #efece4;
  --surface: #ffffff;
  --text: #1a1d21;
  --text-muted: #565d66;
  --border: #dcd7cb;
  --accent: #0b6b5d;
  --accent-strong: #08574c;
  --accent-soft: #dcefe9;
  --on-accent: #ffffff;
  --shadow: 0 1px 2px rgba(20, 24, 28, .05), 0 8px 24px rgba(20, 24, 28, .06);

  --raw: #8a8f98;
  --bronze: #b0703a;
  --silver: #7d8894;
  --gold: #b8901f;

  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Space Grotesk", var(--font-body);
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;

  --radius: 14px;
  --radius-sm: 8px;
  --gutter: 20px;
  --max: 1120px;
  --header-h: 64px;
}

/* Dark palette: system preference unless the visitor chose light. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1419;
    --bg-alt: #141b22;
    --surface: #19212a;
    --text: #e8ebee;
    --text-muted: #9aa5b1;
    --border: #2a3541;
    --accent: #4fd1b5;
    --accent-strong: #7be0c9;
    --accent-soft: #15332e;
    --on-accent: #06251f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --raw: #8d97a3;
    --bronze: #d59258;
    --silver: #aab6c2;
    --gold: #e3bd4c;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1419;
  --bg-alt: #141b22;
  --surface: #19212a;
  --text: #e8ebee;
  --text-muted: #9aa5b1;
  --border: #2a3541;
  --accent: #4fd1b5;
  --accent-strong: #7be0c9;
  --accent-soft: #15332e;
  --on-accent: #06251f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --raw: #8d97a3;
  --bronze: #d59258;
  --silver: #aab6c2;
  --gold: #e3bd4c;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: 1.15;
  margin: 0;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
p { margin: 0 0 1em; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); }
code {
  font-family: var(--font-mono);
  font-size: .88em;
  background: var(--accent-soft);
  padding: .1em .35em;
  border-radius: 4px;
}

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

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

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  background: var(--accent);
  color: var(--on-accent);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  text-decoration: none;
}
.skip-link:focus { top: 12px; color: var(--on-accent); }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 600;
  min-width: 0;
}
.brand:hover { color: var(--text); }
.brand-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: .85rem;
  letter-spacing: 0;
}
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.header-actions { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.icon-btn:hover { background: var(--bg-alt); }

/* Sun shows in dark mode (to switch to light), moon in light mode. */
.icon-sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: block; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }

.menu-toggle .bar { transition: transform .2s ease, opacity .2s ease; transform-origin: 12px 12px; }
.menu-toggle[aria-expanded="true"] .bar-1 { transform: translateY(5px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] .bar-2 { opacity: 0; }
.menu-toggle[aria-expanded="true"] .bar-3 { transform: translateY(-5px) rotate(-45deg); }

/* Mobile nav: a panel under the header. */
.site-nav {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: none;
}
.site-nav.is-open { display: block; }
.site-nav ul { padding: 8px var(--gutter) 16px; }
.site-nav a {
  display: block;
  padding: 12px 4px;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid var(--border);
}
.site-nav li:last-child a { border-bottom: 0; }
.site-nav a[aria-current="true"] { color: var(--accent); }

@media (min-width: 820px) {
  .menu-toggle { display: none; }
  .site-nav {
    position: static;
    display: block;
    background: none;
    border: 0;
    box-shadow: none;
    margin-left: auto;
  }
  .site-nav ul { display: flex; gap: 4px; padding: 0; }
  .site-nav a {
    padding: 8px 12px;
    border: 0;
    border-radius: 8px;
    font-size: .95rem;
    color: var(--text-muted);
  }
  .site-nav a:hover { color: var(--text); background: var(--bg-alt); }
  .site-nav a[aria-current="true"] { color: var(--text); background: var(--bg-alt); }
}

/* ---------- Buttons, tags ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  font-size: .95rem;
  text-decoration: none;
  transition: border-color .15s ease, background-color .15s ease, transform .15s ease;
}
.btn:hover { border-color: var(--accent); color: var(--text); transform: translateY(-1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--on-accent); }
.btn-sm { min-height: 40px; padding: 8px 14px; font-size: .9rem; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags li {
  font-family: var(--font-mono);
  font-size: .76rem;
  line-height: 1.4;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-muted);
}

.card-label, .eyebrow, .project-kind, .section-num {
  font-family: var(--font-mono);
  font-size: .78rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0;
}

.text-link { font-weight: 500; text-decoration: none; }
.text-link:hover { text-decoration: underline; }

/* ---------- Hero ---------- */
.hero { padding: clamp(40px, 9vw, 96px) 0 clamp(40px, 8vw, 80px); }
.hero-grid { display: grid; gap: 32px; }
.eyebrow { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.hero h1 { font-size: clamp(2rem, 6.2vw, 3.6rem); font-weight: 700; margin-bottom: 20px; }
.lede { font-size: clamp(1.02rem, 1.6vw, 1.15rem); color: var(--text-muted); max-width: 60ch; margin-bottom: 28px; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 10px; }

.hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  width: 100%;
  max-width: 440px;
  margin-inline: auto;
}
.hero-card-body { padding: 20px 22px 12px; }
.profile-photo {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  object-position: center top;
}
.profile-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.3rem;
  line-height: 1.2;
  margin: 0 0 4px;
}
.facts { margin: 14px 0 0; }
.facts > div {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  padding: 11px 0;
  border-top: 1px solid var(--border);
}
.facts dt { font-family: var(--font-mono); font-size: .76rem; color: var(--text-muted); padding-top: 3px; }
.facts dd { margin: 0; font-weight: 500; font-size: .95rem; line-height: 1.45; }

@media (min-width: 900px) {
  .hero-grid { grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); gap: 56px; align-items: center; }
}

/* ---------- Sections ---------- */
.section { padding: clamp(56px, 9vw, 104px) 0; }
.section-alt { background: var(--bg-alt); border-block: 1px solid var(--border); }
.section-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: clamp(28px, 5vw, 48px);
}
.section-head h2 { font-size: clamp(1.7rem, 4vw, 2.4rem); }
.section-num { color: var(--accent); }

/* ---------- About ---------- */
.about-grid { display: grid; gap: 32px; }
.prose p { color: var(--text-muted); font-size: 1.05rem; max-width: 62ch; }
.prose p:first-child { color: var(--text); }
.stat-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-self: start; }
.stat-list li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.stat-value {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 4vw, 2.2rem);
  font-weight: 700;
  line-height: 1.1;
  color: var(--accent);
}
.stat-label { display: block; margin-top: 6px; font-size: .88rem; color: var(--text-muted); line-height: 1.4; }

@media (min-width: 900px) {
  .about-grid { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 56px; }
}

/* ---------- Experience ---------- */
.timeline { position: relative; display: grid; gap: 20px; }
.job {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  display: grid;
  gap: 14px;
}
.job-date { font-family: var(--font-mono); font-size: .8rem; color: var(--text-muted); margin: 0; }
.job-company { font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; color: var(--accent); margin: 2px 0 0; }
.job-body h3 { font-size: 1.25rem; margin-bottom: 12px; }
.job-body ul:not(.tags) { display: grid; gap: 8px; margin-bottom: 16px; }
.job-body ul:not(.tags) li,
.project-points li {
  position: relative;
  padding-left: 18px;
  color: var(--text-muted);
  font-size: .97rem;
}
.job-body ul:not(.tags) li::before,
.project-points li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: .72em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

@media (min-width: 760px) {
  .job { grid-template-columns: 190px minmax(0, 1fr); gap: 28px; padding: 28px; }
}

/* A job with several client projects: one block per project. */
.job-project {
  border-left: 3px solid var(--accent-soft);
  padding-left: 16px;
}
.job-project + .job-project { margin-top: 26px; }
.job-project h4 { font-size: 1.08rem; }
.job-client {
  font-family: var(--font-mono);
  font-size: .78rem;
  color: var(--accent);
  margin: 4px 0 10px;
}
.education {
  margin-top: 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 22px;
  display: grid;
  gap: 10px;
}
.education h3 { font-size: 1.2rem; margin: 8px 0 4px; }
.education p { margin: 0; color: var(--text-muted); }
.education-meta { font-family: var(--font-mono); font-size: .82rem; }
@media (min-width: 760px) {
  .education { grid-template-columns: 1fr auto; align-items: end; padding: 28px; }
}

/* ---------- Projects ---------- */
.project {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}
.project h3 { font-size: clamp(1.3rem, 3vw, 1.7rem); margin: 8px 0 12px; }
.project p { color: var(--text-muted); }
.project-points { display: grid; gap: 8px; margin: 0 0 18px; }
.project-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.project-note { font-size: .82rem; margin: 12px 0 0; }

.project-featured { display: grid; gap: 28px; margin-bottom: 20px; }
@media (min-width: 960px) {
  .project-featured {
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    gap: 44px;
    padding: 36px;
    align-items: center;
  }
}

.project-grid { display: grid; gap: 20px; }
@media (min-width: 760px) {
  .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.project-small { display: flex; flex-direction: column; }
.project-small .tags { margin-top: auto; }
.project-small h3 { font-size: 1.25rem; }

/* Pipeline diagram */
.pipeline { margin: 0; }
.pipeline ol { display: grid; gap: 22px; }
.pipe-step {
  position: relative;
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  text-align: center;
}
.pipe-step:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -17px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: translateX(-50%) rotate(45deg);
}
.pipe-name { font-family: var(--font-display); font-weight: 600; font-size: .98rem; }
.pipe-desc { font-family: var(--font-mono); font-size: .72rem; color: var(--text-muted); }
.pipe-group { border-color: var(--accent); background: var(--accent-soft); }
.layers { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: 6px 0 4px; }
.layer {
  font-family: var(--font-mono);
  font-size: .72rem;
  padding: 5px 2px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-width: 3px;
}
.layer-raw { border-bottom-color: var(--raw); }
.layer-bronze { border-bottom-color: var(--bronze); }
.layer-silver { border-bottom-color: var(--silver); }
.layer-gold { border-bottom-color: var(--gold); }

/* Phone screenshots */
.phones {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: center;
}
.phones img {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.phones img:nth-child(2) { transform: translateY(-12px); }
@media (max-width: 959px) {
  .phones { max-width: 520px; margin-inline: auto; padding-top: 12px; }
}

/* ---------- Skills ---------- */
.skills-grid { display: grid; gap: 16px; }
@media (min-width: 640px) { .skills-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1000px) { .skills-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.skill-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.skill-group h3 { font-size: 1.05rem; margin-bottom: 14px; }
.skill-group-wide { grid-column: 1 / -1; border-color: var(--accent); }
.skill-group-wide h3 { color: var(--accent); }
.skill-group .tags li { background: var(--bg); }

.certs {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.certs ul { display: grid; gap: 12px; margin-top: 14px; }
.certs li { display: flex; align-items: flex-start; gap: 10px; font-weight: 500; }
.certs svg { flex: none; color: var(--accent); margin-top: 3px; }
@media (min-width: 760px) { .certs ul { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- Contact ---------- */
.contact-lede { font-size: clamp(1.1rem, 2.4vw, 1.4rem); max-width: 46ch; color: var(--text); margin-bottom: 28px; }
.contact-list { display: grid; gap: 12px; }
@media (min-width: 760px) { .contact-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.contact-list a {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 100%;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: border-color .15s ease, transform .15s ease;
}
.contact-list a:hover { border-color: var(--accent); transform: translateY(-2px); }
.contact-list svg { flex: none; color: var(--accent); }
.contact-list a > span { min-width: 0; }
.contact-kind { display: block; font-family: var(--font-mono); font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.contact-value { display: block; font-weight: 500; overflow-wrap: anywhere; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 24px 0; font-size: .9rem; color: var(--text-muted); }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; }
.footer-inner p { margin: 0; }
.footer-inner a { text-decoration: none; }

/* ---------- Reveal on scroll (only when JS is running) ---------- */
.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity .5s ease, transform .5s ease; }
.js .reveal.is-visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
  .btn, .contact-list a { transition: none; }
}

@media print {
  .site-header, .hero-cta, .site-footer a { display: none; }
  .js .reveal { opacity: 1; transform: none; }
}
