/* ==========================================================================
   Activity page detail and shared-link page
   Used by pages/page_detail.html and pages/page_shared.html (both extend
   base.html). Class names used by page_detail.js: .zoomable,
   .image-lightbox, .lightbox-*, .copy-toast, .faq-item, body.no-scroll.
   ========================================================================== */

.page-detail-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem clamp(1rem, 4vw, 2.5rem) 4rem;
}

.page-detail-container h2 {
    margin: 0 0 0.75rem;
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

/* Breadcrumb (page_list.css also styles this for the list pages) */
.page-detail-container .breadcrumb-nav {
    margin: 0 0 1.5rem;
}

.page-detail-container .breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    font-size: 0.875rem;
    list-style: none;
}

.page-detail-container .breadcrumb a {
    color: var(--brand-primary);
}

.page-detail-container .breadcrumb-separator {
    color: var(--text-muted);
}

.page-detail-container .breadcrumb-current {
    color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   Two-column layout: the sheet on graph paper, then the details
   -------------------------------------------------------------------------- */
.page-detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    gap: clamp(1.5rem, 4vw, 3.5rem);
    align-items: start;
}

.preview-section {
    position: sticky;
    top: calc(var(--header-height, 64px) + 1.5rem);
}

.preview-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: clamp(1.25rem, 4vw, 2.5rem);
    background-color: var(--bg-primary);
    background-image:
        linear-gradient(var(--jg-rule) 1px, transparent 1px),
        linear-gradient(90deg, var(--jg-rule) 1px, transparent 1px);
    background-size: 24px 24px;
    background-position: -1px -1px;
    overflow: hidden;
}

.preview-image {
    display: block;
    width: 100%;
    height: auto;
    max-height: 70vh;
    object-fit: contain;
    background: #ffffff; /* the printed sheet */
    border: 1px solid var(--border-strong);
}

.preview-image.zoomable {
    cursor: zoom-in;
}

.no-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 4rem 1rem;
    color: var(--text-muted);
}

.no-preview i {
    font-size: 2rem;
}

.preview-hint {
    margin: 0.625rem 0 0;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Details column
   -------------------------------------------------------------------------- */
.page-header {
    margin-bottom: 1rem;
}

.page-kind {
    margin: 0 0 0.375rem;
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

.page-kind a {
    color: var(--brand-primary);
}

.page-title {
    margin: 0 0 1rem;
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 5vw, 4.25rem);
    font-weight: 700;
    line-height: 0.98;
    letter-spacing: -0.035em;
    color: var(--text-primary);
}

.page-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.5rem;
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.page-stats__rating i {
    color: var(--accent-yellow);
}

.short-description {
    max-width: 62ch;
    margin: 0 0 1.25rem;
    font-size: 1.0625rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

/* Download / print */
.download-section {
    margin: 1.25rem 0 1.75rem;
}

.download-buttons,
.login-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.btn-page {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 48px;
    padding: 0.625rem 1.25rem;
    font: inherit;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--brand-primary);
    text-decoration: none;
    cursor: pointer;
    background: transparent;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.btn-page:hover {
    color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.btn-page--primary,
.btn-page--primary:hover {
    color: #ffffff;
    background: var(--brand-primary-strong);
    border-color: var(--brand-primary-strong);
}

.btn-page--primary:hover {
    background: var(--accent-primary-hover);
}

.btn-page:focus-visible,
.share-btn:focus-visible,
.tag:focus-visible,
.page-card:focus-visible,
.view-all-link:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

.download-note {
    margin: 0.75rem 0 0;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.download-blocked {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    padding: 0.875rem 0;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-medium);
    border-bottom: 1px solid var(--border-medium);
}

.login-prompt {
    padding: 0;
}

.login-prompt__text {
    margin: 0 0 0.875rem;
    color: var(--text-primary);
}

/* Facts table */
.page-facts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0;
    margin: 0 0 2rem;
    border-top: 1px solid var(--border-medium);
}

.page-facts > div {
    padding: 0.75rem 0.75rem 0.75rem 0;
    border-bottom: 1px solid var(--border-light);
}

.page-facts dt {
    margin: 0 0 0.125rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
}

.page-facts dd {
    margin: 0;
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.description-section,
.tags-section,
.share-section {
    margin: 0 0 1.75rem;
}

.description-content {
    max-width: 68ch;
    line-height: 1.65;
    color: var(--text-secondary);
}

.description-content p {
    margin: 0 0 0.875rem;
}

.tags-list,
.share-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    min-height: 36px;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    color: var(--text-primary);
    text-decoration: none;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
}

.tag:hover {
    color: var(--text-primary);
    border-color: var(--brand-primary);
}

.share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    font-size: 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    cursor: pointer;
    background: transparent;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
}

.share-btn:hover {
    color: var(--text-primary);
    border-color: var(--brand-primary);
}

/* --------------------------------------------------------------------------
   Lower sections
   -------------------------------------------------------------------------- */
.reviews-section,
.related-section,
.faq-section {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 3fr);
    column-gap: clamp(1.5rem, 5vw, 4rem);
    align-items: start;
    margin-top: clamp(3rem, 6vw, 5rem);
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-medium);
}

.reviews-section > *,
.related-section > *,
.faq-section > * {
    grid-column: 2;
}

.reviews-section > .section-header,
.related-section > .section-header,
.faq-section > h2 {
    grid-column: 1;
    grid-row: 1 / span 10;
}

.page-detail-container .reviews-section h2,
.page-detail-container .related-section h2,
.page-detail-container .faq-section h2 {
    font-size: clamp(1.6rem, 3vw, 2.25rem);
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.page-detail-container .section-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    margin: 0;
    text-align: left;
}

.section-header h2 {
    margin: 0;
}

.rating-summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

.stars-display,
.review-rating {
    color: var(--accent-yellow);
}

.review-login-prompt,
.no-reviews {
    margin: 0 0 1rem;
    color: var(--text-secondary);
}

.review-login-prompt a {
    color: var(--brand-primary);
    text-decoration: underline;
}

.review-form-container {
    max-width: 40rem;
    margin-bottom: 2rem;
}

.review-form-container h3 {
    margin: 0 0 0.75rem;
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--text-primary);
}

.existing-review-notice {
    margin: 0 0 1rem;
    color: var(--text-secondary);
}

.review-form .form-group {
    margin: 0 0 1rem;
    padding: 0;
    border: 0;
}

.review-form label,
.review-form legend {
    display: block;
    margin: 0 0 0.375rem;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary);
}

.review-form .required {
    font-weight: 400;
    color: var(--text-muted);
}

.review-form .form-control {
    width: 100%;
    padding: 0.625rem 0.75rem;
    font: inherit;
    color: var(--text-primary);
    background: var(--input-bg);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
}

.review-form .form-control:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 1px;
}

.form-hint {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* Star input: radios are 5..1 in source order, shown right-to-left */
.star-rating-input {
    display: inline-flex;
    flex-direction: row-reverse;
    gap: 0.25rem;
}

.star-rating-input input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.star-rating-input label {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
}

.star-rating-input label:hover,
.star-rating-input label:hover ~ label,
.star-rating-input input:checked ~ label {
    color: var(--accent-yellow);
}

.star-rating-input input:focus-visible + label {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
    border-radius: 2px;
}

.reviews-list {
    display: flex;
    flex-direction: column;
    max-width: 48rem;
}

.review-card {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-light);
}

.review-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.75rem;
    margin-bottom: 0.375rem;
    font-size: 0.875rem;
}

.reviewer-name {
    font-weight: 600;
    color: var(--text-primary);
}

.review-date {
    color: var(--text-muted);
}

.review-title {
    margin: 0 0 0.25rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.review-content {
    line-height: 1.6;
    color: var(--text-secondary);
}

.review-content p {
    margin: 0 0 0.5rem;
}

/* Related pages */
.view-all-link {
    font-size: 0.9375rem;
    color: var(--brand-primary);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 1rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.page-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    color: inherit;
    text-decoration: none;
}

.page-card:hover {
    color: inherit;
}

.page-card:hover .page-card-image {
    border-color: var(--brand-primary);
}

.page-card-image {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 3 / 4;
    padding: 0.625rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    border-radius: 4px;
    transition: border-color 0.15s ease;
}

.page-card-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #ffffff;
    border: 1px solid var(--border-light);
}

.no-image {
    font-size: 1.5rem;
    color: var(--text-muted);
}

.page-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.75rem 0 0;
}

.page-card-title {
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text-primary);
}

.page-card:hover .page-card-title {
    text-decoration: underline;
}

.page-card-meta {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* FAQ */
.faq-list {
    max-width: 48rem;
    border-top: 1px solid var(--border-light);
}

.faq-item {
    border-bottom: 1px solid var(--border-light);
}

.faq-item summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 0;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    list-style: none;
}

.faq-item summary::-webkit-details-marker {
    display: none;
}

.faq-item summary::after {
    content: '+';
    flex-shrink: 0;
    font-size: 1.25rem;
    line-height: 1;
    color: var(--text-muted);
}

.faq-item[open] summary::after {
    content: '−';
}

.faq-item summary:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

.faq-item p {
    max-width: 65ch;
    margin: 0 0 1rem;
    line-height: 1.65;
    color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   Shared-link banner (page_shared.html)
   -------------------------------------------------------------------------- */
.shared-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 1rem;
    margin: 0 0 2rem;
    padding: 0 0 1rem;
    border-bottom: 1px solid var(--border-medium);
}

.shared-banner p {
    margin: 0;
    color: var(--text-primary);
}

.shared-banner .expiry-notice {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Created by page_detail.js
   -------------------------------------------------------------------------- */
body.no-scroll {
    overflow: hidden;
}

.image-lightbox {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.image-lightbox.active {
    opacity: 1;
}

.lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 12, 24, 0.8);
}

.lightbox-content {
    position: relative;
    max-width: min(900px, 100%);
    max-height: 100%;
}

.lightbox-content img {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 3rem);
    object-fit: contain;
    background: #ffffff;
}

.lightbox-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    font-size: 1.125rem;
    color: var(--text-primary);
    cursor: pointer;
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
}

.lightbox-close:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

.copy-toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 10001;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    font-weight: 500;
    color: var(--bg-primary);
    background: var(--text-primary);
    border-radius: 6px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.copy-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.copy-toast i {
    color: var(--success-text);
}

/* --------------------------------------------------------------------------
   Responsive and motion
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
    .page-detail-grid,
    .reviews-section,
    .related-section,
    .faq-section {
        grid-template-columns: 1fr;
    }

    .reviews-section > *,
    .related-section > *,
    .faq-section > *,
    .reviews-section > .section-header,
    .related-section > .section-header,
    .faq-section > h2 {
        grid-column: 1;
        grid-row: auto;
    }

    .section-header,
    .faq-section > h2 {
        margin-bottom: 1rem;
    }

    .preview-section {
        position: static;
    }

    .preview-image {
        max-height: 60vh;
    }
}

@media (max-width: 480px) {
    .download-buttons .btn-page,
    .login-buttons .btn-page {
        flex: 1 1 100%;
    }

    .related-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (prefers-reduced-motion: reduce) {
    .image-lightbox,
    .copy-toast,
    .page-card {
        transition: none;
    }
}

@media print {
    .breadcrumb-nav,
    .download-section,
    .share-section,
    .reviews-section,
    .related-section,
    .faq-section {
        display: none;
    }
}
