/* =========================================================================
   TheSSS AI — projects listing (/projects) and project pages (/projects/<slug>/)
   Cards (.project-card) are in components.css; tabs in components.css.
   ========================================================================= */

/* --- Listing -------------------------------------------------------------------- */
.listing-hero__page {
    color: var(--color-text-subtle);
}

.listing-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    margin-top: var(--space-6);
}

.listing-search {
    flex: 1 1 22rem;
    max-width: 32rem;
}

.listing-search__status {
    min-height: 1.25rem;
    margin-top: var(--space-2);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

.listing {
    padding-top: var(--space-7);
}

.listing .project-grid {
    gap: var(--space-5);
}

@media (min-width: 640px) and (max-width: 767.98px) {
    .listing .project-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.listing-empty {
    padding: var(--space-6);
    border: 1px dashed var(--color-border-strong);
    border-radius: var(--radius-lg);
    color: var(--color-text-muted);
    text-align: center;
}

.listing .pager {
    margin-top: var(--space-8);
}

.pager__disabled {
    opacity: 0.4;
}

.project-card__stats {
    display: inline-flex;
    gap: var(--space-4);
    color: var(--color-text-muted);
}

.project-card__rating,
.project-card__votes {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-weight: var(--weight-semibold);
}

.project-card__votes .icon {
    width: 1rem;
    height: 1rem;
}

.star {
    width: 1rem;
    height: 1rem;
    color: var(--color-border-strong);
}

.star--on {
    color: #f5a524;
    fill: currentColor;
}

/* --- Project page ----------------------------------------------------------------- */
.project-hero h1 {
    font-size: clamp(2.1rem, 1.5rem + 2.6vw, 3.5rem);
}

.project-body {
    padding-top: var(--space-6);
}

.tabs__count {
    margin-left: var(--space-1);
    padding: 0.05rem 0.45rem;
    border-radius: var(--radius-pill);
    background: var(--color-accent-soft);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
}

/* Without JavaScript the panels simply follow each other, each with its heading */
.tabs:not(.is-ready) .tabs__list {
    display: none;
}

.tabs:not(.is-ready) .tabs__panel + .tabs__panel {
    margin-top: var(--space-8);
}

.tabs.is-ready .tabs__heading {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.tabs__heading {
    margin-bottom: var(--space-3);
    font-size: var(--text-xl);
}

.panel-intro {
    color: var(--color-text-muted);
}

.panel-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}

.panel-bar[data-expanded] .icon,
[data-expand-all][aria-pressed="true"] .icon {
    transform: rotate(180deg);
}

/* The brief, exactly as written (a <pre>, so the builders leave its lines alone) */
.req-brief,
.req__text {
    font-family: var(--font-body);
}

.req-brief {
    margin-top: var(--space-5);
    padding: clamp(1.25rem, 1rem + 1.5vw, 2rem);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.9375rem;
    line-height: 1.75;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* Requirement sections */
.req-list {
    display: grid;
    gap: var(--space-2);
    margin-top: var(--space-5);
}

.req-list .disclosure + .disclosure {
    margin-top: 0;
}

.req > summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "title chevron" "meta chevron";
    gap: var(--space-1) var(--space-4);
}

.req__title {
    grid-area: title;
}

.req__meta {
    grid-area: meta;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    font-weight: var(--weight-regular);
}

.req__meta code {
    font-size: var(--text-xs);
    color: var(--color-text-subtle);
}

.req > summary .disclosure__chevron {
    grid-area: chevron;
    align-self: center;
}

@media (min-width: 768px) {
    .req > summary {
        grid-template-columns: minmax(0, 1fr) auto auto;
        grid-template-areas: "title meta chevron";
    }
}

.req__text {
    color: var(--color-text-muted);
    font-size: 0.9375rem;
    line-height: 1.7;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* Conversation timeline */
.chat-list {
    position: relative;
    display: grid;
    gap: var(--space-5);
    max-width: 48rem;
    margin-top: var(--space-6);
}

.chat-list::before {
    content: "";
    position: absolute;
    top: 20px;
    bottom: 20px;
    left: 19px;
    width: 1px;
    background: var(--color-border-strong);
}

.chat {
    position: relative;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    gap: var(--space-4);
}

.chat__avatar {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--color-border);
    border-radius: 50%;
    background: var(--color-accent-soft);
    color: var(--color-accent);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    box-shadow: 0 0 0 4px var(--color-bg);
}

.chat__avatar--ai {
    background: var(--color-surface);
}

.chat__bubble {
    display: grid;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    font-size: 0.9375rem;
    color: var(--color-text-muted);
}

.chat--user .chat__bubble {
    background: var(--color-bg-subtle);
}

.chat__head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: var(--space-1) var(--space-3);
    font-size: var(--text-sm);
}

.chat__head strong {
    color: var(--color-text);
}

.chat__head span {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--color-text-subtle);
}

.chat__summary {
    display: flex;
    gap: var(--space-3);
    align-items: center;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    background: var(--color-accent-soft);
}

.chat__summary .icon {
    color: var(--color-accent);
}

.chat__summary strong {
    display: block;
    color: var(--color-text);
}

.chat__sections > summary {
    width: fit-content;
    color: var(--color-accent);
    font-weight: var(--weight-semibold);
    cursor: pointer;
}

.chat__sections-body {
    display: grid;
    gap: var(--space-3);
    margin-top: var(--space-3);
}

.chat-section {
    padding: var(--space-4);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg);
}

.chat-section__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}

.chat-section__head strong {
    margin-right: auto;
    color: var(--color-text);
}

.chat-section__head code {
    font-size: var(--text-xs);
    color: var(--color-text-subtle);
}

.chat-section__text {
    font-size: var(--text-sm);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.chat-section__note {
    margin-top: var(--space-2);
    font-size: var(--text-sm);
    font-style: italic;
}

.tag--edited {
    background: var(--color-warning-soft);
    color: var(--color-warning);
}

/* Documentation links */
.doc-list {
    display: grid;
    gap: var(--space-3);
    margin-top: var(--space-5);
}

@media (min-width: 640px) {
    .doc-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .doc-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.doc-list a {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text);
    font-weight: var(--weight-semibold);
    text-decoration: none;
    transition: border-color var(--duration-fast) ease, transform var(--duration) var(--ease-out);
}

.doc-list a:hover {
    border-color: var(--color-border-strong);
    transform: translateY(-2px);
}

.doc-list a > .icon:first-child {
    width: 22px;
    height: 22px;
    color: var(--color-accent);
}

.doc-list small {
    display: block;
    font-weight: var(--weight-regular);
    color: var(--color-text-subtle);
}

.doc-list__ext {
    width: 1rem;
    height: 1rem;
    margin-left: auto;
    color: var(--color-text-subtle);
}

/* --- Community ----------------------------------------------------------------------- */
.community {
    display: grid;
    gap: var(--space-4);
    align-items: start;
}

@media (min-width: 900px) {
    .community {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.community h3 {
    font-size: var(--text-base);
}

.rating__score {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.rating__score > span:first-child {
    font-family: var(--font-display);
    font-size: var(--text-3xl);
    font-weight: var(--weight-black);
    line-height: 1;
    letter-spacing: -0.04em;
}

.rating__stars {
    display: inline-flex;
    gap: 2px;
}

.rating__stars .star {
    width: 1.2rem;
    height: 1.2rem;
}

.rating__count {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

.rating__bars {
    display: grid;
    gap: var(--space-2);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

.rating__bars li {
    display: grid;
    grid-template-columns: 3.25rem minmax(0, 1fr) 1.5rem;
    gap: var(--space-3);
    align-items: center;
}

.rating__bars li > span:last-child {
    text-align: right;
}

.rating__bar {
    height: 8px;
    overflow: hidden;
    border-radius: var(--radius-pill);
    background: var(--color-bg-subtle);
    box-shadow: inset 0 0 0 1px var(--color-border);
}

.rating__bar span {
    display: block;
    width: calc(var(--value, 0) * 1%);
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #f5a524, #f97316);
}

.community__empty {
    font-size: var(--text-sm);
    color: var(--color-text-subtle);
}

.review-list,
.related-list {
    display: grid;
    gap: var(--space-3);
}

.review {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    gap: var(--space-3);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

.review .chat__avatar {
    box-shadow: none;
}

.review__head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: var(--space-1) var(--space-3);
    margin-bottom: var(--space-1);
}

.review__head strong {
    color: var(--color-text);
}

.review__head span {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--color-text-subtle);
}

.related-list a {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2);
    margin: calc(-1 * var(--space-2));
    border-radius: var(--radius-md);
    color: var(--color-text);
    text-decoration: none;
}

.related-list a:hover {
    background: var(--color-accent-soft);
}

.related-list strong {
    display: block;
    font-size: var(--text-sm);
    line-height: 1.35;
}

.related-list small {
    font-size: var(--text-xs);
    color: var(--color-text-subtle);
}
