/**
 * SOS Lists Manager — Public Styles
 * WCAG 2.2 AA compliant. Minimal opinionated styles.
 */

/* ============================================================
   Variables
   ============================================================ */
:root {
    --sos-lm-border: #dcdcde;
    --sos-lm-bg: #fff;
    --sos-lm-bg-alt: #f9f9f9;
    --sos-lm-text: #1d2327;
    --sos-lm-muted: #646970;
    --sos-lm-focus: #0073aa;
    --sos-lm-radius: 6px;
    --sos-lm-gap: 1rem;
}

/* ============================================================
   Screen Reader Text (fallback if theme doesn't provide it)
   ============================================================ */
.sos-lm-sr-only,
.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================================
   List Layout
   ============================================================ */
.sos-lm-list {
    display: flex;
    flex-direction: column;
    gap: var(--sos-lm-gap);
}

.sos-lm-list-item {
    padding: 1rem 1.25rem;
    border: 1px solid var(--sos-lm-border);
    border-radius: var(--sos-lm-radius);
    background: var(--sos-lm-bg);
}

/* ============================================================
   Accordion Layout
   ============================================================ */
.sos-lm-accordion {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--sos-lm-border);
    border-radius: var(--sos-lm-radius);
    overflow: hidden;
}

.sos-lm-accordion-item + .sos-lm-accordion-item {
    border-top: 1px solid var(--sos-lm-border);
}

.sos-lm-accordion-item h3 {
    margin: 0;
    padding: 0;
    font-size: inherit;
}

.sos-lm-accordion-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.875rem 1.25rem;
    background: var(--sos-lm-bg);
    border: none;
    cursor: pointer;
    font: inherit;
    font-size: 1rem;
    font-weight: 600;
    color: var(--sos-lm-text);
    text-align: left;
    min-height: 48px;
    gap: 0.75rem;
    transition: background-color 0.15s ease;
}

.sos-lm-accordion-trigger:hover {
    background: var(--sos-lm-bg-alt);
}

.sos-lm-accordion-trigger:focus-visible {
    outline: 2px solid var(--sos-lm-focus);
    outline-offset: -2px;
}

.sos-lm-accordion-title {
    flex: 1;
}

.sos-lm-accordion-icon {
    flex-shrink: 0;
    transition: transform 0.2s ease;
    line-height: 0;
    color: var(--sos-lm-muted);
}

.sos-lm-accordion-trigger[aria-expanded="true"] .sos-lm-accordion-icon {
    transform: rotate(180deg);
}

.sos-lm-accordion-panel[hidden] {
    display: none;
}

.sos-lm-accordion-content {
    padding: 1rem 1.25rem 1.25rem;
    border-top: 1px solid var(--sos-lm-border);
    background: var(--sos-lm-bg);
}

/* ============================================================
   Cards Layout
   ============================================================ */
.sos-lm-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--sos-lm-gap);
}

.sos-lm-card {
    border: 1px solid var(--sos-lm-border);
    border-radius: var(--sos-lm-radius);
    background: var(--sos-lm-bg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.sos-lm-card-body {
    padding: 1.25rem;
    flex: 1;
}

/* ============================================================
   Shared Field Rendering
   ============================================================ */
.sos-lm-field {
    margin-bottom: 0.75rem;
}

.sos-lm-field:last-child {
    margin-bottom: 0;
}

.sos-lm-field-value {
    margin: 0 0 0.5em;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--sos-lm-text);
}

.sos-lm-field-value strong {
    font-weight: 600;
}

.sos-lm-field-value a {
    color: var(--sos-lm-focus);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.sos-lm-field-value a:hover {
    text-decoration-thickness: 2px;
}

.sos-lm-field-value a:focus-visible {
    outline: 2px solid var(--sos-lm-focus);
    outline-offset: 2px;
}

.sos-lm-field-content {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--sos-lm-text);
}

.sos-lm-field-content p:last-child {
    margin-bottom: 0;
}

.sos-lm-field-figure {
    margin: 0.5rem 0;
}

.sos-lm-field-image {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

/* ============================================================
   "See All" Widget Link
   ============================================================ */
.sos-lm-see-all {
    margin: 0.75rem 0 0;
}

.sos-lm-see-all a {
    color: var(--sos-lm-focus);
    text-decoration: underline;
    text-underline-offset: 2px;
    font-weight: 600;
}

.sos-lm-see-all a:hover {
    text-decoration-thickness: 2px;
}

.sos-lm-see-all a:focus-visible {
    outline: 2px solid var(--sos-lm-focus);
    outline-offset: 2px;
}

/* ============================================================
   Modal Trigger (button styled as link)
   ============================================================ */
.sos-lm-modal-trigger {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    font-size: 1.125rem;
    color: var(--sos-lm-focus);
    text-decoration: none;
    text-align: left;
}

.sos-lm-modal-trigger:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.sos-lm-modal-trigger:focus-visible {
    outline: 2px solid var(--sos-lm-focus);
    outline-offset: 2px;
}

/* ============================================================
   Modal Dialog
   ============================================================ */
.sos-lm-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.sos-lm-modal[hidden] {
    display: none;
}

.sos-lm-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}

.sos-lm-modal-content {
    position: relative;
    background: var(--sos-lm-bg);
    border-radius: var(--sos-lm-radius);
    max-width: 40rem;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}

.sos-lm-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--sos-lm-border);
    flex-shrink: 0;
}

.sos-lm-modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.3;
    margin: 0;
    color: var(--sos-lm-text);
}

.sos-lm-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--sos-lm-muted);
    flex-shrink: 0;
    border-radius: 4px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sos-lm-modal-close:hover {
    color: var(--sos-lm-text);
}

.sos-lm-modal-close:focus-visible {
    outline: 2px solid var(--sos-lm-focus);
    outline-offset: 2px;
}

.sos-lm-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 600px) {
    .sos-lm-cards {
        grid-template-columns: 1fr;
    }

    .sos-lm-accordion-trigger {
        padding: 0.75rem 1rem;
    }

    .sos-lm-accordion-content {
        padding: 0.75rem 1rem 1rem;
    }

    .sos-lm-list-item,
    .sos-lm-card-body {
        padding: 0.875rem 1rem;
    }

    .sos-lm-modal {
        padding: 0.75rem;
    }

    .sos-lm-modal-content {
        max-height: 92vh;
    }

    .sos-lm-modal-header {
        padding: 1rem;
    }

    .sos-lm-modal-body {
        padding: 1rem;
    }
}

/* ============================================================
   Linked Titles
   ============================================================ */
.sos-lm-linked-title a {
    color: var(--sos-lm-focus);
    text-decoration: none;
    font-weight: 600;
    font-size: 1.125rem;
}

.sos-lm-linked-title a:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.sos-lm-linked-title a:focus-visible {
    outline: 2px solid var(--sos-lm-focus);
    outline-offset: 2px;
}

/* ============================================================
   Detail Page
   ============================================================ */
.sos-lm-detail {
    max-width: 48rem;
    margin: 2rem auto;
    padding: 0 1.25rem;
}

.sos-lm-detail-article {
    background: var(--sos-lm-bg);
}

.sos-lm-detail-breadcrumb {
    font-size: 0.875rem;
    color: var(--sos-lm-muted);
    margin: 0 0 1rem;
}

.sos-lm-detail-breadcrumb a {
    color: var(--sos-lm-focus);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.sos-lm-detail-breadcrumb a:hover {
    text-decoration-thickness: 2px;
}

.sos-lm-detail-breadcrumb a:focus-visible {
    outline: 2px solid var(--sos-lm-focus);
    outline-offset: 2px;
}

.sos-lm-detail-title {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.3;
    margin: 0 0 1.5rem;
    color: var(--sos-lm-text);
}

.sos-lm-detail-body {
    margin-bottom: 2rem;
}

.sos-lm-detail-field {
    margin-bottom: 1.25rem;
}

.sos-lm-detail-field:last-child {
    margin-bottom: 0;
}

/* ============================================================
   Reduced Motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .sos-lm-accordion-icon,
    .sos-lm-accordion-trigger {
        transition: none;
    }
}

/* ============================================================
   High Contrast
   ============================================================ */
@media (forced-colors: active) {
    .sos-lm-accordion-item,
    .sos-lm-card,
    .sos-lm-list-item {
        border: 2px solid ButtonText;
    }

    .sos-lm-accordion-trigger:focus-visible {
        outline: 3px solid Highlight;
    }

    .sos-lm-modal-content {
        border: 2px solid ButtonText;
    }
}
