/* ============================================================
   TURRNT — A5 newsprint sheets, stacked horizontally
   ============================================================ */

/* Nagasaki by Sasha Iacob (Milc.ro) — free. Caps are a full em tall but the font
   declares a short ascent, so override the metrics to put the glyphs inside the box. */
@font-face {
  font-family: "Nagasaki";
  src: url("/fonts/nagasaki.woff2") format("woff2");
  font-display: swap;
  ascent-override: 100%;
  descent-override: 0%;
  line-gap-override: 0%;
}

:root {
  --bg: #0d0d0d;
  --paper: #ecE9e2;
  --paper-2: #e3dfd6;
  --ink: #141414;
  --blue: #0b3d74;
  --g: clamp(10px, 2.2vmin, 26px);          /* the one spacing: window edges + between sheets */
  --lh: .8;                                  /* display leading: Roboto Flex caps are ~.71em tall */
  --ws: -.1em;                               /* display word spacing */

  --display: "Roboto Flex", "Arial Narrow", sans-serif;      /* main display: compressed + black */
  --feature: "Nagasaki", Impact, sans-serif;                 /* only where Nayeem asks for it: add class="feature" */
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --serif: "Newsreader", "Times New Roman", serif;

  /* newsprint grain */
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .55 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body { overflow: hidden; color: var(--ink); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
img { display: block; }
::selection { background: var(--ink); color: var(--paper); }

/* ---------- the track ---------- */
.track {
  display: flex;
  gap: var(--g);
  height: 100vh; height: 100svh;
  padding: var(--g);
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.track::-webkit-scrollbar { display: none; }
/* keep the same gap after the last sheet (flex scrollers drop end padding) */
.track::after { content: ""; flex: 0 0 1px; margin-left: calc(var(--g) * -1 + 1px); padding-right: var(--g); }

/* ---------- a sheet ---------- */
.sheet {
  /* spacing — only these three are used inside a sheet */
  --m: 4.4cqh;                               /* margin: sheet edge → frame, and gap between blocks */
  --s: calc(var(--m) / 3);                   /* small gap: label → content, caption → photo, rows */
  --line: calc(max(9px, 1.45cqh) * 1.25);   /* height of one mono line (same floor as .mono, so phones stay right) */
  --photo-bottom: calc(var(--m) * 2 + var(--line));   /* photo bottom edge on every photo sheet: footer line + gap above the margin */
  position: relative;
  flex: 0 0 auto;
  height: 100%;
  aspect-ratio: 148 / 210;
  background: var(--paper);
  container-type: size;
  overflow: hidden;
  isolation: isolate;
}
.sheet.l { aspect-ratio: 210 / 148; }

/* grain over everything on the sheet */
.sheet::after {
  content: ""; position: absolute; inset: 0; z-index: 20; pointer-events: none;
  background-image: var(--grain); background-size: 240px;
  mix-blend-mode: multiply; opacity: .32;
}
/* fold creases */
.sheet::before {
  content: ""; position: absolute; inset: 0; z-index: 19; pointer-events: none;
  background:
    linear-gradient(90deg, transparent calc(50% - 1px), rgba(0,0,0,.07) 50%, rgba(255,255,255,.35) calc(50% + 1px), transparent calc(50% + 3px)),
    linear-gradient(180deg, transparent calc(50% - 1px), rgba(0,0,0,.05) 50%, rgba(255,255,255,.3) calc(50% + 1px), transparent calc(50% + 3px));
}
.sheet.p::before { background: linear-gradient(180deg, transparent calc(50% - 1px), rgba(0,0,0,.06) 50%, rgba(255,255,255,.3) calc(50% + 1px), transparent calc(50% + 3px)); }

/* ---------- type ---------- */
.mono  { font-family: var(--mono); font-weight: 500; font-size: max(9px, 1.45cqh); line-height: 1.25; letter-spacing: .01em; }
.mono.caps { text-transform: uppercase; }
.serif { font-family: var(--serif); font-size: max(12px, 2.3cqh); line-height: 1.22; }
.big {
  font-family: var(--display); font-weight: 1000; text-transform: uppercase;
  font-variation-settings: "wdth" 25, "wght" 1000, "opsz" 144;
  line-height: var(--lh); letter-spacing: .01em; word-spacing: var(--ws); margin: 0;
  mix-blend-mode: multiply;                  /* overprint on photos */
}
/* highlighted words inside big text: ink on a fine checker dither (ref: "REALLY").
   The dither runs from halfway up the gap above the capitals to halfway down the gap below.
   Roboto Flex caps are .711em tall; at line-height .8 the inline-block box is .741em above the
   baseline and .059em below it, and the gap between lines is .089em (so .0445em each side). */
.big mark {
  position: relative; isolation: isolate;
  display: inline-block; line-height: .8;
  color: var(--ink); background: none;
  padding: 0 .08em; margin: 0 -.02em;
  -webkit-text-stroke: .045em var(--paper); paint-order: stroke fill;   /* keeps letters crisp on the dither */
}
.big mark::before {
  content: ""; position: absolute; z-index: -1; left: 0; right: 0;
  top: -.0145em;      /* .741 box top → .7555 = cap top + .0445 */
  bottom: .0145em;    /* .059 box bottom → .0445 below baseline */
  background-color: var(--paper);
  background-image: conic-gradient(var(--ink) 25%, transparent 0 50%, var(--ink) 0 75%, transparent 0);
  background-size: 4px 4px;
}

/* Nagasaki feature face — opt-in only */
.feature { font-family: var(--feature); font-weight: 400; font-variation-settings: normal; word-spacing: 0; line-height: 1.06; }

/* highlight words laid over the photos, half on the image, half on the paper */
.over {
  position: absolute; z-index: 10; pointer-events: none;
  white-space: pre-line; line-height: var(--lh);
  mix-blend-mode: normal;
}
.over.ink   { color: var(--ink); }
.over.paper { color: var(--paper); }
.over.box   { color: var(--ink); }
/* box: one paper block behind all the lines (per-line blocks overlapped the line above).
   At line-height .8 the caps sit .03em below the block's top edge and .059em above its bottom,
   so pad .1em / .071em to leave an even .13em of paper all round the letters */
.over.box span { display: inline-block; background: var(--paper); padding: .1em .13em .071em; }

/* the 3-column metadata row (Edition Office style) */
.spec { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 var(--m); }
.spec dt { opacity: .9; }
.spec dd { margin: 0; text-transform: uppercase; }
/* every top row: left / centre / right */
.spec > :nth-child(2) { text-align: center; }
.spec > :nth-child(3) { text-align: right; }
.foot { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; text-transform: uppercase; }
.foot > :last-child { text-align: right; }

/* ---------- photos: black & white, colour on hover ---------- */
.ph { position: relative; overflow: hidden; background: var(--paper-2); }
.ph img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  filter: grayscale(1) contrast(1.18) brightness(1.04);
  mix-blend-mode: multiply;
  transition: filter .8s cubic-bezier(.2,.7,.2,1);
}
.ph:hover img, .ph.live img, .sheet.live .ph.solo img { filter: none; }

/* ---------- layouts ---------- */
.frame { position: absolute; inset: var(--m); display: grid; grid-template-rows: auto 1fr auto; gap: var(--m); }

/* bleed: photo fills the frame, caption on the bottom line of the frame */
/* photo + its overlay word: the word is positioned relative to the photo, so it follows it on any screen */
.phwrap { position: relative; min-height: 0; }
.phwrap > .ph { position: absolute; inset: 0; }
.bleed .phwrap { position: absolute; inset: var(--m) var(--m) var(--photo-bottom); }
.bleed .caption { position: absolute; left: var(--m); right: var(--m); bottom: var(--m); display: flex; justify-content: space-between; }

/* text sheet */
.text .frame { grid-template-rows: auto 1fr auto; }
.fit { position: relative; min-height: 0; }
.fit .big { position: absolute; left: 0; right: 0; top: 0; }
.text .serif { max-width: 34em; }
.text.l .lower { display: grid; grid-template-columns: 1fr 1fr; gap: var(--m); align-items: end; }

/* cover: same frame as every sheet; the masthead overlaps the top of the photo by 3 margins */
.cover .frame { grid-template-rows: auto auto 1fr auto; }
.cover .top { display: grid; grid-template-columns: repeat(3, 1fr); }
.cover .top > :nth-child(2) { text-align: center; }
.cover .top > :nth-child(3) { text-align: right; }
.cover .mast { position: relative; z-index: 3; margin-bottom: calc(var(--m) * -3); }
.cover .mast .big { white-space: nowrap; line-height: .8; display: inline-block; }

/* places: a justified block centred on the sheet, cities stacked in the bottom-right corner */
.places .frame { grid-template-rows: auto; align-content: start; }
/* the rectangle: 62% of the sheet wide, 34% tall, dead centre; type size is fitted to fill it */
.places .story { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 46%; height: 24cqh; }
.places .story .fill {
  position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); margin: 0;
  line-height: 1.0; word-spacing: -.04em; letter-spacing: -.005em;
  text-align: justify;                       /* last-line handling is set by fitBlock() in main.js */
  hyphens: auto; -webkit-hyphens: auto; hyphenate-limit-chars: 6 3 2;
}
.places .cities { position: absolute; right: var(--m); bottom: var(--m); text-align: right; font-size: 8cqh; line-height: .76; }

/* archive grid */
.archive .grid { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: 1fr 1fr; gap: var(--m); min-height: 0; }
.archive figure { margin: 0; display: grid; grid-template-rows: 1fr auto; gap: var(--s); min-height: 0; }

/* contact (Another Practice style) */
.contact .cols { position: absolute; inset: var(--m); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--m); }
.contact .col { display: flex; flex-direction: column; position: relative; }
.contact .col:first-child > :last-child { margin-top: auto; }
.contact .col:first-child .links-wrap { margin-top: calc(var(--m) * 2); }
.contact .col:last-child > div:nth-child(2) { margin-top: auto; margin-bottom: var(--m); }
.contact .intro { max-width: 21em; }
/* right column: everything right-aligned */
.contact .col:last-child { align-items: flex-end; text-align: right; }
.contact .label { margin-bottom: var(--s); }
.contact .links .big, .contact .now .big { font-size: 7.4cqh; line-height: .82; }
.contact .now .big { font-size: 7.4cqh; }
/* link hover: colours swap; the black band runs the full width of the frame (both columns + gutter) */
.contact .links a { position: relative; display: block; text-decoration: none; mix-blend-mode: normal; z-index: 1; }
.contact .links a::before {
  content: ""; position: absolute; z-index: -1; top: 0; bottom: 0; left: 0;
  width: calc(200% + var(--m)); background: var(--ink); opacity: 0;
}
.contact .links a:hover, .contact .links a:focus-visible { color: var(--paper); outline: none; }
.contact .links a:hover::before, .contact .links a:focus-visible::before { opacity: 1; }

/* ---------- small screens: sheets stack vertically ---------- */
@media (max-width: 820px) and (orientation: portrait) {
  body { overflow: auto; }
  .track { flex-direction: column; height: auto; overflow: visible; }
  .track::after { display: none; }
  .sheet { width: 100%; height: auto; }
}

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

.noscript { color: #eee; font-family: var(--mono); padding: 2rem; }
