/* vivekkoshy.com
   Identity is structure and type. There is no brand colour anywhere: links,
   hover and active states are carried by weight, rule and position. The
   photographs supply every scrap of colour on the site. Pages scroll; only a
   single photograph is fitted to the screen. Motion has two registers: the
   interface glides, and the one hand-made thing, the mark, boils.
   See docs/design-decisions.md for why. */

/* ---------------------------------------------------------------- fonts  */
/* Self-hosted and subset. No CDN request. If the files are absent the
   fallback stacks below still produce a correct, if plainer, site. */

@font-face {
  font-family: "Fraunces";
  src: url("/assets/fonts/Fraunces-af7778e69c28.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Plex Mono";
  src: url("/assets/fonts/IBMPlexMono-Regular-84aaa05a60c5.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Plex Mono";
  src: url("/assets/fonts/IBMPlexMono-Medium-b12255c75795.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
/* Vivek's own hand, built from his Calligraphr sheets and normalised to one
   baseline, one x-height and one pen. Used for his name and his poem titles
   only: the signature, and the work in his own voice. Never for reading. */
@font-face {
  font-family: "Vgk";
  src: url("/assets/fonts/Vgk-Regular-e221aac3b8d3.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

/* ---------------------------------------------------------------- tokens */

:root {
  color-scheme: light;

  /* A neutral ramp. Deliberately not warm: cream is the thing being left. */
  --paper:       #fbfbfb;
  --ink:         #141414;
  --ink-muted:   #5a5a5a;
  --line:        #dedede;
  --line-strong: #b0b0b0;
  --shade:       #efefef;

  --work:   "Fraunces", Charter, Cambria, Georgia, serif;
  --record: "Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --hand:   "Vgk", var(--work);

  /* No display type. The largest thing on the site is about 2rem. */
  --t-record: 0.75rem;
  --t-small:  0.875rem;
  --t-body:   1.0625rem;
  --t-read:   1.1875rem;
  --t-head:   clamp(1.6rem, 2.2vw, 2.05rem);

  --gutter: clamp(1rem, 4vw, 3.5rem);
  --measure: 34rem;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

html {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--work);
  font-size: 100%;
  font-optical-sizing: auto;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-size: var(--t-body);
  font-weight: 400;
  line-height: 1.6;
  font-variation-settings: "SOFT" 12, "WONK" 0;
}

/* ------------------------------------------------------------ the record */
/* Every piece of metadata speaks in the machine voice: dates, identifiers,
   counts, capture timestamps, attributions, source links, navigation. */

.mast nav, footer, .year, .index small, .piece-nav, .links, .colophon, .responses summary, .who {
  font-family: var(--record);
  font-size: var(--t-record);
  font-weight: 400;
  letter-spacing: 0.04em;
  font-variation-settings: normal;
}


/* ------------------------------------------------------------ typography */

h1, h2, h3 {
  font-weight: 450;
  line-height: 1.18;
  letter-spacing: -0.005em;
  text-wrap: balance;
  margin: 0;
  /* The one liberty taken with the type: Fraunces' wonky, soft-cornered
     cut on every heading, so the letters lean a little. */
  font-variation-settings: "SOFT" 100, "WONK" 1;
}
h1 { font-size: var(--t-head); }

/* The hand has a small x-height (0.4 em against Fraunces' ~0.5), so it is set
   about a third larger to read at the same size as the type around it. */
.hand {
  font-family: var(--hand);
  font-weight: 400;
  font-variation-settings: normal;
  letter-spacing: 0.01em;
  line-height: 1.1;
}
h1.hand { font-size: calc(var(--t-head) * 1.3); }

p { margin: 0 0 1em; }
small { color: var(--ink-muted); }

/* Links carry no colour. They are marked by a rule that grows from the left. */
a {
  color: inherit;
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 100% 1px;
  transition: background-size 0.3s var(--ease);
  padding-bottom: 0.08em;
}
a:hover { background-size: 100% 2px; }
.mast a, footer a, .wall a, .index a, .doors a { background-size: 0 1px; }
.mast a:hover, footer a:hover, .doors a:hover { background-size: 100% 1px; }
a:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

.skip {
  position: fixed; top: -5rem; left: 1rem; z-index: 9;
  background: var(--ink); color: var(--paper); padding: 0.6rem 1rem;
}
.skip:focus { top: 1rem; }

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

body { min-height: 100svh; display: flex; flex-direction: column; }
main { flex: 1 0 auto; }

.wrap { width: min(100% - (2 * var(--gutter)), 82rem); margin-inline: auto; }

.mast {
  display: flex; justify-content: space-between; align-items: baseline;
  flex-wrap: wrap; gap: 0.25rem 2rem;
  padding: 0.9rem var(--gutter);
  border-bottom: 1px solid var(--line);
}
.mast .name {
  font-size: 1.2rem; letter-spacing: 0.005em;
  font-variation-settings: "SOFT" 100, "WONK" 1;
}
.mast .name.hand { font-size: 1.6rem; letter-spacing: 0.01em; font-variation-settings: normal; }
.mast nav { display: flex; flex-wrap: wrap; gap: 0 1.4rem; }
.mast nav a, footer a { padding-block: 0.6rem; }   /* ~44px targets */
/* The current room's rule is its own element, so it can travel to the next
   room when you change rooms. */
.mast nav a { position: relative; }
.here {
  position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: currentColor;
  view-transition-name: here;
}
.mast nav a[aria-current] { color: var(--ink); }
.mast nav a:not([aria-current]) { color: var(--ink-muted); }
.mast nav a:hover { color: var(--ink); }

footer {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0 1.5rem;
  margin-top: clamp(3rem, 10vh, 6rem);
  padding-block: 0.5rem;
  border-top: 1px solid var(--line);
  color: var(--ink-muted);
}

.room { font-size: var(--t-read); margin: clamp(1.5rem, 5vh, 3rem) 0 clamp(1rem, 3vh, 2rem); }

/* ------------------------------------------------------------------ home */

/* The name is the heading here, so the masthead steps aside, and the page
   is exactly one screen: the portrait stands on the footer rule. */
main:has(> .home) { display: flex; }
main:has(> .home) + footer { margin-top: 0; }
.home {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: clamp(2rem, 6vw, 5rem);
  align-items: end;
  padding-top: clamp(1.5rem, 6vh, 4rem);
}
.portrait {
  display: block; justify-self: center;
  width: auto; height: auto; max-width: 100%;
  max-height: min(calc(100svh - 8rem), 40rem);
}
.home-text { align-self: center; display: grid; gap: 0.6rem; }
.home h1 { font-size: clamp(2rem, 4.2vw, 3.2rem); font-weight: 380; }
.home h1.hand { font-size: clamp(2.6rem, 5.4vw, 4.2rem); font-weight: 400; }
.role { color: var(--ink-muted); margin: 0; }
.doors { display: grid; justify-items: start; gap: 0.1rem; margin-top: clamp(1rem, 4vh, 2.5rem); }
.doors a {
  font-size: var(--t-read); padding-block: 0.35rem;
  font-variation-settings: "SOFT" 100, "WONK" 1;
}

/* ------------------------------------------------------------ the wall  */
/* Every photograph at its own shape. Columns, not a grid: a grid crops or
   leaves holes, and these frames range from tall to panoramic. */

.wall { columns: 3; column-gap: clamp(0.6rem, 1.4vw, 1.25rem); }
.wall a { display: block; break-inside: avoid; margin-bottom: clamp(0.6rem, 1.4vw, 1.25rem); }
.wall img { display: block; width: 100%; height: auto; background: var(--shade); }
@media (max-width: 700px)  { .wall { columns: 2; } }
@media (min-width: 1401px) { .wall { columns: 4; } }

/* ------------------------------------------------------------ photograph */
/* The one page that is fitted to the screen: the whole photograph and its
   title arrive together, whatever the viewport. */

.photo { padding-top: clamp(1rem, 3vh, 2rem); }
.art {
  display: block; margin-inline: auto;
  width: auto; height: auto; max-width: 100%;
  max-height: calc(100svh - 10.5rem);
  object-fit: contain;
}
.caption { max-width: var(--measure); margin: 1rem auto 0; text-align: center; }
.caption h1 { font-size: var(--t-read); }
.caption p { white-space: pre-line; color: var(--ink-muted); margin: 0.35rem 0 0; }

.piece-nav {
  display: flex; justify-content: space-between; gap: 1rem;
  margin-top: clamp(1.5rem, 5vh, 3rem);
  padding-top: 0.25rem;
  border-top: 1px solid var(--line);
}
.piece-nav a { padding-block: 0.6rem; background-size: 0 1px; color: var(--ink-muted); }
.piece-nav a:hover { color: var(--ink); background-size: 100% 1px; }
.piece-nav [rel=next] { text-align: right; margin-left: auto; }

/* A title that travels between pages is one unbroken box: a title wrapped
   across lines cannot be carried, and would cancel the transition. */
.title { display: inline-block; }

/* Where a piece first appeared. A witness, not an advertisement. */
.colophon { color: var(--ink-muted); margin: clamp(1.5rem, 4vh, 2.5rem) 0 0; }
.colophon a { display: inline-block; padding-block: 0.6rem; background-size: 0 1px; }
.colophon a:hover { color: var(--ink); background-size: 100% 1px; }
.caption .colophon { margin: 0; }
.photo .piece-nav { max-width: 48rem; margin-inline: auto; }

/* ---------------------------------------------------------------- poems  */

.index { list-style: none; margin: 0; padding: 0; max-width: 40rem; border-top: 1px solid var(--line); }
.index li { border-bottom: 1px solid var(--line); }
.index a { display: flex; justify-content: space-between; align-items: baseline; gap: 1.5rem; padding: 0.8rem 0; }
.index a span {
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat; background-position: 0 100%; background-size: 0 1px;
  transition: background-size 0.3s var(--ease);
}
.index a:hover span { background-size: 100% 1px; }

.reading { max-width: var(--measure); padding-top: clamp(2rem, 8vh, 5rem); }
.year { color: var(--ink-muted); margin: 0.5rem 0 0; }
.poem {
  white-space: pre-wrap;
  font-size: var(--t-read);
  line-height: 1.8;
  margin: clamp(1.5rem, 4vh, 2.5rem) 0 0;
}

/* The readers' replies stay folded: the poem ends the page unless asked. */
.responses { margin-top: 2rem; }
.responses summary { cursor: pointer; color: var(--ink-muted); padding-block: 0.6rem; list-style: none; }
.responses summary::-webkit-details-marker { display: none; }
.responses summary::before { content: "+ "; }
.responses[open] summary::before { content: "− "; }
.responses summary:hover { color: var(--ink); }
.review { border-top: 1px solid var(--line); padding: 1rem 0; }
.review p { white-space: pre-wrap; margin: 0.3rem 0 0; }
.who { color: var(--ink-muted); margin: 0; }

/* ----------------------------------------------------------------- work  */

.work {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(2rem, 6vw, 5rem);
  align-items: center;
}
.work p { font-size: var(--t-read); max-width: var(--measure); }
.links { display: flex; flex-wrap: wrap; gap: 0 1.5rem; margin-top: 1.5rem; }
.links a { padding-block: 0.6rem; background-size: 0 1px; color: var(--ink-muted); }
.links a:hover { color: var(--ink); background-size: 100% 1px; }

/* ------------------------------------------------------------ the mark   */
/* A contour derived at build time from one photograph, ink on transparency.
   The only ornament on the site; it changes with one line of
   content-work.json. */

.mark { margin: 0; min-width: 0; width: 100%; display: grid; place-items: center; }
.ink {
  --tall: min(60svh, 34rem);
  width: min(100%, var(--tall) * var(--ratio));
  aspect-ratio: var(--ratio);
  background-repeat: no-repeat;
  background-size: 300% 100%;   /* three tracings side by side */
  background-position: 0 0;
  opacity: 0.5;
}

/* The 404: heading laid over the mark, both in one grid cell. */
.lost { display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding-top: clamp(2rem, 8vh, 5rem); }
.lost > * { grid-area: 1 / 1; }
.lost .ink { opacity: 0.26; }
.lost > div { z-index: 1; text-align: center; }

/* -------------------------------------------------------------- motion   */
/* Two registers. The interface glides: one rule travels between rooms, a
   title carries into its page, type changes its posture under the pointer.
   The hand-made boils: the mark is drawn in, then stepped through its three
   tracings at twelve frames a second, as a pencil line quivers from cel to
   cel. Photographs develop as they come into view. No JavaScript. */

@view-transition { navigation: auto; }

::view-transition-group(*) { animation-duration: 0.4s; animation-timing-function: var(--ease); }
::view-transition-old(root) { animation: fade-out 0.18s var(--ease) both; }
::view-transition-new(root) { animation: fade-in 0.28s var(--ease) both; }

@keyframes fade-out { to { opacity: 0; } }
@keyframes fade-in  { from { opacity: 0; } }
@keyframes settle   { from { opacity: 0; transform: translateY(0.35rem); } }

.wall img, .art, .portrait { animation: settle 0.55s var(--ease) both; }

/* Fraunces has a soft, wonky cut and a firm, upright one. Touched, a link
   takes the other. */
.doors a, .index .title {
  transition: background-size 0.3s var(--ease), font-variation-settings 0.5s var(--ease);
}
.doors a:hover, .doors a:focus-visible { font-variation-settings: "SOFT" 0, "WONK" 0; }
.index a:hover .title, .index a:focus-visible .title { font-variation-settings: "SOFT" 100, "WONK" 1; }

@media (prefers-reduced-motion: no-preference) {
  /* A print coming up in the tray: flat grey to full tone, done before the
     photograph is wholly in view. Nothing moves. */
  @supports (animation-timeline: view()) {
    .wall img {
      animation: develop linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 75%;
    }
  }

  .ink {
    mask-image: linear-gradient(to right, #000 50%, transparent 60%);
    mask-size: 250% 100%;
    mask-repeat: no-repeat;
    animation: draw 1.6s cubic-bezier(0.65, 0, 0.35, 1) both, boil 0.25s step-end infinite;
  }

  :root { interpolate-size: allow-keywords; }
  .responses::details-content {
    block-size: 0; overflow-y: clip;
    transition: block-size 0.35s var(--ease), content-visibility 0.35s var(--ease) allow-discrete;
  }
  .responses[open]::details-content { block-size: auto; }
}

@keyframes develop { from { filter: grayscale(1) contrast(0.55) brightness(1.12); } }
@keyframes draw    { from { mask-position: 100% 0; } to { mask-position: 0 0; } }
@keyframes boil {
  0%      { background-position: 0 0; }
  33.333% { background-position: 50% 0; }
  66.667% { background-position: 100% 0; }
}

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --------------------------------------------------------------- narrow  */

@media (max-width: 700px) {
  .home { grid-template-columns: 1fr; align-items: start; gap: 1.25rem; }
  .portrait { max-height: 46svh; }
  .home-text { align-self: start; }
  .doors { margin-top: 0.75rem; }
  .doors a { padding-block: 0.55rem; }
  .work { grid-template-columns: 1fr; }
  .ink { --tall: 36svh; }
  .art { max-height: calc(100svh - 12rem); }
  .piece-nav a { max-width: 48%; }
}
