/* Publications page. Mobile first: base rules are the 390 px artboard, the
   media query adds the 1280 px layout (filters in a column beside the list). */

.pubs { padding-bottom: 48px; }

/* ---------- Filters ---------- */

.pub-filters {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 10px;
  grid-template-areas: "search search" "year year" "type type" "topic topic" "apply apply";
  margin: 0 -16px; padding: 14px 16px 4px; border-bottom: 1px solid var(--line);
}
.pub-filters fieldset { min-width: 0; margin-inline: 0; padding: 0; border: 0; }
.pub-filters .field { min-width: 0; }
.f-search { grid-area: search; }
.f-year { grid-area: year; margin-top: 10px; }
.f-type { grid-area: type; margin-top: 10px; }
.f-topic { grid-area: topic; margin-top: 6px; }
.apply { grid-area: apply; margin: 8px 0 8px; }
.js .apply { display: none; }

.pub-filters .field > label, .pub-filters legend { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.pub-filters legend {
  position: absolute; width: 1px; height: 1px; margin: 0; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.search-box {
  display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 12px;
  border: 1.5px solid var(--ink); border-radius: var(--radius); color: var(--muted);
}
.search-box:focus-within { outline: var(--focus); outline-offset: 2px; }
.search-box input {
  flex: 1; min-width: 0; border: 0; outline: none; background: transparent;
  font: inherit; font-size: 15px; color: var(--ink);
}
.search-box input:focus-visible { outline: none; }

.select-box { position: relative; color: var(--ink); }
.select-box select {
  width: 100%; height: 44px; padding: 0 32px 0 10px; border: 1.5px solid var(--faint); border-radius: var(--radius);
  background: var(--white); color: var(--ink); font: inherit; font-size: 14px;
  appearance: none; -webkit-appearance: none; cursor: pointer;
}
.select-box svg { position: absolute; right: 11px; top: 15px; width: 14px; height: 14px; pointer-events: none; }

/* Type and topic choices are radio buttons drawn as chips: they work as a
   plain form, and as buttons that apply at once when scripts are available. */
/* Scrolls sideways on phones; the padding keeps the focus ring from being clipped. */
.opts { display: flex; gap: 8px; overflow-x: auto; padding: 5px; margin: -5px; scrollbar-width: none; }
.opts label { position: relative; flex: none; display: block; font-weight: 400; margin: 0; }
.opts input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.opts input:focus-visible + .opt { outline: var(--focus); outline-offset: 2px; }

.f-type .opt {
  display: flex; align-items: center; min-height: 36px; padding: 0 14px;
  border: 1.5px solid var(--field); border-radius: var(--radius); background: var(--white); color: var(--ink);
  font-size: 14px; font-weight: 600;
}
.f-type input:checked + .opt { background: var(--ink); border-color: var(--ink); color: var(--white); }

.f-topic .opts { padding: 5px 5px 9px; }
.f-topic label { margin: 2px 3px; }
.f-topic .opt {
  display: flex; align-items: center; min-height: 36px; padding: 0 14px; white-space: nowrap;
  border: 1.5px solid var(--amber); border-radius: 999px; background: var(--white); color: var(--ink);
  font-size: 14px; font-weight: 500;
}
.f-topic .n { display: none; }
/* All topic options look the same: white with an amber border; the selected one is filled amber. */
.f-topic label:hover .opt { background: var(--amber-tint); }
.f-topic input:checked + .opt { background: var(--amber); }

.member-note { margin: 14px 0 0; font-size: 14px; color: var(--muted); }
.member-note strong { color: var(--ink); font-weight: 600; }
.member-note a { margin-left: 6px; font-weight: 600; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.member-note a:hover { text-decoration-thickness: 2px; }

.pub-filters.htmx-request ~ .pub-results { opacity: .6; transition: opacity .2s ease; }

/* ---------- Results ---------- */

.act { color: var(--blue); font-weight: 600; text-decoration: none; }
.act:hover { color: var(--blue); text-decoration: underline; text-underline-offset: 3px; }

.year-group { padding-top: 14px; }
.year-head {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 10px 0 8px; background: var(--white); border-bottom: 3px solid var(--ink);
}
.year-head h2 { margin: 0; font-size: 26px; line-height: 1.1; font-weight: 700; letter-spacing: -.02em; }

.pub-items { margin: 0; padding: 0; list-style: none; }
.pub-item { padding: 12px 0; border-bottom: 1px solid var(--line); }

.pub-meta { font-size: 13px; line-height: 1.4; }
.pub-meta .type { font-family: var(--font-display); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.pub-meta .sep { color: var(--faint); }
.pub-meta .venue { font-family: var(--font-display); font-weight: 700; color: var(--blue); }

.pub-title { margin: 4px 0 0; font-size: 17px; line-height: 1.3; font-weight: 600; }
.pub-title a { color: var(--ink); text-decoration: none; transition: color .2s ease; }
.pub-title a:hover { color: var(--blue); }
.pub-authors { margin: 2px 0 0; font-size: 14px; line-height: 1.4; color: var(--muted); }

/* The topics sit under the actions (and under the citation, when it is open),
   in one row from left to right that wraps when it is full. */
.pub-topics { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.pub-topics .chip {
  display: inline-flex; align-items: center; max-width: 100%; min-height: 24px; margin: 0; padding: 2px 8px; border-radius: 0; font-family: var(--font-display);
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; white-space: normal;
}

.pub-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0 18px; margin-top: 2px; font-size: 14px; font-weight: 600; }
.pub-actions .act { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; }
.pub-actions .act svg { flex: none; }
/* Cite is an action like the others; open, it stays underlined. */
.pub-actions .cite-toggle[aria-expanded="true"] { text-decoration: underline; text-underline-offset: 3px; }

/* Without scripts the Cite link opens its panel through :target. */
.cite-panel { display: none; margin-top: 6px; padding: 14px; background: var(--tint); }
.cite-panel:target, .js .cite-panel.open { display: block; }
.js .cite-panel:target:not(.open) { display: none; }
.cite-panel pre {
  margin: 0; font-size: 12px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; color: var(--ink);
}
.cite-panel code { font: inherit; }
.copy {
  display: none; width: 100%; min-height: 44px; margin-top: 12px; border: 0; border-radius: var(--radius);
  background: var(--ink); color: var(--white); font-size: 14px; font-weight: 600;
}
.js .copy { display: block; }
.copy:hover { background: #2C2747; }

.no-results { padding: 40px 0; text-align: center; color: var(--muted); }
.no-results p { margin: 6px 0 16px; }
.no-results .big { margin: 0; font-family: var(--font-display); font-size: 19px; font-weight: 600; color: var(--ink); }
.no-results .button { min-height: 44px; }

/* ---------- Desktop ---------- */

@media (min-width: 900px) {
  .pubs { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 40px; padding-top: 40px; padding-bottom: 80px; }

  .pub-filters { flex: 1 1 250px; display: flex; flex-direction: column; gap: 18px; margin: 0; padding: 0; border: 0; }
  .pub-filters > .field { margin-top: 0; }
  .apply { margin: 0; }
  .pub-filters .field > label, .pub-filters legend {
    font-family: var(--font-display); font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 6px;
  }
  .pub-filters legend {
    position: static; width: auto; height: auto; overflow: visible; clip: auto; clip-path: none; white-space: normal; padding: 0;
  }
  .pub-filters .f-search label { font-family: var(--font-body); font-size: 13px; font-weight: 600; letter-spacing: 0; text-transform: none; margin-bottom: 6px; }
  .search-box { height: 46px; }
  .select-box select { height: 46px; padding: 0 40px 0 12px; font-size: 15px; }
  .select-box svg { right: 14px; width: 16px; height: 16px; }

  .opts { overflow: visible; padding: 0; margin: 0; }
  /* The types wrap onto as many rows as the column needs: each is as wide as
     its word, and the spare room of a row is divided between them. */
  .f-type .opts { flex-wrap: wrap; gap: 4px; }
  .f-type label { flex: 1 1 auto; }
  .f-type .opt { justify-content: center; min-height: 34px; padding: 0 6px; font-size: 13px; white-space: nowrap; }
  .f-topic .opts { flex-direction: column; gap: 2px; padding: 0; margin: 0; }
  .f-topic label { margin: 0; }
  .f-topic .opt {
    justify-content: space-between; min-height: 34px; padding: 0 12px; border-radius: 0; text-align: left; font-weight: 400;
  }
  .f-topic .name { font-family: var(--font-display); font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
  .f-topic .n { display: inline; font-size: 13px; }

  .pub-results { flex: 999 1 640px; min-width: 0; }

  .member-note { margin: 0 0 20px; font-size: 15px; }
  .year-group:first-of-type { padding-top: 0; }
  .year-group { padding-top: 28px; }
  .year-head { position: static; padding: 0 0 10px; }
  .year-head h2 { font-size: 34px; }

  .pub-item { display: grid; grid-template-columns: 180px 1fr; gap: 24px; padding: 12px 12px; transition: background .2s ease; }
  .pub-item:hover { background: var(--tint); }
  .pub-meta .type, .pub-meta .venue { display: block; }
  .pub-meta .type { font-size: 12px; }
  .pub-meta .venue { margin-top: 2px; font-size: 14px; line-height: 1.35; }
  .pub-meta .sep { display: none; }
  .pub-body { min-width: 0; }

  .pub-title { margin-top: 0; font-size: 20px; }
  .pub-authors { margin-top: 2px; font-size: 15px; }

  .pub-actions { margin-top: 4px; gap: 18px; }
  .pub-actions .act { min-height: 28px; }

  .cite-panel { position: relative; margin-top: 8px; padding: 16px 18px; }
  .cite-panel pre { padding-right: 80px; font-size: 13px; }
  .copy { position: absolute; top: 12px; right: 12px; width: auto; min-height: 32px; margin: 0; padding: 0 12px; font-size: 13px; }

  .no-results { padding: 56px 0; }
  .no-results .big { font-size: 22px; }
}
