/* ==========================================================================
   Mohammed El Aoumrani — Portfolio
   Design system: dark editorial-terminal. Fraunces (display) + Work Sans
   (body) + IBM Plex Mono (labels/nav/tags). One accent color, used sparingly.
   ========================================================================== */

:root {
  --bg: #0b0c0f;
  --bg-alt: #131519;
  --bg-card: #15171c;
  --line: #24262c;
  --text: #ece8df;
  --text-dim: #8d92a0;
  --text-faint: #565b68;
  --accent: #ffb454;
  --accent-dim: #8a6a3a;

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Work Sans', -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

  --max-w: 1120px;
  --gutter: clamp(24px, 6vw, 96px);

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html { scroll-behavior: smooth; overflow-x: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }

::selection { background: var(--accent); color: #1a1200; }

/* ---------- background texture ---------- */

.bg-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 64px 64px;
  opacity: 0.25;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, black 40%, transparent 90%);
}

.bg-glow {
  position: fixed;
  top: -20%;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 900px;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(circle, rgba(255, 180, 84, 0.14) 0%, transparent 65%);
}

main, header, footer { position: relative; z-index: 1; }

/* ---------- layout helpers ---------- */

.hero, .about, .services, .work, .contact {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: clamp(64px, 12vw, 140px) var(--gutter);
}

.section-head { max-width: 640px; margin-bottom: clamp(40px, 6vw, 72px); }

.section-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 16px;
}

.section-head h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.7rem, 3.4vw, 2.6rem);
  line-height: 1.25;
  color: var(--text);
}

.section-note {
  margin-top: 16px;
  font-size: 0.92rem;
  color: var(--text-dim);
  max-width: 56ch;
}

/* ---------- scroll reveal ---------- */

.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
}

.reveal.is-visible { opacity: 1; transform: translateY(0); }

/* ---------- nav ---------- */

.nav {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 10px 20px;
  border-radius: 999px;
  background: rgba(19, 21, 25, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  width: min(680px, calc(100vw - 32px));
}

.nav-mark {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--accent);
  font-size: 0.95rem;
  margin-right: 8px;
}

.nav-links {
  display: flex;
  gap: 24px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-dim);
  flex: 1;
}

.nav-links a { transition: color 0.2s var(--ease); white-space: nowrap; }
.nav-links a:hover { color: var(--text); }

.nav-cta {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--accent);
  color: #1a1200;
  font-weight: 500;
  white-space: nowrap;
  transition: transform 0.2s var(--ease), opacity 0.2s var(--ease);
}
.nav-cta:hover { transform: translateY(-1px); opacity: 0.92; }

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
}
.nav-toggle span {
  display: block;
  width: 100%;
  height: 1.5px;
  background: var(--text);
}

/* ---------- hero ---------- */

.hero {
  position: relative;
  padding-top: clamp(140px, 22vw, 220px);
  padding-bottom: clamp(80px, 10vw, 120px);
}

/* full-bleed background image behind hero text. Stays hidden (display:none,
   set via onerror in HTML) until images/hero-bg.webp actually exists. */
.hero-bg {
  position: absolute;
  top: -20px;
  bottom: 0;
  left: 50%;
  width: 100vw;
  transform: translateX(-50%);
  z-index: -1;
  overflow: hidden;
}
.hero-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.22;
  filter: grayscale(1) contrast(1.1) brightness(0.85);
}
.hero-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, var(--bg) 0%, transparent 30%, var(--bg) 100%);
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-dim);
  letter-spacing: 0.03em;
  margin-bottom: 28px;
}

.hero-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2.6rem, 8vw, 5.6rem);
  line-height: 1.02;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 28px;
}

.hero-line { display: block; overflow: hidden; }

.hero-line .word {
  display: inline-block;
  transform: translateY(110%);
  animation: word-in 0.9s var(--ease) forwards;
  animation-delay: calc(var(--word-i, 0) * 90ms + 150ms);
}

@keyframes word-in {
  to { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .hero-line .word { animation: none; transform: translateY(0); }
}

.hero-role {
  font-family: var(--font-mono);
  font-size: clamp(1rem, 1.6vw, 1.2rem);
  color: var(--accent);
  margin-bottom: 20px;
}

.hero-divider { color: var(--text-faint); }

.hero-desc {
  max-width: 46ch;
  font-size: clamp(1rem, 1.3vw, 1.15rem);
  color: var(--text-dim);
  margin-bottom: 44px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  padding: 14px 26px;
  border-radius: 999px;
  transition: transform 0.2s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease);
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--accent);
  color: #1a1200;
  font-weight: 500;
}
.btn-primary:hover { transform: translateY(-2px); }

.btn-ghost {
  border-color: var(--line);
  color: var(--text-dim);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--text); }

.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* ---------- about ---------- */

.about-body {
  display: flex;
  flex-direction: column;
  gap: 22px;
  max-width: 68ch;
  font-size: 1.05rem;
  color: var(--text-dim);
}
.about-body p:first-child { color: var(--text); }

/* ---------- services ---------- */

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

.service-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: clamp(28px, 4vw, 40px);
  transition: border-color 0.3s var(--ease), transform 0.3s var(--ease);
}
.service-card:hover {
  border-color: var(--accent-dim);
  transform: translateY(-4px);
}

.service-num {
  display: block;
  font-family: var(--font-mono);
  color: var(--text-faint);
  font-size: 0.85rem;
  margin-bottom: 20px;
}

.service-card h3 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.5rem;
  margin-bottom: 14px;
}

.service-card p {
  color: var(--text-dim);
  font-size: 0.98rem;
  margin-bottom: 22px;
}

.service-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.service-tags li {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: 999px;
  padding: 5px 12px;
}

/* ---------- work / projects ---------- */

.work-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  perspective: 1200px;
}

.project-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: clamp(28px, 4vw, 36px);
  display: flex;
  flex-direction: column;
  gap: 18px;
  transform-style: preserve-3d;
  transition: border-color 0.3s var(--ease), transform 0.4s var(--ease);
}
.project-card:hover { border-color: var(--accent-dim); }

/* JS sets the tilt transform inline on mousemove (js/script.js initProjectTilt).
   Reduced motion / touch: no listener attached, this rule below is the only motion. */
@media (prefers-reduced-motion: no-preference) {
  .no-touch .project-card:hover { transform: translateY(-4px); }
}
@media (prefers-reduced-motion: reduce), (pointer: coarse) {
  .project-card:hover { transform: translateY(-4px); }
}

.project-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background:
    repeating-linear-gradient(135deg, var(--bg-alt) 0 12px, #1a1d23 12px 24px);
  border: 1px solid var(--line);
}
.project-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* treated per Images & Media Standards: no full-color fills, accent never used as a fill */
  filter: grayscale(1) contrast(1.1) brightness(0.85);
}

.project-card h3 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.3rem;
}

.project-card p {
  color: var(--text-dim);
  font-size: 0.96rem;
  flex: 1;
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.project-tags li {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  background: var(--bg-alt);
  border-radius: 6px;
  padding: 4px 10px;
}

.project-link {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
  align-self: flex-start;
}
.project-link:hover { text-decoration: underline; }

/* ---------- contact ---------- */

.contact-grid {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: clamp(32px, 6vw, 64px);
}

.contact-list { display: flex; flex-direction: column; gap: 24px; }
.contact-list li { display: flex; flex-direction: column; gap: 4px; }

.contact-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.contact-list a, .contact-list span:not(.contact-label) {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--text);
}
.contact-list a:hover { color: var(--accent); }

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-row { display: flex; flex-direction: column; gap: 8px; }

.form-row label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-dim);
}

.form-row input,
.form-row textarea {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  resize: vertical;
  transition: border-color 0.2s var(--ease);
}
.form-row input:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* honeypot: hidden from real users, still in the DOM for bots to fill */
.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.form-status {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  min-height: 1.2em;
}
.form-status.success { color: #8ed99b; }
.form-status.error { color: #e0806b; }

/* ---------- section dividers ---------- */

.divider {
  position: relative;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.divider-img {
  width: 100%;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  opacity: 0.35;
  filter: grayscale(1) contrast(1.1) brightness(0.85);
}

.divider-line {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.divider-line line {
  stroke: var(--accent);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset 1.4s var(--ease);
}
.divider-line.is-visible line { stroke-dashoffset: 0; }

/* ---------- custom cursor ---------- */

/* JS adds .has-custom-cursor to <html> on non-touch devices only; native
   cursor stays untouched everywhere else (mobile, reduced-motion is fine
   either way since this is a positional aid, not decorative motion). */
.cursor { display: none; }

.has-custom-cursor { cursor: none; }
.has-custom-cursor a,
.has-custom-cursor button,
.has-custom-cursor .project-card,
.has-custom-cursor input,
.has-custom-cursor textarea {
  cursor: none;
}

.has-custom-cursor .cursor {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 200;
  pointer-events: none;
  will-change: transform;
}

.cursor-dot {
  position: absolute;
  top: -3px;
  left: -3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px 2px rgba(255, 180, 84, 0.7);
}

.cursor-ring {
  position: absolute;
  top: -18px;
  left: -18px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--accent-dim);
  transition: width 0.25s var(--ease), height 0.25s var(--ease),
    top 0.25s var(--ease), left 0.25s var(--ease), border-color 0.25s var(--ease);
}

.has-custom-cursor .cursor.is-hovering .cursor-ring {
  top: -28px;
  left: -28px;
  width: 56px;
  height: 56px;
  border-color: var(--accent);
}

/* ---------- footer ---------- */

.site-footer {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 40px var(--gutter) 80px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-faint);
  border-top: 1px solid var(--line);
}
.site-footer a:hover { color: var(--accent); }

/* ---------- responsive ---------- */

@media (max-width: 860px) {
  .services-grid, .work-grid { grid-template-columns: 1fr; }
  .contact-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .nav {
    flex-wrap: wrap;
    border-radius: 24px;
    transition: border-radius 0.3s var(--ease);
  }

  /* mark + toggle stay on the fixed top row always, order pinned explicitly
     so the dropdown (order: 3/4) can never push them sideways */
  .nav-mark { order: 1; flex-shrink: 0; }
  .nav-toggle { order: 2; flex-shrink: 0; display: flex; margin-left: auto; }

  /* animated open/close: always rendered (never display:none) so height
     transitions smoothly instead of snapping, mark/toggle are unaffected
     either way since they live outside this flow */
  .nav-links, .nav-cta {
    flex: 0 0 100%;
    flex-direction: column;
    width: 100%;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    pointer-events: none;
    transition: max-height 0.4s var(--ease), opacity 0.25s ease,
      padding-top 0.4s var(--ease), margin-top 0.4s var(--ease);
  }
  .nav-links { order: 3; gap: 16px; border-top: 1px solid transparent; }
  .nav-cta { order: 4; justify-content: center; }

  .nav.is-open .nav-links {
    display: flex;
    max-height: 320px;
    opacity: 1;
    pointer-events: auto;
    padding-top: 16px;
    margin-top: 16px;
    border-top-color: var(--line);
  }
  .nav.is-open .nav-cta {
    display: inline-flex;
    max-height: 80px;
    opacity: 1;
    pointer-events: auto;
    margin-top: 12px;
  }

  /* hamburger morphs into an X in place, no positional shift */
  .nav-toggle span { transition: transform 0.3s var(--ease), opacity 0.2s ease; }
  .nav.is-open .nav-toggle span:nth-child(1) { transform: translateY(5.5px) rotate(45deg); }
  .nav.is-open .nav-toggle span:nth-child(2) { opacity: 0; }
  .nav.is-open .nav-toggle span:nth-child(3) { transform: translateY(-5.5px) rotate(-45deg); }
}
