/* ===== Project list page ===== */
.projects-page:has(.genre-tabs [data-genre="pptx"][aria-current="page"]) { --genre: var(--g-pptx); }
.projects-page:has(.genre-tabs [data-genre="image"][aria-current="page"]) { --genre: var(--g-image); }
.projects-page:has(.genre-tabs [data-genre="html"][aria-current="page"]) { --genre: var(--g-html); }
.projects-page:has(.genre-tabs [data-genre="business"][aria-current="page"]) { --genre: var(--g-business); }
.projects-page:has(.genre-tabs [data-genre="convert"][aria-current="page"]) { --genre: var(--g-convert); }
.projects-page:has(.genre-tabs [data-genre="general"][aria-current="page"]) { --genre: var(--g-general); }

.project-main { padding: 28px 0 88px; }
.back-to-genres { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px 0 12px; margin-left: -12px; border-radius: 999px; color: var(--muted); font-size: 13px; font-weight: 600; transition: background .2s, color .2s; }
.back-to-genres:hover { background: var(--paper-deep); color: var(--ink); }

/* Intro */
.project-intro { padding: 20px 0 28px; }
.project-intro h1 { font-size: clamp(34px, 4.6vw, 58px); line-height: 1.3; margin: 0; }

/* Toolbar: genre tabs + search */
.project-toolbar { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px; }
.genre-tabs { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
.genre-tabs a { position: relative; display: flex; flex-direction: column; justify-content: center; gap: 2px; min-height: 64px; padding: 10px 14px 10px 16px; border-radius: 10px; font-size: 13px; font-weight: 700; line-height: 1.4; color: var(--ink-soft); transition: background .2s, color .2s; }
.genre-tabs a::before { content: ""; position: absolute; left: 0; top: 16px; bottom: 16px; width: 3px; border-radius: 0 3px 3px 0; background: var(--genre); opacity: .9; }
.genre-tabs a:hover { background: var(--paper); color: var(--ink); }
.genre-tabs span { display: block; min-height: 1.4em; font-family: var(--serif); font-size: 18px; font-weight: 600; line-height: 1.2; color: var(--muted); font-variant-numeric: lining-nums tabular-nums; }
.genre-tabs a[aria-current="page"] { background: var(--ink); color: #fff; }
.genre-tabs a[aria-current="page"] span { color: #d9d3c7; }
.genre-tabs a[aria-current="page"]::before { opacity: 1; }

.project-controls { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 12px; padding: 16px 10px 10px; margin-top: 8px; border-top: 1px solid var(--line); }
.project-controls label { display: block; margin: 0 0 6px 2px; font-size: 12px; font-weight: 700; letter-spacing: .06em; color: var(--muted); }
.project-controls input, .project-controls select { width: 100%; min-height: 50px; border: 1px solid var(--line-strong); border-radius: 10px; padding: 12px 16px; background-color: var(--paper); color: var(--ink); font: inherit; font-size: 16px; transition: border-color .2s, background-color .2s; }
.project-controls input:hover, .project-controls select:hover { border-color: var(--muted); }
.project-controls input:focus, .project-controls select:focus { background-color: #fff; border-color: var(--ink); }
.project-controls input:focus-visible, .project-controls select:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; border-radius: 10px; }
.project-controls input { padding-left: 46px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2362665f' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 16px 50%; }
.project-controls input::placeholder { color: #8a8c84; }
.project-controls select { -webkit-appearance: none; appearance: none; padding-right: 44px; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%231d201e' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 16px center; }

/* Result heading */
.project-list-heading { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 6px 16px; padding: 40px 0 18px; margin-bottom: 4px; border-bottom: 1px solid var(--ink); }
#result-count { margin: 0; font-family: var(--serif); font-size: 22px; font-weight: 600; }
#star-source { margin: 0; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ===== Project cards ===== */
.project-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px 24px; padding-top: 24px; }
.project-card {
  position: relative; display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: 1fr auto auto;
  grid-template-areas: "content content content" "trust trust trust" "footer footer footer";
  padding: 0 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; transition: border-color .25s, box-shadow .25s, transform .25s;
}
.project-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-lift); transform: translateY(-3px); }
/* The primary link uses display:contents, so its keyboard focus is drawn on the article */
.project-primary { grid-area: content; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: auto auto auto 1fr; grid-template-areas: "visual visual visual" "rank owner owner" "rank name name" "desc desc desc"; color: inherit; }
.project-primary:focus { outline: none; }
.project-card:has(.project-primary:focus-visible) { outline: 3px solid var(--accent); outline-offset: 3px; border-color: var(--ink); }
.project-card:target { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash), var(--shadow-lift); }

.project-visual { position: relative; grid-area: visual; margin: 0 -22px; aspect-ratio: 16 / 10; padding: 18px 20px 20px; display: flex; align-items: center; justify-content: center; background: var(--paper-deep); background: color-mix(in srgb, var(--genre) 8%, var(--paper-deep)); border-bottom: 1px solid var(--line); }
.project-preview { display: block; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 6px 14px rgba(30, 24, 14, .18)); transition: transform .35s cubic-bezier(.2, .7, .2, 1); }
.project-primary:hover .project-preview { transform: translateY(-3px); }
/* Truthful source label: project visual vs. GitHub social card. Quiet, never over the image itself */
.project-image-kind { position: absolute; right: 10px; bottom: 6px; max-width: calc(100% - 20px); padding: 1px 7px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 253, 249, .86); color: var(--muted); font-size: 10px; font-weight: 600; line-height: 1.6; letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }

/* ===== Trust: upstream installation/security assessment (not quality, not a guarantee) ===== */
.trust-safe { --trust-color: #2d6b50; --trust-wash: #edf5ef; }
.trust-caution { --trust-color: #83530b; --trust-wash: #fdf4dc; }
.trust-unsafe { --trust-color: #a52f2f; --trust-wash: #fcefeb; }
.trust-pending { --trust-color: #5f6267; --trust-wash: #f0efec; }

.trust-guide { margin: 0 0 24px; padding: 18px 22px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.trust-guide h2 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; margin: 0 0 12px; font-family: var(--sans); font-size: 15px; font-weight: 700; line-height: 1.5; letter-spacing: .02em; color: var(--ink); }
.trust-guide h2 span { font-size: 12px; font-weight: 500; letter-spacing: .04em; color: var(--muted); }
.trust-legend { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; font-weight: 700; line-height: 1.4; }
.trust-legend > span { display: inline-flex; align-items: center; gap: 7px; min-height: 28px; padding: 3px 11px 3px 9px; border: 1px solid color-mix(in srgb, var(--trust-color) 22%, transparent); border-radius: 999px; background: var(--trust-wash); color: var(--trust-color); white-space: nowrap; }
.trust-guide p { margin: 12px 0 0; max-width: 54em; font-size: 12px; line-height: 1.9; color: var(--muted); }

.trust-dot, .trust-legend i { display: block; width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--trust-color); box-shadow: 0 0 0 3px color-mix(in srgb, var(--trust-color) 16%, transparent); }

.project-trust { grid-area: trust; position: relative; z-index: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 9px; margin: 0 0 16px; min-height: 40px; padding: 7px 12px 7px 13px; border: 1px solid color-mix(in srgb, var(--trust-color) 20%, transparent); border-radius: var(--radius-sm); background: var(--trust-wash); color: var(--trust-color); font-size: 12px; font-weight: 700; line-height: 1.5; transition: border-color .2s, background-color .2s; }
.trust-label { white-space: nowrap; }
.trust-action { margin-left: auto; font-size: 11px; font-weight: 600; letter-spacing: .02em; color: var(--ink-soft); white-space: nowrap; }
.project-trust:hover { border-color: color-mix(in srgb, var(--trust-color) 45%, transparent); }
.project-trust:hover .trust-action { color: var(--trust-color); text-decoration: underline; text-underline-offset: 3px; }
.project-trust:focus { outline: none; }
.project-trust:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-color: var(--trust-color); }

.project-topline { display: contents; }
.project-rank { grid-area: rank; align-self: start; padding: 18px 14px 0 0; font-family: var(--serif); font-size: 34px; font-weight: 600; line-height: 1; letter-spacing: -.01em; color: var(--ink); font-variant-numeric: lining-nums tabular-nums; }
.project-owner { grid-area: owner; margin: 18px 0 2px; font-size: 12px; line-height: 1.5; color: var(--muted); overflow-wrap: anywhere; }
.project-name { grid-area: name; margin: 0; font-family: var(--sans); font-size: 18px; font-weight: 700; line-height: 1.4; letter-spacing: 0; overflow-wrap: anywhere; }
.project-description { grid-area: desc; align-self: start; margin: 14px 0 20px; font-size: 14px; line-height: 1.85; color: var(--ink-soft); }
.project-card-footer { grid-area: footer; display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); }
.project-format { display: none; }
.project-stars, .project-open { align-self: stretch; display: flex; align-items: center; min-height: 52px; }
.project-stars { grid-area: stars; font-size: 13px; font-weight: 600; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.project-open { grid-area: open; justify-content: flex-end; font-size: 13px; font-weight: 700; color: var(--accent-dark); white-space: nowrap; }
.project-primary:hover .project-open { text-decoration: underline; text-underline-offset: 4px; }
.project-open:hover { text-decoration: underline; text-underline-offset: 4px; }
.project-open:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Cards without a published image: an honest text entry, no placeholder art */
.project-card--text-only { background: color-mix(in srgb, var(--genre) 3%, var(--surface)); border-top: 3px solid var(--genre); }
.project-card--text-only .project-rank { padding-top: 22px; font-size: 40px; color: var(--genre); }
.project-card--text-only .project-owner { margin-top: 22px; }
.project-card--text-only .project-name { font-size: 19px; }

/* Popularity cues: only while the list is in star order and unfiltered */
.projects-page:has(#project-order option[value="stars"]:checked):has(#project-query:placeholder-shown) .project-card:nth-child(-n+3) .project-rank { color: var(--accent); }
.projects-page:has(#project-order option[value="name"]:checked) .project-rank { font-size: 20px; padding-top: 22px; color: var(--muted); }

/* Empty & error states */
.project-empty { margin-top: 28px; padding: 48px 28px; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface); text-align: center; }
.project-empty h2 { margin: 0 0 10px; font-size: 22px; line-height: 1.5; }
.project-empty p { margin: 0 auto 22px; max-width: 32em; font-size: 14px; line-height: 1.9; color: var(--muted); }
.project-empty button, .project-empty a { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 10px 22px; border: 0; border-radius: 999px; background: var(--ink); color: #fff; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; transition: background .2s; }
.project-empty button:hover, .project-empty a:hover { background: var(--accent-dark); }
.project-main noscript p { margin-top: 24px; padding: 24px; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface); font-size: 14px; }
.project-main noscript a { color: var(--accent-dark); text-decoration: underline; }
[hidden] { display: none !important; }

/* ===== Responsive ===== */
@media (max-width: 1100px) {
  .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 20px; }
  .genre-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .project-main { padding: 12px 0 56px; }
  .project-intro { padding: 14px 0 20px; }
  .project-intro h1 { font-size: clamp(28px, 8.4vw, 38px); }
  .project-toolbar { padding: 6px; border-radius: 12px; }
  .genre-tabs a { min-height: 58px; padding: 8px 8px 8px 12px; font-size: 12px; }
  .genre-tabs span { font-size: 16px; }
  .genre-tabs a::before { top: 14px; bottom: 14px; }
  .project-controls { grid-template-columns: 1fr; gap: 12px; padding: 14px 6px 8px; }
  .project-list-heading { flex-direction: column; align-items: flex-start; padding-top: 30px; }
  #result-count { font-size: 20px; }
  .project-grid { grid-template-columns: 1fr; gap: 18px; padding-top: 18px; }
  .project-card { padding: 0 18px; }
  .project-visual { margin: 0 -18px; padding: 14px 14px 16px; }
  .project-rank { font-size: 30px; }
  .project-image-kind { right: 8px; bottom: 4px; }
  .trust-guide { padding: 16px 16px 18px; border-radius: 12px; }
  .trust-legend { gap: 6px; }
  .trust-legend > span { padding: 2px 10px 2px 8px; }
  .project-trust { padding: 7px 10px 7px 11px; }
  .project-empty { padding: 32px 18px; }
}
@media (max-width: 360px) {
  .genre-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  .project-card:hover, .project-primary:hover .project-preview { transform: none; }
}
