/* ==========================================================================
   Marwane EL MOUFAOUED · Portfolio
   Mobile-first. Breakpoints: 640px, 768px, 900px, 1024px, 1280px.
   ========================================================================== */

:root {
  --bg: #0c0e12;
  --bg-elev: #12151b;
  --line: #232832;
  --border: #3d4350;
  --text: #e8eaf0;
  --muted: #9aa2b1;
  --accent: #c778dd;
  --accent-soft: rgba(199, 120, 221, 0.14);

  --font: "Fira Code", ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo,
    Consolas, "Liberation Mono", monospace;

  --container: 1080px;
  --gutter: clamp(1rem, 5vw, 2rem);
  --header-h: 64px;

  /* hover zoom: same speed and easing on the way in and out */
  --zoom: 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);

  color-scheme: dark;
}

/* ---------- Base ---------- */

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

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

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

/* ---------- Background grid ---------- */

/* --grid-cell is read by js/main.js so the trail lines up with the lines. */
.bg-grid {
  --grid-cell: 44px;
  --grid-line: rgba(255, 255, 255, 0.04);

  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: var(--grid-cell) var(--grid-cell);
  /* brighter towards the top centre, fading out to the edges for depth */
  -webkit-mask-image: radial-gradient(ellipse 85% 75% at 50% 25%, #000 35%, rgba(0, 0, 0, 0.3) 100%);
  mask-image: radial-gradient(ellipse 85% 75% at 50% 25%, #000 35%, rgba(0, 0, 0, 0.3) 100%);
}

.bg-grid__trail {
  display: block;
  width: 100%;
  height: 100%;
}

h1,
h2,
h3,
p,
ul,
dl,
dd {
  margin: 0;
}

ul {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

svg {
  display: block;
}

svg text {
  font-family: var(--font);
}

strong {
  font-weight: 600;
  color: var(--text);
}

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

::selection {
  background: var(--accent);
  color: var(--bg);
}

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

.accent,
.hash {
  color: var(--accent);
}

.nowrap {
  white-space: nowrap;
}

.sprite {
  position: absolute;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  font-weight: 500;
  transition: background-color 0.2s, border-color 0.2s, scale var(--zoom);
}

.btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--muted);
}

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

.btn--accent:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.btn--sm {
  min-height: 40px;
  padding: 0.35rem 0.85rem;
  font-size: 0.9rem;
}

/* ---------- Header ---------- */

.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(12, 14, 18, 0.88);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.header.is-scrolled,
.nav-open .header {
  border-bottom-color: var(--line);
}

.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 44px;
  font-weight: 700;
}

.brand__mark {
  width: 22px;
  height: 22px;
  color: var(--accent);
}

.nav__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
}

.nav__link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--muted);
  transition: color 0.2s;
}

.nav__link:hover,
.nav__link.is-active {
  color: var(--text);
}

.nav-toggle {
  display: none;
}

/* Small screens: the nav becomes a full-height panel under the header.
   Only when JS is available; without it the links simply wrap. */
@media (max-width: 767.98px) {
  .js .nav-toggle {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 6px;
    width: 44px;
    height: 44px;
    margin-right: -6px;
    padding: 0 6px;
    background: none;
    border: 0;
    color: var(--text);
    cursor: pointer;
  }

  .nav-toggle__bar {
    display: block;
    width: 26px;
    height: 2px;
    background: currentColor;
    transition: transform 0.25s, width 0.25s;
  }

  .nav-toggle__bar:last-child {
    width: 18px;
  }

  .nav-open .nav-toggle__bar:nth-child(2) {
    transform: translateY(4px) rotate(45deg);
  }

  .nav-open .nav-toggle__bar:last-child {
    width: 26px;
    transform: translateY(-4px) rotate(-45deg);
  }

  .js .nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: calc(100vh - var(--header-h));
    height: calc(100dvh - var(--header-h));
    padding: 1.5rem var(--gutter) 2rem;
    background: var(--bg);
    overflow-y: auto;
    visibility: hidden;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.2s, transform 0.2s, visibility 0s 0.2s;
  }

  .js .nav-open .nav {
    visibility: visible;
    opacity: 1;
    transform: none;
    transition-delay: 0s;
  }

  .js .nav__list {
    flex-direction: column;
    gap: 0.25rem;
  }

  .js .nav__link {
    width: 100%;
    min-height: 56px;
    font-size: 1.5rem;
    font-weight: 500;
  }

  .js body.nav-open {
    overflow: hidden;
  }

  html:not(.js) .header__inner {
    flex-wrap: wrap;
    padding-block: 0.5rem;
  }
}

/* ---------- Social rail (wide screens) ---------- */

.rail {
  display: none;
}

@media (min-width: 1280px) {
  .rail {
    position: fixed;
    top: 0;
    left: 1.5rem;
    z-index: 40;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    color: var(--muted);
  }

  .rail__line {
    width: 1px;
    height: 150px;
    margin-bottom: 0.5rem;
    background: var(--border);
  }

  .rail a {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    transition: color 0.2s;
  }

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

  .rail svg {
    width: 20px;
    height: 20px;
  }
}

/* ---------- Hero ---------- */

.hero {
  padding-block: clamp(2rem, 7vw, 5rem) clamp(3rem, 8vw, 6rem);
}

.hero__grid {
  display: grid;
  gap: clamp(2.5rem, 6vw, 4rem);
  align-items: center;
}

.hero__hello {
  color: var(--muted);
  font-size: 1.05rem;
}

.hero__title {
  margin-top: 0.25rem;
  font-size: clamp(1.75rem, 1.1rem + 3.2vw, 2.75rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.hero__role {
  margin-top: 0.75rem;
  font-size: clamp(1.05rem, 0.9rem + 0.8vw, 1.35rem);
  font-weight: 500;
  line-height: 1.45;
}

.hero__lead {
  max-width: 34rem;
  margin-top: 1.5rem;
  color: var(--muted);
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2rem;
}

.hero__visual {
  position: relative;
  width: 100%;
  max-width: 440px;
  margin-inline: auto;
}

/* decorative outline square behind the portrait, tucked behind the head */
.hero__visual::before {
  content: "";
  position: absolute;
  z-index: 0;
  pointer-events: none;
  top: 2%;
  left: 18%;
  width: 40%;
  aspect-ratio: 1;
  border: 1px solid var(--accent);
  opacity: 0.6;
}

.portrait {
  position: relative;
  z-index: 1;
  display: block;
  border-bottom: 1px solid var(--border);
}

/* soft accent glow so the dark sweater separates from the background */
.portrait::before {
  content: "";
  position: absolute;
  inset: 12% 6% 0;
  z-index: -1;
  background: radial-gradient(closest-side, rgba(199, 120, 221, 0.22), transparent);
}

.portrait img {
  display: block;
  width: 100%;
  height: auto;
}

.status {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin: -1px 0 0 auto;
  width: fit-content;
  max-width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.status__dot {
  flex: none;
  width: 0.7rem;
  height: 0.7rem;
  background: var(--accent);
  transform: translateY(1px);
}

@media (min-width: 900px) {
  .hero__grid {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  }

  .hero__visual {
    margin-inline: auto 0;
  }
}

/* ---------- Sections ---------- */

.section {
  position: relative;
  padding-block: clamp(2.5rem, 7vw, 4.5rem);
}

.section__head {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: clamp(1.75rem, 4vw, 3rem);
}

.section__title {
  flex: 1;
  display: flex;
  align-items: center;
  min-width: 0;
  font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2rem);
  font-weight: 500;
  line-height: 1.2;
}

.section__title::after {
  content: "";
  flex: 0 1 clamp(3rem, 30vw, 22rem);
  height: 1px;
  margin-left: 1rem;
  background: var(--accent);
}

.section__more {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  font-weight: 500;
  white-space: nowrap;
}

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

/* decorative shapes in the page margins */
@media (min-width: 1024px) {
  .section::before {
    content: "";
    position: absolute;
    pointer-events: none;
  }

  #projets::before {
    top: 30%;
    right: 0;
    width: 56px;
    height: 110px;
    border: 1px solid var(--border);
    border-right: 0;
  }

  #competences::before,
  #contact::before {
    width: 68px;
    height: 68px;
    background-image: radial-gradient(circle, var(--muted) 1.5px, transparent 2px);
    background-size: 16px 16px;
    opacity: 0.5;
  }

  #competences::before {
    top: 1rem;
    left: 0.5rem;
  }

  #a-propos::before {
    bottom: 12%;
    left: 0;
    width: 48px;
    height: 96px;
    border: 1px solid var(--border);
    border-left: 0;
  }

  #contact::before {
    right: 1rem;
    bottom: 1rem;
  }
}

/* ---------- Projects ---------- */

.projects {
  display: grid;
  gap: 1rem;
}

.project {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  transition: border-color 0.2s, opacity 0.6s, transform 0.6s, scale var(--zoom);
}

.project:hover {
  border-color: var(--accent);
}

.project__thumb {
  aspect-ratio: 2 / 1;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

.project__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: scale var(--zoom);
}

/* logos keep their proportions, centred with breathing room */
.project__thumb--logo img {
  padding: 12% 10%;
  object-fit: contain;
}

.project__stack {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.6;
}

.project__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem;
}

.project__title {
  font-size: 1.35rem;
  font-weight: 500;
  line-height: 1.3;
}

/* The title link stretches over the whole card, making the card clickable. */
.project__title a {
  transition: color 0.2s;
}

.project__title a::after {
  content: "";
  position: absolute;
  inset: 0;
}

.project:hover .project__title a {
  color: var(--accent);
}

.project__title a:focus-visible {
  outline: none;
}

.project__title a:focus-visible::after {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.project__subtitle {
  margin-top: 0.35rem;
  color: var(--accent);
  font-size: 0.875rem;
  line-height: 1.5;
}

.project__desc {
  margin-top: 0.85rem;
  margin-bottom: 1.25rem;
  color: var(--muted);
  font-size: 0.9375rem;
}

/* Live / Code buttons sit above the stretched card link. */
.project__links {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: auto;
}

@media (min-width: 640px) {
  .projects {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Tablet: the third card spans the full row */
@media (min-width: 640px) and (max-width: 1023.98px) {
  .project:last-child {
    grid-column: 1 / -1;
  }
}

@media (min-width: 1024px) {
  .projects {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ---------- Skills ---------- */

.skills {
  display: grid;
  gap: 1rem;
}

.skill {
  border: 1px solid var(--border);
  transition: border-color 0.2s, scale var(--zoom);
}

.skill__title {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border);
  font-size: 1rem;
  font-weight: 600;
}

.skill__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.85rem;
}

.skill__list li {
  padding: 0.2rem 0.6rem;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.875rem;
  transition: border-color 0.2s, color 0.2s, scale var(--zoom);
}

@media (min-width: 600px) {
  .skills {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .skills {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* ---------- About ---------- */

.about {
  display: grid;
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
}

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

.about__text p + p {
  margin-top: 1.25rem;
}

.qualities {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.75rem;
}

.qualities li {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--accent);
  color: var(--text);
  font-weight: 500;
  transition: background-color 0.2s, scale var(--zoom);
}

.qualities li::before {
  content: "#";
  color: var(--accent);
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  transition: border-color 0.2s, scale var(--zoom);
}

.card__name {
  padding: 0.5rem 0.85rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.75rem;
}

.facts {
  padding: 0.5rem 0.85rem;
}

.facts > div {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.55rem 0;
  font-size: 0.9375rem;
}

.facts > div + div {
  border-top: 1px dashed var(--line);
}

.facts dt {
  color: var(--accent);
}

.facts dt::after {
  content: ":";
  color: var(--muted);
}

@media (min-width: 900px) {
  .about {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  }
}

/* ---------- Contacts ---------- */

.contact {
  display: grid;
  gap: 2rem;
  align-items: start;
}

.contact__text {
  max-width: 32rem;
  color: var(--muted);
}

.contact__card {
  padding: 1rem;
  transition: border-color 0.2s, opacity 0.6s, transform 0.6s, scale var(--zoom);
}

.contact__title {
  font-size: 1rem;
  font-weight: 600;
}

.contact__list {
  margin-top: 0.75rem;
}

.contact__list li {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  column-gap: 0.75rem;
  min-height: 44px;
  color: var(--muted);
  font-size: 0.9375rem;
}

.contact__list svg {
  flex: none;
  width: 20px;
  height: 20px;
}

.contact__list a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 0;
  overflow-wrap: anywhere;
  transition: color 0.2s;
}

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

.copy {
  grid-column: 2;
  justify-self: start;
  margin-bottom: 0.5rem;
  min-width: 4.75rem;
  min-height: 40px;
  padding: 0.15rem 0.6rem;
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.copy:hover,
.copy.is-done {
  border-color: var(--accent);
  color: var(--accent);
}

html:not(.js) .copy {
  display: none;
}

@media (min-width: 480px) {
  .contact__list li {
    grid-template-columns: 20px minmax(0, 1fr) auto;
  }

  .copy {
    grid-column: 3;
    margin-bottom: 0;
  }
}

@media (min-width: 800px) {
  .contact {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 3rem;
  }

  .contact__card {
    min-width: 24rem;
  }
}

/* ---------- Footer ---------- */

.footer {
  margin-top: clamp(2rem, 6vw, 4rem);
  padding-block: 2rem 1.5rem;
  border-top: 1px solid var(--border);
}

.footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem 3rem;
}

.footer__brand p {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.footer__heading {
  font-size: 1.25rem;
  font-weight: 500;
}

.footer__media ul {
  display: flex;
  gap: 0.25rem;
  margin: 0.25rem 0 0 -10px;
}

.footer__media a {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: var(--muted);
  transition: color 0.2s;
}

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

.footer__media svg {
  width: 22px;
  height: 22px;
}

.footer__copy {
  margin-top: 2rem;
  padding-inline: var(--gutter);
  color: var(--muted);
  font-size: 0.875rem;
  text-align: center;
}

/* ---------- Hover zoom ---------- */

/* Only with a real mouse (on touch screens :hover sticks after a tap) and when
   the visitor has not asked for reduced motion. Uses `scale`, not `transform`,
   so it does not fight the .reveal entrance animation. */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .brand__mark,
  .rail svg,
  .footer__media svg,
  .contact__list svg {
    transition: scale var(--zoom), color 0.2s;
  }

  .portrait img {
    transform-origin: 50% 100%;
    transition: scale var(--zoom);
  }

  /* small logos */
  .brand:hover .brand__mark,
  .rail a:hover svg,
  .footer__media a:hover svg {
    scale: 1.25;
  }

  .contact__list li:hover svg {
    scale: 1.2;
    color: var(--accent);
  }

  .hero__visual:hover .portrait img {
    scale: 1.03;
  }

  .btn:hover {
    scale: 1.05;
  }

  .btn:active {
    scale: 0.97;
  }

  /* projects: the card grows, its picture grows a bit more inside the frame */
  .project:hover {
    z-index: 1;
    scale: 1.03;
  }

  .project:hover .project__thumb img {
    scale: 1.08;
  }

  .skill:hover,
  .card:hover {
    border-color: var(--accent);
    scale: 1.02;
  }

  .skill__list li:hover {
    border-color: var(--accent);
    color: var(--text);
    scale: 1.1;
  }

  .qualities li:hover {
    background: var(--accent-soft);
    scale: 1.1;
  }
}

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: no-preference) {
  .js .reveal {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out, border-color 0.2s, scale var(--zoom);
  }

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

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

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Print ---------- */

@media print {
  .bg-grid,
  .header,
  .rail,
  .nav-toggle,
  .copy {
    display: none !important;
  }

  .js .reveal {
    opacity: 1 !important;
    transform: none !important;
  }
}
