/* =========================================================
   Document viewer, photo lightbox, gallery, articles and
   publication links. Colours come from theme.css.
   ========================================================= */

body.dv-open { overflow: hidden; }

/* ---------- Links under the bio ---------- */
.link-row { display: flex; flex-wrap: wrap; gap: 14px 28px; }

/* ---------- Publication extras ---------- */
.pub.no-link:hover { padding-left: 0; }
.pub-links { position: relative; z-index: 2; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px !important; }
.pub-tag {
  display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: .7rem; letter-spacing: .04em;
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--rule); color: var(--ink-2); text-decoration: none; background: var(--card);
}
a.pub-tag:hover { border-color: var(--ink); color: var(--ink); }
.pub-tag svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pub .pub-links > span.pub-tag { border-color: color-mix(in srgb, var(--l2) 45%, var(--rule)); color: var(--l2); }
.pub.extra { display: none; }
.pubs.expanded .pub.extra, .pubs.filtered .pub.extra { display: grid; }
.pubs .pub[hidden] { display: none !important; }
.show-all { margin-top: 24px; }
.pubs.filtered ~ .show-all { display: none; }

/* ---------- Articles ---------- */
.article-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.article-grid a {
  display: grid; grid-template-rows: auto 1fr auto; gap: 14px; height: 100%; padding: 24px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--rule); text-decoration: none; transition: transform .25s, border-color .25s, box-shadow .25s;
}
.article-grid a:hover { transform: translateY(-3px); border-color: var(--l1); box-shadow: 0 18px 40px -28px rgba(15, 27, 45, .4); }
.a-no { font-family: var(--mono); font-size: .75rem; color: var(--l1); }
.article-grid h3 { font-family: var(--serif); font-size: 1.2rem; line-height: 1.3; }
.a-src { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.a-src svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Gallery ---------- */
.photo-grid { columns: 3 260px; column-gap: 14px; }
.photo { break-inside: avoid; margin: 0 0 14px; position: relative; border-radius: var(--radius); overflow: hidden; background: var(--paper-2); }
.photo[hidden] { display: none; }
.photo button { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.photo img { width: 100%; height: auto; transition: transform .5s ease; }
.photo:hover img { transform: scale(1.04); }
.photo figcaption {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 36px 14px 12px; font-size: .82rem; line-height: 1.35; color: #fff;
  background: linear-gradient(transparent, rgba(6, 12, 21, .85)); opacity: 0; transform: translateY(6px); transition: all .3s; pointer-events: none;
}
.photo:hover figcaption, .photo:focus-within figcaption { opacity: 1; transform: none; }
@media (hover: none) { .photo figcaption { opacity: 1; transform: none; font-size: .76rem; } }

/* ---------- Lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 200; background: rgba(6, 12, 21, .94); display: grid; grid-template-columns: 64px 1fr 64px; align-items: center; }
.lightbox[hidden] { display: none; }
.lightbox figure { margin: 0; display: grid; justify-items: center; gap: 14px; max-height: 100vh; padding: 56px 0 24px; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 150px); object-fit: contain; border-radius: 8px; }
.lightbox figcaption { color: #e9e4da; text-align: center; font-size: .92rem; max-width: 70ch; display: grid; gap: 6px; padding: 0 12px; }
.lb-count { font-family: var(--mono); font-size: .72rem; opacity: .6; }
.lightbox button { background: none; border: 0; color: #fff; cursor: pointer; }
.lb-nav { font-size: 2.6rem; height: 100%; opacity: .7; }
.lb-nav:hover { opacity: 1; }
.lb-close { position: absolute; top: 10px; right: 14px; font-size: 2rem; width: 48px; height: 48px; opacity: .8; }
@media (max-width: 640px) {
  .lightbox { grid-template-columns: 0 1fr 0; }
  .lb-nav { position: absolute; bottom: 10px; height: 48px; width: 64px; }
  .lb-prev { left: 8px; } .lb-next { right: 8px; }
}

/* ---------- Document viewer ---------- */
.docviewer { position: fixed; inset: 0; z-index: 200; display: grid; grid-template-rows: auto minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); background: #1d2633; }
.docviewer[hidden] { display: none; }
.dv-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--deep); color: var(--deep-ink); border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.dv-title { min-width: 0; flex: 1 1 260px; }
.dv-title small { display: block; font-family: var(--mono); font-size: .66rem; letter-spacing: .12em; text-transform: uppercase; color: var(--l1); }
.dv-title strong { display: block; font-family: var(--serif); font-weight: 500; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dv-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dv-group { display: inline-flex; align-items: center; border: 1px solid rgba(255, 255, 255, .18); border-radius: 999px; }
.dv-controls button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; min-width: 36px; height: 36px; padding: 0 10px; border-radius: 999px; font-size: 1.05rem; }
.dv-controls button:hover { background: rgba(255, 255, 255, .1); }
.dv-page, .dv-zoom { font-family: var(--mono); font-size: .78rem !important; padding: 0 6px; }
.dv-link { border: 1px solid rgba(255, 255, 255, .18) !important; font-size: .82rem !important; }
.dv-close { font-size: 1.6rem !important; }
.dv-body { overflow: auto; position: relative; padding: 16px; outline: none; }
.dv-pages { display: grid; justify-items: center; gap: 16px; padding-bottom: 40px; }
.dv-page-wrap { background: #fff; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); max-width: none; user-select: none; }
.dv-page-wrap canvas { display: block; }
.dv-status { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: #d7dbe2; padding: 24px; line-height: 1.7; pointer-events: none; }
.dv-status[hidden] { display: none; }
.dv-status code { background: rgba(255, 255, 255, .1); padding: 2px 6px; border-radius: 4px; font-family: var(--mono); font-size: .85em; }
@media (max-width: 640px) {
  .dv-bar { padding: 8px 10px; }
  .dv-title { flex-basis: 100%; }
  .dv-link { display: none; }
  .dv-controls { width: 100%; justify-content: space-between; }
  .dv-body { padding: 10px; }
}

/* Printing the page while a document is open prints nothing useful */
@media print {
  body.dv-open > *:not(.docviewer) { display: none !important; }
  .docviewer { display: none !important; }
  body.dv-open::after { content: "Printing is disabled for this document."; display: block; padding: 40px; font: 16px sans-serif; }
}
