/* Collection pages: /projects/, /writing/, and their detail pages.
   Uses the palette from style.css (--base-clr, --accent-clr, ...) rather than
   introducing new colours. */

/* ---------------------------------------------------------------------------
   Opt out of the global hero layout.

   style.css sets #content to a viewport-height flex row, centred both ways.
   That is right for the landing pages, which are a single centred block, and
   wrong for a list: it makes the page header and the list flex siblings side
   by side, and floats everything in the vertical middle. These pages read
   top-down, left-aligned.
   --------------------------------------------------------------------------- */
#content.collection {
  display: block;
  align-items: initial;
  justify-content: initial;
  text-align: left;
  min-height: 100vh;
  max-width: 920px;
  margin: 0;
  padding: clamp(3rem, 9vh, 6rem) clamp(1.5rem, 5vw, 4rem) 8rem;
  position: relative;
  line-height: 1.6;
}

#content.collection > div,
#content.collection > article {
  text-align: left;
  max-width: none;
}

/* A scrim over the animated backdrop, so long-form text stays legible.
   #content comes after the backdrop in the DOM, so at the same z-index this
   paints on top of the sketch but still behind the text. */
#content.collection::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(
    100deg,
    rgba(17, 18, 26, 0.94) 0%,
    rgba(17, 18, 26, 0.82) 45%,
    rgba(17, 18, 26, 0.5) 100%
  );
}

/* ---------------------------------------------------------------------------
   Page header
   --------------------------------------------------------------------------- */
.collection-head {
  margin-bottom: clamp(2.2rem, 5vh, 3.4rem);
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent-clr);
  margin-bottom: 1rem;
}

/* The rule runs out from the label to the edge of the column. */
.eyebrow::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--line-clr);
}

.collection h1 {
  color: var(--text-clr);
  font-size: clamp(2.1rem, 6vw, 3.3rem);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.03em;
  margin: 0 0 0.75rem;
  text-wrap: balance;
}

.collection-dek {
  color: var(--secondary-text-clr);
  font-size: clamp(0.96rem, 2.4vw, 1.08rem);
  max-width: 54ch;
  margin: 0;
}

.feed-link {
  display: inline-block;
  color: var(--accent-clr);
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid var(--line-clr);
  border-radius: 0.3em;
  padding: 0.25em 0.6em;
  margin-left: 0.6em;
  vertical-align: 0.12em;
  white-space: nowrap;
  transition: border-color 160ms ease, background 160ms ease;
}

.feed-link:hover,
.feed-link:focus-visible {
  background: var(--hover-clr);
  border-color: var(--accent-clr);
}

/* ---------------------------------------------------------------------------
   The index: one row per entry.

   Built to look deliberate at two entries as well as twenty -- rows carry
   their own rhythm, so a short list reads as curated rather than empty.
   --------------------------------------------------------------------------- */
.index-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line-clr);
}

.index-item {
  border-bottom: 1px solid var(--line-clr);
}

.index-link {
  display: flex;
  align-items: flex-start;
  gap: clamp(1rem, 3vw, 2rem);
  padding: 1.7rem 0.9rem 1.7rem 1rem;
  text-decoration: none;
  color: inherit;
  position: relative;
  transition: background 170ms ease, padding-left 170ms ease;
}

/* Accent rail that wipes in on hover. */
.index-link::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent-clr);
  transform: scaleY(0);
  transform-origin: center top;
  transition: transform 200ms ease;
}

.index-link:hover,
.index-link:focus-visible {
  background: rgba(94, 99, 255, 0.06);
  padding-left: 1.5rem;
  outline: none;
}

.index-link:hover::before,
.index-link:focus-visible::before {
  transform: scaleY(1);
}

/* Left rail: a sequence number for projects, a date for articles. Both encode
   something true -- projects are a curated order, articles are chronological. */
.index-marker {
  flex: 0 0 auto;
  min-width: 3.4rem;
  padding-top: 0.3rem;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--secondary-text-clr);
  font-variant-numeric: tabular-nums;
  opacity: 0.75;
}

.index-marker .marker-year {
  display: block;
  font-size: 0.68rem;
  opacity: 0.7;
  letter-spacing: 0.1em;
}

.index-body {
  flex: 1 1 auto;
  min-width: 0;
}

.index-title {
  color: var(--text-clr);
  font-size: clamp(1.1rem, 2.8vw, 1.32rem);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.012em;
  margin: 0 0 0.4rem;
}

.index-link:hover .index-title {
  color: var(--accent-clr);
}

.index-blurb {
  color: var(--secondary-text-clr);
  margin: 0;
  max-width: 58ch;
  font-size: 0.95rem;
}

.index-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.9rem;
  margin-top: 0.75rem;
  font-size: 0.78rem;
  color: var(--secondary-text-clr);
}

.index-thumb {
  flex: 0 0 clamp(84px, 14vw, 132px);
  align-self: center;
  border-radius: 0.4em;
  overflow: hidden;
  border: 1px solid var(--line-clr);
}

.index-thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}

.index-arrow {
  flex: 0 0 auto;
  align-self: center;
  color: var(--secondary-text-clr);
  font-size: 1.1rem;
  line-height: 1;
  transition: transform 170ms ease, color 170ms ease;
}

.index-link:hover .index-arrow {
  transform: translateX(5px);
  color: var(--accent-clr);
}

/* ---------------------------------------------------------------------------
   Tags, badges
   --------------------------------------------------------------------------- */
.tag-row {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag {
  font-size: 0.72rem;
  color: var(--secondary-text-clr);
  border: 1px solid var(--line-clr);
  border-radius: 0.3em;
  padding: 0.18em 0.55em;
  white-space: nowrap;
}

.badge {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--accent-clr);
  border: 1px solid var(--accent-clr);
  border-radius: 0.3em;
  padding: 0.18em 0.5em;
  white-space: nowrap;
}

.dot {
  opacity: 0.5;
}

/* ---------------------------------------------------------------------------
   Empty state -- reads as intentional, not broken
   --------------------------------------------------------------------------- */
.empty {
  border: 1px dashed var(--line-clr);
  border-radius: 0.5em;
  padding: 2.4rem 1.6rem;
  text-align: center;
  color: var(--secondary-text-clr);
  font-size: 0.95rem;
  margin: 0;
}

/* ---------------------------------------------------------------------------
   Single entry (project / article detail)
   --------------------------------------------------------------------------- */
.breadcrumb {
  margin: 0 0 2rem;
}

.breadcrumb a {
  color: var(--secondary-text-clr);
  text-decoration: none;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  transition: color 150ms ease;
}

.breadcrumb a:hover,
.breadcrumb a:focus-visible {
  color: var(--accent-clr);
}

.entry {
  max-width: 68ch;
}

.entry-head {
  border-bottom: 1px solid var(--line-clr);
  padding-bottom: 1.6rem;
  margin-bottom: 2rem;
}

.entry-head h1 {
  color: var(--text-clr);
  font-size: clamp(1.8rem, 5vw, 2.7rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.025em;
  margin: 0.4rem 0 0.7rem;
  text-wrap: balance;
}

.entry-dek {
  color: var(--secondary-text-clr);
  font-size: clamp(0.98rem, 2.5vw, 1.1rem);
  margin: 0 0 1rem;
}

.entry-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.7rem;
  color: var(--secondary-text-clr);
  font-size: 0.8rem;
  margin: 0;
  letter-spacing: 0.03em;
}

.entry-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin: 1.1rem 0 0;
}

.entry-links a {
  color: var(--accent-clr);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid var(--line-clr);
  border-radius: 0.35em;
  padding: 0.45em 0.9em;
  transition: border-color 150ms ease, background 150ms ease;
}

.entry-links a:hover,
.entry-links a:focus-visible {
  background: var(--hover-clr);
  border-color: var(--accent-clr);
}

.entry-links a.primary {
  background: var(--accent-clr);
  border-color: var(--accent-clr);
  color: #fff;
}

.entry-links a.primary:hover {
  filter: brightness(1.12);
  background: var(--accent-clr);
}

.entry-hero {
  display: block;
  width: 100%;
  border-radius: 0.5em;
  border: 1px solid var(--line-clr);
  margin-bottom: 2rem;
}

/* Article hero images only (not project covers, which keep the full-width
   .entry-hero above) -- sized down ~40% from the column width and centered,
   rather than left-hugging at a partial width. */
.article-hero {
  width: 60%;
  margin-left: auto;
  margin-right: auto;
}

@media (max-width: 700px) {
  /* At column widths this narrow, 60% starts looking like a thumbnail
     rather than a hero; ease back toward full width as the column shrinks. */
  .article-hero {
    width: 85%;
  }
}

/* ---------------------------------------------------------------------------
   Rendered markdown
   --------------------------------------------------------------------------- */
.prose {
  color: var(--text-clr);
  font-size: 1rem;
  line-height: 1.75;
}

.prose h2,
.prose h3,
.prose h4 {
  line-height: 1.25;
  letter-spacing: -0.015em;
  margin: 2.3rem 0 0.8rem;
}

.prose h2 {
  font-size: 1.38rem;
}

.prose h3 {
  font-size: 1.14rem;
}

.prose p,
.prose ul,
.prose ol {
  margin: 0 0 1.2rem;
}

.prose ul,
.prose ol {
  padding-left: 1.35rem;
}

.prose li {
  margin-bottom: 0.4rem;
}

.prose a {
  color: var(--accent-clr);
}

.prose blockquote {
  margin: 1.6rem 0;
  padding-left: 1.2rem;
  border-left: 2px solid var(--accent-clr);
  color: var(--secondary-text-clr);
  font-style: italic;
}

.prose code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.87em;
  background: var(--hover-clr);
  border-radius: 0.3em;
  padding: 0.12em 0.38em;
}

.prose pre {
  background: var(--hover-clr);
  border: 1px solid var(--line-clr);
  border-radius: 0.5em;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  margin: 0 0 1.4rem;
}

.prose pre code {
  background: none;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.65;
}

.prose img {
  max-width: 100%;
  border-radius: 0.4em;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.4rem;
  font-size: 0.92rem;
  display: block;
  overflow-x: auto;
}

.prose th,
.prose td {
  border: 1px solid var(--line-clr);
  padding: 0.5em 0.7em;
  text-align: left;
}

.prose th {
  background: var(--hover-clr);
}

/* ---------------------------------------------------------------------------
   Related items
   --------------------------------------------------------------------------- */
.related {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line-clr);
}

.related h2 {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--secondary-text-clr);
  margin: 0 0 0.9rem;
}

.related ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.related li {
  margin-bottom: 0.4rem;
}

.related a {
  color: var(--accent-clr);
  text-decoration: none;
}

.related a:hover {
  text-decoration: underline;
}

/* ---------------------------------------------------------------------------
   Narrow screens
   --------------------------------------------------------------------------- */
/* Matches style.css's own breakpoint, so these overrides land in the same
   range as the mobile rules they are correcting. */
@media (max-width: 800px) {
  #content.collection {
    /* style.css nudges #content down by `top: 50%` on mobile, which is meant
       for the short centred hero pages and leaves a screen of dead space above
       a list. */
    top: 0;
    margin: 0;
    /* The sidebar becomes a fixed 60px bar along the bottom on mobile; without
       this the last row scrolls underneath it. */
    padding: 2.2rem 1.25rem calc(60px + 3rem);
  }

  .index-link {
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    padding: 1.4rem 0.5rem 1.4rem 0.75rem;
  }

  .index-link:hover,
  .index-link:focus-visible {
    padding-left: 1.1rem;
  }

  .index-marker {
    min-width: 0;
    padding-top: 0;
  }

  /* The arrow is a desktop hover affordance; on touch the whole row is tappable. */
  .index-arrow {
    display: none;
  }

  .index-thumb {
    order: 3;
    flex: 1 1 100%;
    margin-top: 0.4rem;
  }

  .index-thumb img {
    aspect-ratio: 21 / 9;
  }
}

@media (prefers-reduced-motion: reduce) {
  .index-link,
  .index-link::before,
  .index-arrow,
  .feed-link,
  .entry-links a {
    transition: none;
  }
}
