/* ═══════════════════════════════════════════════════════════
   NIZAR SOILIHI PORTFOLIO — DESIGN SYSTEM
   Color palette: Deep black · Electric blue · Pure white
   Typography: Syne (display) + DM Sans (body) + JetBrains Mono
   ═══════════════════════════════════════════════════════════ */

:root {
  /* Colors */
  --black:        #060810;
  --black-2:      #0d1117;
  --black-3:      #161b24;
  --black-4:      #1e2533;
  --blue:         #2563eb;
  --blue-light:   #3b82f6;
  --blue-glow:    #60a5fa;
  --blue-dark:    #1d4ed8;
  --white:        #ffffff;
  --white-90:     rgba(255,255,255,0.9);
  --white-60:     rgba(255,255,255,0.6);
  --white-30:     rgba(255,255,255,0.3);
  --white-10:     rgba(255,255,255,0.1);
  --white-05:     rgba(255,255,255,0.05);

  /* Typography */
  --font-display: 'Syne', sans-serif;
  --font-body:    'DM Sans', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  /* Spacing */
  --space-xs:  0.5rem;
  --space-sm:  1rem;
  --space-md:  1.5rem;
  --space-lg:  2.5rem;
  --space-xl:  4rem;
  --space-2xl: 7rem;

  /* Layout */
  --max-width: 1200px;
  --nav-h: 72px;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── RESET ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
html, body {
  width: 100%;
  max-width: 100vw;
  /*overflow-x: hidden;*/
  position: relative;
}
body {
  font-family: var(--font-body);
  background: var(--black);
  color: var(--white);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* ── SCROLLBAR ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--black-2); }
::-webkit-scrollbar-thumb { background: var(--blue-dark); border-radius: 3px; }

/* ── SELECTION ──────────────────────────────────────────── */
::selection { background: var(--blue); color: var(--white); }

/* ── NOISE TEXTURE overlay ──────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.035'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
  opacity: 0.4;
}

/* ── TYPOGRAPHY ─────────────────────────────────────────── */
.t-display {
  font-family: var(--font-display);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
}
.t-heading {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
}
.t-display, .t-heading, h1, h2, h3, h4, h5, h6 {
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
}
.t-mono { font-family: var(--font-mono); }
.t-muted { color: var(--white-60); }
.t-blue { color: var(--blue-light); }

/* ── LAYOUT UTILITIES ───────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-md);
}
.section { padding: var(--space-2xl) 0; }
.section--sm { padding: var(--space-xl) 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-lg); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-lg); }

@media (max-width: 992px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .section { padding: var(--space-xl) 0; }
  .page-header { padding: calc(var(--nav-h) + var(--space-md)) 0 var(--space-md); }
  .page-header__title { font-size: 2.5rem; }
}

/* ── RESPONSIVE UTILS ───────────────────────────────────── */
.hidden-mobile { display: block; }
@media (max-width: 768px) {
  .hidden-mobile { display: none !important; }
}

.stack-mobile { display: grid; }
@media (max-width: 768px) {
  .stack-mobile { grid-template-columns: 1fr !important; gap: var(--space-lg) !important; }
}

.stack-tablet { display: grid; }
@media (max-width: 992px) {
  .stack-tablet { grid-template-columns: 1fr !important; gap: var(--space-lg) !important; }
}

/* Fix grid blowout */
.stack-mobile > *, .stack-tablet > *, .grid-2 > *, .grid-3 > * {
  min-width: 0;
}

/* ── CARDS ──────────────────────────────────────────────── */
.card {
  background: var(--black-3);
  border: 1px solid var(--white-10);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.35s var(--ease);
  position: relative; /* Ensure it stays in flow */
  opacity: 1; /* Default to visible, JS will hide if needed */
}
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  height: var(--nav-h);
  background: rgba(6, 8, 16, 0.8);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--white-10);
  transition: background 0.3s var(--ease);
}
.nav.scrolled {
  background: rgba(6, 8, 16, 0.97);
  box-shadow: 0 4px 30px rgba(0,0,0,0.5);
}
.nav__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-md);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav__logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: -0.05em;
}
.nav__logo-n { color: var(--white); }
.logo_img {
  display: inline-block;
  transition: transform 0.3s var(--ease-bounce);
  height: 55px;
  width: 55px;
  margin-top: 5px;
}
.nav__logo:hover .logo_img { transform: translateY(-3px); }
.nav__links {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}
.nav__link {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--white-60);
  transition: color 0.2s;
  position: relative;
}
.nav__link::after {
  content: '';
  position: absolute;
  bottom: -4px; left: 0; right: 0;
  height: 2px;
  background: var(--blue-light);
  transform: scaleX(0);
  transition: transform 0.3s var(--ease);
}
.nav__link:hover, .nav__link.active {
  color: var(--white);
}
.nav__link:hover::after, .nav__link.active::after {
  transform: scaleX(1);
}
.nav__toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  width: 28px;
}
.nav__toggle span {
  display: block;
  height: 2px;
  background: var(--white);
  border-radius: 2px;
  transition: all 0.3s;
}
.nav__mobile {
  display: none;
  flex-direction: column;
  background: var(--black-2);
  border-top: 1px solid var(--white-10);
  padding: var(--space-sm) var(--space-md);
  gap: var(--space-sm);
}
.nav__mobile.open { display: flex; }
.nav__mobile-link {
  font-size: 1rem;
  font-weight: 500;
  color: var(--white-60);
  padding: var(--space-xs) 0;
  border-bottom: 1px solid var(--white-05);
  transition: color 0.2s;
}
.nav__mobile-link:hover { color: var(--white); }

/* ── BUTTONS ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.75rem 1.75rem;
  border-radius: 6px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  transition: all 0.25s var(--ease);
  cursor: pointer;
}
.btn--primary {
  background: var(--blue);
  color: var(--white);
  border: 2px solid var(--blue);
  box-shadow: 0 0 20px rgba(37,99,235,0.35);
}
.btn--primary:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
  box-shadow: 0 0 35px rgba(37,99,235,0.55);
  transform: translateY(-2px);
}
.btn--outline {
  background: transparent;
  color: var(--white);
  border: 2px solid var(--white-30);
}
.btn--outline:hover {
  border-color: var(--white);
  background: var(--white-05);
  transform: translateY(-2px);
}
.btn--ghost {
  background: transparent;
  color: var(--blue-light);
  border: none;
  padding: 0;
  font-size: 0.875rem;
}
.btn--ghost:hover { color: var(--blue-glow); }
.btn--sm { padding: 0.5rem 1.25rem; font-size: 0.8rem; }
.btn--danger {
  background: #dc2626;
  color: white;
  border: 2px solid #dc2626;
}
.btn--danger:hover { background: #b91c1c; border-color: #b91c1c; }

/* ── CARDS ──────────────────────────────────────────────── */
.card {
  background: var(--black-3);
  border: 1px solid var(--white-10);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.35s var(--ease);
}
.card:hover {
  border-color: rgba(59,130,246,0.4);
  transform: translateY(-6px);
  box-shadow: 0 20px 50px rgba(0,0,0,0.5), 0 0 30px rgba(37,99,235,0.1);
}
.card__image {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  background: var(--black-4);
}
.card__image-placeholder {
  width: 100%;
  aspect-ratio: 16/9;
  background: linear-gradient(135deg, var(--black-4) 0%, var(--black-3) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--white-30);
}
.card__body { padding: var(--space-md); }
.card__tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--blue-light);
  background: rgba(37,99,235,0.15);
  border: 1px solid rgba(37,99,235,0.3);
  padding: 0.2em 0.7em;
  border-radius: 4px;
  margin-bottom: var(--space-xs);
}
.card__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  margin: var(--space-xs) 0;
  line-height: 1.3;
}
.card__excerpt {
  font-size: 0.875rem;
  color: var(--white-60);
  margin-bottom: var(--space-sm);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-sm);
  border-top: 1px solid var(--white-10);
}
.card__meta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.8rem;
  color: var(--white-60);
}

/* ── TECH BADGES ────────────────────────────────────────── */
.tech-badges { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: var(--space-xs) 0; }
.tech-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--white-60);
  background: var(--white-05);
  border: 1px solid var(--white-10);
  padding: 0.2em 0.6em;
  border-radius: 4px;
}

/* ── LIKE BUTTON ────────────────────────────────────────── */
.like-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-size: 0.875rem;
  color: var(--white-60);
  background: var(--white-05);
  border: 1px solid var(--white-10);
  padding: 0.35rem 0.85rem;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.25s var(--ease);
  user-select: none;
}
.like-btn:hover { color: var(--white); border-color: var(--white-30); }
.like-btn.liked {
  color: #ef4444;
  border-color: rgba(239,68,68,0.4);
  background: rgba(239,68,68,0.1);
}
.like-btn i { transition: transform 0.3s var(--ease-bounce); }
.like-btn.liked i { transform: scale(1.3); }

/* ── SECTION HEADER ─────────────────────────────────────── */
.section-header {
  margin-bottom: var(--space-xl);
}
.section-header__label {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--blue-light);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}
.section-header__title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2rem, 5vw, 3rem);
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.section-header__desc {
  font-size: 1rem;
  color: var(--white-60);
  margin-top: var(--space-sm);
  max-width: 540px;
}

/* ── FLASH MESSAGES ─────────────────────────────────────── */
.flashes {
  position: fixed;
  top: calc(var(--nav-h) + 1rem);
  right: 1rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: calc(100vw - 2rem);
}
.flash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 1.25rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  animation: slideIn 0.3s var(--ease-bounce);
  box-shadow: 0 8px 25px rgba(0,0,0,0.4);
}
.flash--success { background: #166534; border: 1px solid #22c55e; color: #bbf7d0; }
.flash--error   { background: #7f1d1d; border: 1px solid #ef4444; color: #fecaca; }
.flash--info    { background: #1e3a5f; border: 1px solid #3b82f6; color: #bfdbfe; }
.flash--warning { background: #78350f; border: 1px solid #f59e0b; color: #fde68a; }
.flash__close { font-size: 1.2rem; opacity: 0.7; cursor: pointer; }
.flash__close:hover { opacity: 1; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── PAGE HEADER (inner pages) ───────────────────────────── */
.page-header {
  padding: calc(var(--nav-h) + var(--space-xl)) 0 var(--space-xl);
  background: linear-gradient(180deg, var(--black-2) 0%, var(--black) 100%);
  border-bottom: 1px solid var(--white-10);
  position: relative;
  overflow: hidden;
}
.page-header::after {
  content: '';
  position: absolute;
  top: 0; left: 30%;
  width: 40%; height: 100%;
  background: radial-gradient(ellipse, rgba(37,99,235,0.08) 0%, transparent 70%);
  pointer-events: none;
}
.page-header__title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.5rem, 7vw, 4.5rem);
  letter-spacing: -0.04em;
  line-height: 1;
}
.page-header__sub {
  color: var(--white-60);
  font-size: 1.1rem;
  margin-top: var(--space-sm);
}

/* ── COMMENTS ───────────────────────────────────────────── */
.comments-section { margin-top: var(--space-xl); }
.comments-section h3 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: var(--space-lg);
}
.comment {
  background: var(--black-3);
  border: 1px solid var(--white-10);
  border-radius: 10px;
  padding: var(--space-md);
  margin-bottom: var(--space-sm);
}
.comment__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.comment__author {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--blue-light);
}
.comment__date {
  font-size: 0.75rem;
  color: var(--white-30);
  font-family: var(--font-mono);
}
.comment__text { font-size: 0.9rem; color: var(--white-90); line-height: 1.6; }
.comment-form {
  background: var(--black-3);
  border: 1px solid var(--white-10);
  border-radius: 10px;
  padding: var(--space-md);
  margin-top: var(--space-md);
}
.comment-form h4 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: var(--space-sm);
}

/* ── FORMS ──────────────────────────────────────────────── */
.form-group { margin-bottom: var(--space-md); }
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--white-60);
  margin-bottom: 0.5rem;
  font-family: var(--font-display);
}
.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--black-4);
  border: 1px solid var(--white-10);
  border-radius: 8px;
  color: var(--white);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.2);
}
.form-control::placeholder { color: var(--white-30); }
textarea.form-control { resize: vertical; min-height: 130px; }

/* ── FILTER TABS ────────────────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-xl);
  flex-wrap: wrap;
}
.filter-tab {
  padding: 0.5rem 1.25rem;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font-display);
  color: var(--white-60);
  background: var(--white-05);
  border: 1px solid var(--white-10);
  cursor: pointer;
  transition: all 0.2s;
}
.filter-tab:hover { color: var(--white); border-color: var(--white-30); }
.filter-tab.active {
  background: var(--blue);
  color: var(--white);
  border-color: var(--blue);
  box-shadow: 0 0 15px rgba(37,99,235,0.4);
}

/* ── FOOTER ─────────────────────────────────────────────── */
.footer {
  background: var(--black-2);
  border-top: 1px solid var(--white-10);
  padding: var(--space-xl) 0 var(--space-sm);
}
.footer__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-md);
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: start;
  gap: var(--space-xl);
  margin-bottom: var(--space-lg);
}
.footer__logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--white);
  display: block;
  margin-bottom: 0.5rem;
}
.footer__tagline { font-size: 0.875rem; color: var(--white-60); }
.footer__links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.footer__links a {
  font-size: 0.875rem;
  color: var(--white-60);
  transition: color 0.2s;
}
.footer__links a:hover { color: var(--blue-light); }
.footer__social {
  display: flex;
  gap: var(--space-sm);
}
.footer__social a {
  width: 42px; height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--white-10);
  border-radius: 8px;
  font-size: 1rem;
  color: var(--white-60);
  transition: all 0.2s;
}
.footer__social a:hover {
  border-color: var(--blue);
  color: var(--blue-light);
  background: rgba(37,99,235,0.1);
}
.footer__bottom {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-sm) var(--space-md) 0;
  border-top: 1px solid var(--white-10);
  font-size: 0.8rem;
  color: var(--white-30);
  font-family: var(--font-mono);
}

/* ── DIVIDER ────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--white-10);
  margin: var(--space-xl) 0;
}

/* ── EMPTY STATE ────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-md);
  color: var(--white-30);
}
.empty-state i { font-size: 3rem; margin-bottom: var(--space-sm); display: block; }
.empty-state p { font-size: 0.9rem; }

/* ── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .nav__links { display: none; }
  .nav__toggle { display: flex; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .footer__inner { grid-template-columns: 1fr; gap: var(--space-lg); }
  .section { padding: var(--space-xl) 0; }
}

/* ── RICH TEXT CONTENT (Quill Output) ───────────────────── */
.rich-text {
  font-size: 1.05rem;
  line-height: 1.85;
  color: var(--white-90);
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
}

.rich-text h1, .rich-text h2, .rich-text h3 {
  font-family: var(--font-display);
  color: var(--white);
  margin: var(--space-lg) 0 var(--space-sm);
  line-height: 1.2;
}

.rich-text p { margin-bottom: var(--space-md); }

.rich-text ul, .rich-text ol {
  margin-bottom: var(--space-md);
  padding-left: 1.5rem;
}

.rich-text ul { list-style: disc; }
.rich-text ol { list-style: decimal; }

.rich-text li { margin-bottom: 0.5rem; }

.rich-text pre {
  background: var(--black-2);
  border: 1px solid var(--white-10);
  border-radius: 8px;
  padding: 1.25rem;
  overflow-x: auto;
  margin: var(--space-md) 0;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.5;
}

.rich-text code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--white-10);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  color: var(--blue-glow);
}

.rich-text pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

.rich-text img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: var(--space-lg) auto;
  border-radius: 12px;
  border: 1px solid var(--white-10);
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.rich-text blockquote {
  border-left: 4px solid var(--blue);
  padding: 0.5rem 1.5rem;
  margin: var(--space-md) 0;
  background: var(--white-05);
  font-style: italic;
  color: var(--white-60);
}

/* Responsive Table */
.rich-text table {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: var(--space-md) 0;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.rich-text th, .rich-text td {
  padding: 0.75rem 1rem;
  border: 1px solid var(--white-10);
  text-align: left;
  min-width: 120px; /* Evite que les colonnes soient trop écrasées */
}

.rich-text th {
  background: var(--black-2);
  color: var(--white);
  font-weight: 700;
}

.rich-text tr:nth-child(even) {
  background: var(--white-05);
}

/* Custom properties for dynamic personalization */
.rich-text.custom-styled {
  font-family: var(--custom-font, inherit);
  color: var(--custom-color, var(--white-90));
}

/* ── ANIMATIONS ────────────────────────────────────────── */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideRight {
  from { opacity: 0; transform: translateX(-30px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes pulse-blue {
  0%   { box-shadow: 0 0 0 0 rgba(37,99,235,0.4); }
  70%  { box-shadow: 0 0 0 15px rgba(37,99,235,0); }
  100% { box-shadow: 0 0 0 0 rgba(37,99,235,0); }
}
