/* ═══════════════════════════════════════════════════════════
   SIGNAL — Nabil Rouissi Portfolio
   portfolio.css — Origin v2 / Swiss-Bauhaus · White Edition
═══════════════════════════════════════════════════════════ */

/* ─── TOKENS ─────────────────────────────────────────────── */
:root {
  --black:   #0A0A0A;
  --white:   #FAFAFA;
  --red:     #D91E18;
  --red-dim: #A01510;
  --g1:      #1A1A1A;
  --g2:      #2E2E2E;
  --g3:      #555555;
  --g4:      #888888;
  --g5:      #BFBFBF;
  --g6:      #E5E5E5;
  --g7:      #F2F2F2;

  --sans: 'Space Grotesk', Helvetica Neue, Helvetica, Arial, sans-serif;
  --mono: 'Space Mono', 'Courier New', monospace;

  --m:   64px;
  --g:   24px;
  --nav: 64px;

  /* theme-aware grid line for hero */
  --grid-line: rgba(229,229,229,0.7);
}

/* ─── RESET ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  background: var(--white);
  color: var(--black);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }

/* ─── LAYOUT ─────────────────────────────────────────────── */
.wrap {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 var(--m);
}

/* ─── NAV ────────────────────────────────────────────────── */
nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  height: var(--nav);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--m);
  background: rgba(250,250,250,0.96);
  border-bottom: 1px solid var(--g6);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: transform 0.3s ease;
}
nav.hide { transform: translateY(-100%); }

/* ─── NAV LOGO + BEATING CURSOR MARK ──────────────────────── */
@keyframes logoIn {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}
/* Lub-dub heartbeat — box is 22px; arms start inside, peak past box edge */
@keyframes lcBeatH {
  0%, 100% { width: 10px; }
  8%        { width: 46px; }   /* extends 12px past each side */
  20%       { width: 13px; }
  30%       { width: 28px; }
  46%       { width: 10px; }
}
@keyframes lcBeatV {
  0%, 100% { height: 10px; }
  8%        { height: 46px; }
  20%       { height: 13px; }
  30%       { height: 28px; }
  46%       { height: 10px; }
}
@keyframes lcDotBeat {
  0%, 100% { transform: translate(-50%,-50%) scale(1); }
  8%        { transform: translate(-50%,-50%) scale(2.4); }
  20%       { transform: translate(-50%,-50%) scale(1.4); }
  30%       { transform: translate(-50%,-50%) scale(2); }
  46%       { transform: translate(-50%,-50%) scale(1); }
}

.nav-logo {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--g4);
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  animation: logoIn 0.55s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both;
  transition: color 0.2s;
}
.nav-logo:hover { color: var(--black); }

/* Standalone logo mark — 4-corner bracket, cursor inside, arms overflow */
.nav-logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  position: relative;
  flex-shrink: 0;
  overflow: visible;
  background:
    linear-gradient(var(--red),var(--red)) 0    0    / 6px 1.5px no-repeat,
    linear-gradient(var(--red),var(--red)) 0    0    / 1.5px 6px no-repeat,
    linear-gradient(var(--red),var(--red)) 100% 0    / 6px 1.5px no-repeat,
    linear-gradient(var(--red),var(--red)) 100% 0    / 1.5px 6px no-repeat,
    linear-gradient(var(--red),var(--red)) 0    100% / 6px 1.5px no-repeat,
    linear-gradient(var(--red),var(--red)) 0    100% / 1.5px 6px no-repeat,
    linear-gradient(var(--red),var(--red)) 100% 100% / 6px 1.5px no-repeat,
    linear-gradient(var(--red),var(--red)) 100% 100% / 1.5px 6px no-repeat;
}

/* Cursor anchored to center of box; overflow:visible lets arms exit */
.logo-cursor {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
/* Horizontal arm */
.lc-h {
  position: absolute;
  height: 1px;
  background: var(--red);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  animation: lcBeatH 1.15s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
/* Vertical arm */
.lc-v {
  position: absolute;
  width: 1px;
  background: var(--red);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  animation: lcBeatV 1.15s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
/* Center dot */
.lc-dot {
  position: absolute;
  width: 3px; height: 3px;
  background: var(--red);
  border-radius: 50%;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  animation: lcDotBeat 1.15s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

/* Box dims slightly on hover to draw attention to the NR text */
.nav-logo-mark { transition: opacity 0.2s; }
.nav-logo:hover .nav-logo-mark { opacity: 0.75; }

.nav-links {
  display: flex;
  gap: 36px;
  list-style: none;
}
.nav-links a {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--g4);
  transition: color 0.2s;
  position: relative;
}
.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -4px; left: 0; right: 0;
  height: 1px;
  background: var(--red);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s ease;
}
.nav-links a:hover,
.nav-links a.active { color: var(--black); }
.nav-links a.active::after,
.nav-links a:hover::after { transform: scaleX(1); }

/* ─── TYPE ATOMS ─────────────────────────────────────────── */
.lbl {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--g4);
  display: block;
}
.lbl-red { color: var(--red); }

.red-rule {
  display: block;
  width: 48px;
  height: 3px;
  background: var(--red);
  margin: 16px 0 14px;
}

/* ─── SECTION HEAD ───────────────────────────────────────── */
.sh {
  display: flex;
  flex-direction: column;
  margin-bottom: 48px;
}
.sh-num {
  font-family: var(--sans);
  font-size: clamp(48px, 5vw, 72px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 0.92;
  color: var(--g6);
}

/* ─── DIVIDERS ───────────────────────────────────────────── */
.rule { display: block; width: 100%; height: 1px; background: var(--g6); }

/* ─── REVEAL ─────────────────────────────────────────────── */
.rv {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.rv.on { opacity: 1; transform: translateY(0); }
.rv-d1 { transition-delay: 0.07s; }
.rv-d2 { transition-delay: 0.14s; }
.rv-d3 { transition-delay: 0.21s; }
.rv-d4 { transition-delay: 0.28s; }

/* ─── CURSOR — crosshair reticle ─────────────────────────── */
/* Hide OS cursor on mouse/trackpad devices — custom cursor takes over */
@media (pointer: fine) {
  * { cursor: none !important; }
}
/* Hide custom cursor on touch devices — they have no pointer to track */
@media (pointer: coarse) {
  .cur, .cur-ring { display: none !important; }
}

/* Horizontal arm */
.cur {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
}
/* The reticle is built from two thin lines + center dot */
.cur::before,
.cur::after {
  content: '';
  position: absolute;
  background: var(--red);
  transition: width .18s ease, height .18s ease, opacity .18s ease;
}
/* Horizontal bar */
.cur::before {
  width: 11px; height: 1px;
  top: 0; left: 50%;
  transform: translateX(-50%);
}
/* Vertical bar */
.cur::after {
  width: 1px; height: 11px;
  left: 0; top: 50%;
  transform: translateY(-50%);
}

/* Center dot */
.cur-ring {
  position: fixed;
  width: 3px; height: 3px;
  background: var(--red);
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.45;
  transform: translate(-50%, -50%);
  transition: width .18s ease, height .18s ease, transform .18s ease, border-radius .18s ease, opacity .18s ease;
}

/* ─── CURSOR HEARTBEAT — lub-dub pulse on hover ──────────── */
@keyframes curBeatH {
  0%, 100% { width: 11px; }
  8%        { width: 26px; }
  20%       { width: 13px; }
  30%       { width: 20px; }
  46%       { width: 11px; }
}
@keyframes curBeatV {
  0%, 100% { height: 11px; }
  8%        { height: 26px; }
  20%       { height: 13px; }
  30%       { height: 20px; }
  46%       { height: 11px; }
}
@keyframes curDotBeat {
  0%, 100% {
    width: 3px; height: 3px;
    border-radius: 50%;
    opacity: 0.45;
    transform: translate(-50%,-50%) rotate(0deg);
  }
  8% {
    width: 7px; height: 7px;
    border-radius: 1px;
    opacity: 0.75;
    transform: translate(-50%,-50%) rotate(45deg);
  }
  20% {
    width: 4px; height: 4px;
    border-radius: 2px;
    opacity: 0.55;
    transform: translate(-50%,-50%) rotate(45deg);
  }
  30% {
    width: 5px; height: 5px;
    border-radius: 1px;
    opacity: 0.65;
    transform: translate(-50%,-50%) rotate(45deg);
  }
  46% {
    width: 3px; height: 3px;
    border-radius: 50%;
    opacity: 0.45;
    transform: translate(-50%,-50%) rotate(0deg);
  }
}

/* Hover state — heartbeat pulse (lub-dub) */
.cur.lg::before { animation: curBeatH 0.82s cubic-bezier(0.4,0,0.2,1) infinite; }
.cur.lg::after  { animation: curBeatV 0.82s cubic-bezier(0.4,0,0.2,1) infinite; }
.cur-ring.lg    { animation: curDotBeat 0.82s cubic-bezier(0.4,0,0.2,1) infinite; }

/* ─── SOCIAL ICONS ───────────────────────────────────────── */
.nav-social {
  display: flex;
  gap: 16px;
  align-items: center;
}
.nav-social a {
  color: var(--g4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}
.nav-social a:hover { color: var(--black); }
.nav-social svg { display: block; }

/* Footer social — slightly larger */
.footer-social {
  display: flex;
  gap: 14px;
  align-items: center;
}
.footer-social a {
  color: var(--g4);
  display: flex;
  align-items: center;
  transition: color 0.2s;
}
.footer-social a:hover { color: var(--black); }

/* ─── FOOTER ─────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--g6);
  padding: 20px var(--m);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.f-txt {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--g5);
}

/* ─── SHARED JS (included per-page) ─────────────────────── */
/* cursor + nav-hide + reveal observer */

/* ─── MOBILE NAV ─────────────────────────────────────────── */
.nav-menu-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  margin-left: 8px;
}
.nav-menu-btn span {
  display: block;
  width: 22px;
  height: 1.5px;
  background: var(--black);
  transform-origin: center;
  transition: transform 0.25s cubic-bezier(0.16,1,0.3,1), opacity 0.2s ease;
}
.nav-menu-btn.open span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.nav-menu-btn.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-menu-btn.open span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

/* Full-screen mobile overlay — always dark regardless of theme */
.nav-mobile {
  position: fixed;
  inset: 0;
  background: #0A0A0A;
  z-index: 999;
  display: flex;
  flex-direction: column;
  padding: 0 24px;
  transform: translateY(-100%);
  transition: transform 0.4s cubic-bezier(0.16,1,0.3,1);
  pointer-events: none;
}
.nav-mobile.open {
  transform: translateY(0);
  pointer-events: all;
}
.nav-mobile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  border-bottom: 1px solid #1A1A1A;
  flex-shrink: 0;
}
.nav-logo-mobile {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 700;
  color: #FAFAFA;
  text-decoration: none;
  letter-spacing: -0.01em;
}
.nav-mobile-close {
  background: none;
  border: none;
  cursor: pointer;
  width: 36px; height: 36px;
  position: relative;
  flex-shrink: 0;
}
.nav-mobile-close span {
  position: absolute;
  top: 50%; left: 50%;
  width: 20px; height: 1.5px;
  background: #FAFAFA;
}
.nav-mobile-close span:nth-child(1) { transform: translate(-50%,-50%) rotate(45deg); }
.nav-mobile-close span:nth-child(2) { transform: translate(-50%,-50%) rotate(-45deg); }

.nav-mobile-links {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
  padding: 8px 0;
}
.nav-mobile-links a {
  font-family: var(--sans);
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  color: #FAFAFA;
  text-decoration: none;
  padding: 18px 0;
  border-bottom: 1px solid #1A1A1A;
  transition: color 0.15s;
  opacity: 0;
  transform: translateY(12px);
  transition: color 0.15s, opacity 0.3s ease, transform 0.3s ease;
}
.nav-mobile-links a:last-child { border-bottom: none; }
.nav-mobile-links a:hover { color: #D91E18; }
.nav-mobile.open .nav-mobile-links a {
  opacity: 1;
  transform: translateY(0);
}
.nav-mobile.open .nav-mobile-links a:nth-child(1) { transition-delay: 0.06s; }
.nav-mobile.open .nav-mobile-links a:nth-child(2) { transition-delay: 0.10s; }
.nav-mobile.open .nav-mobile-links a:nth-child(3) { transition-delay: 0.14s; }
.nav-mobile.open .nav-mobile-links a:nth-child(4) { transition-delay: 0.18s; }
.nav-mobile.open .nav-mobile-links a:nth-child(5) { transition-delay: 0.22s; }
.nav-mobile.open .nav-mobile-links a:nth-child(6) { transition-delay: 0.26s; }

.nav-mobile-foot {
  padding: 24px 0;
  border-top: 1px solid #1A1A1A;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.nav-mobile-foot-lbl {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #555555;
}

/* ─── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 1024px) { :root { --m: 40px; } }

/* ── 768px — Tablet / large mobile ─────────────────────── */
@media (max-width: 768px) {
  :root { --m: 24px; }

  /* Nav */
  .nav-links  { display: none; }
  .theme-btn  { display: none; }
  .nav-menu-btn { display: flex; }

  /* ── index.html ── */
  .hero-stats {
    position: static;
    display: flex;
    gap: 24px;
    margin-top: 36px;
  }
  .hero-meta { flex-wrap: wrap; gap: 10px; }

  /* ── work.html ── */
  .featured-grid { grid-template-columns: 1fr !important; }
  .card-dark     { min-height: 360px; }
  .more-grid     { grid-template-columns: 1fr !important; }

  /* ── about.html ── */
  .about-layout  { grid-template-columns: 1fr !important; }
  .focus-grid    { grid-template-columns: repeat(2, 1fr) !important; }

  /* ── cv.html ── */
  .cv-layout     { grid-template-columns: 1fr !important; }
  .skills-groups { grid-template-columns: 1fr !important; }
  .cv-left .cv-section:not(:last-child) { border-bottom: 1px solid var(--g6); padding-bottom: 32px; margin-bottom: 32px; }

  /* ── contact.html ── */
  .contact-grid  { grid-template-columns: 1fr !important; }
  .contact-underline { width: 100% !important; max-width: 320px; }

  /* ── art.html ── */
  .cat-grid  { grid-template-columns: repeat(2, 1fr) !important; }
  .art-intro { grid-template-columns: 1fr !important; }

  /* ── method.html ── */
  .methods-grid     { grid-template-columns: 1fr !important; }
  .tools-grid       { grid-template-columns: 1fr !important; }
  .principles-grid  { grid-template-columns: repeat(2, 1fr) !important; }
  .philosophy-tools { grid-template-columns: 1fr !important; }

  /* ── art-graphic / art-photography ── */
  .art-grid-main { grid-template-columns: repeat(2, 1fr) !important; }
  .art-piece.wide { grid-column: span 1; }
  .photo-grid { grid-template-columns: repeat(2, 1fr) !important; grid-auto-rows: 200px !important; }

  /* ── case studies ── */
  .overview-text { grid-column: 1 / -1 !important; }
  .overview-aside { grid-column: 1 / -1 !important; }
  .method-grid   { grid-template-columns: 1fr !important; }
  .insights-grid { grid-template-columns: 1fr !important; }
  .decision      { grid-template-columns: 1fr !important; }
  .testing-row   { grid-template-columns: 1fr !important; }
  .screens-row   { grid-template-columns: repeat(2, 1fr) !important; }
  .cs-metrics    { flex-direction: column !important; border-left: none !important; border-top: 1px solid var(--g6); }
  .cs-metric     { border-right: none !important; border-bottom: 1px solid var(--g6) !important; padding: 20px 0 !important; }
  .journey       { grid-template-columns: 1fr !important; }
  .persona-card  { grid-template-columns: 1fr !important; }

  /* ── Typography ── */
  .hero-title        { white-space: normal !important; font-size: clamp(52px, 12vw, 96px) !important; }
  .card-title        { white-space: normal !important; }
  .contact-heading   { font-size: clamp(40px, 10vw, 72px) !important; }
  .hero__meta        { flex-wrap: wrap !important; gap: 16px !important; }
}

/* ── 600px — Mobile ─────────────────────────────────────── */
@media (max-width: 600px) {
  /* index.html hero  */
  .hero-title { font-size: clamp(40px, 11vw, 68px) !important; }
  .hero-stats { gap: 16px; }
  .hero-stat-num { font-size: 22px; }

  /* focus grid → single col */
  .focus-grid { grid-template-columns: 1fr !important; }
  .principles-grid { grid-template-columns: 1fr !important; }

  /* case study hero meta → stack */
  .hero__meta { flex-direction: column !important; gap: 10px !important; }
  .screens-row { grid-template-columns: 1fr !important; }
}

/* ── 480px — Small mobile ───────────────────────────────── */
@media (max-width: 480px) {
  .cat-grid   { grid-template-columns: 1fr !important; }
  .photo-grid { grid-template-columns: 1fr !important; grid-auto-rows: 260px !important; }
  .art-grid-main { grid-template-columns: 1fr !important; }

  .skill-item { flex-direction: column; gap: 6px; }
  .skill-dots { margin-top: 2px; }

  .cat-nav { flex-wrap: wrap; gap: 4px; }
  .cat-nav a { font-size: 9px; }

  .photo-caption { font-size: 9px; }
}

/* ═══════════════════════════════════════════════════════════
   DARK MODE — token flip + overrides
═══════════════════════════════════════════════════════════ */

html.dark {
  --black:      #FAFAFA;
  --white:      #0A0A0A;
  --g1:         #F2F2F2;
  --g2:         #E5E5E5;
  --g3:         #BFBFBF;
  /* --g4: #888888 stays as true mid-grey */
  --g5:         #555555;
  --g6:         #2E2E2E;
  --g7:         #1A1A1A;
  --grid-line:  rgba(46,46,46,0.7);
}

/* Social icons — dark mode hover */
html.dark .nav-social a:hover  { color: #FAFAFA; }
html.dark .footer-social a:hover { color: #FAFAFA; }

/* Nav bg is hardcoded — must override explicitly */
html.dark nav {
  background: rgba(10,10,10,0.96);
  border-bottom-color: #2E2E2E;
}

/* Dark work cards always stay dark regardless of theme */
html.dark .card-dark              { background: #1A1A1A !important; color: #FAFAFA !important; }
html.dark .card-dark .card-ghost  { color: #2E2E2E !important; }
html.dark .card-dark:hover .card-ghost { color: #3C3C3C !important; }
html.dark .card-dark .card-desc   { color: #888888 !important; }
html.dark .card-dark .card-link   { color: #888888 !important; }

/* ─── THEME TOGGLE BUTTON ─────────────────────────────── */
.theme-btn {
  background: none;
  border: 1px solid var(--g6);
  border-radius: 4px;
  cursor: pointer;
  padding: 5px 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--g4);
  transition: color .2s, border-color .2s, background .2s;
  margin-left: 20px;
  flex-shrink: 0;
}
.theme-btn:hover { color: var(--black); border-color: var(--g4); }
.theme-btn svg { display: block; }

/* ─── CONTENT LOADER — .has-image state ──────────────── */
/* Applied by content-loader.js when an image is found     */
[data-content].has-image {
  background-color: transparent !important;
}
/* Fade out placeholder labels on image-filled elements */
[data-content].has-image > span,
[data-content].has-image .card-img-lbl,
[data-content].has-image .placeholder-lbl {
  opacity: 0;
  transition: opacity .3s;
}

/* ─── MARQUEE (homepage ticker) ───────────────────────── */
.marquee {
  position: absolute;
  bottom: 28px;
  left: 0; right: 0;
  overflow: hidden;
  pointer-events: none;
}
.marquee-track {
  display: flex;
  width: max-content;
  animation: marqueeScroll 35s linear infinite;
}
.marquee-track span {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--g5);
  white-space: nowrap;
  padding-right: 80px;
}
@keyframes marqueeScroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
