/*
 * 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");
@import url("../shared/grouplabel.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, #1c6ea3);
  --hp-grouplabel: var(--ee-grouplabel, #b45309);
  --hp-grouplabel-rest: var(--ee-grouplabel-rest, #5c6675);
  --hp-focus: var(--ee-focus, #1d4ed8);
  --hp-control-border: var(--ee-control-border, #7b8494);
}
.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-control-border); /* ≥3:1 on white (1.4.11) */
  border-radius: 8px;
  font-size: 14.5px;
  font-family: inherit;
}
.hp-topic-input::placeholder {
  color: var(--hp-muted); /* 5.81:1 on white */
}
.hp-topic-input:focus-visible {
  outline: 3px solid var(--hp-focus);
  outline-offset: 2px;
}
.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: 24px; /* ≥ 24×24 CSS px target (2.5.8) */
  height: 24px;
  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: 3px solid var(--hp-focus, #1d4ed8);
  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;
  /* minmax(0, 1fr), NOT bare 1fr: a bare 1fr track is minmax(auto, 1fr), so
     one card with an unbreakable run of text (2026-09-28: a 135-char
     "organizational" creator name rendered nowrap) inflates its column's
     min-content and blows the grid out to e.g. 860px + 322px — which reads as
     a single column. With a 0 minimum the tracks always split the row evenly
     and the card's own text wraps instead. */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px 22px;
}
/* Operator's explicit call: one full-width column below 900px. */
@media (max-width: 900px) {
  .hp-cardgrid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Card skeleton (2026-11-27): rendered by the template while the cards load
   so the hidden upstream list never flashes full width. Same grid, same card
   box; decorative bars only (aria-hidden; the container is aria-busy with a
   visually hidden "Loading latest content"). The sheen runs THREE times
   (~4 s, under the 5 s of WCAG 2.2.2; the overlay never loops an
   animation for good) and not at all under prefers-reduced-motion. */
.hp-skeleton .hp-skel-card {
  border: 1px solid var(--hp-line);
  border-radius: 10px;
  padding: 14px 16px;
  min-height: 168px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 11px;
  min-width: 0;
}
.hp-skel-line {
  display: block;
  height: 12px;
  border-radius: 6px;
  background-color: var(--hp-line-soft);
  background-image: linear-gradient(
    90deg,
    var(--hp-line-soft) 0%,
    var(--hp-line) 50%,
    var(--hp-line-soft) 100%
  );
  background-size: 200% 100%;
  animation: hp-skel-sheen 1.4s linear 3;
}
.hp-skel-line.hp-skel-tall {
  height: 18px;
}
.hp-skel-w40 { width: 40%; }
.hp-skel-w60 { width: 60%; }
.hp-skel-w70 { width: 70%; }
.hp-skel-w90 { width: 90%; }
.hp-skel-w100 { width: 100%; }
@keyframes hp-skel-sheen {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .hp-skel-line {
    animation: none;
    background-image: none;
  }
}
.hp-card {
  border: 1px solid var(--hp-line);
  border-radius: 10px;
  padding: 14px 16px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 7px;
  /* Never let content widen the card (grid item / flex item min-size), and
     break otherwise-unbreakable tokens (URLs, identifiers, run-on names). */
  min-width: 0;
  overflow-wrap: anywhere;
  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: 3px solid var(--hp-focus);
  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); /* AA title blue #1c6ea3 (tokens.css) */
}
.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 {
  /* Was `nowrap` (keep a name on one line). A run-on creator name — an
     affiliation/address pushed as the name — then can't wrap at all and
     forces the column wide (see .hp-cardgrid). Names may now break at spaces;
     the ORCID mark still sits inline after the last word. */
  white-space: normal;
}
.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 (.hp-grouplabel): the frozen mockup's
   .grouplabel — 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. The declarations live in static/shared/grouplabel.css (imported
   above), shared with the Ask page's "Knowledge maps" heading; the colour is
   the AA --ee-grouplabel token (#b45309, 2026-11-07). */

/* ── 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;
}
