/* ============================================================
   viewer-chrome.css — Gallery-owned chrome styles
   Phase 4 Task 4.1 — ported from viewer-library.css.

   This file contains CSS rules for the six gallery-owned chrome
   partials (_sidebar, _toolbar, _info_bar, _reaction_picker,
   _dropup_menu, _help_modal). Phase 6 deletes the viewer-library.css
   <link> tag; by that point all chrome styling must already be here.

   Uses the same --pv-* CSS custom property tokens defined in
   viewer-library.css (:root block). If viewer-library.css is absent,
   viewer-glass-overrides.css and this file remain self-consistent
   because the token declarations are part of the vendor stylesheet
   which ships until Phase 6.

   Selector naming convention: preserve exact pv-* class names
   from the legacy library-ui so Alpine partials use the same
   classes — minimising Alpine HTML churn in Tasks 4.2–4.6.
   Gallery-specific additions use the gallery-* prefix.
   ============================================================ */

/* ============================================================
   Sidebar chrome partials
   ============================================================ */

/* Core sidebar container — mirrors viewer-library.css lines 80-128 */
.pv-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    height: 100%;
    width: var(--pv-sidebar-width, 320px);
    z-index: 200;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--pv-sidebar-bg, var(--pv-bg, #1a1a1a));
    backdrop-filter: var(--pv-sidebar-backdrop-filter, none);
    -webkit-backdrop-filter: var(--pv-sidebar-backdrop-filter, none);
    border-left: var(--pv-sidebar-border-left, none);
    color: var(--pv-text, #e2e8f0);
    overflow: hidden;
    will-change: transform;
    box-shadow: var(--pv-shadow, 0 4px 20px rgba(0, 0, 0, 0.4));
}

.pv-sidebar.pv-sidebar--open {
    transform: translateX(0);
}

/* Backdrop — mobile overlay behind open sidebar */
.pv-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 199;
    background: var(--pv-overlay-bg, rgba(0, 0, 0, 0.5));
}

.pv-sidebar-backdrop.pv-sidebar-backdrop--visible {
    display: block;
}

/* Desktop: never show the backdrop. The sidebar is a side panel,
   not a full-viewport overlay — no dimming needed, no click-to-close. */
@media (min-width: 769px) {
    .pv-sidebar-backdrop,
    .pv-sidebar-backdrop.pv-sidebar-backdrop--visible {
        display: none;
    }
}

/* When backdrop is visible (mobile sidebar open), info bar shifts to
   left-aligned anchor. `body` prefix bumps specificity to (0,0,2,1) so
   this wins cleanly over `.pv-info-bar.pv-info-center` (0,0,2,0) in
   source-order, without `!important`. */
body .pv-sidebar-backdrop--visible ~ .pv-info-bar {
    left: 16px;
    transform: none;
}

/* ============================================================
   Sidebar toggle button (floating, outside sidebar DOM)
   ============================================================ */

.pv-sidebar-toggle {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 201;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: var(--pv-toggle-btn-border, 1px solid rgba(255, 255, 255, 0.2));
    background: var(--pv-toggle-btn-bg, rgba(0, 0, 0, 0.5));
    color: var(--pv-text, #e2e8f0);
    cursor: pointer;
    font-size: 22px;
    transition: all var(--pv-transition, 0.2s ease);
    backdrop-filter: var(--pv-toggle-btn-backdrop-filter, blur(8px));
    -webkit-backdrop-filter: var(--pv-toggle-btn-backdrop-filter, blur(8px));
}

.pv-sidebar-toggle:hover {
    background: var(--pv-hover-bg, rgba(255, 255, 255, 0.05));
    border-color: var(--pv-border-strong, rgba(255, 255, 255, 0.15));
}

/* When collapsed, the toggle is a circle ("open" affordance) */
.pv-sidebar-toggle[aria-expanded="false"] {
    border-radius: 9999px;
}

/* ============================================================
   Sidebar header (profile context)
   ============================================================ */

.pv-header {
    padding: 16px;
    border-bottom: 1px solid var(--pv-border, rgba(255, 255, 255, 0.08));
    flex-shrink: 0;
}

.pv-header-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pv-header-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--pv-border-strong, rgba(255, 255, 255, 0.15));
    flex-shrink: 0;
}

.pv-header-info {
    min-width: 0;
    flex: 1;
}

.pv-header-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--pv-text, #e2e8f0);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pv-header-subtitle {
    font-size: 12px;
    color: var(--pv-text-muted, #94a3b8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pv-header-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.pv-header-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--pv-text-muted, #94a3b8);
    text-decoration: none;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--pv-border, rgba(255, 255, 255, 0.08));
    transition: all var(--pv-transition, 0.2s ease);
}

.pv-header-link:hover {
    color: var(--pv-accent, #e13e13);
    border-color: var(--pv-accent-border, rgba(225, 62, 19, 0.6));
    background: var(--pv-accent-active, rgba(225, 62, 19, 0.25));
}

/* ============================================================
   Sidebar content (scrollable section + thumbnail area)
   ============================================================ */

.pv-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
}

.pv-content::-webkit-scrollbar {
    width: 4px;
}

.pv-content::-webkit-scrollbar-track {
    background: transparent;
}

.pv-content::-webkit-scrollbar-thumb {
    background: var(--pv-border-strong, rgba(255, 255, 255, 0.15));
    border-radius: 2px;
}

/* ============================================================
   Section headings + accordion
   ============================================================ */

.pv-section {
    animation: pv-slide-up 0.2s ease-out;
}

.pv-section-heading {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--pv-text-muted, #94a3b8);
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    transition: all var(--pv-transition, 0.2s ease);
}

.pv-section-heading:hover {
    color: var(--pv-text, #e2e8f0);
    background: var(--pv-hover-bg, rgba(255, 255, 255, 0.05));
}

.pv-section-body {
    overflow: hidden;
    transition: max-height 0.25s ease, opacity 0.2s ease;
}

.pv-section--collapsed .pv-section-body {
    display: none;
}

/* ============================================================
   Thumbnail grid
   ============================================================ */

.pv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 6px;
    padding: 4px 12px 12px;
}

.pv-thumbnail {
    position: relative;
    display: block;
    aspect-ratio: 2 / 1;
    border-radius: var(--pv-thumbnail-radius, 4px);
    overflow: hidden;
    cursor: pointer;
    border: none;
    padding: 0;
    background: var(--pv-hover-bg, rgba(255, 255, 255, 0.05));
    transition: opacity 0.15s ease;
}

.pv-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.pv-thumbnail:hover {
    opacity: 0.88;
}

/* Selected thumbnail — neutral contrast ring (gallery override) */
.pv-thumbnail--selected {
    outline: none;
}

.pv-thumbnail--selected::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    border: 2px solid transparent;
    border-radius: inherit;
    box-sizing: border-box;
}

.pv-sidebar[data-theme="dark"] .pv-thumbnail--selected::after,
[data-theme="dark"] .pv-thumbnail--selected::after {
    border-color: #ffffff;
    background: rgba(255, 255, 255, 0.18);
}

.pv-sidebar[data-theme="light"] .pv-thumbnail--selected::after,
[data-theme="light"] .pv-thumbnail--selected::after {
    border-color: #111111;
    background: rgba(255, 255, 255, 0.32);
}

/* ============================================================
   Placeholder (empty library)
   ============================================================ */

.pv-placeholder-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px 16px;
    color: var(--pv-text-muted, #94a3b8);
}

.pv-placeholder-icon {
    font-size: 40px;
    opacity: 0.4;
}

.pv-placeholder-caption {
    font-size: 13px;
    text-align: center;
}

/* ============================================================
   Toolbar chrome partial (top of sidebar)
   ============================================================ */

.pv-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 14px 12px;
    background: var(--pv-toolbar-bg, transparent);
    border-bottom: var(--pv-toolbar-border-bottom, 1px solid var(--pv-border, rgba(255, 255, 255, 0.08)));
    backdrop-filter: var(--pv-toolbar-backdrop-filter, none);
    -webkit-backdrop-filter: var(--pv-toolbar-backdrop-filter, none);
    flex-shrink: 0;
}

/* Toolbar pinned to the top of the sidebar (Phase 1 sidebar-toolbar-restore).
   Sidebar is a flex/scroll column; sticky keeps the controls reachable while
   thumbnails scroll. Padding matches .pv-header (16px horizontal) so the
   toolbar and header share the same gutter. */
.pv-sidebar > .pv-toolbar {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 12px 16px;
}

.pv-toolbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--pv-border, rgba(255, 255, 255, 0.08));
    border-radius: 8px;
    background: transparent;
    color: var(--pv-text-muted, #94a3b8);
    cursor: pointer;
    font-size: 18px;
    transition: all var(--pv-transition, 0.2s ease);
    flex-shrink: 0;
}

.pv-toolbar-btn:hover {
    color: var(--pv-text, #e2e8f0);
    border-color: var(--pv-border-strong, rgba(255, 255, 255, 0.15));
    background: var(--pv-hover-bg, rgba(255, 255, 255, 0.05));
}

.pv-toolbar-btn.active {
    color: var(--pv-accent, #e13e13);
    border-color: var(--pv-accent-border, rgba(225, 62, 19, 0.6));
    background: var(--pv-accent-bg, transparent);
}

/* Resolution wrapper */
.pv-res-wrapper {
    position: relative;
}

.pv-res-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--pv-border, rgba(255, 255, 255, 0.08));
    border-radius: 8px;
    background: transparent;
    color: var(--pv-text-muted, #94a3b8);
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    font-family: inherit;
    letter-spacing: 0.5px;
    transition: all var(--pv-transition, 0.2s ease);
    flex-shrink: 0;
    padding: 0;
}

.pv-res-btn:hover {
    color: var(--pv-text, #e2e8f0);
    border-color: var(--pv-border-strong, rgba(255, 255, 255, 0.15));
    background: var(--pv-hover-bg, rgba(255, 255, 255, 0.05));
}

.pv-res-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: var(--pv-bg-elevated, #242424);
    border: 1px solid var(--pv-border-strong, rgba(255, 255, 255, 0.15));
    border-radius: 8px;
    padding: 4px;
    min-width: 80px;
    z-index: 300;
    box-shadow: var(--pv-shadow, 0 4px 20px rgba(0, 0, 0, 0.4));
    display: none;
}

.pv-res-dropdown.open {
    display: block;
}

.pv-res-option {
    display: block;
    width: 100%;
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--pv-text-muted, #94a3b8);
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    transition: all var(--pv-transition, 0.2s ease);
}

.pv-res-option:hover {
    background: var(--pv-hover-bg, rgba(255, 255, 255, 0.05));
    color: var(--pv-text, #e2e8f0);
}

.pv-res-option.active {
    color: var(--pv-accent, #e13e13);
}

/* ============================================================
   Info bar chrome partial (floating bottom panel)
   ============================================================ */

.pv-info-bar {
    position: fixed;
    bottom: 16px;
    z-index: 202;
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--pv-info-bar-bg, rgba(0, 0, 0, 0.45));
    backdrop-filter: var(--pv-info-bar-backdrop-filter, blur(20px) saturate(1.4));
    -webkit-backdrop-filter: var(--pv-info-bar-backdrop-filter, blur(20px) saturate(1.4));
    border: var(--pv-info-bar-border, 1px solid rgba(255, 255, 255, 0.08));
    border-radius: 14px;
    color: rgba(255, 255, 255, 0.85);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    pointer-events: auto;
    max-width: calc(100vw - 32px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.pv-info-bar.visible {
    display: flex;
}

/* Alignment variants */
.pv-info-bar.pv-info-left {
    left: 16px;
}

.pv-info-bar.pv-info-center {
    left: 50%;
    transform: translateX(-50%);
}

/* Nav buttons */
.pv-info-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.15s ease;
    flex-shrink: 0;
    padding: 0;
}

.pv-info-nav:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.25);
}

.pv-info-nav:disabled {
    opacity: 0.25;
    cursor: default;
    pointer-events: none;
}

/* Text area */
.pv-info-text {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    padding: 0 6px;
    text-align: center;
}

.pv-info-title {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.pv-info-subtitle {
    font-size: 11px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.45);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

/* Description display row (Task 12 Step 12.0) — matches subtitle style */
.pv-info-description {
    font-size: 11px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.45);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

/* Mobile: dock info bar flat to bottom edge */
@media (max-width: 480px) {
    .pv-info-bar,
    .pv-info-bar.pv-info-center,
    .pv-info-bar.pv-info-left {
        left: 0;
        right: 0;
        bottom: 0;
        transform: none;
        width: 100%;
        max-width: none;
        margin: 0;
        border-radius: 0;
        border: 0;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.35);
        padding: 6px 8px calc(6px + env(safe-area-inset-bottom)) 8px;
        gap: 6px;
        justify-content: space-between;
    }

    .pv-info-bar .pv-info-text {
        display: none;
    }

    body[data-theme="light"] .pv-info-bar,
    .pv-info-bar[data-theme="light"] {
        border-top-color: rgba(15, 23, 42, 0.10);
    }
}

/* ============================================================
   Responsive sidebar widths
   ============================================================ */

@media (max-width: 480px) {
    .pv-sidebar {
        width: 100vw;
        max-width: 100vw;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .pv-sidebar {
        width: 80vw;
    }
}

/* ============================================================
   Fullscreen — hide chrome overlays
   ============================================================ */

:fullscreen .pv-sidebar-toggle,
:fullscreen .pv-sidebar,
:fullscreen .pv-sidebar-backdrop,
:fullscreen .pv-info-bar {
    display: none !important;
}

/* ============================================================
   Animations
   ============================================================ */

@keyframes pv-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes pv-slide-up {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Reaction picker partial
   Gallery-chrome owned 6×6 emoji picker overlay.
   CSS re-uses .reaction-picker-* classes from reaction-picker.css
   — this block is intentionally minimal to avoid duplication.
   ============================================================ */

/* The gallery-reaction-picker-mount uses the same overlay + panel
   classes as the legacy #reaction-picker-mount — both are styled by
   reaction-picker.css. No duplicate rules needed here; this selector
   just ensures the mount stays inert when closed. */
.gallery-reaction-picker-mount {
    display: contents;
}

/* ============================================================
   Dropup menu partial (gallery-dropup)
   Gallery-owned panel replacing the legacy DOM-injected dropup.
   Selector prefix gallery-dropup to avoid collision with the
   legacy pv-dropup-* classes in dropup-menu.css during
   the Phase 4 → Phase 5 transition.
   ============================================================ */

.gallery-dropup {
    position: fixed;
    bottom: calc(56px + 16px + 8px); /* info bar height + gap */
    right: 16px;
    z-index: 210;
}

.gallery-dropup__panel {
    min-width: 280px;
    max-height: 60vh;
    overflow-y: auto;
    background: rgba(20, 20, 20, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    padding: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* Transition classes (used by Alpine x-transition:enter/leave) */
.gallery-dropup__panel--enter {
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.gallery-dropup__panel--enter-start {
    opacity: 0;
    transform: translateY(8px);
}

.gallery-dropup__panel--enter-end {
    opacity: 1;
    transform: translateY(0);
}

/* Tags row */
.gallery-dropup__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 8px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 4px;
}

.gallery-dropup__tag {
    display: inline-flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.85);
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    line-height: 1.4;
}

/* Meta row */
.gallery-dropup__meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px 8px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 4px;
}

.gallery-dropup__meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.65);
}

.gallery-dropup__meta-item i {
    width: 16px;
    font-size: 14px;
    text-align: center;
    flex-shrink: 0;
}

/* Action buttons */
.gallery-dropup__actions {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.gallery-dropup__btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.9);
    padding: 10px 12px;
    border-radius: 6px;
    font: inherit;
    text-align: left;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.1s ease;
}

.gallery-dropup__btn:hover {
    background: rgba(255, 255, 255, 0.06);
}

.gallery-dropup__btn i {
    font-size: 18px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.gallery-dropup__btn--danger {
    color: #e13e13;
}

.gallery-dropup__btn--danger:hover {
    background: rgba(225, 62, 19, 0.12);
}

/* --- Owner section (gated on isOwner && image) --- */

.gallery-dropup__actions--owner {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin-top: 4px;
    padding-top: 4px;
}

.gallery-dropup__action-btn {
    /* Extends .gallery-dropup__btn — no additional overrides needed */
}

.gallery-dropup__action-btn--danger {
    color: #e13e13;
}

.gallery-dropup__action-btn--danger:hover {
    background: rgba(225, 62, 19, 0.12);
}

/* --- Inline delete-confirm row (replaces owner buttons when confirming) --- */

.gallery-dropup__confirm-delete {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 6px 12px;
}

.gallery-dropup__confirm-delete-label {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gallery-dropup__confirm-delete-error {
    font-size: 11px;
    color: #e13e13;
    line-height: 1.3;
}

.gallery-dropup__confirm-delete-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.gallery-dropup__confirm-delete-btn {
    font-size: 12px;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.1s ease;
}

.gallery-dropup__confirm-delete-btn--yes {
    color: #fff;
    background: #e13e13;
    border: 1px solid #e13e13;
}

.gallery-dropup__confirm-delete-btn--yes:hover {
    background: #c41212;
    border-color: #c41212;
}

.gallery-dropup__confirm-delete-btn--yes:disabled {
    opacity: 0.5;
    cursor: wait;
}

.gallery-dropup__confirm-delete-btn--no {
    color: rgba(255, 255, 255, 0.7);
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.20);
}

.gallery-dropup__confirm-delete-btn--no:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.9);
}

.gallery-dropup__confirm-delete-btn--no:disabled {
    opacity: 0.5;
    cursor: wait;
}

/* Light-theme overrides for owner section */
[data-theme="light"] .gallery-dropup__actions--owner {
    border-top-color: rgba(15, 23, 42, 0.10);
}

[data-theme="light"] .gallery-dropup__confirm-delete-label {
    color: rgba(15, 23, 42, 0.9);
}

[data-theme="light"] .gallery-dropup__confirm-delete-btn--no {
    color: rgba(15, 23, 42, 0.6);
    border-color: rgba(15, 23, 42, 0.15);
}

[data-theme="light"] .gallery-dropup__confirm-delete-btn--no:hover {
    background: rgba(15, 23, 42, 0.06);
    color: rgba(15, 23, 42, 0.85);
}

/* ============================================================
   Help modal partial
   Chrome-partial version of the legacy #gallery-help block.
   Shares the gallery-help-* class names with viewer-glass-overrides.css
   and the inline CSS that was in viewer_page.html, so the existing
   animation and glass-panel CSS continues to apply unchanged.
   ============================================================ */

/* Backdrop overlay for the Alpine-owned help modal */
.gallery-help-backdrop {
    position: fixed;
    inset: 0;
    z-index: -1; /* behind .gallery-help-panel, inside the modal stacking context */
    cursor: pointer;
}

/* Re-declare the core modal rules here so this file is self-contained
   once the inline <style> block in viewer_page.html is removed in Phase 5.
   These rules intentionally duplicate the ones in viewer-glass-overrides.css
   so viewer-chrome.css can stand alone; duplicates are harmless until Phase 6
   drops viewer-glass-overrides.css alongside viewer-library.css. */

#gallery-help-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity 0.18s ease;
}

#gallery-help-modal[hidden] { display: none; }

#gallery-help-modal.gallery-help--open { opacity: 1; }

/* ============================================================
   Light-theme token overrides for chrome partials
   Mirrors the :root dark defaults above with light values.
   Applied when <html data-theme="light"> (set by pre-paint script).
   ============================================================ */

[data-theme="light"] .pv-sidebar {
    color: var(--pv-text, #1e293b);
}

[data-theme="light"] .pv-info-bar {
    color: rgba(15, 23, 42, 0.85);
}

[data-theme="light"] .pv-info-title {
    color: rgba(15, 23, 42, 0.9);
}

[data-theme="light"] .pv-info-subtitle {
    color: rgba(15, 23, 42, 0.45);
}

[data-theme="light"] .pv-info-nav {
    border-color: rgba(15, 23, 42, 0.12);
    background: rgba(15, 23, 42, 0.06);
    color: rgba(15, 23, 42, 0.6);
}

[data-theme="light"] .pv-info-nav:hover {
    background: rgba(15, 23, 42, 0.12);
    color: #000;
    border-color: rgba(15, 23, 42, 0.25);
}

[data-theme="light"] .gallery-dropup__panel {
    background: rgba(250, 250, 252, 0.92);
    border-color: rgba(15, 23, 42, 0.12);
    color: rgba(15, 23, 42, 0.9);
}

[data-theme="light"] .gallery-dropup__btn {
    color: rgba(15, 23, 42, 0.9);
}

[data-theme="light"] .gallery-dropup__btn:hover {
    background: rgba(15, 23, 42, 0.06);
}

[data-theme="light"] .gallery-dropup__tag {
    background: rgba(15, 23, 42, 0.06);
    border-color: rgba(15, 23, 42, 0.12);
    color: rgba(15, 23, 42, 0.85);
}

[data-theme="light"] .gallery-dropup__meta-item {
    color: rgba(15, 23, 42, 0.65);
}

/* ============================================================
   Owner editing chrome — Phase 1 Task 1.2
   All classes use gallery-owner-* prefix.
   ============================================================ */

/* Owner menu dropdown panel */
.gallery-owner-menu__panel {
    position: absolute;
    z-index: 500;
    min-width: 160px;
    background: rgba(var(--pv-surface-rgb, 30 30 30), 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(var(--pv-border-rgb, 255 255 255), 0.18);
    border-radius: 8px;
    padding: 4px 0;
    box-shadow: 0 8px 32px rgba(0,0,0,0.48);
}

.gallery-owner-menu__item {
    display: block;
    width: 100%;
    padding: 9px 16px;
    background: none;
    border: none;
    color: inherit;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
}

.gallery-owner-menu__item:hover,
.gallery-owner-menu__item:focus-visible {
    background: rgba(var(--pv-border-rgb, 255 255 255), 0.10);
    outline: none;
}

.gallery-owner-menu__item--danger { color: #e13e13; }
.gallery-owner-menu__item--danger:hover,
.gallery-owner-menu__item--danger:focus-visible {
    background: rgba(225 62 19 / 0.12);
}

/* Confirm dialog */
.gallery-owner-dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 600;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-owner-dialog {
    background: rgba(var(--pv-surface-rgb, 30 30 30), 0.96);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(var(--pv-border-rgb, 255 255 255), 0.18);
    border-radius: 12px;
    padding: 24px;
    max-width: 360px;
    width: 90vw;
    box-shadow: 0 16px 64px rgba(0,0,0,0.6);
}

.gallery-owner-dialog__title { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.gallery-owner-dialog__body { font-size: 14px; opacity: 0.7; margin-bottom: 20px; }
.gallery-owner-dialog__actions { display: flex; gap: 8px; justify-content: flex-end; }

.gallery-owner-dialog__cancel,
.gallery-owner-dialog__confirm {
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid rgba(var(--pv-border-rgb, 255 255 255), 0.2);
    background: rgba(var(--pv-border-rgb, 255 255 255), 0.08);
    color: inherit;
    font-size: 14px;
    cursor: pointer;
}

.gallery-owner-dialog__confirm--danger {
    background: #e13e13;
    border-color: #e13e13;
    color: #fff;
}
.gallery-owner-dialog__confirm--danger:hover { background: #c0340f; }

/* Move-to-collection picker */
.gallery-owner-move-picker {
    position: absolute;
    z-index: 510;
    min-width: 200px;
    background: rgba(var(--pv-surface-rgb, 30 30 30), 0.92);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(var(--pv-border-rgb, 255 255 255), 0.18);
    border-radius: 8px;
    padding: 4px 0;
    box-shadow: 0 8px 32px rgba(0,0,0,0.48);
    max-height: 240px;
    overflow-y: auto;
}

.gallery-owner-move-picker__item {
    display: block;
    width: 100%;
    padding: 9px 16px;
    background: none;
    border: none;
    color: inherit;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
}
.gallery-owner-move-picker__item:disabled { opacity: 0.4; cursor: default; }
.gallery-owner-move-picker__item:hover:not(:disabled),
.gallery-owner-move-picker__item:focus-visible:not(:disabled) {
    background: rgba(var(--pv-border-rgb, 255 255 255), 0.10);
    outline: none;
}

/* Sidebar owner affordances */
/* Row wrapper for section heading + owner action cluster */
.pv-section-heading-row {
    display: flex;
    align-items: center;
    width: 100%;
}
/* Override existing .pv-section-heading width:100% so it coexists with actions in flex row */
.pv-section-heading-row > .pv-section-heading {
    flex: 1;
    width: auto;
}
/* Action cluster is a SIBLING of the heading button — hover trigger on the row, not the button */
.gallery-owner-section-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s ease;
    padding-right: 8px;
}
.pv-section-heading-row:hover .gallery-owner-section-actions,
.pv-section-heading-row:focus-within .gallery-owner-section-actions {
    opacity: 1;
}

.gallery-owner-section-btn {
    padding: 2px 5px;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    border-radius: 4px;
    opacity: 0.6;
    font-size: 14px;
}
.gallery-owner-section-btn:hover,
.gallery-owner-section-btn:focus-visible {
    opacity: 1;
    background: rgba(var(--pv-border-rgb, 255 255 255), 0.12);
    outline: none;
}
.gallery-owner-section-btn--danger:hover { color: #e13e13; }

.gallery-owner-thumbnail-kebab {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    opacity: 0;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: opacity 0.15s ease, background 0.15s ease, border-color 0.15s ease;
    z-index: 2;
}
.gallery-owner-thumbnail-kebab i {
    font-size: 18px;
    line-height: 1;
}
.gallery-owner-thumbnail-kebab:hover,
.gallery-owner-thumbnail-kebab:focus-visible {
    background: rgba(0, 0, 0, 0.85);
    border-color: rgba(255, 255, 255, 0.25);
    outline: none;
}
.pv-thumbnail:hover .gallery-owner-thumbnail-kebab,
.pv-thumbnail:focus-within .gallery-owner-thumbnail-kebab,
.gallery-owner-thumbnail-kebab:focus-visible {
    opacity: 1;
}
@media (hover: none) {
    /* Touch devices: always-visible kebab. */
    .gallery-owner-thumbnail-kebab {
        opacity: 1;
    }
}

.gallery-owner-add-collection {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 8px 12px;
    background: none;
    border: 1px dashed rgba(var(--pv-border-rgb, 255 255 255), 0.2);
    border-radius: 6px;
    color: inherit;
    font-size: 13px;
    cursor: pointer;
    margin: 8px 0;
    opacity: 0.6;
}
.gallery-owner-add-collection:hover,
.gallery-owner-add-collection:focus-visible {
    opacity: 1;
    border-color: rgba(var(--pv-border-rgb, 255 255 255), 0.4);
    outline: none;
}

/* Drag-reorder cursor */
.pv-thumbnail[draggable="true"] { cursor: grab; }
.pv-thumbnail[draggable="true"]:active { cursor: grabbing; }

/* ============================================================
   Toast notification center — Phase 1 Task 1.2
   Fixed-position toast stack at top-center of the viewport.
   Uses the same --pv-* custom property tokens as the rest
   of the viewer chrome. Gallery-owned; gallery-toast-* prefix.
   ============================================================ */

.gallery-toast-center {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001; /* above help modal (10000) */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none; /* clicks pass through the container */
    max-width: calc(100vw - 32px);
}

.gallery-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(var(--pv-surface-rgb, 30 30 30), 0.94);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(var(--pv-border-rgb, 255 255 255), 0.15);
    border-radius: 10px;
    color: var(--pv-text, #e2e8f0);
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    pointer-events: auto; /* buttons inside need clicks */
    min-width: 200px;
    max-width: 420px;
}

.gallery-toast--success {
    border-left: 3px solid #22c55e;
}

.gallery-toast--error {
    border-left: 3px solid #e13e13;
}

.gallery-toast__icon {
    font-size: 20px;
    flex-shrink: 0;
}

.gallery-toast--success .gallery-toast__icon {
    color: #22c55e;
}

.gallery-toast--error .gallery-toast__icon {
    color: #e13e13;
}

.gallery-toast__message {
    flex: 1;
    min-width: 0;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gallery-toast__dismiss {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--pv-text-muted, #94a3b8);
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    transition: all 0.15s ease;
}

.gallery-toast__dismiss:hover {
    color: var(--pv-text, #e2e8f0);
    background: rgba(var(--pv-border-rgb, 255 255 255), 0.10);
}

/* Toast animation classes (used by Alpine x-transition) */
.gallery-toast-enter {
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.gallery-toast-enter-start {
    opacity: 0;
    transform: translateY(-8px);
}

.gallery-toast-enter-end {
    opacity: 1;
    transform: translateY(0);
}

.gallery-toast-leave {
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.gallery-toast-leave-start {
    opacity: 1;
    transform: translateY(0);
}

.gallery-toast-leave-end {
    opacity: 0;
    transform: translateY(-8px);
}

/* Light-theme overrides */
[data-theme="light"] .gallery-toast {
    background: rgba(250, 250, 252, 0.94);
    color: rgba(15, 23, 42, 0.9);
    border-color: rgba(15, 23, 42, 0.12);
}

[data-theme="light"] .gallery-toast__dismiss {
    color: rgba(15, 23, 42, 0.5);
}

[data-theme="light"] .gallery-toast__dismiss:hover {
    color: rgba(15, 23, 42, 0.85);
    background: rgba(15, 23, 42, 0.06);
}

/* ============================================================
   Inline section heading edit — Task 2
   ============================================================ */

.gallery-owner-section-heading-edit {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px 6px;
}

.gallery-owner-section-heading-input {
    width: 100%;
    background: rgba(var(--pv-border-rgb, 255 255 255), 0.08);
    border: 1px solid rgba(var(--pv-border-rgb, 255 255 255), 0.30);
    border-radius: 4px;
    color: inherit;
    font: inherit;
    font-weight: 600;
    padding: 4px 8px;
    outline: none;
}
.gallery-owner-section-heading-input:focus { border-color: #e13e13; }
.gallery-owner-section-heading-input--error { border-color: #e13e13; }
.gallery-owner-section-heading-input--busy  { opacity: 0.7; cursor: wait; }

.gallery-owner-section-heading-error {
    font-size: 11px;
    color: #e13e13;
}

.gallery-owner-section-heading-display {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}

/* ============================================================
   Inline section create (footer) + delete-confirm (heading) — Task 4
   ============================================================ */

/* --- Create input at footer --- */

.gallery-owner-section-create {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px 8px;
}

.gallery-owner-section-create-input {
    width: 100%;
    background: rgba(var(--pv-border-rgb, 255 255 255), 0.08);
    border: 1px solid rgba(var(--pv-border-rgb, 255 255 255), 0.30);
    border-radius: 4px;
    color: inherit;
    font: inherit;
    padding: 6px 8px;
    outline: none;
}
.gallery-owner-section-create-input:focus { border-color: #e13e13; }
.gallery-owner-section-create-input--error { border-color: #e13e13; }
.gallery-owner-section-create-input--busy  { opacity: 0.7; cursor: wait; }

.gallery-owner-section-create-error {
    font-size: 11px;
    color: #e13e13;
}

/* --- Delete-confirm pills on heading row --- */

.gallery-owner-section-confirm {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
}

.gallery-owner-section-confirm__label {
    font-size: 12px;
    color: rgba(var(--pv-border-rgb, 255 255 255), 0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.gallery-owner-section-confirm-yes {
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    background: #e13e13;
    border: 1px solid #e13e13;
    border-radius: 3px;
    padding: 2px 8px;
    cursor: pointer;
    white-space: nowrap;
}
.gallery-owner-section-confirm-yes:hover { background: #c41212; }
.gallery-owner-section-confirm-yes:disabled { opacity: 0.5; cursor: wait; }

.gallery-owner-section-confirm-no {
    font-size: 11px;
    font-weight: 500;
    color: inherit;
    background: transparent;
    border: 1px solid rgba(var(--pv-border-rgb, 255 255 255), 0.30);
    border-radius: 3px;
    padding: 2px 8px;
    cursor: pointer;
    white-space: nowrap;
}
.gallery-owner-section-confirm-no:hover { background: rgba(var(--pv-border-rgb, 255 255 255), 0.08); }
.gallery-owner-section-confirm-no:disabled { opacity: 0.5; cursor: wait; }

/* ============================================================
   Inline image title edit (Task 11)
   ============================================================ */

.pv-info-title-edit { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.gallery-title-edit-input {
    width: 100%;
    background: rgba(var(--pv-border-rgb, 255 255 255), 0.08);
    border: 1px solid rgba(var(--pv-border-rgb, 255 255 255), 0.30);
    border-radius: 4px;
    color: inherit;
    font: inherit;
    font-weight: 600;
    padding: 2px 6px;
    outline: none;
}
.gallery-title-edit-input:focus { border-color: #e13e13; }
.gallery-title-edit-input--error { border-color: #e13e13; }
.gallery-title-edit-input--busy  { opacity: 0.7; cursor: wait; }
.gallery-title-edit-error { font-size: 11px; color: #e13e13; }

/* ============================================================
   Inline image description edit (Task 12)
   ============================================================ */

.pv-info-description-edit {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.gallery-desc-edit-textarea {
    width: 100%;
    min-height: 28px;
    background: rgba(var(--pv-border-rgb, 255 255 255), 0.08);
    border: 1px solid rgba(var(--pv-border-rgb, 255 255 255), 0.30);
    border-radius: 4px;
    color: inherit;
    font: inherit;
    font-size: 11px;
    padding: 4px 6px;
    outline: none;
    resize: vertical;
    line-height: 1.3;
    font-family: inherit;
}

.gallery-desc-edit-textarea:focus { border-color: #e13e13; }
.gallery-desc-edit-textarea:disabled { opacity: 0.7; cursor: wait; }

.gallery-desc-edit-error {
    font-size: 11px;
    color: #e13e13;
}

/* ============================================================
   Inline tags editing surface (Task 12)
   ============================================================ */

.gallery-tags-edit {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 4px 8px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 4px;
}

.gallery-tags-edit__host {
    /* TagCombobox mounts its root here — inherits existing .pv-tag-* styles */
}

.gallery-tags-edit__error {
    font-size: 11px;
    color: #e13e13;
    line-height: 1.3;
}

.gallery-tags-edit__actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.gallery-tags-edit__btn {
    font-size: 12px;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.1s ease;
    color: rgba(255, 255, 255, 0.7);
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.20);
}

.gallery-tags-edit__btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.9);
}

.gallery-tags-edit__btn:disabled {
    opacity: 0.5;
    cursor: wait;
}

.gallery-tags-edit__btn--primary {
    color: #fff;
    background: #e13e13;
    border: 1px solid #e13e13;
}

.gallery-tags-edit__btn--primary:hover {
    background: #c41212;
    border-color: #c41212;
}

/* Light-theme overrides for description + tags edit */
[data-theme="light"] .gallery-desc-edit-textarea {
    background: rgba(15, 23, 42, 0.06);
    border-color: rgba(15, 23, 42, 0.15);
    color: rgba(15, 23, 42, 0.9);
}

[data-theme="light"] .gallery-tags-edit {
    border-bottom-color: rgba(15, 23, 42, 0.10);
}

[data-theme="light"] .gallery-tags-edit__btn {
    color: rgba(15, 23, 42, 0.6);
    border-color: rgba(15, 23, 42, 0.15);
}

[data-theme="light"] .gallery-tags-edit__btn:hover {
    background: rgba(15, 23, 42, 0.06);
    color: rgba(15, 23, 42, 0.85);
}
