/**
 * Archive Description Collapsible Styles
 */

/* Base archive description styles */
/* This is the page's own prose — the block that exists for search engines and
   for the visitor who wants to read rather than scan. It runs the full width of
   a 1320px container by default, which is roughly 150 characters a line and
   past the point where the eye reliably finds the start of the next one, so it
   takes a measure and centres in the column. Muted, because it sits below
   everything the visitor actually came for. */
.archive-description {
    max-width: 74ch;
    margin: 30px auto;
    color: var(--clr-text-muted);
    line-height: 1.8;
    font-size: 15.5px;
}

.archive-description p {
    margin-bottom: 15px;
}

.archive-description p:last-child {
    margin-bottom: 0;
}

/* Collapsible description container */
.collapsible-description {
    position: relative;
    overflow: hidden;
}

/* Description content wrapper */
.description-content {
    position: relative;
    overflow: hidden;
}

/* Truncated and full content states */
.description-truncated,
.description-full {
    transition: all 0.4s ease;
    opacity: 1;
}

/*
 * Initial hidden state for the full copy and the "הסתר" button label.
 * Only the starting state lives here — collapsible-description.js drives the
 * toggle with jQuery fadeIn/fadeOut, which writes its own inline display and
 * therefore overrides this from the first interaction onward.
 */
.is-hidden {
    display: none;
}

.description-truncated.hiding {
    opacity: 0;
}

.description-full.showing {
    opacity: 1;
}

/* Fade overlay effect */
.description-fade-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: linear-gradient(
            to bottom,
            transparent 0%,
            var(--bg-site) 100%
    );
    pointer-events: none;
    transition: opacity 0.4s ease;
    z-index: 5;
}

.description-fade-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

/* Toggle button container */
.description-toggle-container {
    text-align: center;
    margin-top: 20px;
    position: relative;
    z-index: 10;
}

/* "Read more" is the quietest control on the page: it reveals text the visitor
   has already decided they are or are not interested in. An outlined pill in the
   accent, the same shape the subcategory buttons take, rather than a filled
   metal bar competing with the contact CTAs above it. */
.description-toggle-btn {
    color: var(--clr-main);
    font-size: 15px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background-color: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-pill);
    text-align: center;
    padding: 8px 18px;
    margin: 4px auto 40px !important;
    width: auto !important;
    cursor: pointer;
    transition: background-color 0.25s ease, border-color 0.25s ease;
}

/* Button hover effects */
.description-toggle-btn:hover {
    background-color: var(--accent-soft);
    border-color: var(--clr-main);
}

/* Button focus state for accessibility */
.description-toggle-btn:focus-visible {
    outline: none;
    border-color: var(--clr-main);
    box-shadow: 0 0 0 3px var(--clr-main-soft);
}

/* Toggle text spans */
.toggle-text-expand,
.toggle-text-collapse {
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

/* Toggle icon */
.toggle-icon {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 14px;
    opacity: 0.9;
}

/* Rotate icon when expanded */
.description-toggle-btn[aria-expanded="true"] .toggle-icon {
    transform: rotate(180deg);
}

/* Button states for different content states */
.description-toggle-btn.expanding {
    pointer-events: none;
}

.description-toggle-btn.collapsing {
    pointer-events: none;
}

/* Loading state animation */
.description-toggle-btn.loading {
    opacity: 0.7;
}

.description-toggle-btn.loading .toggle-icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Word count indicator (optional) */
.description-word-count {
    font-size: 12px;
    color: var(--clr-text-muted);
    text-align: right;
    margin-top: 10px;
    opacity: 0.7;
}

/* Animation for content transitions */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOutDown {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

.description-full.animating-in {
    animation: fadeInUp 0.4s ease forwards;
}

.description-truncated.animating-out {
    animation: fadeOutDown 0.3s ease forwards;
}

/* Responsive Design */
@media (max-width: 991px) {
    .collapsible-description {
        padding: 15px;
        margin: 20px 0;
    }

    .description-toggle-btn {
        padding: 12px 24px;
        font-size: 15px;
        min-width: 110px;
    }

    .description-fade-overlay {
        height: 60px;
    }

    .archive-description {
        font-size: 15px;
    }
}

@media (max-width: 576px) {
    .collapsible-description {
        padding: 12px;
        margin: 15px 0;
        border-radius: var(--radius-md);
    }

    .description-toggle-btn {
        padding: 10px 20px;
        font-size: 14px;
        min-width: 100px;
        gap: 8px;
    }

    .description-fade-overlay {
        height: 50px;
    }

    .archive-description {
        font-size: 14px;
        line-height: 1.5;
    }

    .description-toggle-container {
        margin-top: 15px;
    }
}

@media (max-width: 400px) {
    .description-toggle-btn {
        padding: 8px 16px;
        font-size: 13px;
        min-width: 90px;
    }

    .toggle-icon {
        font-size: 12px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .description-fade-overlay {
        background: linear-gradient(
                to bottom,
                transparent 0%,
                var(--bg-site) 100%
        );
    }

    .description-toggle-btn {
        border: 2px solid var(--clr-text);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .description-truncated,
    .description-full,
    .description-fade-overlay,
    .toggle-icon,
    .description-toggle-btn {
        transition: none !important;
        animation: none !important;
    }

    .description-toggle-btn:hover {
        transform: none;
    }
}

/* Print styles */
@media print {
    .collapsible-description .description-truncated {
        display: none !important;
    }

    .collapsible-description .description-full {
        display: block !important;
    }

    .description-fade-overlay,
    .description-toggle-container {
        display: none !important;
    }

    .collapsible-description {
        background: none;
        border: none;
        padding: 0;
    }
}

/* Focus-within enhancement for better UX */
.collapsible-description:focus-within {
    box-shadow: 0 0 0 2px var(--clr-main-soft);
}

/* Smooth height transitions (advanced) */
.description-content.transitioning {
    overflow: hidden;
    transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Error state styles (in case of JS failure) */
.no-js .collapsible-description .description-truncated {
    display: none;
}

.no-js .collapsible-description .description-full {
    display: block;
}

.no-js .description-fade-overlay,
.no-js .description-toggle-container {
    display: none;
}
