/* ============================================================
   Zarif Rahman — writer portfolio
   One infinite horizontal river on cream paper. Watercolor-blot
   images under drifting fog; drawing on them with the pencil
   cursor parts the fog, which flows back in from a corner.
   Liquid-glass chrome, Fraunces display type.
   ============================================================ */

:root {
  --bg: #f2ecdf;          /* keep in sync with BG in js/main.js */
  --ink: #211d18;
  --muted: #756c5e;
  --hair: rgba(33, 29, 24, 0.16);
  --display: "Fraunces", Georgia, serif;
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: "Inter", system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;             /* no vertical scroll — the river runs left */
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 300;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  touch-action: none;           /* drag drives the river */
}

::selection { background: var(--ink); color: var(--bg); }

a { color: inherit; text-decoration: none; }

/* ---------- Liquid glass ---------- */
.glass {
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0.1));
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  box-shadow:
    0 10px 30px rgba(33, 29, 24, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.65),
    inset 0 -8px 18px rgba(255, 255, 255, 0.18);
}

/* ---------- WebGL canvas — under text, over paper ---------- */
#gl {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

/* ---------- The river ---------- */
.world {
  position: fixed;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
.zoom { position: absolute; inset: 0; will-change: transform; }
.track { position: absolute; inset: 0; will-change: transform; }
.stream {
  position: absolute;
  top: 0;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 7vw;
}

.panel { flex: 0 0 auto; position: relative; }
.panel + .panel { margin-left: 11vw; }

/* image placeholders the GL planes track */
.gl-img {
  position: relative;
  background-size: cover;
  background-position: center;
}
.no-gl .gl-img {
  background-size: cover;
  background-position: center;
  filter: sepia(0.14) contrast(0.92) brightness(1.04);
}

/* ---------- Panel: hero ---------- */
.p-hero { width: 82vw; padding-left: 4vw; }
.hero__title {
  font-family: var(--display);
  font-weight: 380;
  font-size: clamp(3rem, 8.5vh, 6.2rem);
  line-height: 1.04;
  letter-spacing: -0.015em;
}
.hero__title em { font-style: italic; font-weight: 320; }
.hero__title .word { display: inline-block; }
.hero__attr {
  margin-top: 2rem;
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted);
}
.hero__go {
  margin-top: clamp(2.4rem, 6vh, 4rem);
  display: flex;
  align-items: center;
  gap: 1.4rem;
  font-size: 0.62rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
}
.hero__arrow {
  font-style: normal;
  font-size: 1.4rem;
  animation: nudge 2.4s ease-in-out infinite;
}
@keyframes nudge {
  0%, 100% { transform: translateX(0); opacity: 0.5; }
  50%      { transform: translateX(0.8rem); opacity: 1; }
}
.hero__wind  { position: absolute; top: 13vh; right: 14vw; width: 72px; }
.hero__bird  { position: absolute; top: 21vh; right: 27vw; width: 46px; }
.hero__bird2 { position: absolute; top: 16vh; right: 22vw; width: 30px; opacity: 0.7; }

/* ---------- Panel: chapter sections (image + writing) ---------- */
.p-sec {
  display: flex;
  align-items: center;
  gap: 0;
}
.sec__text {
  position: relative;
  z-index: 2;
  width: clamp(20rem, 34vw, 30rem);
  margin-right: -5vw;           /* text overlaps the image, davidwhyte-style */
}
.p-sec--flip { flex-direction: row-reverse; }
.p-sec--flip .sec__text { margin-right: 0; margin-left: -5vw; }

.kicker {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.64rem;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1.5rem;
}
.kicker__star { width: 15px; flex: 0 0 auto; }

.p-sec h2, .block__title {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2rem, 5.8vh, 3.5rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin-bottom: 1.5rem;
  text-shadow: 0 1px 24px rgba(242, 236, 223, 0.9);
}
.p-sec h2 em, .block__title em, .quote em { font-style: italic; font-weight: 340; }

.sec__body,
.sec__body p {
  font-size: clamp(0.92rem, 2vh, 1.05rem);
  color: rgba(33, 29, 24, 0.8);
  max-width: 44ch;
}
.sec__body p + p { margin-top: 1.1em; }

.sec__img--tall  { height: 64vh; aspect-ratio: 3 / 4; }
.sec__img--med   { height: 54vh; aspect-ratio: 4 / 5; }
.sec__img--wide  { height: 56vh; aspect-ratio: 3 / 2; }
.sec__img--small {
  height: 30vh;
  aspect-ratio: 4 / 5;
  align-self: flex-end;
  margin-left: -6vw;
  margin-bottom: -8vh;
  z-index: 1;
}

/* ---------- Panel: quote interlude ---------- */
.p-quote { max-width: 42vw; text-align: center; }
.quote {
  font-family: var(--serif);
  font-size: clamp(2rem, 6vh, 3.6rem);
  line-height: 1.25;
  white-space: nowrap;
}
.quote__src {
  margin-top: 1.4rem;
  font-size: 0.62rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--muted);
}
.q__sprig { width: 26px; margin: 0 auto 1.4rem; }

/* ---------- Panel: writings block ---------- */
.p-block { width: min(52vw, 46rem); }
.block__title { margin-bottom: 2rem; }
.works { list-style: none; }
.work { border-top: 1px solid var(--hair); }
.work:last-child { border-bottom: 1px solid var(--hair); }
.work__link {
  display: block;
  padding: 1.1rem 0;
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.45s ease;
}
.works:hover .work__link { opacity: 0.4; }
.works .work__link:hover { opacity: 1; transform: translateX(0.7rem); }
.work__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}
.work__head h4 {
  font-family: var(--display);
  font-weight: 420;
  font-size: clamp(1.15rem, 2.8vh, 1.6rem);
}
.work__meta {
  font-size: 0.6rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.work__excerpt {
  margin-top: 0.4rem;
  max-width: 58ch;
  font-size: 0.86rem;
  color: rgba(33, 29, 24, 0.62);
}

/* ---------- Contact bits ---------- */
.contact__mail {
  display: inline-block;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.3rem, 3.4vh, 2rem);
  border-bottom: 1px solid var(--hair);
  padding-bottom: 0.3rem;
  transition: border-color 0.35s ease;
}
.contact__mail:hover { border-color: var(--ink); }
.contact__social { margin-top: 1.6rem; display: flex; gap: 2rem; }
.contact__social a {
  font-size: 0.64rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color 0.3s ease;
}
.contact__social a:hover { color: var(--ink); }
.contact__loop {
  margin-top: clamp(1.8rem, 4.5vh, 2.8rem);
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.64rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
}
.c__spiral { width: 26px; }
.c__sun { position: absolute; top: -12vh; right: 0; width: 42px; }
.contact__fine {
  margin-top: 1.8rem;
  font-size: 0.56rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(33, 29, 24, 0.4);
}

/* ---------- Ornaments ---------- */
.orn {
  display: block;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.55;
  pointer-events: none;
}

/* ---------- Nav / HUD ---------- */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.3rem clamp(1.4rem, 4vw, 3.5rem);
}
.nav__brand {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.15rem;
  letter-spacing: 0.03em;
  padding: 0.55rem 1.4rem;
}
.nav__links { padding: 0.7rem 1.6rem; display: flex; }
.nav__links a {
  font-size: 0.66rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color 0.3s ease;
}
.nav__links a + a { margin-left: clamp(1.2rem, 2.6vw, 2.2rem); }
.nav__links a:hover { color: var(--ink); }

.hud {
  position: fixed;
  bottom: 1.6rem;
  left: clamp(1.4rem, 4vw, 3.5rem);
  right: clamp(1.4rem, 4vw, 3.5rem);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 1.6rem;
}
.hud__chapter {
  font-size: 0.6rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  min-width: 10.5rem;
  text-align: center;
  padding: 0.55rem 1.2rem;
}
.hud__line {
  position: relative;
  flex: 1;
  height: 22px;
  cursor: pointer;
}
.hud__line::before {
  content: "";
  position: absolute;
  top: 50%; left: 0; right: 0;
  height: 1px;
  background: var(--hair);
}
.hud__fill {
  position: absolute;
  top: 50%; left: 0;
  height: 1px;
  width: 0;
  background: var(--ink);
  opacity: 0.6;
}
.hud__thumb {
  position: absolute;
  top: 50%;
  left: 0;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.6);
  cursor: grab;
  transition: box-shadow 0.3s ease;
}
.hud__thumb:active { cursor: grabbing; }
.hud__thumb:hover { box-shadow: 0 10px 26px rgba(33, 29, 24, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.7); }
.hud__icon {
  width: 16px;
  height: 16px;
  fill: var(--ink);
  opacity: 0.75;
  pointer-events: none;
}

/* ---------- Hover particles ---------- */
.pips { position: fixed; inset: 0; z-index: 65; pointer-events: none; }
.pip {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--ink);
  opacity: 0;
}
.pip--soft { background: var(--muted); }

/* ---------- Pencil cursor ---------- */
.cursor { display: none; }
@media (pointer: fine) {
  body { cursor: none; }
  a, button { cursor: none; }
  .cursor { display: block; position: fixed; inset: 0; z-index: 70; pointer-events: none; }
  .cursor__dot,
  .cursor__pen {
    position: absolute;
    top: 0; left: 0;
  }
  .cursor__dot {
    width: 4px; height: 4px;
    border-radius: 50%;
    background: var(--ink);
    transform: translate(-50%, -50%);
  }
  .cursor__pen { width: 0; height: 0; }
  .cursor__pencil {
    position: absolute;
    left: -14px;              /* pencil tip sits on the pointer */
    top: -29px;
    width: 30px;
    height: 30px;
    fill: var(--ink);
    filter: drop-shadow(0 1px 0 rgba(242, 236, 223, 0.9));
  }
}

/* ---------- Pointer-dependent hero hint ---------- */
.hint--coarse { display: none; }
@media (pointer: coarse) {
  .hint--fine { display: none; }
  .hint--coarse { display: inline; }
}

/* ---------- Preloader ---------- */
.veil {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: var(--bg);
  display: grid;
  place-items: center;
}
.veil__inner { text-align: center; }
.veil__name {
  font-family: var(--display);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.8rem, 4vw, 3rem);
  letter-spacing: 0.04em;
}
.veil__hint {
  margin-top: 1rem;
  font-size: 0.68rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Small screens ---------- */
@media (max-width: 700px) {
  .nav { padding: 1rem 1.2rem; }
  .nav__brand { font-size: 0.95rem; padding: 0.45rem 1rem; white-space: nowrap; }
  .nav__links { padding: 0.55rem 1rem; }
  .nav__links a { letter-spacing: 0.18em; font-size: 0.56rem; }
  .p-hero { width: 150vw; }
  .p-sec { flex-direction: column; align-items: flex-start; gap: 4vh; }
  .p-sec--flip { flex-direction: column; }
  .sec__text { width: 78vw; margin: 0 !important; }
  .sec__img--tall, .sec__img--med, .sec__img--wide { height: 44vh; }
  .sec__img--small { display: none; }
  .p-quote { max-width: 86vw; }
  .quote { white-space: normal; }
  .p-block { width: 84vw; }
  .hud__chapter { display: none; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .hero__arrow { animation: none; }
}
