/* =============================================
   PORTFOLIO — Muhammad Fahmi Al Kahfi
   Design System & Shared Styles
   ============================================= */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* --- CSS Variables --- */
:root {
  --teal:        #14B8A6;
  --teal-dark:   #0D9488;
  --teal-light:  #CCFBF1;
  --teal-soft:   rgba(20, 184, 166, 0.1);

  --dark:        #1E293B;
  --mid:         #475569;
  --muted:       #94A3B8;
  --border:      #E2E8F0;
  --bg:          #F8FAFC;
  --white:       #FFFFFF;

  --pink-soft:   rgba(251, 113, 133, 0.25);
  --teal-glow:   rgba(20, 184, 166, 0.30);

  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   20px;
  --radius-xl:   32px;

  --shadow-sm:   0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.10);

  --nav-h:       68px;
  --transition:  0.25s ease;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--dark);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

/* --- Typography --- */
h1 { font-size: clamp(2.2rem, 5vw, 3.5rem); font-weight: 800; line-height: 1.15; }
h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); font-weight: 700; line-height: 1.25; }
h3 { font-size: 1.2rem; font-weight: 600; }
h4 { font-size: 1rem; font-weight: 600; }
p  { color: var(--mid); line-height: 1.75; }

.section-title {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  color: var(--teal);
  margin-bottom: 0.5rem;
}
.section-subtitle {
  color: var(--muted);
  font-size: 1rem;
  margin-bottom: 2.5rem;
}
.page-hero-title {
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 800;
  color: var(--dark);
  text-align: center;
  margin-bottom: 0.5rem;
}
.page-hero-sub {
  text-align: center;
  color: var(--muted);
  font-size: 1rem;
  margin-bottom: 3rem;
}

/* --- Layout --- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 2rem;
}
.section {
  padding: 5rem 0;
}
.section-alt {
  background: var(--white);
  padding: 5rem 0;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }

/* --- Navbar --- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  height: var(--nav-h);
  display: flex;
  align-items: center;
}
.navbar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}
.nav-brand {
  font-size: 1rem;
  font-weight: 700;
  color: var(--dark);
  white-space: nowrap;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.nav-item {
  position: relative;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.4rem 0.9rem;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--mid);
  transition: color var(--transition);
  white-space: nowrap;
}
.nav-link:hover { color: var(--teal); }
.nav-link.active {
  background: var(--teal);
  color: var(--white);
}
.nav-link.active:hover { color: var(--white); }
.nav-link svg { width: 14px; height: 14px; transition: transform var(--transition); }
.nav-item:hover .nav-link svg { transform: rotate(180deg); }

/* Dropdown — top:100% + padding-top bridges the gap so hover stays active */
.dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 200px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: visible;
  z-index: 999;
  padding-top: 8px;
}
/* Invisible bridge so moving mouse into dropdown doesn't break hover */
.dropdown::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 0;
  right: 0;
  height: 8px;
}
/* Visible box starts below the bridge */
.dropdown a:first-child { border-radius: var(--radius-md) var(--radius-md) 0 0; }
.dropdown a:last-child  { border-radius: 0 0 var(--radius-md) var(--radius-md); }
.nav-item:hover .dropdown { display: block; }
.dropdown-header {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.4rem 1.2rem 0.2rem;
  pointer-events: none;
  border-top: 1px solid var(--border);
  margin-top: 0.25rem;
}
.dropdown-header:first-child { border-top: none; margin-top: 0; }
.dropdown a {
  display: block;
  padding: 0.7rem 1.2rem;
  font-size: 0.875rem;
  color: var(--mid);
  transition: background var(--transition), color var(--transition);
}
.dropdown a:hover {
  background: var(--teal-soft);
  color: var(--teal-dark);
}

/* Mobile toggle */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  padding: 0.5rem;
  color: var(--dark);
}
.nav-toggle svg { width: 24px; height: 24px; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0.65rem 1.5rem;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  border: 2px solid transparent;
}
.btn-primary {
  background: var(--teal);
  color: var(--white);
  border-color: var(--teal);
}
.btn-primary:hover {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn-outline {
  background: transparent;
  color: var(--teal);
  border-color: var(--teal);
}
.btn-outline:hover {
  background: var(--teal);
  color: var(--white);
}
.btn-scroll {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: transparent;
  border: 2px solid var(--teal);
  color: var(--teal);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  cursor: pointer;
}
.btn-scroll:hover {
  background: var(--teal);
  color: var(--white);
}
.btn-scroll svg { width: 20px; height: 20px; }

/* --- Cards --- */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  transition: box-shadow var(--transition), transform var(--transition);
}
.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
}
.card-icon {
  width: 44px; height: 44px;
  background: var(--teal-soft);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--teal);
  margin-bottom: 1rem;
}
.card-icon svg { width: 22px; height: 22px; }

/* --- Tags / Badges --- */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
  background: var(--teal-soft);
  color: var(--teal-dark);
  border: 1px solid rgba(20, 184, 166, 0.2);
  transition: all var(--transition);
  cursor: pointer;
}
.tag:hover, .tag.active {
  background: var(--teal);
  color: var(--white);
  border-color: var(--teal);
}
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* --- Progress Bar --- */
.progress-wrap { margin-top: 0.75rem; }
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 4px;
}
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal-dark), var(--teal));
  border-radius: 3px;
  transition: width 1s ease;
  width: 0;
}

/* --- Timeline --- */
.timeline { position: relative; padding-left: 28px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 6px; top: 8px; bottom: 0;
  width: 2px;
  background: var(--border);
}
.timeline-item {
  position: relative;
  margin-bottom: 2rem;
}
.timeline-dot {
  position: absolute;
  left: -24px; top: 6px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--teal);
  border: 2px solid var(--white);
  box-shadow: 0 0 0 2px var(--teal);
}
.timeline-dot.inactive {
  background: var(--border);
  box-shadow: 0 0 0 2px var(--border);
}
.timeline-meta {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0.4rem;
}
.timeline-org {
  font-size: 0.85rem;
  color: var(--teal);
  font-weight: 500;
}
.timeline-period {
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.timeline-location {
  font-size: 0.8rem;
  color: var(--muted);
}

/* --- Section Divider --- */
.divider {
  width: 60px;
  height: 4px;
  background: var(--teal);
  border-radius: 2px;
  margin-bottom: 1.5rem;
}

/* --- Link styled --- */
.link-teal {
  color: var(--teal);
  font-size: 0.875rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color var(--transition);
}
.link-teal:hover { color: var(--teal-dark); }
.link-teal svg { width: 14px; height: 14px; }

/* --- Image Gallery --- */
.img-gallery {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scroll-snap-type: x mandatory;
}
.img-gallery::-webkit-scrollbar { height: 4px; }
.img-gallery::-webkit-scrollbar-track { background: var(--border); border-radius: 2px; }
.img-gallery::-webkit-scrollbar-thumb { background: var(--teal); border-radius: 2px; }
.img-gallery img {
  width: 160px;
  height: 110px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  scroll-snap-align: start;
}

/* --- Expand Panel --- */
.expand-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease, padding 0.3s ease;
}
.expand-panel.open {
  max-height: 600px;
}
.expand-panel-inner {
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  margin-top: 1rem;
}

/* --- Modal / Overlay --- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2.5rem;
  position: relative;
  animation: modalIn 0.3s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-close {
  position: absolute;
  top: 1.25rem; right: 1.25rem;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg);
  border: none;
  display: flex; align-items: center; justify-content: center;
  color: var(--mid);
  transition: background var(--transition);
}
.modal-close:hover { background: var(--border); }
.modal-close svg { width: 18px; height: 18px; }

/* --- Footer --- */
footer {
  background: var(--dark);
  color: var(--muted);
  padding: 2rem 0;
  text-align: center;
  font-size: 0.875rem;
}
footer a { color: var(--teal); }

/* =========================================================
   AUTO-SCROLL CAROUSELS (landing page)
   ========================================================= */
@keyframes scroll-left {
  /* translate3d forces GPU compositing, eliminates sub-pixel jitter */
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(-50%, 0, 0); }
}

.carousel-wrap {
  overflow: hidden;
  position: relative;
  /* Fade edges for polished look */
  -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 7%, #000 93%, transparent 100%);
  mask-image:         linear-gradient(to right, transparent 0%, #000 7%, #000 93%, transparent 100%);
}

.carousel-track {
  display: flex;
  /* NO gap here — margin-right on each card keeps pitch uniform so -50% is exact */
  width: max-content;
  animation: scroll-left 40s linear infinite;
  will-change: transform;
}

.carousel-track:hover {
  animation-play-state: paused;
}

/* ── Academic / Experience slide card ── */
.slide-card {
  flex-shrink: 0;
  width: 260px;
  margin-right: 1.25rem; /* gap via margin keeps -50% translate mathematically exact */
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  color: inherit;
  transition: box-shadow var(--transition), transform var(--transition);
  text-decoration: none;
}
.slide-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
}

.slide-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--teal-soft);
  color: var(--teal-dark);
  border: 1px solid rgba(20,184,166,0.2);
  width: fit-content;
  margin-bottom: 0.1rem;
}

.slide-icon {
  color: var(--teal);
  line-height: 1;
}

.slide-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--dark);
  line-height: 1.3;
}

.slide-org {
  font-size: 0.83rem;
  color: var(--teal);
  font-weight: 500;
}

.slide-sub {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

.slide-period {
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: auto;
  padding-top: 0.4rem;
}

/* ── Project slide card ── */
.slide-proj {
  flex-shrink: 0;
  width: 280px;
  margin-right: 1.25rem; /* gap via margin keeps -50% translate mathematically exact */
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  color: inherit;
  text-decoration: none;
  transition: box-shadow var(--transition), transform var(--transition);
}
.slide-proj:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
}

.slide-thumb-area {
  height: 148px;
  overflow: hidden;
  background: var(--bg);
  flex-shrink: 0;
}
.slide-thumb-area img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.slide-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: var(--border);
}
.slide-thumb-placeholder svg { width: 36px; height: 36px; }

.slide-body {
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.slide-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.1rem;
}

.slide-headline {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--dark);
  line-height: 1.3;
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .container { padding: 0 1.25rem; }
  .section, .section-alt { padding: 3.5rem 0; }
  .grid-3 { grid-template-columns: 1fr; }
  .nav-links { display: none; flex-direction: column; position: absolute; top: var(--nav-h); left: 0; right: 0; background: var(--white); padding: 1rem; border-bottom: 1px solid var(--border); gap: 0.25rem; }
  .nav-links.open { display: flex; }
  .nav-toggle { display: block; }
  .dropdown { position: static; box-shadow: none; border: none; padding-left: 1rem; }
}


/* =========================================================
   HERO — CV DOWNLOAD BUTTON
   ========================================================= */
.hero-cv-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0.75rem 1.75rem;
  border-radius: 40px;
  background: var(--teal);
  color: var(--white);
  font-size: 0.95rem;
  font-weight: 600;
  border: 2px solid var(--teal);
  transition: all var(--transition);
  text-decoration: none;
  margin-bottom: 1.5rem;
}
.hero-cv-btn:hover {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.hero-cv-btn svg { width: 18px; height: 18px; flex-shrink: 0; }

/* =========================================================
   TESTIMONIAL SLIDER
   ========================================================= */
.testi-slider-wrap { position: relative; }
.testi-slider { overflow: hidden; }
.testi-track {
  display: flex;
  transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}
.testi-slide { min-width: 100%; padding: 0 0.25rem; }
.testi-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2rem 2.5rem;
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.testi-card::before {
  content: '\201C';
  position: absolute;
  top: 1rem; left: 1.5rem;
  font-size: 4rem;
  color: var(--teal-light);
  font-family: Georgia, serif;
  line-height: 1;
  pointer-events: none;
}
.testi-avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--teal-soft);
  display: flex; align-items: center; justify-content: center;
  color: var(--teal-dark);
  font-size: 1.5rem;
  font-weight: 700;
  border: 3px solid var(--teal-light);
}
.testi-avatar img { width: 100%; height: 100%; object-fit: cover; }
.testi-body { flex: 1; }
.testi-quote {
  font-size: 1rem;
  font-style: italic;
  color: var(--mid);
  line-height: 1.8;
  margin-bottom: 1.25rem;
  padding-top: 1.5rem;
}
.testi-name { font-weight: 600; color: var(--dark); font-size: 0.95rem; }
.testi-role { font-size: 0.82rem; color: var(--muted); margin-top: 2px; }
.testi-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
}
.testi-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--white);
  display: flex; align-items: center; justify-content: center;
  color: var(--mid);
  transition: all var(--transition);
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.testi-btn:hover { border-color: var(--teal); color: var(--teal); box-shadow: var(--shadow-md); }
.testi-btn svg { width: 16px; height: 16px; }
.testi-dots { display: flex; gap: 0.5rem; align-items: center; }
.testi-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: all 0.3s ease;
  cursor: pointer;
  border: none;
  padding: 0;
}
.testi-dot.active { background: var(--teal); width: 24px; border-radius: 4px; }
@media (max-width: 640px) {
  .testi-card { flex-direction: column; gap: 1rem; padding: 1.5rem; }
  .testi-avatar { width: 52px; height: 52px; font-size: 1.1rem; }
}

/* =========================================================
   PROJECT IMAGE SWIPER (modal)
   ========================================================= */
.modal-swiper {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #0f172a;
  margin-bottom: 1.5rem;
  height: 260px;
}
.modal-swiper-track {
  display: flex;
  height: 100%;
  transition: transform 0.4s ease;
}
.modal-swiper-slide {
  min-width: 100%;
  height: 100%;
  flex-shrink: 0;
}
.modal-swiper-slide img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.modal-swiper-placeholder {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 0.75rem;
  color: rgba(255,255,255,0.3);
}
.modal-swiper-placeholder svg { width: 48px; height: 48px; }
.modal-swiper-placeholder span { font-size: 0.82rem; }
.modal-swiper-btn {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  border: none;
  color: white;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
  z-index: 10;
}
.modal-swiper-btn:hover { background: rgba(0,0,0,0.7); }
.modal-swiper-btn svg { width: 16px; height: 16px; }
.modal-swiper-prev { left: 0.75rem; }
.modal-swiper-next { right: 0.75rem; }
.modal-swiper-counter {
  position: absolute;
  bottom: 0.75rem; right: 0.75rem;
  background: rgba(0,0,0,0.5);
  color: white;
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 20px;
}

/* =========================================================
   EXPAND PANEL IMAGES (Academic & Experience)
   ========================================================= */
.panel-img-row {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding: 0.75rem 0 0.25rem;
  scroll-snap-type: x mandatory;
}
.panel-img-row::-webkit-scrollbar { height: 3px; }
.panel-img-row::-webkit-scrollbar-track { background: var(--border); }
.panel-img-row::-webkit-scrollbar-thumb { background: var(--teal); border-radius: 2px; }
.panel-img-row img {
  width: 160px; height: 110px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  scroll-snap-align: start;
  border: 1px solid var(--border);
}
