/*
 * victorvalentineromo.com: internal link modules.
 * Uses the portfolio tokens from css/style.css. No new face, color, or effect.
 * Light theme ([data-theme="light"]): --cyan (#0088aa) gives 3.91:1 on --void,
 * so links use --dl-link (#00728f, 5.24:1 on --void, 4.89:1 on --depth).
 * The prefers-color-scheme light ramp in style.css sits in a layer that the
 * unlayered :root tokens override, so it never applies; this file follows suit.
 */
/* The article column is 68ch in css/articles.css. A ch unit follows the face, so
 * the column widened from 719px to 750px when Outfit replaced the fallback, and
 * every inline link moved with the text (measured layout shift). 46.875rem is
 * the 750px that 68ch of Outfit gives at the 16px root, fixed before the swap. */
.article-container:not(.hub-container) { max-width: 46.875rem; }

:root { --dl-link: var(--cyan); }
[data-theme="light"] { --dl-link: #00728f; }

.article-content a,
.dl-page-related a { color: var(--dl-link); }
.article-content a { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--dl-link) 45%, transparent); text-underline-offset: 0.18em; border-bottom: 0; }
.article-content a:hover { text-decoration-color: var(--dl-link); }

/* Shared link treatment inside modules: primary text, underlined in the accent. */
.dl-callout a,
.dl-related a,
.dl-next a,
.dl-pager a,
.dl-cluster a,
.dl-topic-map a,
.dl-breadcrumb a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in srgb, var(--dl-link) 50%, transparent);
  text-underline-offset: 0.2em;
  border-bottom: 0;
  transition: text-decoration-color 0.15s ease;
}
.dl-callout a:hover,
.dl-related a:hover,
.dl-next a:hover,
.dl-pager a:hover,
.dl-cluster a:hover,
.dl-topic-map a:hover,
.dl-breadcrumb a:hover { text-decoration-color: var(--dl-link); }
.dl-callout a:focus-visible,
.dl-related a:focus-visible,
.dl-next a:focus-visible,
.dl-pager a:focus-visible,
.dl-cluster a:focus-visible,
.dl-cluster summary:focus-visible,
.dl-topic-map a:focus-visible,
.dl-topic-map button:focus-visible,
.dl-topic-map-open:focus-visible,
.dl-breadcrumb a:focus-visible {
  outline: 2px solid var(--dl-link);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ── Topic map trigger ── */
.dl-tools { margin: 0 0 var(--space-8); }
.dl-topic-map-open {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: var(--space-2) var(--space-4);
  font: 500 0.9rem/1.3 var(--font-body);
  color: var(--text);
  background: var(--depth);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}
.dl-topic-map-open:hover { border-color: var(--dl-link); }

/* ── In-article callout ── */
.article-content .dl-callout {
  margin: var(--space-10) 0;
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--depth);
  display: grid;
  gap: var(--space-2);
}
.article-content .dl-callout-label {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-dim);
}
.article-content .dl-callout-link { font-weight: 500; line-height: 1.45; }

/* ── Related grid ── */
.dl-related { margin-top: var(--space-16); }
.dl-related-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--text);
  margin: 0 0 var(--space-6);
}
.dl-related-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: var(--space-4);
}
.dl-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--depth);
  transition: border-color 0.15s ease;
}
.dl-card:hover { border-color: var(--dl-link); }
.dl-card:focus-within { border-color: var(--dl-link); }
.dl-related .dl-card-link { font-weight: 500; line-height: 1.4; text-decoration-color: transparent; }
.dl-related .dl-card:hover .dl-card-link,
.dl-related .dl-card-link:focus-visible { text-decoration-color: var(--dl-link); }
.dl-card-link::after { content: ""; position: absolute; inset: 0; border-radius: 12px; }
.dl-card-text { margin: 0; font-size: 0.875rem; line-height: 1.5; color: var(--text-muted); }
.dl-card-cluster { margin: auto 0 0; font-size: 0.78rem; color: var(--text-dim); }

/* ── Previous and next in the cluster ── */
.dl-pager {
  margin-top: var(--space-12);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}
.dl-pager .dl-pager-link {
  display: flex;
  flex-direction: column;
  gap: var(--space-1, 0.25rem);
  padding: var(--space-4) 0;
  border-top: 1px solid var(--border);
  font-weight: 500;
  line-height: 1.4;
}
.dl-pager .dl-pager-next { text-align: right; }
.dl-pager-dir { font-size: 0.8rem; font-weight: 400; color: var(--text-dim); text-decoration: none; display: block; }
@media (max-width: 560px) {
  .dl-pager { grid-template-columns: 1fr; }
  .dl-pager .dl-pager-next { text-align: left; }
}

/* ── Next step ── */
.dl-next {
  margin-top: var(--space-10);
  padding: var(--space-6) var(--space-8);
  border-radius: 16px;
  border: 1px solid var(--edge);
  background: var(--surface);
}
.dl-next-label { margin: 0 0 var(--space-2); font-size: 0.8rem; font-weight: 500; color: var(--text-dim); }
.dl-next .dl-next-link {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 500;
  line-height: 1.3;
}
.dl-next-text { margin: var(--space-2) 0 0; color: var(--text-secondary); font-size: 0.95rem; line-height: 1.6; }
/* Inside the existing CTA card the next step is one more line, set off by a
 * rule, so the article ends with one portfolio card, not two stacked cards. */
.article-cta .dl-next-inline {
  margin: var(--space-6) 0 0;
  padding-top: var(--space-5);
  border-top: 1px solid var(--edge);
}
.dl-next-inline .dl-next-label { display: block; margin: 0 0 var(--space-2); }
.dl-next-inline .dl-next-link {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1.3;
}
.dl-next-inline .dl-next-text { display: block; }
/* The CTA card links use --dl-link: cyan on the dark theme, #00728f on the light theme. */
.article-cta a { color: var(--dl-link); }

/* ── Cluster navigation: after the article on phones, a sidebar on desktop ── */
.dl-cluster {
  max-width: 46.875rem;
  margin: var(--space-12) auto 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--depth);
}
.dl-cluster-summary {
  cursor: pointer;
  padding: var(--space-4) var(--space-5);
  min-height: 44px;
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text);
}
.dl-cluster-count { display: block; font-family: var(--font-body); font-size: 0.8rem; font-weight: 400; color: var(--text-dim); }
.dl-cluster-list {
  list-style: none;
  margin: 0;
  padding: 0 var(--space-5) var(--space-5);
  display: grid;
  gap: var(--space-2);
  font-size: 0.875rem;
  line-height: 1.45;
}
.dl-cluster .dl-cluster-list a,
.dl-topic-map .dl-cluster-list a { color: var(--text-secondary); text-decoration-color: transparent; }
.dl-cluster .dl-cluster-list a:hover,
.dl-topic-map .dl-cluster-list a:hover { text-decoration-color: var(--dl-link); }
.dl-cluster .dl-cluster-list a[aria-current="page"],
.dl-topic-map .dl-cluster-list a[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
  text-decoration-color: var(--dl-link);
}
@supports selector(::details-content) {
  @media (min-width: 76rem) {
    .article-main:has(> .dl-cluster) {
      display: grid;
      grid-template-columns: minmax(14rem, 17rem) minmax(0, 46.875rem);
      justify-content: center;
      column-gap: var(--space-12);
      align-items: start;
    }
    .article-main:has(> .dl-cluster) > .article-container { grid-column: 2; grid-row: 1; margin: 0; }
    .article-main > .dl-cluster {
      grid-column: 1;
      grid-row: 1;
      position: sticky;
      top: 5rem;
      margin: 0;
      max-height: calc(100vh - 6rem);
      overflow-y: auto;
      overscroll-behavior: contain;
    }
    .dl-cluster-details::details-content { content-visibility: visible; display: block; }
    .dl-cluster-summary { list-style: none; cursor: default; }
    .dl-cluster-summary::-webkit-details-marker { display: none; }
  }
}

/* ── Topic map dialog (opens only from its button) ── */
.dl-topic-map {
  margin: auto;
  width: min(60rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--void);
  color: var(--text);
  overflow: auto;
  overscroll-behavior: contain;
}
.dl-topic-map::backdrop { background: rgb(5 6 12 / 0.72); }
.dl-topic-map-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-6);
  background: var(--void);
  border-bottom: 1px solid var(--border);
}
.dl-topic-map-title { margin: 0; font-family: var(--font-heading); font-size: 1.35rem; font-weight: 500; color: var(--text); }
.dl-topic-map-close {
  flex-shrink: 0;
  min-height: 44px;
  min-width: 44px;
  padding: var(--space-2) var(--space-4);
  font: 500 0.9rem/1 var(--font-body);
  color: var(--text);
  background: var(--depth);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.dl-topic-map-intro { margin: var(--space-4) var(--space-6) 0; color: var(--text-secondary); font-size: 0.95rem; }
.dl-topic-map-group { margin: var(--space-6) var(--space-6) var(--space-3); font-size: 1rem; font-weight: 600; color: var(--text); }
.dl-topic-map .dl-cluster-list { padding: 0 var(--space-6); columns: 2 18rem; column-gap: var(--space-8); display: block; }
.dl-topic-map .dl-cluster-list li { break-inside: avoid; margin-bottom: var(--space-2); }
.dl-topic-map .dl-cluster-list:last-child { padding-bottom: var(--space-6); }

/* ── Breadcrumb on pages without one ── */
.dl-breadcrumb { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-4); font-size: 0.85rem; color: var(--text-dim); }
.dl-breadcrumb-article { margin-bottom: var(--space-6); }

/* ── Writing grid on the portfolio pages ── */
.dl-page-related { padding-bottom: var(--space-16); }
.dl-page-related .dl-related { margin-top: 0; padding-block: 0; }
.dl-page-related .dl-related-title { font-size: clamp(1.5rem, 3vw, 2rem); }
@media (min-width: 64rem) {
  .dl-page-related .dl-related-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .dl-card, .dl-callout a, .dl-related a, .dl-next a, .dl-pager a, .dl-cluster a, .dl-topic-map a { transition: none; }
}

/* Running-text links on the portfolio pages and breadcrumb crumbs carry an
 * underline, so they are not told apart by color alone (axe link-in-text-block). */
main p a:not([class]),
main li a:not([class]),
.article-breadcrumb a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in srgb, currentColor 45%, transparent);
  text-underline-offset: 0.2em;
}
