/* =====================================================================
   Affan Sagri portfolio — styles (v2: motion)
   Colours, easing and timing live in :root, so changing a value there
   updates the whole site. Motion only switches on when js adds the
   "motion" class to <html>; without it everything is simply visible.
   ===================================================================== */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("../fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #0b0b0c;
  --surface: #121214;
  --border: #26262a;
  --border-strong: #3a3a40;
  --text: #f4f0e8;          /* warm white */
  --muted: #a9a59c;
  --accent: #4d8dff;        /* the one blue */
  --accent-soft: rgba(77, 141, 255, 0.16);
  --danger: #ffb4a8;
  --radius: 16px;
  --wrap: 1160px;
  --gutter: clamp(16px, 4vw, 32px);
  --display: "Bricolage Grotesque", "Inter", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* One easing curve and three durations, used everywhere */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 0.2s;
  --t: 0.5s;
  --t-slow: 0.9s;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 1rem/1.6 var(--body);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
img, video, iframe { display: block; max-width: 100%; }
a { color: inherit; }
p { margin: 0; }
h1, h2, h3, h4 { margin: 0; }
h1, h2, h3 { font-family: var(--display); font-weight: 650; letter-spacing: -0.025em; line-height: 1.05; }

.wrap { width: 100%; max-width: calc(var(--wrap) + var(--gutter) * 2); margin-inline: auto; padding-inline: var(--gutter); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

.skip { position: absolute; left: 12px; top: -60px; background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 8px; z-index: 100; font-weight: 600; text-decoration: none; }
.skip:focus { top: 12px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  border-bottom: 1px solid transparent;
  transition: background-color var(--t) var(--ease), border-color var(--t) var(--ease), backdrop-filter var(--t) var(--ease);
}
.site-header.scrolled {
  background: rgba(11, 11, 12, 0.78);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom-color: var(--border);
}
.bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 64px; transition: height var(--t) var(--ease); }
.site-header.scrolled .bar { height: 56px; }
.brand { font: 650 1.2rem/1 var(--display); letter-spacing: -0.015em; text-decoration: none; white-space: nowrap; }
.bar-nav { display: flex; align-items: center; gap: clamp(14px, 3vw, 28px); }
.nav-link { position: relative; color: var(--muted); text-decoration: none; font-size: 0.95rem; font-weight: 500; padding: 8px 2px; transition: color var(--t-fast); }
.nav-link::after { content: ""; position: absolute; left: 0; right: 0; bottom: 2px; height: 2px; border-radius: 2px; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform var(--t) var(--ease); }
.nav-link:hover, .nav-link[aria-current="true"] { color: var(--text); }
.nav-link:hover::after, .nav-link[aria-current="true"]::after { transform: scaleX(1); }
.progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--accent); transform: scaleX(var(--p, 0)); transform-origin: left; opacity: 0; transition: opacity var(--t) var(--ease); }
.site-header.scrolled .progress { opacity: 0.9; }

/* ---------- Buttons ---------- */
.btn {
  position: relative; overflow: hidden; isolation: isolate;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--text); color: #101012;
  font: 600 0.98rem/1 var(--body);
  padding: 15px 22px; border-radius: 999px; white-space: nowrap;
  text-decoration: none; border: 1px solid transparent;
  transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease), background-color var(--t-fast);
}
.btn::before { /* light sweep on hover */
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(105deg, transparent 30%, rgba(77, 141, 255, 0.28) 50%, transparent 70%);
  transform: translateX(-120%); transition: transform 0.8s var(--ease);
}
.btn:hover { background: #fff; transform: translateY(-2px); box-shadow: 0 10px 30px -8px rgba(77, 141, 255, 0.45), 0 0 0 4px var(--accent-soft); }
.btn:hover::before { transform: translateX(120%); }
.btn:active { transform: translateY(0) scale(0.99); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 999px; box-shadow: 0 0 0 4px var(--accent-soft); }
.btn .wa { width: 22px; height: 22px; flex: none; }
.btn .arrow { width: 18px; height: 18px; flex: none; margin-left: -2px; transition: transform var(--t) var(--ease); }
.btn:hover .arrow { transform: translateX(4px); }
.btn-sm { padding: 9px 14px 9px 11px; font-size: 0.88rem; gap: 8px; }
.btn-sm .wa { width: 20px; height: 20px; }
.btn-lg { padding: 19px 30px; font-size: 1.08rem; }
.btn-lg .wa { width: 26px; height: 26px; }

.text-link { color: var(--text); text-decoration: none; font-weight: 500; position: relative; padding-bottom: 3px; transition: color var(--t-fast); }
.text-link::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--border-strong); transition: background-color var(--t-fast); }
.text-link::before { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform var(--t) var(--ease); z-index: 1; }
.text-link:hover { color: var(--accent); }
.text-link:hover::before { transform: scaleX(1); }
.text-link span { display: inline-block; transition: transform var(--t) var(--ease); }
.text-link:hover span { transform: translateY(3px); }

/* ---------- Hero ---------- */
.hero { position: relative; padding-top: clamp(24px, 4.5vw, 60px); text-align: center; overflow: hidden; }
.hero-glow {
  position: absolute; z-index: 0; left: 50%; top: 0; width: min(1200px, 130%); height: 100%; translate: -50% 0;
  background: radial-gradient(closest-side, rgba(77, 141, 255, 0.2), rgba(77, 141, 255, 0.05) 55%, transparent 100%);
  pointer-events: none;
}
.hero-inner { position: relative; z-index: 1; }
.hero-title { font-size: clamp(2.35rem, 6.6vw, 4.5rem); text-wrap: balance; }
.line { display: inline-block; overflow: hidden; vertical-align: top; padding: 0.06em 0.04em 0.12em; margin: -0.06em -0.04em -0.12em; }
.line-in { display: inline-block; }
.accent { color: var(--accent); }
.hero-sub { max-width: 40rem; margin: 16px auto 0; color: var(--muted); font-size: clamp(1rem, 2.2vw, 1.18rem); text-wrap: balance; }

.intro { margin: clamp(24px, 3.6vw, 40px) auto 0; }
.intro[hidden] { display: none; }
.intro .player { margin-inline: auto; box-shadow: 0 0 140px -30px rgba(77, 141, 255, 0.4), 0 40px 90px -30px #000; }
.intro-caption { display: flex; align-items: center; gap: 10px; margin-top: 14px; color: #cfc8b8; font-size: 0.86rem; line-height: 1.4; text-align: left; }
.intro-caption i { flex: none; width: 8px; height: 8px; border-radius: 50%; background: #f0b94a; box-shadow: 0 0 0 4px rgba(240, 185, 74, 0.18); }

.hero-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 14px 30px; margin-top: clamp(24px, 3.6vw, 36px); padding-bottom: clamp(8px, 2vw, 16px); }

/* ---------- Video players ---------- */
.player { position: relative; width: 100%; background: #000; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; aspect-ratio: var(--ar, 16 / 9); transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease), transform var(--t) var(--ease); }
.player-poster { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; background: #000; cursor: pointer; color: inherit; display: block; overflow: hidden; }
.player-poster img { width: 100%; height: 100%; object-fit: contain; transition: transform var(--t-slow) var(--ease), filter var(--t) var(--ease); }
.player-poster::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0) 50%); pointer-events: none; transition: opacity var(--t) var(--ease); }
.play {
  position: absolute; left: 50%; top: 50%; z-index: 1;
  width: clamp(58px, 9vw, 84px); aspect-ratio: 1; translate: -50% -50%;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--text); color: #101012;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  transition: scale var(--t) var(--ease), background-color var(--t) var(--ease), color var(--t) var(--ease);
}
.play::after { content: ""; position: absolute; inset: -9px; border-radius: 50%; border: 1px solid rgba(244, 240, 232, 0.55); opacity: 0; scale: 0.82; transition: opacity var(--t) var(--ease), scale var(--t-slow) var(--ease); }
.play svg { width: 42%; height: 42%; margin-left: 6%; }
.dur { position: absolute; right: 12px; bottom: 12px; z-index: 1; padding: 4px 9px; border-radius: 999px; background: rgba(11, 11, 12, 0.72); color: var(--text); font: 500 0.78rem/1.2 var(--body); font-variant-numeric: tabular-nums; pointer-events: none; }
.player-poster:hover img, .player-poster:focus-visible img { transform: scale(1.04); filter: brightness(1.06); }
.player-poster:hover .play, .player-poster:focus-visible .play { scale: 1.1; background: var(--accent); color: #fff; }
.player-poster:hover .play::after, .player-poster:focus-visible .play::after { opacity: 1; scale: 1; }
.player-poster:focus-visible { outline-offset: -4px; border-radius: var(--radius); }
.player video, .player iframe { position: absolute; inset: 0; width: 100%; height: 100%; background: #000; border: 0; object-fit: contain; }

.player-error { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: rgba(8, 8, 9, 0.94); padding: 20px; text-align: center; font-size: 0.95rem; }
.player-error p { color: var(--danger); max-width: 28ch; }
.player-error button { font: 600 0.9rem var(--body); color: var(--text); background: transparent; border: 1px solid var(--border-strong); border-radius: 999px; padding: 9px 16px; cursor: pointer; transition: border-color var(--t-fast); }
.player-error button:hover { border-color: var(--text); }

/* ---------- Moving text strip ---------- */
.strip { overflow: hidden; margin-top: clamp(40px, 7vw, 88px); padding: clamp(14px, 2vw, 22px) 0; border-block: 1px solid var(--border); -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent); mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent); }
.strip-track { display: flex; width: max-content; animation: marquee 46s linear infinite; will-change: transform; }
.strip:hover .strip-track { animation-play-state: paused; }
.strip-item { display: flex; align-items: center; flex: none; white-space: nowrap; font: 650 clamp(2.6rem, 8vw, 6.4rem)/1.05 var(--display); letter-spacing: -0.035em; padding-right: clamp(28px, 4vw, 56px); gap: clamp(28px, 4vw, 56px); }
.strip-item:nth-child(even) { color: transparent; -webkit-text-stroke: 1.5px rgba(244, 240, 232, 0.55); }
.strip-item::after { content: ""; flex: none; width: 0.34em; height: 0.34em; background: var(--accent); clip-path: polygon(0 0, 100% 50%, 0 100%); }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ---------- Selected work ---------- */
.work { padding-top: clamp(56px, 9vw, 104px); }
.work-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 40px; margin-bottom: clamp(28px, 4.5vw, 48px); }
.section-title { font-size: clamp(2rem, 5vw, 3.2rem); }
.work-intro { color: var(--muted); max-width: 30rem; }

.group + .group { margin-top: clamp(56px, 9vw, 96px); }
.group-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; margin-bottom: 20px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.group-head h3 { font-size: 1.35rem; }
.group-head p { color: var(--muted); font-size: 0.95rem; }

/* Long-form: pairs side by side. flex-grow = aspect ratio, so mixed 3:2 and 16:9 share one height. */
.row { display: flex; gap: clamp(16px, 2.4vw, 28px); }
.row + .row { margin-top: clamp(28px, 4vw, 40px); }
.row > .card { flex: var(--ar-num) 1 0; min-width: 0; }
.row.single > .card { flex: 0 1 calc(50% - 14px); }

.card .meta { display: flex; flex-direction: column; gap: 3px; margin-top: 14px; }
.card h4 { font: 600 1.02rem/1.35 var(--body); }
.card .sub { color: var(--muted); font-size: 0.86rem; }
.card:hover .player, .card:focus-within .player { border-color: rgba(77, 141, 255, 0.55); box-shadow: 0 24px 60px -24px rgba(77, 141, 255, 0.35), 0 0 0 1px rgba(77, 141, 255, 0.15); transform: translateY(-4px); }

/* Slider controls: shown only on small screens */
.rail-ui { display: none; }

/* Short-form: copy on the left, portrait reel(s) on the right */
.short-layout { display: grid; grid-template-columns: minmax(0, 300px) auto; justify-content: center; gap: clamp(32px, 7vw, 96px); align-items: center; padding-top: 8px; }
.short-copy h3 { font-size: clamp(1.7rem, 3.6vw, 2.5rem); }
.short-copy p { margin-top: 14px; color: var(--muted); max-width: 30ch; font-size: 1.05rem; }
.portrait-list { display: flex; flex-wrap: wrap; gap: 24px; justify-content: center; }
.portrait-list .card { width: min(320px, 100%); }

/* ---------- Contact ---------- */
.contact { padding-top: clamp(72px, 11vw, 128px); }
.contact-card { position: relative; overflow: hidden; text-align: center; border: 1px solid var(--border); border-radius: 28px; background: var(--surface); padding: clamp(48px, 8vw, 96px) var(--gutter); }
.contact-glow { position: absolute; z-index: 0; left: 50%; top: 100%; width: 120%; aspect-ratio: 2 / 1; translate: -50% -50%; background: radial-gradient(closest-side, rgba(77, 141, 255, 0.28), transparent); pointer-events: none; }
.contact-card > :not(.contact-glow) { position: relative; z-index: 1; }
.contact-title { font-size: clamp(2.2rem, 6.4vw, 4.4rem); text-wrap: balance; }
.contact-text { max-width: 36rem; margin: 18px auto 0; color: var(--muted); font-size: clamp(1rem, 2.2vw, 1.15rem); text-wrap: balance; }
.contact-actions { margin-top: 34px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.email-link { color: var(--muted); transition: color var(--t-fast); }
.email-link:hover { color: var(--text); }
.email-link[hidden], #email-footer[hidden] { display: none; }

.site-footer { margin-top: clamp(56px, 9vw, 96px); border-top: 1px solid var(--border); padding: 24px 0 32px; color: var(--muted); font-size: 0.9rem; }
.foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 24px; }
.foot-links { display: flex; gap: 20px; }
.foot-links a { text-decoration: none; transition: color var(--t-fast); }
.foot-links a:hover { color: var(--text); }
.noscript { color: var(--muted); }

/* ---------- Motion (only when js adds html.motion) ---------- */
.motion .line-in { transform: translateY(112%); animation: rise 1s var(--ease) both; animation-delay: 0.1s; }
.motion .line:nth-child(2) .line-in { animation-delay: 0.22s; }
.motion .enter { opacity: 0; animation: fadeUp 0.9s var(--ease) both; animation-delay: calc(0.28s + var(--i, 0) * 0.12s); }
.motion .intro.enter { animation-name: fadeScale; }
.motion .hero-glow { opacity: 0; animation: glowIn 2.2s var(--ease) 0.1s both; }
.motion [data-reveal] { opacity: 0; transform: translateY(32px); transition: opacity 0.9s var(--ease), transform 0.9s var(--ease); transition-delay: calc(var(--i, 0) * 0.1s); }
.motion [data-reveal].in { opacity: 1; transform: none; }
@keyframes rise { from { transform: translateY(112%); } to { transform: none; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }
@keyframes fadeScale { from { opacity: 0; transform: translateY(26px) scale(0.975); } to { opacity: 1; transform: none; } }
@keyframes glowIn { to { opacity: 1; } }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .row + .row { margin-top: 0; }
  /* Long-form examples become a swipeable row, with the next one peeking in */
  .rail { display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; -webkit-overflow-scrolling: touch; margin-inline: calc(var(--gutter) * -1); padding-inline: var(--gutter); scroll-padding-inline: var(--gutter); overscroll-behavior-x: contain; padding-bottom: 4px; }
  .rail::-webkit-scrollbar { display: none; }
  .rail .row { display: contents; }
  .rail .row > .card, .rail .row.single > .card { flex: 0 0 86%; width: auto; scroll-snap-align: start; }
  .rail-ui { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; }
  .rail-count { color: var(--muted); font-size: 0.88rem; font-variant-numeric: tabular-nums; }
  .rail-btns { display: flex; gap: 10px; }
  .rail-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border-strong); background: transparent; color: var(--text); display: grid; place-items: center; cursor: pointer; transition: border-color var(--t-fast), background-color var(--t-fast), opacity var(--t-fast); }
  .rail-btn:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
  .rail-btn:disabled { opacity: 0.35; cursor: default; }
  .rail-btn svg { width: 18px; height: 18px; }
  .card:hover .player, .card:focus-within .player { transform: none; }
  .short-layout { grid-template-columns: 1fr; gap: 24px; }
  .short-copy { text-align: center; }
  .short-copy p { margin-inline: auto; }
}
@media (max-width: 460px) {
  .bar { height: 56px; }
  .btn-sm .long { display: none; }
  .hero-actions .btn { width: 100%; }
  .contact-actions .btn { width: 100%; padding-inline: 16px; }
  .btn-lg { font-size: 1rem; }
  .btn-lg .wa { width: 24px; height: 24px; }
  .btn-lg .arrow { display: none; }
}
@media (min-width: 461px) { .btn-sm .long { display: inline; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .motion .line-in, .motion .enter, .motion .hero-glow, .motion [data-reveal] { opacity: 1; transform: none; }
  .player-poster:hover img, .player-poster:focus-visible img, .card:hover .player, .card:focus-within .player { transform: none; }
  .strip-track { transform: none; }
}
