/*
 * Engineering Edge — homepage content preferences: settings pickers, topics
 * chips, the quiet hint, the personalized latest list, cards, and the
 * first-login modal. Namespaced hp-*, responsive to ~360px, WCAG AA.
 */
@import url("../shared/tokens.css");

/* The hp-* names are kept for the existing selectors but now alias the shared
   token set (static/shared/tokens.css) — one source of truth (§2). Fallbacks
   keep the surface styled even if the token sheet fails to load. The blue/green/
   grey were nudged darker than the raw mockup for WCAG AA (see tokens.css). */
:root {
  --hp-orange: var(--ee-orange, #f78f01);
  --hp-ink: var(--ee-ink, #1e293b);
  --hp-muted: var(--ee-muted, #5c6675);
  --hp-line: var(--ee-line, #e2e8f0);
  --hp-line-soft: var(--ee-line-soft, #eef2f6);
  --hp-bg-soft: var(--ee-bg-soft, #f8fafc);
  --hp-faint: var(--ee-faint, #94a3b8);
  --hp-blue-deep: var(--ee-blue-deep, #1c6ea3);
  --hp-slate-deep: var(--ee-slate-deep, #566071);
  --hp-ok: var(--ee-ok, #157f3c);
  --hp-label-grey: var(--ee-label-grey, #667180);
  /* exact frozen-mockup heading colours (see tokens.css) */
  --hp-card-title: var(--ee-card-title, #2596d1);
  --hp-grouplabel: var(--ee-grouplabel, #f78f01);
  --hp-grouplabel-rest: var(--ee-grouplabel-rest, #94a3b8);
}
.hp-settings {
  font-size: 14.5px;
  color: var(--hp-ink);
}
.hp-explain {
  color: var(--hp-muted);
  margin: 0 0 18px;
}
.hp-section-title {
  font-size: 15px;
  font-weight: 600;
  margin: 22px 0 8px;
}
.hp-section-hint {
  color: var(--hp-muted);
  font-size: 13px;
  margin: 0 0 8px;
}

/* checkboxes */
.hp-check {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 4px;
  min-height: 34px;
  cursor: pointer;
  line-height: 1.3;
}
.hp-check input {
  width: 16px;
  height: 16px;
  flex: none;
}
.hp-competitions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0 14px;
}

/* field → subfield tree */
.hp-fieldtree {
  border: 1px solid var(--hp-line);
  border-radius: 8px;
  max-height: 360px;
  overflow-y: auto;
  padding: 4px 6px;
}
.hp-field {
  border-bottom: 1px solid var(--hp-line);
}
.hp-field:last-child {
  border-bottom: 0;
}
.hp-field-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.hp-expand {
  width: 34px;
  height: 34px;
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--hp-muted);
  font-size: 13px;
  flex: none;
}
.hp-field-check {
  font-weight: 600;
  flex: 1;
  min-width: 0;
}
.hp-domain {
  margin-left: auto;
  color: var(--hp-muted);
  font-size: 12px;
  font-weight: 400;
  padding-left: 8px;
}
.hp-subs {
  padding: 2px 0 8px 40px;
}
.hp-sub-check {
  min-height: 32px;
}

/* topics type-ahead */
.hp-topic-wrap {
  position: relative;
  max-width: 460px;
}
.hp-topic-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--hp-line);
  border-radius: 8px;
  font-size: 14.5px;
  font-family: inherit;
}
.hp-topic-input:focus {
  outline: 2px solid var(--hp-orange);
  outline-offset: 1px;
}
.hp-topic-suggest {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--hp-line);
  border-radius: 0 0 8px 8px;
  max-height: 260px;
  overflow-y: auto;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
}
.hp-suggest-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  padding: 9px 12px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  color: var(--hp-ink);
}
.hp-suggest-item:hover,
.hp-suggest-item.active {
  background: var(--hp-bg-soft);
}
.hp-topic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.hp-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fdf0dd;
  color: #7c4a03;
  border: 1px solid #f5d9ae;
  border-radius: 14px;
  padding: 3px 6px 3px 12px;
  font-size: 13px;
}
.hp-chip-x {
  border: 0;
  background: none;
  cursor: pointer;
  color: #7c4a03;
  font-size: 16px;
  line-height: 1;
  width: 22px;
  height: 22px;
  border-radius: 50%;
}
.hp-chip-x:hover {
  background: rgba(0, 0, 0, 0.08);
}

/* actions */
.hp-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 24px;
  flex-wrap: wrap;
}
.hp-btn {
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid var(--hp-line);
  background: #fff;
  color: var(--hp-ink);
  border-radius: 8px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.hp-btn:hover {
  border-color: #94a3b8;
}
.hp-btn-primary {
  background: var(--hp-orange);
  border-color: var(--hp-orange);
  color: var(--hp-ink); /* dark ink on orange ≈5.9:1 (AA), matches other CTAs */
}
.hp-btn-primary:hover {
  background: #e07f00;
}
.hp-link {
  color: var(--hp-blue-deep);
  background: none;
  border: 0;
  cursor: pointer;
  font-size: 14px;
  text-decoration: underline;
  font-family: inherit;
}
.hp-status {
  color: var(--hp-muted);
  font-size: 13.5px;
}

/* ── quiet hint (homepage) ─────────────────────────────────── */
.hp-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #5c6675;
  margin: -4px 0 10px;
}
.hp-hint-link {
  color: var(--hp-blue-deep);
}
.hp-hint-x {
  border: 0;
  background: none;
  cursor: pointer;
  color: #94a3b8;
  font-size: 16px;
  line-height: 1;
  width: 24px;
  height: 24px;
}

/* ── personalized latest list (homepage) ───────────────────── */
.hp-match-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #b45309;
  background: #fdf0dd;
  border-radius: 5px;
  display: inline-block;
  padding: 3px 10px;
  margin: 4px 0 12px;
}
.hp-rest-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #5c6675;
  margin: 18px 0 12px;
}
.hp-item-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.hp-date {
  color: #5c6675;
  font-size: 12.5px;
}
.hp-item-title {
  font-size: 16px;
  font-weight: 600;
}
.hp-item-creators {
  color: #5c6675;
  font-size: 13px;
  margin-top: 3px;
}
.hp-item-desc {
  color: #334155;
  font-size: 13.5px;
  margin-top: 5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── first-login modal ─────────────────────────────────────── */
.hp-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 5vh 16px;
  overflow-y: auto;
}
.hp-modal {
  background: #fff;
  color: #1e293b;
  border-radius: 12px;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 26px 28px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.3);
  font-family: "Inter", -apple-system, "Segoe UI", sans-serif;
}
.hp-modal-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 8px;
}
.hp-modal-intro {
  color: #5c6675;
  font-size: 14px;
  margin: 0 0 16px;
}
.hp-modal-sub {
  font-size: 14px;
  font-weight: 600;
  margin: 18px 0 6px;
}
.hp-modal .hp-fieldtree {
  max-height: 240px;
}
.hp-modal-btns {
  display: flex;
  gap: 12px;
  margin-top: 22px;
  flex-wrap: wrap;
}
.hp-modal :focus-visible {
  outline: 2px solid var(--hp-orange, #f78f01);
  outline-offset: 2px;
}

/* ── responsive ────────────────────────────────────────────── */
@media (max-width: 600px) {
  .hp-competitions {
    grid-template-columns: 1fr;
  }
  .hp-domain {
    display: none;
  }
  .hp-modal {
    padding: 20px 16px;
  }
  .hp-fieldtree {
    max-height: 300px;
  }
}

/* ── latest-content Grid cards (frozen spec v3) ────────────── */
/* Applies to both the default (everyone) and personalized renderings when
   HOMEPAGE_CARDS_ENABLED. Ported from docs/homepage-cards-explorer.html
   variant 3, namespaced hp-*. */
.hp-latest {
  font-family: "Inter", -apple-system, "Segoe UI", sans-serif;
}
.hp-cardgrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px 22px;
}
/* Operator's explicit call: one full-width column below 900px. */
@media (max-width: 900px) {
  .hp-cardgrid {
    grid-template-columns: 1fr;
  }
}
.hp-card {
  border: 1px solid var(--hp-line);
  border-radius: 10px;
  padding: 14px 16px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 7px;
  transition: transform 0.15s, box-shadow 0.15s;
  text-decoration: none;
  color: var(--hp-ink);
}
.hp-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.09);
  text-decoration: none;
}
.hp-card:focus-visible {
  outline: 2px solid var(--hp-orange);
  outline-offset: 2px;
}
.hp-tophead {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.hp-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  padding: 1px 7px;
  background: var(--hp-bg-soft);
  border: 1px solid var(--hp-line);
  color: var(--hp-muted);
}
.hp-badge i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
}
.hp-pdf {
  color: var(--hp-ok);
  font-weight: 700;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  flex: none;
}
.hp-card-title {
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--hp-card-title); /* exact mockup --blue-deep #2596d1 */
}
.hp-card:hover .hp-card-title {
  text-decoration: underline;
}
.hp-authors {
  font-size: 12.5px;
  color: var(--hp-muted);
  line-height: 1.45;
}
.hp-authors .au {
  white-space: nowrap;
}
.hp-orcid {
  display: inline-block;
  width: 12px;
  height: 12px;
  vertical-align: -1.5px;
  margin-left: 2px;
}
.hp-snip {
  font-size: 13px;
  color: var(--hp-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hp-foot {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  margin-top: auto;
  padding-top: 4px;
}
.hp-pubin {
  font-size: 12px;
  color: var(--hp-muted);
}
.hp-pubin em {
  font-style: italic;
  color: var(--hp-slate-deep);
}
.hp-added {
  color: var(--hp-label-grey);
}
/* One inline text run: competitions (bold) then topics, " · "-separated, with
   natural wrapping. A single block element (one .hp-foot row, 2px below the
   date line — same rhythm), NOT the previous per-item spans that stacked. */
.hp-subj {
  font-size: 11px;
  line-height: 1.45;
  color: var(--hp-label-grey);
}
/* Competition tags — subtly distinguished from topics: a slightly deeper,
   cooler slate + medium weight (topics keep the plain grey above). Inline, so
   they flow within the line. Both stay AA on white at 11px. */
.hp-subj-comp {
  color: var(--hp-slate-deep);
  font-weight: 600;
}
/* Section + group heading label — the frozen mockup's .grouplabel, copied
   verbatim (docs/homepage-cards-explorer.html): a small uppercase orange label
   with a thin rule extending to the right edge. Used for the main "Latest
   content" section heading (an <h2>, styles only — SR text unchanged) and the
   personalized-mode group labels. Colours are the EXACT mockup values (below
   WCAG AA — operator spec-fidelity choice 2026-09-14; see tokens.css). */
.hp-grouplabel {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--hp-grouplabel); /* mockup --orange #f78f01 */
  margin: 18px 0 10px;
}
.hp-grouplabel::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--hp-line); /* mockup --line #e2e8f0 */
}
/* secondary/less-prominent label (mockup .grouplabel.rest) */
.hp-grouplabel.rest {
  color: var(--hp-grouplabel-rest); /* mockup --faint #94a3b8 */
}

/* ── search results: full-width cards, one per line (§3) ───── */
.hp-card-searchitem {
  display: block;
  margin-bottom: 16px;
}
.hp-card-searchitem:last-child {
  margin-bottom: 0;
}
