/*
 * GAPphotos Photo Detail — ShutterWingPhotos-inspired layout
 * Main column: image + actions bar + comments
 * Sidebar: info cards with key-value rows
 */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@500;600;700&family=Outfit:wght@500;600;700;800&family=Source+Sans+3:wght@400;500;600;700&display=swap');

:root {
    --night: #080f1a;
    --panel: #111827;
    --surface: #1a2332;
    --elevated: #243044;
    --signal: #60a5fa;
    --signal-bright: #93c5fd;
    --signal-dim: #3b82f6;
    --text: #e8eef4;
    --muted: #8494a7;
    --line: rgba(96, 165, 250, 0.14);
    --line-strong: rgba(96, 165, 250, 0.28);
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
    --radius: 14px;
    --radius-lg: 16px;
    --mono: 'JetBrains Mono', ui-monospace, monospace;
    --display: 'Outfit', 'PingFang SC', sans-serif;
    --body: 'Source Sans 3', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    --beacon: #f87171;
    --success: #34d399;
}

body.page-photo-detail {
    font-family: var(--body);
    color: var(--text);
    background: var(--night) !important;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.55;
}

body.page-photo-detail::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 320px;
    background: linear-gradient(180deg, rgba(96, 165, 250, 0.1) 0%, transparent 100%);
    pointer-events: none;
    z-index: 0;
}

body.page-photo-detail > * { position: relative; z-index: 1; }

body.page-photo-detail ::selection {
    background: rgba(96, 165, 250, 0.35);
    color: #fff;
}

@media (prefers-reduced-motion: reduce) {
    body.page-photo-detail *, body.page-photo-detail *::before, body.page-photo-detail *::after {
        animation: none !important;
        transition: none !important;
    }
}

/* ── Page shell ── */
.pv-main {
    flex: 1;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.25rem clamp(1rem, 2.5vw, 1.75rem) 3rem;
    box-sizing: border-box;
}

.pv-nav-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.pv-back {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    padding: 0.4rem 0.8rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(26, 35, 50, 0.7);
    transition: color 0.2s, border-color 0.2s;
}

.pv-back:hover { color: var(--text); border-color: var(--line-strong); }

.pv-crumb {
    font-size: 0.8rem;
    color: var(--muted);
}

.pv-crumb a { color: var(--signal); text-decoration: none; font-weight: 600; }
.pv-crumb a:hover { color: var(--signal-bright); }
.pv-crumb span { margin: 0 0.3rem; opacity: 0.45; }

.pv-page-title {
    font-family: var(--display);
    font-size: clamp(1.35rem, 3vw, 1.85rem);
    font-weight: 700;
    line-height: 1.25;
    color: var(--text);
    margin: 0 0 1.25rem;
    text-align: left;
}

.pv-hot-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-family: var(--mono);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    vertical-align: middle;
    margin-left: 0.5rem;
    padding: 0.2rem 0.5rem;
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border-radius: 6px;
    border: 1px solid rgba(239, 68, 68, 0.35);
}

/* ── Two-column layout (SWP photo-detail-layout) ── */
.pv-detail-layout {
    display: flex;
    flex-wrap: wrap;
    gap: clamp(1rem, 2vw, 1.5rem);
    width: 100%;
    align-items: flex-start;
}

.pv-main-col {
    flex: 1 1 0;
    min-width: 0;
}

.pv-sidebar {
    flex: 0 0 340px;
    min-width: 0;
    max-width: 100%;
}

@media (min-width: 992px) {
    .pv-sidebar { flex-basis: 380px; }
}

/* ── Photo wrapper + image ── */
.pv-photo-wrap {
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 0;
    background: var(--panel);
    border: 1px solid var(--line);
}

.pv-photo-stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #060a10;
    cursor: zoom-in;
    min-height: 200px;
}

.pv-photo-stage img {
    width: 100%;
    max-height: 80vh;
    height: auto;
    object-fit: contain;
    display: block;
}

.pv-expand {
    position: absolute;
    top: 0.85rem;
    right: 0.85rem;
    width: 38px; height: 38px;
    border-radius: 50%;
    border: 1px solid var(--line-strong);
    background: rgba(8, 15, 26, 0.75);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(6px);
    transition: background 0.2s;
    z-index: 2;
}

.pv-expand:hover { background: var(--signal-dim); }

/* Actions bar attached to image */
.pv-actions-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: rgba(31, 41, 55, 0.85);
    border-top: 1px solid var(--line);
}

.pv-actions-bar__stats {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.pv-stat-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.pv-stat-inline i { color: var(--signal); font-size: 0.85rem; }

.pv-actions-bar__btns {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.pv-like-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: transparent;
    color: var(--muted);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--body);
}

.pv-like-btn:hover {
    border-color: var(--signal);
    color: var(--signal-bright);
}

.pv-like-btn.is-liked {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.45);
    color: #fca5a5;
}

.pv-like-btn--danger:hover {
    border-color: var(--beacon);
    color: #fca5a5;
}

.pv-download-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.85rem 1rem;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--signal-dim), var(--signal));
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    transition: filter 0.2s, transform 0.2s;
    font-family: var(--body);
}

.pv-download-btn:hover {
    color: #fff;
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.pv-btn-primary {
    background: linear-gradient(135deg, var(--signal-dim), var(--signal));
    border: none;
    color: #fff;
    font-weight: 600;
    border-radius: 8px;
}

.pv-btn-primary:hover { color: #fff; filter: brightness(1.06); }

/* ── Sidebar info cards ── */
.pv-info-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.35rem;
    margin-bottom: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--line);
}

.pv-info-card--actions {
    padding: 1rem 1.25rem;
}

.pv-info-card__title {
    font-family: var(--display);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.pv-info-card__title i {
    color: var(--signal);
    font-size: 0.9rem;
}

.pv-kv-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.pv-kv {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    font-size: 0.9rem;
}

.pv-kv__label {
    color: var(--muted);
    flex-shrink: 0;
}

.pv-kv__val {
    color: var(--text);
    font-weight: 500;
    text-align: right;
    word-break: break-word;
}

.pv-kv__val.is-mono {
    font-family: var(--mono);
    letter-spacing: 0.04em;
    font-size: 0.85rem;
}

.pv-kv__val a {
    color: var(--signal-bright);
    text-decoration: none;
}

.pv-kv__val a:hover { text-decoration: underline; }

.pv-info-desc-block {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

.pv-info-desc-block__label {
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 0.4rem;
}

.pv-info-desc-block__text {
    color: var(--text);
    line-height: 1.65;
    font-size: 0.925rem;
    word-break: break-word;
}

.pv-spotter-row {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.pv-spotter-row__avatar {
    width: 48px; height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--display);
    font-weight: 800;
    font-size: 1.15rem;
    color: #fff;
    background: linear-gradient(135deg, var(--signal-dim), var(--signal));
    flex-shrink: 0;
}

.pv-spotter-row__name {
    display: block;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
    text-decoration: none;
    margin-bottom: 0.15rem;
}

.pv-spotter-row__name:hover { color: var(--signal-bright); }

.pv-spotter-row__link {
    font-size: 0.8rem;
    color: var(--signal);
    text-decoration: none;
}

.pv-spotter-row__link:hover { color: var(--signal-bright); }

/* Related photos (main column grid) */
.pv-related {
    margin-top: 1.25rem;
}

.pv-related__title {
    font-family: var(--display);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.pv-related__title i {
    color: var(--signal);
    font-size: 0.9rem;
}

.pv-related-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
}

.pv-related-card {
    display: flex;
    flex-direction: column;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    overflow: hidden;
    background: var(--surface);
    text-decoration: none;
    transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.pv-related-card:hover {
    border-color: var(--line-strong);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.pv-related-card__img {
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #060a10;
}

.pv-related-card__img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.pv-related-card:hover .pv-related-card__img img {
    transform: scale(1.05);
}

.pv-related-card__title {
    padding: 0.7rem 0.85rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (min-width: 992px) {
    .pv-related-grid {
        gap: 1rem;
    }

    .pv-related-card__title {
        padding: 0.75rem 0.9rem;
        font-size: 0.9rem;
    }
}

/* ── Comments (full width below layout) ── */
.pv-comments {
    width: 100%;
    margin-top: 1.5rem;
    padding: 1.25rem 1.35rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.15);
    text-align: left;
    box-sizing: border-box;
}

.pv-comments__title {
    font-family: var(--display);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 1rem;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.pv-comments__title i { color: var(--signal); }
.pv-comments__title span { font-weight: 500; color: var(--muted); font-size: 0.9rem; }

.pv-comment-form {
    margin-bottom: 1.25rem;
}

.pv-comment-form textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--elevated);
    color: var(--text);
    border-radius: 8px;
    font-family: var(--body);
    font-size: 0.925rem;
    padding: 0.75rem;
    resize: vertical;
}

.pv-comment-form textarea:focus {
    border-color: var(--signal);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
    outline: none;
}

.pv-no-comments {
    text-align: center;
    color: var(--muted);
    font-style: italic;
    padding: 1.5rem;
}

.pv-comments-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.pv-comment-item {
    padding: 1rem 0;
    border-bottom: 1px solid var(--line);
}

.pv-comment-item:last-child { border-bottom: none; }

.pv-comment-item__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.pv-comment-item__user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pv-comment-item__avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, var(--signal-dim), var(--signal));
}

.pv-comment-item__date {
    font-size: 0.75rem;
    color: var(--muted);
    font-family: var(--mono);
}

.pv-comment-item__body {
    color: var(--muted);
    line-height: 1.65;
    font-size: 0.925rem;
    padding-left: 2.5rem;
}


/* ── Reject / review ── */
.pv-reject {
    padding: 1rem 1.15rem;
    margin-bottom: 1rem;
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.35);
    border-radius: var(--radius);
    border-left: 4px solid var(--beacon);
    color: #fecaca;
    font-size: 0.925rem;
}

.pv-reject strong {
    font-size: 0.85rem;
    color: #f87171;
}

.pv-review-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.pv-review-list li {
    padding: 0.65rem 0.75rem;
    margin-bottom: 0.45rem;
    background: var(--panel);
    border-radius: 8px;
    border-left: 3px solid var(--muted);
    font-size: 0.85rem;
    color: var(--muted);
}

.pv-review-list li.approved { border-left-color: var(--success); }
.pv-review-list li.rejected { border-left-color: var(--beacon); }

.pv-review-list .pv-meta {
    font-family: var(--mono);
    font-size: 0.68rem;
    margin-top: 0.2rem;
    opacity: 0.75;
}

/* ── Lightbox ── */
.pv-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(4, 8, 14, 0.94);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.pv-lightbox.is-open { opacity: 1; visibility: visible; }

.pv-lightbox img {
    max-width: 100%;
    max-height: 92vh;
    object-fit: contain;
    border-radius: 8px;
}

.pv-lightbox__close {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    width: 44px; height: 44px;
    border-radius: 50%;
    border: 1px solid var(--line-strong);
    background: rgba(26, 35, 50, 0.9);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pv-lightbox__close:hover { background: var(--signal-dim); }

/* ── Overrides ── */
.page-photo-detail .pv-appeal {
    background: var(--surface);
    border: 1px solid var(--line) !important;
    border-radius: var(--radius);
}

.page-photo-detail .pv-appeal .card-header {
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    color: var(--text);
}

.page-photo-detail .pv-appeal .card-body { color: var(--text); }

.page-photo-detail .pv-appeal .form-control {
    background: var(--panel);
    border-color: var(--line);
    color: var(--text);
}

.page-photo-detail .text-muted { color: var(--muted) !important; }
.page-photo-detail .text-secondary { color: var(--muted) !important; }
.page-photo-detail .alert { border-radius: var(--radius); border: 1px solid var(--line); }
.page-photo-detail .alert-secondary { background: var(--surface); color: var(--muted); }
.page-photo-detail .alert-secondary a { color: var(--signal); }

.page-photo-detail .btn-outline-danger {
    color: #fca5a5;
    border-color: rgba(248, 113, 113, 0.5);
}

.page-photo-detail .btn:focus-visible,
.page-photo-detail a:focus-visible {
    outline: 2px solid var(--signal);
    outline-offset: 2px;
}

.pv-footer {
    margin-top: auto;
    padding: 1.5rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--muted);
    border-top: 1px solid var(--line);
}

/* ── Mobile & tablet ── */
@media (max-width: 991px) {
    .pv-detail-layout {
        flex-direction: column;
        gap: 1rem;
    }

    .pv-main-col,
    .pv-sidebar {
        flex: none;
        width: 100%;
    }

    /* Stats already in sidebar — keep action bar compact */
    .pv-actions-bar__stats { display: none; }

    .pv-actions-bar {
        justify-content: center;
        padding: 0.75rem;
    }

    .pv-comments {
        margin-top: 0.25rem;
        padding: 1rem 1.1rem;
        border-radius: var(--radius);
    }
}

@media (max-width: 768px) {
    .pv-main {
        padding: 0.85rem 1rem calc(2rem + env(safe-area-inset-bottom, 0));
    }

    .pv-nav-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        margin-bottom: 0.75rem;
    }

    .pv-back {
        align-self: flex-start;
        min-height: 44px;
        padding: 0.5rem 1rem;
    }

    .pv-crumb {
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 0.15rem;
    }

    .pv-crumb::-webkit-scrollbar { display: none; }

    .pv-page-title {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.35rem 0.5rem;
        font-size: 1.25rem;
        margin-bottom: 1rem;
        line-height: 1.35;
    }

    .pv-hot-tag {
        margin-left: 0;
        margin-top: 0;
    }

    .pv-photo-stage img {
        max-height: min(58vh, 520px);
    }

    .pv-expand {
        width: 44px;
        height: 44px;
        top: 0.65rem;
        right: 0.65rem;
    }

    .pv-info-card {
        padding: 1rem 1.1rem;
        margin-bottom: 0.75rem;
        border-radius: var(--radius);
    }

    .pv-info-card--actions {
        padding: 0.75rem 1rem;
    }

    .pv-download-btn {
        min-height: 48px;
        font-size: 1rem;
    }

    .pv-like-btn {
        min-height: 44px;
        padding: 0.5rem 1.15rem;
        flex: 1 1 auto;
        justify-content: center;
    }

    .pv-actions-bar__btns {
        width: 100%;
    }

    .pv-actions-bar__btns form {
        flex: 1 1 0;
        min-width: 0;
    }

    .pv-actions-bar__btns .pv-like-btn {
        width: 100%;
    }

    .pv-comment-item__head {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .pv-comment-item__date {
        width: 100%;
        padding-left: 2.5rem;
        margin-top: 0.15rem;
    }

    .pv-lightbox {
        padding: max(1rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
    }

    .pv-lightbox__close {
        top: max(0.75rem, env(safe-area-inset-top));
        right: max(0.75rem, env(safe-area-inset-right));
        width: 48px;
        height: 48px;
    }

    .pv-lightbox img {
        max-height: calc(100dvh - 5rem);
    }

    .pv-footer {
        padding: 1.25rem 1rem calc(1.25rem + env(safe-area-inset-bottom, 0));
    }
}

@media (max-width: 576px) {
    .pv-main {
        padding-left: max(0.75rem, env(safe-area-inset-left, 0));
        padding-right: max(0.75rem, env(safe-area-inset-right, 0));
    }

    /* Edge-to-edge photo */
    .pv-photo-wrap {
        margin-left: calc(-1 * max(0.75rem, env(safe-area-inset-left, 0)));
        margin-right: calc(-1 * max(0.75rem, env(safe-area-inset-right, 0)));
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .pv-actions-bar {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .pv-kv {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.2rem;
        padding-bottom: 0.5rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    }

    .pv-kv:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }

    .pv-kv__val { text-align: left; }

    .pv-related-grid {
        gap: 0.65rem;
    }

    .pv-related-card__title {
        padding: 0.6rem 0.7rem;
        font-size: 0.82rem;
    }

    .pv-comment-item__body { padding-left: 0; }

    .pv-comment-item__date { padding-left: 2.5rem; }

    .pv-comment-form .btn {
        width: 100%;
        min-height: 44px;
    }

    .pv-reject {
        padding: 0.85rem 1rem;
        font-size: 0.875rem;
    }

    .page-photo-detail .pv-appeal .card-body {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
}

@media (max-width: 380px) {
    .pv-page-title { font-size: 1.1rem; }

    .pv-actions-bar__btns {
        flex-direction: column;
    }

    .pv-actions-bar__btns form { width: 100%; }
}
