/* MyST Theme Options */

:root {
  --cite-group-open: '[';
  --cite-group-close: ']';
}

/* User Provided Stylesheet */

/* Underworld Technical Notes — site styling.
 *
 * The aim is that the site and the archival PDF look like the same
 * publication. The PDF sets its body in a serif with small-caps labels in a
 * muted blue down the margin; the site borrows that vocabulary rather than
 * inventing a second identity. Anything here that is merely decorative should
 * be removed instead of elaborated.
 */

:root {
  --uwtn-ink: #16202b;
  --uwtn-muted: #5d6b7a;
  --uwtn-rule: #dfe4ea;
  --uwtn-accent: #1a4f80;        /* the PDF's theme colour, blue.darken(30%) */
  --uwtn-paper: #ffffff;
  --uwtn-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
                "Times New Roman", serif;
  --uwtn-sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --uwtn-ink: #e6e9ec;
    --uwtn-muted: #9aa7b4;
    --uwtn-rule: #2b3541;
    --uwtn-accent: #7cb3e0;
    --uwtn-paper: #131a21;
  }
}

/* ---- masthead ---------------------------------------------------------- */

.uwtn-masthead {
  border-bottom: 1px solid var(--uwtn-rule);
  padding-bottom: 1.6rem;
  margin-bottom: 2.4rem;
}

.uwtn-kicker {
  font-family: var(--uwtn-sans);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--uwtn-accent);
  margin: 0 0 0.15rem;
}

.uwtn-wordmark {
  font-family: var(--uwtn-serif);
  font-weight: 600;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--uwtn-ink);
  margin: 0 0 0.7rem;
}

.uwtn-standfirst {
  font-family: var(--uwtn-serif);
  font-size: 1.05rem;
  line-height: 1.55;
  color: var(--uwtn-muted);
  max-width: 34em;
  margin: 0;
}

/* ---- the feed ---------------------------------------------------------- */

/* MyST strips <article>, <p class> and <time>, so entries are divs. The title
   stays a real heading but loses its class -- hence the descendant selector. */
.uwtn-entry {
  border-top: 1px solid var(--uwtn-rule);
  padding: 1.5rem 0 1.4rem;
}

.uwtn-entry:first-child {
  border-top: none;
  padding-top: 0;
}

/* Article id and date, echoing the identity strip down the PDF's margin. */
.uwtn-entry-meta,
.uwtn-kicker {
  font-family: var(--uwtn-sans);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--uwtn-muted);
  margin: 0 0 0.35rem;
  display: flex;
  gap: 0.9rem;
}

.uwtn-id { color: var(--uwtn-accent); font-weight: 600; }

.uwtn-entry :is(h1, h2, h3, h4) {
  font-family: var(--uwtn-serif);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 0.3rem;
}

/* The theme's hover anchor (¶) belongs on documentation, not on a feed. */
.uwtn-entry :is(h1, h2, h3, h4) > a[href^="#"] { display: none; }

.uwtn-entry :is(h1, h2, h3, h4) a {
  color: var(--uwtn-ink);
  text-decoration: none;
  background-image: linear-gradient(var(--uwtn-accent), var(--uwtn-accent));
  background-size: 0% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size 0.18s ease;
}

.uwtn-entry :is(h1, h2, h3, h4) a:hover { background-size: 100% 1px; }

.uwtn-entry-byline {
  font-family: var(--uwtn-sans);
  font-size: 0.82rem;
  color: var(--uwtn-muted);
  margin: 0 0 0.55rem;
}

.uwtn-entry-summary {
  font-family: var(--uwtn-serif);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--uwtn-ink);
  max-width: 38em;
  margin: 0 0 0.7rem;
}

/* ---- affordances ------------------------------------------------------- */

.uwtn-entry-links {
  font-family: var(--uwtn-sans);
  font-size: 0.8rem;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem;
  align-items: baseline;
}

.uwtn-entry-links a {
  color: var(--uwtn-accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.uwtn-entry-links a:hover { border-bottom-color: currentColor; }

.uwtn-read::after { content: " →"; }

/* The DOI is the published identifier, so it is shown in full rather than
   hidden behind a word. */
.uwtn-doi-label {
  font-size: 0.64rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--uwtn-muted);
  margin-right: 0.35em;
}

.uwtn-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0;
  margin: 0.7rem 0 0;
}

.uwtn-tag {
  font-family: var(--uwtn-sans);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--uwtn-muted);
  border: 1px solid var(--uwtn-rule);
  border-radius: 2px;
  padding: 0.1rem 0.45rem;
}

.uwtn-colophon {
  border-top: 1px solid var(--uwtn-rule);
  margin-top: 2.4rem;
  padding-top: 1.2rem;
  font-family: var(--uwtn-sans);
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--uwtn-muted);
  max-width: 38em;
}

/* ---- article pages ----------------------------------------------------- */

/* Give the body the same serif as the PDF, so an article reads as the same
   document in a different medium. Code and maths keep the theme's fonts. */
.uwtn-article-body,
article.content p,
article.content li,
article.content blockquote {
  font-family: var(--uwtn-serif);
  font-size: 1.02rem;
  line-height: 1.62;
}

article.content h1,
article.content h2,
article.content h3 {
  font-family: var(--uwtn-serif);
  letter-spacing: -0.005em;
}

/* Captions read as apparatus, matching the PDF: sans, smaller, lighter. */
article.content figcaption,
article.content figcaption p {
  font-family: var(--uwtn-sans);
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--uwtn-muted);
}

@media (max-width: 640px) {
  .uwtn-entry-meta { flex-direction: column; gap: 0.1rem; }
  .uwtn-entry-title { font-size: 1.3rem; }
}

/* ---- year rules -------------------------------------------------------- */

/* The feed is grouped the way the article ids are, by year. If the series ever
   adopts volumes this label is where that happens. */
.uwtn-year {
  font-family: var(--uwtn-sans);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--uwtn-muted);
  margin: 2.4rem 0 0.9rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid var(--uwtn-ink);
}

.uwtn-year:first-child { margin-top: 0; }
.uwtn-year + .uwtn-entry { border-top: none; padding-top: 0.2rem; }

/* ---- the lead item ----------------------------------------------------- */

.uwtn-lead {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 1.6rem;
  align-items: start;
}

.uwtn-lead .uwtn-thumb { order: 2; }
.uwtn-lead .uwtn-entry-text { order: 1; }

.uwtn-lead :is(h1, h2, h3, h4) { font-size: 2rem; line-height: 1.12; }
.uwtn-lead .uwtn-entry-summary { font-size: 1.08rem; }

.uwtn-thumb {
  display: block;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--uwtn-rule);
}

.uwtn-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 260px;
  object-fit: cover;
  /* Decorative, so it should not compete with the words. */
  filter: saturate(0.82);
  transition: filter 0.25s ease, transform 0.4s ease;
}

.uwtn-thumb:hover img { filter: saturate(1); transform: scale(1.02); }

/* ---- article banner ---------------------------------------------------- */

/* Kept from the Ghost posts, and only on the web: the banner is a raw HTML
   block, which the HTML build renders and the Typst build drops, so the
   archival PDF stays free of decoration. */
.uwtn-banner {
  margin: 0 0 2rem;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--uwtn-rule);
}

.uwtn-banner img {
  display: block;
  width: 100%;
  max-height: 300px;
  object-fit: cover;
}

@media (max-width: 720px) {
  .uwtn-lead { grid-template-columns: 1fr; gap: 1rem; }
  .uwtn-lead .uwtn-thumb { order: 1; }
  .uwtn-lead .uwtn-entry-text { order: 2; }
  .uwtn-lead :is(h1, h2, h3, h4) { font-size: 1.5rem; }
  .uwtn-banner img { max-height: 180px; }
}

/* ---- image credit ------------------------------------------------------ */

/* Unsplash's licence asks for attribution wherever the photograph appears.
   It sits on the image rather than beside it, so it credits without competing
   with the article, and is always reachable — revealed on hover, and on focus
   for anyone navigating by keyboard. */
.uwtn-banner { position: relative; }

.uwtn-credit {
  position: absolute;
  right: 0;
  bottom: 0;
  max-width: 100%;
  padding: 0.3rem 0.6rem;
  font-family: var(--uwtn-sans);
  font-size: 0.66rem;
  line-height: 1.4;
  color: #fff;
  background: rgba(12, 18, 24, 0.72);
  backdrop-filter: blur(3px);
  border-top-left-radius: 3px;
  opacity: 0;
  transform: translateY(0.3rem);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.uwtn-banner:hover .uwtn-credit,
.uwtn-banner:focus-within .uwtn-credit { opacity: 1; transform: none; }

.uwtn-credit a { color: #fff; text-decoration: underline; text-underline-offset: 2px; }

/* Touch devices have no hover, so the credit is simply always shown. */
@media (hover: none) {
  .uwtn-credit { opacity: 1; transform: none; position: static; background: none;
                 color: var(--uwtn-muted); padding: 0.4rem 0 0; }
  .uwtn-credit a { color: var(--uwtn-accent); }
}

/* ---- topics ------------------------------------------------------------ */

a.uwtn-tag { text-decoration: none; transition: border-color 0.15s ease, color 0.15s ease; }
a.uwtn-tag:hover { color: var(--uwtn-accent); border-color: var(--uwtn-accent); }

.uwtn-topic-head { border-bottom: 1px solid var(--uwtn-rule);
                   padding-bottom: 1.2rem; margin-bottom: 2rem; }
.uwtn-topic-head .uwtn-wordmark { font-size: clamp(1.6rem, 4vw, 2.2rem); }

.uwtn-topic-list { display: flex; flex-wrap: wrap; gap: 0.6rem; }

.uwtn-topic-link {
  font-family: var(--uwtn-sans);
  font-size: 0.9rem;
  color: var(--uwtn-ink);
  text-decoration: none;
  border: 1px solid var(--uwtn-rule);
  border-radius: 3px;
  padding: 0.45rem 0.8rem;
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
}

.uwtn-topic-link:hover { border-color: var(--uwtn-accent); color: var(--uwtn-accent); }

.uwtn-topic-count {
  font-size: 0.7rem;
  color: var(--uwtn-muted);
  font-variant-numeric: tabular-nums;
}

/* The searchable query token on a topic page. Visible on purpose: it tells the
   reader the query exists, which hidden text cannot, and it is what the search
   index is built from. */
.uwtn-query {
  font-family: var(--uwtn-sans);
  font-size: 0.75rem;
  color: var(--uwtn-muted);
  margin-top: 0.6rem;
}

.uwtn-query code {
  font-size: 0.75rem;
  background: var(--uwtn-rule);
  border-radius: 2px;
  padding: 0.1rem 0.35rem;
  color: var(--uwtn-ink);
}

/* Facets the series has not covered yet. Shown rather than hidden: an empty
   subject is a statement about the corpus, not an oversight. */
.uwtn-axis { margin-bottom: 2rem; }

.uwtn-unused {
  font-family: var(--uwtn-sans);
  font-size: 0.72rem;
  color: var(--uwtn-muted);
  margin-top: 0.7rem;
}

/* ---- baked bibliography ------------------------------------------------ */

/* Rendered from Zotero at build time rather than fetched by client script, so
   it is present without JavaScript, when Zotero is down, and in the archive. */
.uwtn-bibliography { margin-top: 1.4rem; }

.uwtn-ref {
  font-family: var(--uwtn-serif);
  font-size: 0.94rem;
  line-height: 1.5;
  color: var(--uwtn-ink);
  padding: 0.55rem 0 0.55rem 1.4rem;
  text-indent: -1.4rem;          /* hanging indent, as a reference list wants */
  border-bottom: 1px solid var(--uwtn-rule);
  max-width: 42em;
}

.uwtn-ref:last-child { border-bottom: none; }
.uwtn-ref a { color: var(--uwtn-accent); text-decoration: none; }
.uwtn-ref a:hover { text-decoration: underline; }

/* ---- discussion -------------------------------------------------------- */

.uwtn-discuss {
  margin-top: 3rem;
  padding: 1.3rem 1.4rem;
  border: 1px solid var(--uwtn-rule);
  border-radius: 3px;
  font-family: var(--uwtn-sans);
}

.uwtn-discuss-head {
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--uwtn-accent);
  margin-bottom: 0.45rem;
}

.uwtn-discuss-body {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--uwtn-muted);
  max-width: 42em;
  margin-bottom: 0.9rem;
}

.uwtn-discuss-links { display: flex; flex-wrap: wrap; gap: 1.4rem; font-size: 0.85rem; }
.uwtn-discuss-links a { color: var(--uwtn-accent); text-decoration: none; }
.uwtn-discuss-links a:hover { text-decoration: underline; }
.uwtn-discuss-links a::after { content: " →"; }

/* A DOI on a listing is an identifier, shown rather than linked -- see
   scripts/build_index.py for why. */
.uwtn-doi { color: var(--uwtn-muted); font-variant-numeric: tabular-nums; }

/* ---- comments ---------------------------------------------------------- */

/* Giscus's script inserts its own frame here, sized by its own postMessage
   resizing -- there is no MyST iframe wrapper to fight. The block sits above
   the discussion links, which remain as the fallback. */
.uwtn-comments {
  margin-top: 2.5rem;
}

.uwtn-comments iframe { border: none; width: 100%; }


/* ---- front page -------------------------------------------------------- */

/* The front page is Underworld's own, not the series'. It leads with the
   software and what it is for; the Technical Notes are one thing among
   several, reached from the header. The masthead above is reserved for
   /notes/, so that the two pages are visibly different publications. */

.uwtn-hero {
  border-bottom: 1px solid var(--uwtn-rule);
  padding-bottom: 1.8rem;
  margin-bottom: 2rem;
}

.uwtn-hero-title {
  font-family: var(--uwtn-serif);
  font-weight: 600;
  font-size: clamp(2.4rem, 7vw, 4rem);
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--uwtn-ink);
  margin: 0 0 0.8rem;
}

.uwtn-hero .uwtn-standfirst { font-size: 1.15rem; max-width: 36em; }

.uwtn-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.4rem;
  align-items: center;
  margin-top: 1.4rem;
  font-family: var(--uwtn-sans);
  font-size: 0.9rem;
}

.uwtn-hero-actions a { color: var(--uwtn-accent); text-decoration: none; }
.uwtn-hero-actions a:hover { text-decoration: underline; }

.uwtn-cta {
  background: var(--uwtn-accent);
  color: var(--uwtn-paper) !important;
  padding: 0.5rem 1.1rem;
  border-radius: 3px;
  font-weight: 600;
}
.uwtn-cta:hover { filter: brightness(1.12); text-decoration: none !important; }

/* Three recent notes, as a pointer into the series rather than a feed of it.
   Deliberately terser than .uwtn-entry: this is a signpost, not the contents. */
.uwtn-briefs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1.2rem;
  margin: 1.6rem 0 2.4rem;
}

.uwtn-brief {
  display: block;
  border-top: 2px solid var(--uwtn-accent);
  padding-top: 0.7rem;
  text-decoration: none;
  color: inherit;
}
.uwtn-brief:hover .uwtn-brief-title { text-decoration: underline; }

.uwtn-brief-id {
  display: block;
  font-family: var(--uwtn-sans);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--uwtn-accent);
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.uwtn-brief-title {
  display: block;
  font-family: var(--uwtn-serif);
  font-size: 1.08rem;
  line-height: 1.25;
  color: var(--uwtn-ink);
  margin-bottom: 0.35rem;
}

.uwtn-brief-summary {
  display: block;
  font-family: var(--uwtn-serif);
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--uwtn-muted);
}

/* Section headings on the front page.
 *
 * A div, not a markdown heading. The theme nests headings several levels
 * inside <main>, so a selector aimed at them either misses -- as `main > h2`
 * did -- or has to reach through the template's own classes and breaks the
 * next time they change. The outline is hidden on this page, so nothing is
 * lost by not making these real headings. */
.uwtn-section {
  font-family: var(--uwtn-serif);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--uwtn-ink);
  border-top: 1px solid var(--uwtn-rule);
  padding-top: 1.6rem;
  margin: 2.6rem 0 0.4rem;
}

.uwtn-section-note {
  font-family: var(--uwtn-serif);
  color: var(--uwtn-muted);
  margin: 0 0 1.2rem;
}
