/*
 * lucasmerlin.me: the blog, the about page and the list of tools.
 * Builds on sketch.css (tokens, .link, .btn, .h2, sketched boxes and underlines).
 */

/* ------------------------------------------------------------------------------
 * Page frame: top bar, main column, footer
 * ------------------------------------------------------------------------------ */

.site {
  display: flex;
  flex-direction: column;
  gap: 64px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 24px 56px;
  /* The tilted photo frames and their offset tint may reach a few pixels past a
     narrow window; cut that off instead of letting the page scroll sideways. */
  overflow-x: clip;
}

.site-main {
  display: flex;
  flex-direction: column;
  gap: 64px;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--ink);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.wordmark span {
  color: var(--muted);
  font-weight: 400;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-right: -10px;
}

.nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 0 10px;
  color: var(--ink);
  font-size: 19px;
  text-decoration: none;
}

.nav-link:hover {
  text-decoration: underline;
  text-decoration-color: var(--faint);
  text-underline-offset: 6px;
}

.nav-link.active {
  font-weight: 700;
}

.nav-link.active:hover {
  text-decoration: none;
}

/* The current page is underlined by hand, in the accent colour. */
.nav-link .underline {
  left: 8px;
  bottom: 6px;
  width: calc(100% - 16px);
  height: 8px;
}

.nav-link .underline path {
  stroke: var(--accent);
  stroke-width: 3;
}

/* The small arrow after links to other sites. */
.ext {
  flex-shrink: 0;
  width: 0.7em;
  height: 0.7em;
  overflow: visible;
}

.ext path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.site-footer {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.footer-rule {
  position: relative;
  height: 8px;
}

.footer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 20px;
  color: var(--ink-soft);
  font-size: 16px;
}

.footer-row nav {
  display: flex;
  gap: 16px;
}

.footer-row .link {
  font-size: 16px;
}

/* ------------------------------------------------------------------------------
 * Shared pieces
 * ------------------------------------------------------------------------------ */

.intro {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 720px;
}

.intro-title {
  font-size: clamp(40px, 5vw, 60px);
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.intro-text {
  color: var(--ink-soft);
  font-size: clamp(19px, 2vw, 22px);
  line-height: 1.45;
  text-wrap: pretty;
}

.intro-text a,
.prose a {
  color: var(--link);
  text-underline-offset: 3px;
}

.intro-text a:hover,
.prose a:hover {
  color: var(--link-hover);
}

.section {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 4px 16px;
}

.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  color: var(--ink-soft);
  font-size: 17px;
}

/* The accent, darkened enough to read as text on paper. */
.kicker {
  color: #b23c0b;
  font-weight: 700;
}

/* A photo in a slightly tilted, sketched frame, with a tinted shape behind it. */
.frame {
  position: relative;
  display: block;
  margin: 0;
  padding: 12px;
  transform: rotate(-1.2deg);
}

.frame img {
  position: relative;
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 6 / 5;
  object-fit: cover;
  background: var(--rule);
}

.frame-fill {
  transform: translate(10px, 12px);
}

/* ------------------------------------------------------------------------------
 * Home: latest post, earlier posts, tools
 * ------------------------------------------------------------------------------ */

.featured {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr));
  align-items: center;
  gap: 40px 56px;
}

.featured-text {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.featured-title {
  font-size: clamp(32px, 3.6vw, 42px);
  line-height: 1.12;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.featured-title a {
  color: inherit;
  text-decoration: none;
}

.featured-title a:hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

.featured-excerpt {
  color: #3d3a35;
  font-size: 20px;
  line-height: 1.5;
  text-wrap: pretty;
}

.featured .row {
  padding-top: 6px;
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  gap: 32px;
}

.post-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 14px 20px;
  color: var(--ink);
  text-decoration: none;
}

.post-card img {
  position: relative;
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  background: var(--rule);
}

.post-card-text {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 6px;
}

.post-card time {
  color: var(--ink-soft);
  font-size: 16px;
}

.card-title {
  font-size: 22px;
  line-height: 1.22;
  font-weight: 700;
  text-wrap: balance;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
  gap: 20px;
}

.tool-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 22px;
  color: var(--ink);
  text-decoration: none;
}

.tool-name {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 20px;
}

.tool-blurb {
  position: relative;
  color: var(--ink-soft);
  font-size: 17px;
}

.post-card:hover .outline,
.tool-card:hover .outline {
  stroke-width: 2.8;
}

.post-card:hover .card-title,
.tool-card:hover .tool-name {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

/* ------------------------------------------------------------------------------
 * A post (and the about page)
 * ------------------------------------------------------------------------------ */

.post {
  display: flex;
  flex-direction: column;
  gap: 40px;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

.post-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.back {
  align-self: flex-start;
  margin-left: -4px;
}

.post-date {
  color: var(--ink-soft);
  font-size: 17px;
}

.post-title {
  font-size: clamp(36px, 5vw, 54px);
  line-height: 1.1;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

/* The frame's padding hangs out, so the photo lines up with the text. */
.hero {
  margin: 0 -12px;
}

.hero img {
  aspect-ratio: auto;
  max-height: 640px;
}

.post-foot {
  display: flex;
}

/* ------------------------------------------------------------------------------
 * Post bodies (rendered Markdown)
 * ------------------------------------------------------------------------------ */

.prose {
  font-size: 19px;
  line-height: 1.65;
  overflow-wrap: break-word;
}

.prose :where(h2, h3, h4, h5, h6, p, ul, ol, figure, blockquote, table, pre) {
  margin: 0;
}

.prose > * + * {
  margin-top: 1.1em;
}

.prose h2 {
  margin-top: 1.8em;
  font-size: 30px;
  line-height: 1.2;
}

.prose h3 {
  margin-top: 1.6em;
  font-size: 24px;
  line-height: 1.25;
}

.prose h4,
.prose h5,
.prose h6 {
  margin-top: 1.4em;
  font-size: 20px;
  line-height: 1.3;
}

.prose > :first-child {
  margin-top: 0;
}

.prose :is(h2, h3, h4, h5, h6) + * {
  margin-top: 0.5em;
}

.prose ul,
.prose ol {
  padding-left: 1.4em;
}

.prose li + li,
.prose li > :is(ul, ol) {
  margin-top: 0.35em;
}

.prose img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.prose figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.prose figcaption {
  color: var(--ink-soft);
  font-size: 16px;
  text-align: center;
}

.prose blockquote {
  padding-left: 1em;
  color: var(--ink-soft);
  font-style: italic;
}

.prose hr {
  height: 2px;
  margin: 2em 0;
  border: 0;
  background: var(--rule);
}

.prose table {
  border-collapse: collapse;
  font-size: 17px;
}

.prose th,
.prose td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--rule);
  text-align: left;
}

.prose code,
.prose pre {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

.prose :not(pre) > code {
  padding: 0.1em 0.35em;
  border-radius: 6px 8px 5px 7px;
  background: rgb(31 29 26 / 0.07);
  font-size: 0.86em;
}

/* Code blocks: highlighted on the server, inside a sketched box. */
/* The padding keeps the pre a few pixels inside the sketched outline, so its
   scrollbar (wide code scrolls sideways) never touches the drawn line. */
.prose .code {
  position: relative;
  margin-left: -8px;
  margin-right: -8px;
  padding: 4px 6px 6px;
}

.prose .code pre {
  position: relative;
  padding: 16px 18px 14px;
  overflow-x: auto;
  font-size: 15px;
  line-height: 1.55;
  tab-size: 4;
  scrollbar-width: thin;
  scrollbar-color: var(--faint) transparent;
}

/* Safari ignores scrollbar-width and scrollbar-color. */
.prose .code pre::-webkit-scrollbar {
  height: 8px;
}

.prose .code pre::-webkit-scrollbar-track {
  background: transparent;
}

.prose .code pre::-webkit-scrollbar-thumb {
  border-radius: 8px 5px 7px 4px;
  background: var(--faint);
}

.prose .code pre::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* ------------------------------------------------------------------------------
 * Phones
 * ------------------------------------------------------------------------------ */

@media (max-width: 699px) {
  .site {
    gap: 44px;
    padding: 16px 16px 40px;
  }

  .site-main {
    gap: 48px;
  }

  .site-header {
    gap: 0 16px;
  }

  .site-nav {
    margin-left: -10px;
  }

  .featured {
    gap: 28px;
  }

  .prose .code pre {
    padding: 12px 12px 10px;
    font-size: 14px;
  }
}
