/* ============================================================
   JOHN TRABELSI — brutalist-modern monochrome portfolio
   Type:  Archivo (display) · Space Grotesk (body) · Space Mono (labels)
   Color: pure monochrome, single optional accent
   ============================================================ */

:root {
  /* palette (GRID = light default) */
  --bg:    #ffffff;
  --panel: #ffffff;
  --ink:   #111110;
  --muted: #6f6f6a;
  --line:  rgba(17, 17, 16, 0.16);
  --line-strong: rgba(17, 17, 16, 0.34);
  --hero-ink: #ffffff;

  --accent: var(--ink);          /* monochrome by default */
  --logo-filter: brightness(0);  /* white logo -> black on light bg */

  /* type */
  --f-display: "Archivo", system-ui, sans-serif;
  --f-body:    "Space Grotesk", system-ui, sans-serif;
  --f-mono:    "Space Mono", ui-monospace, monospace;

  /* rhythm */
  --gut: clamp(16px, 3.5vw, 56px);     /* page side gutter */
  --maxw: 1680px;

  /* motion factor, driven by Tweaks (0 = off) */
  --pf: 1;

  --label-size: clamp(10px, 0.78vw, 13px);
}

[data-mode="invert"] {
  --bg:    #0b0b0a;
  --panel: #161614;
  --ink:   #f3f3f0;
  --muted: #8f8f89;
  --line:  rgba(243, 243, 240, 0.18);
  --line-strong: rgba(243, 243, 240, 0.4);
  --logo-filter: none;            /* logo already white */
}

[data-mode="stencil"] {
  --bg:    #ffffff;
  --panel: #ffffff;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-body);
  font-weight: 400;
  line-height: 1.32;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition: background .5s ease, color .5s ease;
}
img, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--ink); color: var(--bg); }

/* ---------- shared atoms ---------- */
.mono {
  font-family: var(--f-mono);
  font-size: var(--label-size);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.mono--ink { color: var(--ink); }
.idx { font-variant-numeric: tabular-nums; }

.shell { max-width: var(--maxw); margin: 0 auto; padding-inline: var(--gut); }

.rule { border: 0; border-top: 1px solid var(--line); margin: 0; }
.rule--strong { border-top-color: var(--line-strong); }

/* section header band: sticky mono label + index */
.band {
  display: grid;
  grid-template-columns: minmax(0,1fr);
  gap: 0;
}
.band__head {
  position: sticky; top: 59px; z-index: 5;
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 14px 0 13px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  transition: background .5s ease;
}

/* ============================================================
   NAV
   ============================================================ */
.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  height: 60px; padding-inline: var(--gut);
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: background .4s ease, border-color .4s ease, backdrop-filter .4s ease;
}
.nav__logo { display: flex; align-items: center; gap: 12px; }
.nav__logo img { height: 26px; width: auto; filter: brightness(0) invert(1); transition: filter .4s ease; }
.nav__logo .mono { color: #fff; letter-spacing: 0.22em; font-size: 12px; transition: color .4s ease; }
.nav__links { display: flex; align-items: center; gap: clamp(16px, 2.4vw, 38px); }
.nav__links a {
  font-family: var(--f-mono); font-size: 12px; letter-spacing: 0.14em;
  text-transform: uppercase; color: #fff;
  position: relative; padding: 4px 0; transition: color .4s ease;
}
.nav__links a::after {
  content: ""; position: absolute; left: 0; bottom: -1px; height: 1px; width: 0;
  background: #fff; transition: width .35s cubic-bezier(.2,.7,.2,1), background .4s ease;
}
.nav__links a:hover::after { width: 100%; }

/* scrolled state — solid white (or dark in invert mode), dark content */
.nav--solid {
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px) saturate(1.1);
  border-bottom-color: var(--line);
}
.nav--solid .nav__logo img { filter: var(--logo-filter); }
.nav--solid .nav__logo .mono { color: var(--ink); }
.nav--solid .nav__links a { color: var(--ink); }
.nav--solid .nav__links a::after { background: var(--accent); }
@media (max-width: 560px) { .nav__logo .mono { display: none; } }

/* ============================================================
   HERO
   ============================================================ */
.hero {
  position: relative; height: 100svh; min-height: 600px;
  overflow: hidden; background: #000;
}
.hero__media { position: absolute; inset: -8% 0 -8% 0; }
.hero__media video {
  width: 100%; height: 100%; object-fit: cover;
  filter: saturate(1.12) contrast(1.04) brightness(.92);
  will-change: transform;
}
.hero__scrim {
  position: absolute; inset: 0;
  background:
    linear-gradient(to bottom, rgba(0,0,0,.5) 0%, rgba(0,0,0,.12) 32%, rgba(0,0,0,.22) 68%, rgba(0,0,0,.66) 100%);
}
.hero__grain { position: absolute; inset: 0; opacity: .5; mix-blend-mode: overlay;
  background-image: radial-gradient(rgba(255,255,255,.5) 1px, transparent 1.4px);
  background-size: 4px 4px; pointer-events: none; }

.hero__frame {
  position: absolute; inset: 76px var(--gut) var(--gut) var(--gut);
  border: 1px solid rgba(255,255,255,.32);
  display: grid; grid-template-rows: auto 1fr auto;
  pointer-events: none;
}
.hero__frame > * { pointer-events: auto; }
.hero__cornertop, .hero__cornerbot {
  display: flex; justify-content: space-between;
  padding: 12px 14px; color: rgba(255,255,255,.82);
}
.hero__cornerbot { align-items: end; }
.hero__corner-r { text-align: right; }

.hero__center { align-self: center; padding: 0 14px; color: var(--hero-ink); }
.hero__kicker { color: rgba(255,255,255,.78); margin-bottom: clamp(14px, 2vw, 26px); display: inline-block; }
.hero__title {
  font-family: var(--f-display);
  font-weight: 800; font-stretch: 125%;
  font-size: clamp(2.35rem, 8.45vw, 8.55rem);
  line-height: 0.92; letter-spacing: -0.02em;
  text-transform: uppercase; margin: 0;
  text-wrap: balance;
}
.hero__title .ln { display: block; overflow: hidden; }
.hero__title .ln > span { display: block; }
.hero__title .arrow { color: rgba(255,255,255,.55); font-weight: 400; font-stretch: normal; }
.hero__title em { font-style: normal; color: #fff; }

.hero__scroll {
  display: flex; align-items: center; gap: 10px;
  color: rgba(255,255,255,.8);
}
.hero__scroll .bar { display: inline-block; width: 46px; height: 1px; background: rgba(255,255,255,.6);
  transform-origin: left; animation: scrollbar 2.4s ease-in-out infinite; }
@keyframes scrollbar { 0%,100%{ transform: scaleX(.35);} 50%{ transform: scaleX(1);} }
@media (prefers-reduced-motion: reduce){ .hero__scroll .bar { animation: none; } }

/* ============================================================
   ABOUT
   ============================================================ */
.about { padding-block: clamp(80px, 12vh, 180px); }
.about__grid {
  display: grid; grid-template-columns: 1fr; gap: clamp(28px, 5vw, 64px);
}
.statement {
  font-family: var(--f-display); font-weight: 600;
  font-size: clamp(1.7rem, 4.0vw, 3.6rem);
  line-height: 1.42; letter-spacing: -0.018em;
  text-wrap: pretty; max-width: 22ch + 40ch; margin: 0;
}
.statement .word { display: inline-block; }
.statement strong { font-weight: 800; }
.statement em { font-style: normal; color: var(--accent); }
.about__meta {
  display: flex; flex-wrap: wrap; gap: 12px 28px; align-items: center;
  padding-top: clamp(20px, 3vw, 36px);
}
.contactlinks { display: flex; flex-wrap: wrap; gap: 10px; }
.contactlink {
  font-family: var(--f-mono); font-size: 13px; letter-spacing: 0.06em;
  text-transform: uppercase; padding: 11px 16px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  display: inline-flex; align-items: center; gap: 9px;
  transition: background .25s ease, color .25s ease, border-color .25s ease, transform .25s ease;
}
.contactlink .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.contactlink:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); transform: translateY(-2px); }
.contactlink:hover .dot { background: var(--bg); }

/* ============================================================
   PROCESS
   ============================================================ */
.process { padding-block: clamp(70px, 10vh, 150px); }
.process__head {
  font-family: var(--f-display); font-weight: 800; font-stretch: 120%;
  text-transform: uppercase; letter-spacing: -0.015em;
  font-size: clamp(2.1rem, 7.4vw, 7rem); line-height: 0.95; margin: 0 0 clamp(26px,4vw,52px);
  text-wrap: balance;
}
.process__head .thin { font-weight: 400; font-stretch: normal; color: var(--muted); }
.process__body {
  font-family: var(--f-body); font-weight: 400;
  font-size: clamp(1.15rem, 2.0vw, 1.8rem); line-height: 1.34;
  max-width: 54ch; color: var(--ink);
}
.process__media { margin-top: clamp(36px, 5vw, 76px); }
.process__media .frame { position: relative; overflow: hidden; border: 1px solid var(--line); aspect-ratio: 1378 / 382; background: #0b0b0a; }
.process__media image-slot { width: 100%; height: 100%; }
.process__media image-slot::part(frame) { background-color: #0b0b0a; background-image: none; }
[data-lines="off"] .process__media .frame { border-color: transparent; }

/* ============================================================
   PROJECTS
   ============================================================ */
.works { padding-bottom: clamp(40px, 8vh, 110px); }
.section-gap { height: clamp(40px, 8vh, 96px); }

/* layout 3: one big feature + stacked list */
.featured { display: block; padding-top: clamp(26px, 3vw, 44px); }

.feature { display: block; }
.feature .frame { position: relative; overflow: hidden; border: 1px solid var(--line); }
.feature image-slot, .card image-slot, .row__thumb image-slot, .feat-card image-slot { width: 100%; height: 100%; }
.feature .frame { aspect-ratio: 16 / 8.5; }

/* 02+ large cover grid */
.feat-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(22px, 3vw, 48px); margin-top: clamp(30px, 4.5vw, 64px);
}
@media (max-width: 760px){ .feat-grid { grid-template-columns: 1fr; } }
.feat-card { display: flex; flex-direction: column; }
.feat-card .frame { position: relative; overflow: hidden; border: 1px solid var(--line); aspect-ratio: 16 / 8.5; }
.feat-card__meta { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding-top: 16px; }
.feat-card__title {
  font-family: var(--f-display); font-weight: 800; font-stretch: 110%;
  text-transform: uppercase; letter-spacing: -0.01em; line-height: .96;
  font-size: clamp(1.5rem, 2.5vw, 2.5rem); margin: 0;
}
.feat-card__num { font-family: var(--f-mono); font-size: 13px; color: var(--muted); flex: 0 0 auto; }
.feat-card .tags { padding-top: 11px; }
.feature__meta { display: flex; justify-content: space-between; align-items: baseline; padding-top: 16px; gap: 16px; }
.feature__title {
  font-family: var(--f-display); font-weight: 800; font-stretch: 110%;
  text-transform: uppercase; letter-spacing: -0.01em; line-height: .98;
  font-size: clamp(1.8rem, 3.4vw, 3.1rem); margin: 0;
}
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-family: var(--f-mono); font-size: 10.5px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
  border: 1px solid var(--line); border-radius: 3px; padding: 4px 7px;
}

/* stacked list (right column of featured) */
.stack { display: flex; flex-direction: column; border-top: 1px solid var(--line-strong); }
.row {
  display: grid; grid-template-columns: 30px 84px 1fr auto; gap: 16px;
  align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line);
}
.row__num { font-family: var(--f-mono); font-size: 12px; color: var(--muted); }
.row__thumb { width: 84px; height: 60px; overflow: hidden; border: 1px solid var(--line); }
.row__title {
  font-family: var(--f-display); font-weight: 700; font-stretch: 105%;
  text-transform: uppercase; font-size: clamp(1.05rem, 1.7vw, 1.5rem);
  line-height: 1; letter-spacing: -0.005em;
}
.row__cats { font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .08em; color: var(--muted);
  text-transform: uppercase; justify-self: end; text-align: right; max-width: 30ch; }
@media (max-width: 560px){
  .row { grid-template-columns: 26px 1fr; }
  .row__thumb, .row__cats { display: none; }
}

/* generic project grid (professional work / concepts) */
.grid-works { display: grid; gap: clamp(20px, 2.4vw, 38px); padding-top: clamp(26px,3vw,44px); }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
@media (max-width: 900px){ .grid-2 { grid-template-columns: 1fr; } .grid-3 { grid-template-columns: repeat(2,1fr);} }
@media (max-width: 560px){ .grid-3 { grid-template-columns: 1fr; } }

.card .frame { position: relative; overflow: hidden; border: 1px solid var(--line); aspect-ratio: 16/8.5; }
.card { display: flex; flex-direction: column; }
.card.tall .frame { aspect-ratio: 16/8.5; }
.card__meta { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding-top: 13px; }
.card .tags { padding-top: 10px; }
.card__title {
  font-family: var(--f-display); font-weight: 700; font-stretch: 108%;
  text-transform: uppercase; letter-spacing: -0.005em; line-height: .98;
  font-size: clamp(1.3rem, 2.1vw, 2rem); margin: 0;
}
.card__num { font-family: var(--f-mono); font-size: 12px; color: var(--muted); }

/* image reveal animation on frames — cover is GONE by default; JS adds .motion-on */
.frame .reveal-cover {
  position: absolute; inset: 0; background: var(--ink); z-index: 3;
  transform-origin: top; transform: scaleY(0); pointer-events: none;
}
.motion-on .frame .reveal-cover { transform: scaleY(1); }
.motion-on .in .frame .reveal-cover { transform: scaleY(0); transition: transform 1.05s cubic-bezier(.76,0,.18,1); }

.card:hover image-slot, .feature:hover image-slot { }
.frame:hover { border-color: var(--line-strong); }

/* themed empty-state for the user-fillable slots (subtle hatch + mono caption) */
image-slot { color: var(--muted); }
image-slot::part(frame) {
  background-color: var(--panel);
  background-image: repeating-linear-gradient(45deg, transparent 0 9px, rgba(17,17,16,0.05) 9px 10px);
}
image-slot::part(empty) {
  font-family: var(--f-mono); color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.12em; font-size: 11px;
}

/* ============================================================
   FOOTER
   ============================================================ */
.foot { border-top: 1px solid var(--line-strong); padding-top: clamp(40px,6vw,80px); padding-bottom: 40px; }
.foot__cta { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 24px; }
.foot__email {
  font-family: var(--f-display); font-weight: 800; font-stretch: 110%;
  text-transform: none; letter-spacing: -0.02em; line-height: .92;
  font-size: clamp(2rem, 7vw, 6.6rem); display: inline-block;
}
.foot__email:hover em { color: var(--accent); }
.foot__email em { font-style: normal; transition: color .3s ease; }
.foot__socials { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.foot__socials a { font-family: var(--f-mono); font-size: 13px; letter-spacing: .1em; text-transform: uppercase;
  display: inline-flex; gap: 10px; align-items: center; color: var(--muted); transition: color .25s; }
.foot__socials a:hover { color: var(--ink); }
.foot__socials a .ic { width: 15px; height: 15px; object-fit: contain;
  filter: grayscale(1) brightness(0) opacity(0.55); transition: filter .25s; }
[data-mode="invert"] .foot__socials a .ic { filter: grayscale(1) brightness(0) invert(1) opacity(0.6); }
.foot__socials a:hover .ic { filter: grayscale(1) brightness(0) opacity(1); }
[data-mode="invert"] .foot__socials a:hover .ic { filter: grayscale(1) brightness(0) invert(1) opacity(1); }
.foot__socials a .arr { opacity: 0; transform: translateX(-4px); transition: .25s; }
.foot__socials a:hover .arr { opacity: 1; transform: translateX(0); }

.foot__mark { overflow: hidden; padding-top: clamp(40px,6vw,80px); }
.foot__mark .marquee {
  display: inline-flex; gap: 0.18em; white-space: nowrap;
  font-family: var(--f-display); font-weight: 800; font-stretch: 130%;
  text-transform: uppercase; letter-spacing: -0.02em; line-height: .8;
  font-size: clamp(4rem, 19vw, 19rem); color: var(--ink);
  will-change: transform; animation: marquee 26s linear infinite;
}
@keyframes marquee { from { transform: translateX(0);} to { transform: translateX(-50%);} }
[data-motion="off"] .foot__mark .marquee, 
@media (prefers-reduced-motion: reduce){ .foot__mark .marquee { animation: none; } }

.foot__legal {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px;
  padding-top: clamp(26px,4vw,48px); border-top: 1px solid var(--line); margin-top: clamp(30px,5vw,60px);
}
.foot__legal .links { display: flex; gap: 22px; flex-wrap: wrap; }

/* ============================================================
   SCROLL REVEAL primitives (driven by .in)
   ============================================================ */
/* reveals are visible by default; JS adds .motion-on to <html> to enable them */
.motion-on [data-reveal] { opacity: 0; transform: translateY(28px); }
.motion-on [data-reveal].in { opacity: 1; transform: none; transition: opacity .9s ease, transform .9s cubic-bezier(.2,.7,.2,1); }
.motion-on [data-reveal].in[data-delay="1"] { transition-delay: .08s; }
.motion-on [data-reveal].in[data-delay="2"] { transition-delay: .16s; }
.motion-on [data-reveal].in[data-delay="3"] { transition-delay: .24s; }

/* line-mask reveal for big statements (hidden start only when .motion-on) */
.linemask { display: block; overflow: hidden; }
.linemask > span { display: block; }
.motion-on .linemask > span { transform: translateY(110%); }
.motion-on .in .linemask > span { transform: translateY(0); transition: transform 1s cubic-bezier(.76,0,.18,1); }
.motion-on .in .linemask:nth-child(2) > span { transition-delay: .07s; }
.motion-on .in .linemask:nth-child(3) > span { transition-delay: .14s; }
.motion-on .in .linemask:nth-child(4) > span { transition-delay: .21s; }

/* ============================================================
   STENCIL direction overrides — type takes over
   ============================================================ */
[data-mode="stencil"] .hero__title { font-stretch: 135%; font-size: clamp(2.8rem, 11vw, 12rem); }
[data-mode="stencil"] .process__head { font-stretch: 135%; font-size: clamp(2.4rem, 9vw, 9rem); }
[data-mode="stencil"] .statement { font-weight: 700; font-size: clamp(1.9rem, 4.6vw, 4.4rem); }
[data-mode="stencil"] .card__title, [data-mode="stencil"] .feature__title { font-stretch: 125%; }
[data-mode="stencil"] .foot__mark .marquee { font-stretch: 150%; }

/* hide internal grid lines toggle */
[data-lines="off"] .feature .frame,
[data-lines="off"] .row__thumb,
[data-lines="off"] .card .frame { border-color: transparent; }
[data-lines="off"] .row { border-bottom-color: transparent; }

/* scroll progress under nav */
.scrollprogress {
  position: fixed; top: 59px; left: 0; height: 2px; width: 0; z-index: 49;
  background: var(--accent); transition: width .08s linear;
}
[data-motion="off"] .scrollprogress { display: none; }

/* tweaks mount container (kept out of layout flow) */
#tweaks-root { position: fixed; z-index: 100; }
