/* ============================================================
   components.css — uses tokens from base.css.
   ============================================================ */

/* ---------- Lede ---------- */
.lede {
  color: var(--fg);
  font-size: var(--t-lede);
  line-height: var(--lh-relaxed);
  margin-top: 1rem;
  max-width: var(--measure);
}

/* ---------- Colour helpers ---------- */
.muted { color: var(--muted); }

/* ---------- Mono — used for dates, labels, metadata ---------- */
.mono {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  font-feature-settings: "ss02";
  letter-spacing: 0;
}

/* ---------- Entries list (home, project index, blog index) ---------- */
.entries {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  margin: 0.5rem -0.75rem 0;
}

.entries li {
  display: grid;
  grid-template-columns: 4.75rem 1fr auto;
  grid-template-areas: "date title tag";
  align-items: baseline;
  column-gap: 0.75rem;
  row-gap: 0.25rem;
  padding: 0.375rem 0.75rem;
  border-radius: var(--r-md);
  color: var(--fg);
  font-size: var(--t-base);
  line-height: 1.5;
  transition: background-color var(--dur) var(--ease);
}

.entries li:has(a):hover { background: var(--surface-sunken); }

.entries .date {
  grid-area: date;
  color: var(--subtle);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.entries .title {
  grid-area: title;
  min-width: 0;
}

.entries .title a,
.entries .title > span {
  border-bottom: 0;
}

.entries .title a[target="_blank"]::after {
  content: "";
  display: inline-block;
  width: 0.7em;
  height: 0.7em;
  margin-left: 0.3em;
  vertical-align: baseline;
  background-color: currentColor;
  opacity: 0.5;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><line x1='7' y1='17' x2='17' y2='7'/><polyline points='7 7 17 7 17 17'/></svg>") center / contain no-repeat;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><line x1='7' y1='17' x2='17' y2='7'/><polyline points='7 7 17 7 17 17'/></svg>") center / contain no-repeat;
  transition: opacity var(--dur) var(--ease);
}

.entries .title a[target="_blank"]:hover::after {
  opacity: 1;
}

.entries .tag {
  grid-area: tag;
  display: inline-block;
  padding: 0.0625rem 0.5rem;
  border: 1px solid var(--rule);
  border-radius: var(--r-full);
  background: var(--bg);
  color: var(--muted);
  white-space: nowrap;
  font-family: var(--font-mono);
  font-feature-settings: "ss02";
  font-size: var(--t-pill);
  line-height: 1.4;
}

@media (max-width: 520px) {
  .entries { gap: 0.75rem; }
  .entries li {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "date tag"
      "title title";
    row-gap: 0.375rem;
    padding: 0.5rem 0.75rem;
  }
  .entries .tag { justify-self: end; }
}

/* ---------- Search input ---------- */
.search {
  width: 100%;
  margin-top: 2rem;
  padding: 0.5rem 0 0.5rem 1.375rem;
  font: inherit;
  font-size: var(--t-sm);
  color: var(--fg);
  background: transparent url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23a8a49e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>") left center no-repeat;
  border: 0;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  outline: none;
  transition: border-color var(--dur) var(--ease);
}

.search::placeholder { color: var(--subtle); }
.search:focus { border-bottom-color: var(--fg); }
.search::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23a8a49e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><line x1='18' y1='6' x2='6' y2='18'/><line x1='6' y1='6' x2='18' y2='18'/></svg>") center no-repeat;
  opacity: 0.6;
  cursor: pointer;
  transition: opacity var(--dur) var(--ease);
}
.search::-webkit-search-cancel-button:hover { opacity: 1; }

/* ---------- Card grid (Tools) ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 0.625rem;
}

.tool-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.25rem;
  min-height: 7rem;
  padding: 1rem 1.125rem;
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  background: var(--bg);
  color: var(--fg);
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.tool-card:hover {
  background: var(--surface);
  border-color: #ddd9d3;
}

.tool-card__name {
  font-size: var(--t-base);
  font-weight: var(--w-medium);
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.tool-card__tag {
  font-family: var(--font-mono);
  font-size: var(--t-pill);
  color: var(--subtle);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1;
}

/* ---------- Back link ---------- */
.back {
  display: inline-block;
  color: var(--muted);
  font-size: var(--t-sm);
  border: 0;
  margin-bottom: 3rem;
}

.back:hover { color: var(--fg); border: 0; }

/* ---------- Related posts / end-of-article CTA ---------- */
.related {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
}

.related__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.related__label {
  margin: 0;
  font-size: var(--t-xs);
  font-family: var(--font-mono);
  font-weight: var(--w-regular);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--subtle);
}

.related__all {
  color: var(--muted);
  font-size: var(--t-sm);
  border: 0;
  transition: color var(--dur) var(--ease);
}

.related__all:hover { color: var(--fg); border: 0; }

.related__grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.related__card {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 0.875rem 1rem;
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  background: var(--bg);
  color: var(--fg);
  transition:
    background-color var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}

.related__card:hover {
  background: var(--surface);
  border-color: #ddd9d3;
  transform: translateY(-1px);
  border-bottom: 1px solid #ddd9d3;
}

.related__date {
  color: var(--subtle);
  font-variant-numeric: tabular-nums;
}

.related__title {
  font-size: var(--t-base);
  font-weight: var(--w-medium);
  line-height: 1.4;
  color: var(--fg);
}

/* ---------- Page head (blog post) ---------- */
.page-head .date-line {
  display: block;
  color: var(--subtle);
  font-size: var(--t-xs);
  font-family: var(--font-mono);
  margin-bottom: 0.75rem;
}

.post-subtitle {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: var(--t-base);
  line-height: var(--lh-relaxed);
}

/* ============================================================
   Prose — rendered WP post body
   ============================================================ */

.prose p {
  margin-bottom: 1.25rem;
  color: var(--fg);
  font-size: var(--t-base);
  line-height: var(--lh-body);
}

.prose h2 { margin-top: 2.5rem; margin-bottom: 1rem; }
.prose h3 { margin-top: 2rem;   margin-bottom: 0.5rem; }

.prose ul, .prose ol {
  padding-left: 1.25rem;
  margin-bottom: 1.25rem;
  color: var(--fg);
  font-size: var(--t-base);
}

.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose li { margin-bottom: 0.5rem; line-height: var(--lh-body); }

.prose img,
.prose video,
.prose iframe {
  max-width: 100%;
  height: auto;
  border-radius: var(--r-sm);
}

.prose figure { margin: 1.5rem 0; }
.prose figcaption {
  margin-top: 0.5rem;
  color: var(--subtle);
  font-size: var(--t-xs);
  font-family: var(--font-mono);
}

.prose a { border-bottom: 1px solid var(--rule); }
.prose a:hover { border-bottom-color: var(--fg); }

.prose blockquote {
  color: var(--muted);
  padding-left: 1.25rem;
  border-left: 2px solid var(--rule);
  margin: 1.5rem 0;
  font-size: var(--t-base);
}

.prose pre,
.prose code {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
}

.prose pre {
  position: relative;
  overflow: auto;
  max-height: 28rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border-radius: var(--r-sm);
  margin-bottom: 1.25rem;
  line-height: 1.5;
  scrollbar-width: thin;
  scrollbar-color: var(--subtle) transparent;
}
.prose pre::-webkit-scrollbar { width: 8px; height: 8px; }
.prose pre::-webkit-scrollbar-thumb {
  background: var(--subtle);
  border-radius: var(--r-full);
}
.prose pre::-webkit-scrollbar-track { background: transparent; }

.prose pre .copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  color: var(--subtle);
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  cursor: pointer;
  opacity: 0.4;
  transition: opacity var(--dur) var(--ease), color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}

.prose pre .copy-btn svg { width: 14px; height: 14px; display: block; }
.prose pre:hover .copy-btn,
.prose pre .copy-btn:focus-visible { opacity: 1; }
.prose pre .copy-btn:hover { color: var(--fg); background: var(--bg); }
.prose pre .copy-btn[data-copied] { color: var(--fg); opacity: 1; }

.prose :not(pre) > code {
  background: var(--surface-sunken);
  padding: 1px 5px;
  border-radius: 3px;
}

/* ---------- Tables ---------- */
.prose table {
  width: 100%;
  margin: 1.5rem 0;
  border-collapse: collapse;
  font-size: var(--t-sm);
  line-height: 1.5;
}

.prose thead th {
  text-align: left;
  font-weight: var(--w-medium);
  color: var(--muted);
  font-size: var(--t-xs);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--rule);
}

.prose tbody td,
.prose tbody th {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--rule);
  color: var(--fg);
  vertical-align: top;
  text-align: left;
  font-weight: var(--w-regular);
}

.prose tbody tr:last-child td,
.prose tbody tr:last-child th { border-bottom: 0; }

.prose table code { font-size: 0.8em; }

.prose figure:has(> table) {
  margin: 1.5rem 0;
  overflow-x: auto;
}

.prose figure:has(> table) > table { margin: 0; }

.prose figure:has(> table) > figcaption {
  text-align: left;
}

/* ---------- Alerts ---------- */
.prose .alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin: 1.5rem 0;
  padding: 0.875rem 1rem;
  border: 1px solid var(--rule);
  border-left-width: 3px;
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: var(--t-sm);
  line-height: var(--lh-relaxed);
}

.prose .alert svg {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin-top: 0.15rem;
}

.prose .alert p {
  margin: 0;
  font-size: var(--t-sm);
  line-height: var(--lh-relaxed);
  color: var(--fg);
}

.prose .alert p + p { margin-top: 0.5rem; }

.prose .alert--info    { border-left-color: var(--info); background: var(--info-bg); }
.prose .alert--info svg    { color: var(--info); }

.prose .alert--warning { border-left-color: var(--warn); background: var(--warn-bg); }
.prose .alert--warning svg { color: var(--warn); }
