/* ------------------------------------------------------------------
   Surveillance — portfolio
   All measurements are taken 1:1 from /WIREFRAMES.
   Desktop is drawn on a 1920x1080 grid, mobile (portrait) on 1080x1920,
   and everything scales with --u (one design pixel).
   ------------------------------------------------------------------ */

:root {
  --black: #090909;
  --white: #fafafa;
  --grey: #1e1e1e;
}

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

html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--black);
}

body {
  color: var(--white);
  font-family: 'Chivo Mono', ui-monospace, monospace;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
img { display: block; user-select: none; -webkit-user-drag: none; }

/* ---------- design grid ------------------------------------------------ */

.app {
  /* desktop: 1920 x 1080 */
  --u: min(calc(var(--W, 100vw) / 1920), calc(var(--H, 100vh) / 1080));

  --fl: calc(28 * var(--u));            /* frame insets */
  --ft: calc(25 * var(--u));
  --fr: calc(27 * var(--u));
  --fb: calc(25 * var(--u));

  --line: var(--grey);
  --rl: max(1px, calc(2 * var(--u)));   /* list rule */
  --row: calc(var(--fs) * 4.389);      /* rows follow the type (mockup: 79 / 18) */
  /* row edge to the top of the caps (two lines, centred under the nudge;
     0.3635em = the font's ascent/descent offset minus its 0.685em cap height).
     The list uses it left and right too, so the text sits evenly in its row. */
  --row-x: calc((var(--row) + var(--nudge)) / 2 - (var(--lh) / 2 + 0.3635) * 1em);

  --pad-l: calc(30 * var(--u));
  --pad-r: calc(24 * var(--u));
  --fs: clamp(11px, calc(16 * var(--u)), 14px);  /* one type size for the whole site, capped on big screens */
  --lh: 1.1667;
  --c-gap: calc(19 * var(--u) + 0.07em);  /* footer text to frame, measured from the glyphs, same right and bottom */
  --c-dsc: 0.257em;                     /* space under the caps inside the line box (font descent + half-leading) */
  --nudge: calc(var(--fs) / 6);         /* optical: browser sets the type ~1.5px higher than the mockup */

  --ic-w: calc(var(--fs) * 1.38);       /* menu icon follows the type too */
  --ic-h: calc(var(--fs) * 0.92);
  --ic-t: calc(9 * var(--u));
  --ic-r: calc(8 * var(--u));

  --bx: calc(112 * var(--u));           /* artwork box, inset from the frame */
  --bt: calc(92 * var(--u));
  --bb: calc(92 * var(--u));
}

@media (orientation: portrait) {
  .app {
    /* mobile: 1080 x 1920 */
    --u: min(calc(var(--W, 100vw) / 1080), calc(var(--H, 100vh) / 1920));

    --fl: calc(25 * var(--u));
    --ft: calc(28 * var(--u));
    --fr: calc(25 * var(--u));
    --fb: calc(27 * var(--u));

    --rl: 1px;
    --row: calc(var(--fs) * 3.663);       /* keeps the mockup's text-to-row ratio (100 / 27.3) */

    --pad-l: calc(22 * var(--u));
    --pad-r: calc(17 * var(--u));
    --fs: 11px;
    --lh: 1.1355;
    --c-gap: calc(23 * var(--u) + 0.276em);
    --c-dsc: 0.276em;
    --nudge: 0px;

    --ic-t: calc(14 * var(--u));
    --ic-r: calc(12 * var(--u));

    --bx: calc(58 * var(--u));
    --bt: calc(70 * var(--u));
    --bb: calc(var(--row) + 27 * var(--u)); /* clears the text row */
  }
}

/* ---------- shell ------------------------------------------------------ */

.app {
  position: fixed;
  inset: 0;
  font-size: var(--fs);
  line-height: var(--lh);
  overflow: hidden;
  text-transform: uppercase;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  transition: opacity 0.5s linear;
}
.app.is-loading { opacity: 0; }
.app[data-view='project'] { touch-action: none; }

/* frame + background shape. The shape's black fill sits on top of the
   frame so the border disappears inside the shape's arms (as drawn). */
.frame,
.window {
  position: absolute;
  left: var(--fl);
  top: var(--ft);
  right: var(--fr);
  bottom: var(--fb);
}
.frame { border: 1px solid var(--line); }

.bg { position: absolute; inset: 0; }
.shape {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
}
.shape path { fill: var(--black); stroke: var(--grey); stroke-width: 1px; vector-effect: non-scaling-stroke; } /* 1px at any screen size */
@media (orientation: landscape) { .shape.is-desktop { display: block; } }
@media (orientation: portrait) { .shape.is-mobile { display: block; } }

.window { overflow: hidden; }

/* ---------- meta (name / client — role / year) ------------------------ */

.meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2em;
  padding: var(--nudge) var(--pad-r) 0 var(--pad-l);
  white-space: nowrap;
}
.meta-l,
.meta-r { min-width: 0; }
.meta-l span,
.meta-r span { display: block; overflow: hidden; text-overflow: ellipsis; }
.meta-r { text-align: right; flex-shrink: 0; }

/* ---------- list view -------------------------------------------------- */

.list {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  touch-action: pan-y;
  visibility: hidden;
}
.list::-webkit-scrollbar { display: none; }
.app[data-view='list'] .list,
.app.is-morphing .list { visibility: visible; }

.list-inner {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding-top: 1px;
}
.rows { list-style: none; }
.rows li { position: relative; }

.row {
  position: relative;
  height: var(--row);
  /* minus the glyphs' side bearings, so the ink lands on --row-x */
  padding-left: calc(var(--row-x) - 0.08em);
  padding-right: calc(var(--row-x) - 0.07em);
  background: var(--black);
  cursor: pointer;
}
.row::before,
.rows li:last-child .row::after {
  content: '';
  position: absolute;
  pointer-events: none;
  border: 0 solid var(--line);
}
.row::before { inset: 0; border-width: var(--rl) var(--rl) 0; }
.rows li:last-child .row::after { left: 0; right: 0; top: 100%; border-top-width: var(--rl); }

@media (hover: hover) {
  .row:hover { background: var(--grey); }
}
.row:focus-visible,
.menu:focus-visible { outline: 1px solid var(--white); outline-offset: -4px; }

/* description bottom-left, email bottom-right. Each sits on a black
   pad so the shape's lines break around the type. */
.foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2em;
  /* 0.4em = the black pad; 0.07em = right side bearing of the last glyph */
  margin: auto calc(var(--c-gap) - 0.07em - 0.4em) calc(var(--c-gap) - var(--c-dsc) - 0.4em) calc(var(--c-gap) - 0.4em);
}
.about,
.contact {
  padding: 0.4em;
  background: var(--black);
}
.contact { font-style: normal; text-align: right; white-space: nowrap; }
.about br.m { display: none; }          /* mobile-only line break */
@media (orientation: portrait) {
  .foot { gap: 0.4em; }
  .about { min-width: 0; text-wrap: balance; }
  .about br.m { display: inline; }
}
/* the narrowest phones: the about rewraps itself, so the contact never has to */
@media (orientation: portrait) and (max-width: 340px) {
  .about br,
  .about br.m { display: none; }
}

/* ---------- project view ----------------------------------------------- */

.pv {
  --pv-top: 0px;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 100%;
  z-index: 2;
}
.app[data-view='list']:not(.is-morphing) .pv { display: none; }

.pv-bg,
.pv-media,
.pv-meta,
.pv-lines { position: absolute; inset: 0; }
.pv-bg { background: var(--black); opacity: 0; }
.pv-media,
.pv-meta { overflow: hidden; }

@media (orientation: portrait) {
  .pv-meta { top: auto; height: var(--row); } /* no rule or bar: artwork runs behind the text */
}

.slide {
  position: absolute;
  inset: 0;
  display: none;
}
.slide.is-shown { display: block; }
/* keep each artwork slide on its own GPU layer, so a slide never repaints the
   artwork when it starts or settles, only moves it */
.pv-media .slide { will-change: transform; }
.slide.meta.is-shown { display: flex; }
/* while a row grows into the page, its text slides from the row's insets to
   the page's (--list: 1 = row, 0 = page; set by the morph) */
.pv-meta .meta {
  padding-left: calc(var(--pad-l) + (var(--row-x) - 0.08em - var(--pad-l)) * var(--list, 0));
  padding-right: calc(var(--pad-r) + (var(--row-x) - 0.07em - var(--pad-r)) * var(--list, 0));
}

/* artwork is laid out against the full viewport (export full-frame
   1920x1080 / 1080x1920 artboards) and clipped by the frame. It holds
   still against the viewport while the page grows out of its list row. */
.art {
  position: absolute;
  left: calc(-1 * var(--fl));
  top: calc(-1 * (var(--ft) + var(--pv-top)));
  width: var(--W, 100vw);
  height: var(--H, 100vh);
}
/* "box": true in project.json: the artwork sits in a centred box instead,
   cropped to fill it */
.is-boxed .art {
  left: var(--bx);
  top: calc(var(--bt) - var(--pv-top));
  width: auto;
  right: var(--bx);
  height: calc(var(--H, 100vh) - var(--ft) - var(--fb) - var(--bt) - var(--bb));
  border: 1px solid var(--line);
  background: var(--black);
  overflow: hidden;
}
/* one shot = one step of the cycle: a single image, or in a box on mobile
   two landscape images stacked */
.shot {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
}
.shot.is-on { display: flex; }
.shot img,
.shot video {
  display: block;
  flex: 1;
  min-height: 0;
  width: 100%;
  object-fit: contain;
}
.is-boxed .shot img,
.is-boxed .shot video { object-fit: cover; }
.shot > * + * { border-top: 1px solid var(--line); }

/* the outline a list row carries while it grows into / out of the page */
.pv-lines {
  bottom: calc(-1 * var(--rl));
  border: var(--rl) solid var(--line);
  opacity: 0;
  pointer-events: none;
}

/* ---------- menu ------------------------------------------------------- */

.menu {
  position: absolute;
  z-index: 3;
  top: calc(var(--ft) + var(--ic-t) - 12px);
  right: calc(var(--fr) + var(--ic-r) - 12px);
  padding: 12px;
  box-sizing: content-box;
  width: var(--ic-w);
  height: var(--ic-h);
}
.menu svg { display: block; width: 100%; height: 100%; fill: var(--white); }
.app[data-view='list'] .menu { pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  .app { transition: none; }
}
