/* ============================================================
   Manel Benchenni — Portfolio
   Token system: color, type, layout, signature (signal wave)
   ============================================================ */

:root[data-theme="light"] {
  --bg: #F6F8FA;
  --surface: #FFFFFF;
  --surface-2: #EDF1F4;
  --text: #12161C;
  --text-muted: #5B6472;
  --border: #E1E6EB;
  --accent: #17807E;
  --accent-2: #C97A2B;
  --shadow: rgba(15, 23, 32, 0.08);
  --shadow-strong: rgba(15, 23, 32, 0.14);
}

:root[data-theme="dark"] {
  --bg: #0A0E13;
  --surface: #10161D;
  --surface-2: #171F28;
  --text: #E8EDF2;
  --text-muted: #8B96A5;
  --border: #212B36;
  --accent: #4FD8C4;
  --accent-2: #F0B65B;
  --shadow: rgba(0, 0, 0, 0.35);
  --shadow-strong: rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background 0.4s ease, color 0.4s ease;
}

h1, h2, h3, h4 {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  margin: 0;
  letter-spacing: -0.01em;
}

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

button {
  font-family: inherit;
  cursor: pointer;
  background: none;
  border: none;
  color: inherit;
}

.mono { font-family: 'JetBrains Mono', monospace; }

/* ---------- scroll progress (signal thread) ---------- */
.signal-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0%;
  background: var(--accent);
  z-index: 1000;
  transition: width 0.1s linear;
}

/* ---------- header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.logo {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}
.logo-dot { color: var(--accent); }

.main-nav {
  display: flex;
  gap: 28px;
}
.main-nav a {
  font-size: 0.92rem;
  color: var(--text-muted);
  font-weight: 500;
  position: relative;
  padding: 4px 0;
  transition: color 0.2s ease;
}
.main-nav a:hover,
.main-nav a:focus-visible { color: var(--text); }
.main-nav a::after {
  content: '';
  position: absolute;
  left: 0; bottom: -2px;
  width: 0; height: 1px;
  background: var(--accent);
  transition: width 0.25s ease;
}
.main-nav a:hover::after { width: 100%; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-toggle {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: border-color 0.2s ease, transform 0.3s ease;
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle svg { width: 18px; height: 18px; }
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

.nav-toggle {
  display: none;
  width: 38px; height: 38px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.nav-toggle span {
  width: 20px; height: 2px;
  background: var(--text);
  transition: transform 0.25s ease, opacity 0.25s ease;
}

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

/* ---------- layout helpers ---------- */
.section-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 32px;
}
.section { padding: 110px 0; }
.section-alt { background: var(--surface); }

.section-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 14px;
}
.section-title {
  font-size: clamp(1.8rem, 3.2vw, 2.6rem);
  font-weight: 600;
  margin-bottom: 20px;
}
.section-lede {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 620px;
  margin-bottom: 50px;
}

/* ---------- reveal on scroll ---------- */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.reveal.in-view {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- hero ---------- */
.hero {
  position: relative;
  min-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 32px 40px;
  overflow: hidden;
}

.hero-signal {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0.5;
}
.hero-signal svg {
  width: 130%;
  height: 260px;
}
.signal-path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.4;
  stroke-linejoin: round;
  stroke-linecap: round;
  opacity: 0.35;
  stroke-dasharray: 6000;
  stroke-dashoffset: 6000;
  animation: draw-signal 5.5s ease-out forwards, pulse-signal 4s ease-in-out 5.5s infinite;
}
@keyframes draw-signal {
  to { stroke-dashoffset: 0; }
}
@keyframes pulse-signal {
  0%, 100% { opacity: 0.22; }
  50% { opacity: 0.45; }
}

.hero-inner { position: relative; max-width: 760px; }

.eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 22px;
}

.hero-title {
  font-size: clamp(2.6rem, 8vw, 5.2rem);
  font-weight: 700;
  line-height: 1.02;
  margin-bottom: 26px;
}

.hero-tagline {
  font-size: clamp(1.02rem, 1.6vw, 1.22rem);
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 auto 36px;
}

.hero-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 30px;
}

.btn {
  padding: 13px 28px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.94rem;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  display: inline-block;
}
.btn-primary {
  background: var(--accent);
  color: var(--bg);
}
.btn-primary:hover { transform: translateY(-2px); }
.btn-ghost {
  border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--accent); transform: translateY(-2px); }

.hero-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.dot-sep { margin: 0 8px; color: var(--border); }

.scroll-cue {
  position: absolute;
  bottom: 34px;
  left: 50%;
  transform: translateX(-50%);
  width: 22px; height: 36px;
  border: 1px solid var(--border);
  border-radius: 20px;
  display: flex;
  justify-content: center;
  padding-top: 7px;
}
.scroll-cue span {
  width: 3px; height: 8px;
  border-radius: 3px;
  background: var(--accent);
  animation: scroll-cue-move 1.8s ease-in-out infinite;
}
@keyframes scroll-cue-move {
  0% { transform: translateY(0); opacity: 1; }
  70% { transform: translateY(10px); opacity: 0; }
  100% { opacity: 0; }
}

/* ---------- profile ---------- */
.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px 60px;
  align-items: start;
}
.profile-text {
  color: var(--text-muted);
  font-size: 1.05rem;
}
.profile-tags {
  grid-column: span 2;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 6px;
  padding-top: 26px;
  border-top: 1px solid var(--border);
}
.profile-tags li {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 999px;
}

/* ---------- timeline ---------- */
.timeline {
  position: relative;
  max-width: 760px;
  padding-left: 28px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 4px; top: 8px; bottom: 8px;
  width: 1px;
  background: var(--border);
}
.timeline-item {
  position: relative;
  padding-bottom: 48px;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: '';
  position: absolute;
  left: -28px;
  top: 6px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--bg);
}
.timeline-date {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--accent);
  margin-bottom: 8px;
  letter-spacing: 0.03em;
}
.timeline-body h3 {
  font-size: 1.2rem;
  margin-bottom: 4px;
}
.timeline-role {
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  margin-bottom: 10px;
}
.timeline-body p:last-child {
  color: var(--text-muted);
  max-width: 620px;
}

/* ---------- projects ---------- */
.project-list {
  display: flex;
  flex-direction: column;
  gap: 70px;
}
.project-card {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 48px;
  align-items: center;
}
.project-card:nth-child(even) { direction: rtl; }
.project-card:nth-child(even) > * { direction: ltr; }

.gallery-frame {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
  box-shadow: 0 20px 40px -20px var(--shadow-strong);
}
.gallery-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 16%, transparent), transparent 60%),
    var(--surface-2);
}
.gallery-fallback span {
  font-family: 'JetBrains Mono', monospace;
  font-size: 2.6rem;
  color: var(--border);
  font-weight: 500;
}
.gallery-frame img.slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 1;
}
.gallery-frame img.slide.active { opacity: 1; }

.gallery-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
}
.gallery-dots button {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.2s ease, transform 0.2s ease;
}
.gallery-dots button.active {
  background: var(--accent);
  transform: scale(1.3);
}

.project-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}
.project-body h3 {
  font-size: 1.5rem;
  margin-bottom: 16px;
}
.project-body > p {
  color: var(--text-muted);
  margin-bottom: 22px;
}
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.tag-list li {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.76rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
}

.other-projects { margin-top: 100px; }
.mini-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}
.mini-card {
  background: var(--bg);
  padding: 28px 24px;
  transition: background 0.25s ease;
}
.section-alt .mini-card { background: var(--surface); }
.mini-card:hover { background: var(--surface-2); }
.mini-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}
.mini-card h4 {
  font-size: 1rem;
  margin-bottom: 10px;
  line-height: 1.3;
}
.mini-card p {
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* ---------- skills ---------- */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 36px 32px;
}
.skill-group h3 {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip-list li {
  font-size: 0.84rem;
  padding: 7px 13px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

/* ---------- contact ---------- */
.contact-section { text-align: center; }
.contact-section .section-eyebrow,
.contact-section .section-title,
.contact-section .section-lede { margin-left: auto; margin-right: auto; }
.contact-links {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  margin-top: 20px;
}
.contact-link {
  background: var(--bg);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  transition: background 0.2s ease, transform 0.2s ease;
}
.contact-link:hover { background: var(--surface-2); transform: translateY(-2px); }
.contact-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.contact-value { font-size: 0.92rem; font-weight: 500; word-break: break-word; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 30px 0; }
.footer-inner {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ============ responsive ============ */
@media (max-width: 900px) {
  .profile-grid { grid-template-columns: 1fr; }
  .profile-tags { grid-column: span 1; }
  .project-card { grid-template-columns: 1fr; }
  .project-card:nth-child(even) { direction: ltr; }
  .mini-grid { grid-template-columns: repeat(2, 1fr); }
  .skills-grid { grid-template-columns: repeat(2, 1fr); }
  .contact-links { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px) {
  .main-nav {
    position: fixed;
    top: 68px; left: 0; right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 20px 32px 26px;
    gap: 18px;
    transform: translateY(-130%);
    transition: transform 0.3s ease;
    z-index: 90;
  }
  .main-nav.open { transform: translateY(0); }
  .nav-toggle { display: flex; }
  .nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav-toggle.open span:nth-child(2) { opacity: 0; }
  .nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
  .section { padding: 80px 0; }
  .section-inner { padding: 0 22px; }
  .mini-grid { grid-template-columns: 1fr; }
  .skills-grid { grid-template-columns: 1fr; }
}
