/*
 * bikeshkumar.com
 * One stylesheet. Tokens first, then layout, then components.
 */

@font-face {
  font-family: "Manrope";
  src: url("../fonts/manrope-latin.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

/* ------------------------------------------------------------------ */
/* Tokens                                                             */
/* ------------------------------------------------------------------ */

:root {
  --ink: #1f1e1b;
  --ink-muted: #787774;
  --ink-faint: #9b9a97;
  --ink-hairline: #c3c2bf;
  --line: #e9e9e7;
  --paper: #ffffff;
  --hover: rgba(55, 53, 47, 0.06);

  --font: "Manrope", ui-sans-serif, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;

  --edge-x: clamp(24px, 4.5vw + 7px, 72px);
  --edge-y: 48px;
  --gap: 28px;
  --measure: 260px;
  --sidebar: calc(var(--measure) + var(--edge-x) * 2);
  --control: 36px;
  --radius: 6px;
  --column: 640px;
  --frame: 1440px;
  --offset: max(0px, (100vw - var(--frame)) / 2);

  --shadow: rgba(15, 15, 15, 0.05) 0 0 0 1px, rgba(15, 15, 15, 0.1) 0 3px 6px, rgba(15, 15, 15, 0.2) 0 9px 24px;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

/* ------------------------------------------------------------------ */
/* Base                                                               */
/* ------------------------------------------------------------------ */

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/24px var(--font);
  -webkit-font-smoothing: antialiased;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

::selection {
  background: rgba(35, 131, 226, 0.18);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 20;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  text-decoration: none;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* Trim line-box padding so spacing is measured from the letters. */
.trim {
  text-box: trim-both cap alphabetic;
}

/* ------------------------------------------------------------------ */
/* Layout                                                             */
/* ------------------------------------------------------------------ */

.sidebar {
  position: fixed;
  inset: 0 auto 0 var(--offset);
  z-index: 2;
  display: flex;
  flex-direction: column;
  width: var(--sidebar);
  padding: var(--edge-y) var(--edge-x);
  overflow-y: auto;
  scrollbar-width: none;
  border-right: 1px solid var(--line);
  background: var(--paper);
}

.sidebar::-webkit-scrollbar {
  display: none;
}

.topbar {
  position: absolute;
  top: var(--edge-y);
  right: calc(var(--edge-x) + var(--offset));
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
}

.main {
  margin-left: calc(var(--sidebar) + var(--offset));
  margin-right: var(--offset);
  padding: calc(var(--edge-y) + 96px + var(--gap)) var(--edge-x) var(--edge-y);
}

.main--full {
  margin-left: var(--offset);
  padding-top: var(--edge-y);
}

.column {
  max-width: var(--column);
  margin: 0 auto;
}

/* ------------------------------------------------------------------ */
/* Profile                                                            */
/* ------------------------------------------------------------------ */

.profile {
  display: flex;
  flex-direction: column;
}

.profile a {
  text-decoration: underline;
  text-decoration-color: var(--ink-hairline);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  transition: text-decoration-color 160ms var(--ease);
}

.profile a:hover {
  text-decoration-color: currentColor;
}

.profile__photo-link {
  width: max-content;
}

.profile__photo {
  width: 96px;
  height: 96px;
  margin-bottom: var(--gap);
  border-radius: 50%;
  object-fit: cover;
  filter: grayscale(1) brightness(1.04) contrast(1.06);
  box-shadow: 0 0 0 1px rgba(15, 15, 15, 0.12);
}

.profile__name {
  margin: 0 0 16px;
  font-size: 22px;
  font-weight: 600;
  line-height: 28px;
}

.profile__name a {
  text-decoration: none;
}

.profile__name a:hover {
  color: var(--ink-muted);
}

.profile__roles {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.profile__bio {
  margin: var(--gap) 0 0;
  text-wrap: pretty;
}

.social {
  display: flex;
  gap: 4px;
  margin: calc(var(--gap) - 7px) 0 0 -7px;
  padding: 0;
  list-style: none;
}

.social a {
  display: grid;
  place-items: center;
  width: var(--control);
  height: var(--control);
  border-radius: var(--radius);
  transition: background 80ms var(--ease);
}

.social a:hover {
  background: var(--hover);
}

.social svg {
  width: 22px;
  height: 22px;
}

.copyright {
  margin: auto 0 0;
  padding-top: var(--gap);
  color: var(--ink-muted);
  font-size: 14px;
  line-height: 20px;
}

/* ------------------------------------------------------------------ */
/* Controls                                                           */
/* ------------------------------------------------------------------ */

.icon-button {
  display: grid;
  place-items: center;
  width: var(--control);
  height: var(--control);
  border-radius: var(--radius);
  color: var(--ink);
  transition: background 80ms var(--ease);
}

.icon-button:hover {
  background: var(--hover);
}

.icon-button svg {
  width: 24px;
  height: 24px;
}

.button {
  display: inline-flex;
  align-items: center;
  height: var(--control);
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper);
  font: 500 14px/1 var(--font);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 80ms var(--ease);
}

.button:hover {
  background: #000;
}

.button:disabled {
  background: var(--ink-muted);
  cursor: default;
}

/* ------------------------------------------------------------------ */
/* Subscribe                                                          */
/* ------------------------------------------------------------------ */

.subscribe {
  position: relative;
}

.subscribe__panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 360px;
  max-width: calc(100vw - var(--edge-x) * 2);
  padding: var(--gap);
  border-radius: calc(var(--radius) * 2);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.subscribe__panel[hidden] {
  display: none;
}

.subscribe__title {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  line-height: 28px;
}

.subscribe__text {
  margin: 16px 0 0;
}

.subscribe__form {
  display: flex;
  gap: 8px;
  margin-top: var(--gap);
}

.subscribe__input {
  flex: 1;
  min-width: 0;
  height: var(--control);
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--ink);
  color: var(--ink);
  font: 400 14px/20px var(--font);
}

.subscribe__input::placeholder {
  color: var(--ink-faint);
}

.subscribe__input:focus {
  outline: none;
}

.subscribe__status {
  margin: 0;
  color: var(--ink-muted);
  font-size: 14px;
  line-height: 20px;
}

.subscribe__status:not(:empty) {
  margin-top: 16px;
}

/* ------------------------------------------------------------------ */
/* Essay                                                              */
/* ------------------------------------------------------------------ */

.essay__title {
  margin: 0;
  font-size: clamp(26px, 1vw + 20px, 32px);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.essay__meta {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  color: var(--ink-muted);
  font-size: 14px;
  line-height: 20px;
}

.essay__body {
  margin-top: 40px;
  overflow-wrap: anywhere;
}

.essay__body p {
  margin: 0 0 20px;
  text-wrap: pretty;
}

.essay__body > :last-child {
  margin-bottom: 0;
}

.essay__body h2 {
  margin: 48px 0 16px;
  font-size: 22px;
  font-weight: 600;
  line-height: 28px;
}

.essay__body h3 {
  margin: 32px 0 12px;
  font-size: 17px;
  font-weight: 600;
}

.essay__body ul,
.essay__body ol {
  margin: 0 0 20px;
  padding-left: 1.3em;
}

.essay__body li + li {
  margin-top: 8px;
}

.essay__body li::marker {
  color: var(--ink-muted);
}

.essay__body blockquote {
  margin: var(--gap) 0;
  padding-left: 18px;
  border-left: 2px solid var(--ink);
}

.essay__body blockquote p {
  margin: 0;
}

.essay__body a {
  text-decoration-color: var(--ink-hairline);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.essay__body a:hover {
  text-decoration-color: currentColor;
}

.essay__body code {
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: #f1f1ef;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.88em;
}

.essay__body pre {
  margin: var(--gap) 0;
  padding: 16px 20px;
  overflow-x: auto;
  border-radius: var(--radius);
  background: #f7f7f5;
  font-size: 14px;
  line-height: 22px;
}

.essay__body pre code {
  padding: 0;
  background: none;
  font-size: inherit;
}

.essay__body hr {
  height: 1px;
  margin: 40px 0;
  border: 0;
  background: var(--line);
}

.essay__body figure {
  margin: 40px 0;
}

.essay__body img {
  width: 100%;
  border-radius: var(--radius);
}

.essay__body figcaption {
  margin-top: 12px;
  color: var(--ink-muted);
  font-size: 14px;
  line-height: 20px;
}

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: var(--edge-y);
}

.pager a {
  display: flex;
  align-items: center;
  height: 12px;
  color: var(--ink);
  transition: color 160ms var(--ease);
}

.pager a:hover {
  color: var(--ink-muted);
}

.pager__next {
  grid-column: 2;
  justify-self: end;
}

.pager svg {
  width: 28px;
  height: 10px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ------------------------------------------------------------------ */
/* Essays index                                                       */
/* ------------------------------------------------------------------ */

.find {
  display: block;
  margin-top: -6px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  transition: border-color 160ms var(--ease);
}

.find:focus-within {
  border-bottom-color: var(--ink-faint);
}

.find__input {
  width: 100%;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font: 400 24px/34px var(--font);
  letter-spacing: -0.01em;
}

.find__input::placeholder {
  color: var(--ink-faint);
}

.find__input::-webkit-search-cancel-button {
  display: none;
}

.list {
  margin: 32px 0 0;
  padding: 0;
  list-style: none;
}

.list__item a {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 32px;
  padding: 14px 0;
  text-decoration: none;
}

.list__title {
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.list__item a:hover .list__title,
.list__item a[aria-selected="true"] .list__title {
  text-decoration: underline;
  text-decoration-color: var(--ink-hairline);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.list__date {
  color: var(--ink-muted);
  font-size: 14px;
  line-height: 20px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.list__empty {
  padding: 14px 0;
  color: var(--ink-muted);
}

/* ------------------------------------------------------------------ */
/* Responsive                                                         */
/* ------------------------------------------------------------------ */

@media (min-width: 1600px) {
  :root {
    --column: 680px;
  }
}

@media (max-width: 1023px) {
  body {
    display: flex;
    flex-direction: column;
  }

  .topbar {
    position: relative;
    inset: auto;
    order: 0;
    justify-content: flex-end;
    padding: var(--edge-y) var(--edge-x) 0;
  }

  .sidebar {
    position: static;
    order: 1;
    width: auto;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .profile {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: 16px;
    max-width: var(--column);
  }

  .profile__photo-link {
    grid-row: 1 / span 2;
  }

  .profile__photo {
    width: 64px;
    height: 64px;
    margin: 0;
  }

  .profile__name {
    align-self: end;
    margin-bottom: 10px;
  }

  .profile__roles {
    flex-flow: row wrap;
    align-self: start;
    gap: 0 6px;
  }

  .profile__roles li + li::before {
    content: "·";
    margin-right: 6px;
    color: var(--ink-faint);
  }

  .profile__bio,
  .social {
    grid-column: 1 / -1;
  }

  .copyright {
    margin-top: var(--gap);
    padding-top: 0;
  }

  .main {
    order: 2;
    margin-left: 0;
    padding: var(--edge-y) var(--edge-x);
  }

  .column {
    margin: 0;
  }

  .subscribe {
    position: static;
  }

  .subscribe__panel {
    right: var(--edge-x);
  }
}

@media (max-width: 599px) {
  :root {
    --edge-y: 24px;
  }

  body {
    font-size: 16px;
  }

  .profile__roles {
    flex-direction: column;
    gap: 4px;
  }

  .profile__roles li + li::before {
    content: none;
  }

  .subscribe__panel {
    left: var(--edge-x);
    width: auto;
    max-width: none;
  }

  .find__input {
    font-size: 20px;
    line-height: 28px;
  }

  .list__item a {
    gap: 16px;
  }

  .list__date {
    font-size: 13px;
  }
}

@media (hover: none) {
  .list__item a:hover .list__title {
    text-decoration: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
