/* 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.
   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;
}

/* ---------------------------------------------------------------- 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;

  /* 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, .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); }

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,
.mast a[aria-current] { 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 nav { display: flex; flex-wrap: wrap; gap: 0 1.4rem; }
.mast nav a, footer a { padding-block: 0.6rem; }   /* ~44px targets */
.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; }
.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; }
.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;
  padding-top: clamp(2rem, 8vh, 5rem);
}
.practice { list-style: none; margin: 1.5rem 0; padding: 0; display: grid; gap: 0.4rem; }
.practice li { padding-left: 1.1rem; position: relative; }
.practice li::before {
  content: ""; position: absolute; left: 0; top: 0.8em;
  width: 0.55rem; height: 1px; background: var(--line-strong);
}

/* ------------------------------------------------------------ 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; display: grid; place-items: center; }
.mark img {
  display: block; width: auto; height: auto; max-width: 100%;
  max-height: min(60svh, 34rem);
  opacity: 0.5;
  animation: settle 0.8s var(--ease) both;
}

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

/* -------------------------------------------------------------- motion   */
/* Continuity, not ornament. Cross-document transitions carry a thumbnail
   into its photograph. No JavaScript. */

@view-transition { navigation: auto; }

::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; }

@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; }
  .mark img { max-height: 36svh; }
  .art { max-height: calc(100svh - 12rem); }
  .piece-nav a { max-width: 48%; }
}
