/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #0a0a0a;
    color: #e0e0e0;
    min-height: 100vh;
}

/* Gate Pages */
.gate {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #0a0a0a;
}

.gate-card {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 12px;
    padding: 48px;
    text-align: center;
    max-width: 420px;
    width: 90%;
}

.gate-card h1 {
    font-size: 1.5rem;
    margin-bottom: 16px;
    color: #fff;
}

.gate-card p {
    margin-bottom: 24px;
    color: #999;
    line-height: 1.6;
}

.gate-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn {
    padding: 12px 32px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.btn-primary {
    background: #e63946;
    color: #fff;
}

.btn-primary:hover {
    background: #c1121f;
}

.btn-secondary {
    background: #333;
    color: #999;
}

.btn-secondary:hover {
    background: #444;
}

#password-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#password-input {
    padding: 12px 16px;
    border: 1px solid #333;
    border-radius: 8px;
    background: #111;
    color: #fff;
    font-size: 1rem;
    text-align: center;
}

#password-input:focus {
    outline: none;
    border-color: #e63946;
}

.error {
    color: #e63946;
    margin-top: 8px;
    font-size: 0.9rem;
}

/* Gallery Header */
.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #222;
    position: sticky;
    top: 0;
    background: #0a0a0a;
    z-index: 10;
}

.gallery-header h1 {
    font-size: 1.3rem;
    color: #fff;
}

.favorites-btn {
    background: none;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 8px 16px;
    color: #e63946;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 1rem;
    transition: all 0.2s;
}

.favorites-btn:hover {
    background: #1a1a1a;
}

.heart-icon { font-size: 1.2rem; }

.favorites-count {
    background: #333;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    color: #ccc;
}

/* Works Grid */
.works-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    padding: 24px;
}

/* Work Card */
.work-card {
    background: #1a1a1a;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #222;
    transition: border-color 0.2s;
}

.work-card:hover {
    border-color: #444;
}

.work-card-thumb {
    position: relative;
    cursor: pointer;
    aspect-ratio: 1;
    overflow: hidden;
    background: #111;
}

/* Skeleton shimmer while image loads */
.work-card-thumb img[src=""] {
    visibility: hidden;
}

.work-card-thumb img[src=""] + .placeholder-img,
.work-card-thumb:has(img[src=""])::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, #111 25%, #1a1a1a 50%, #111 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.work-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s, opacity 0.3s;
}

.work-card-thumb img:not([src=""]) {
    opacity: 1;
}

.work-card:hover .work-card-thumb img {
    transform: scale(1.03);
}

.work-card-info {
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.work-card-title {
    font-size: 0.9rem;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.work-card-price {
    font-size: 0.85rem;
    color: #999;
    margin-left: 8px;
    white-space: nowrap;
}

.work-card-actions {
    padding: 0 12px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.heart-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.3rem;
    color: #555;
    transition: all 0.2s;
    padding: 4px;
}

.heart-btn:hover {
    color: #e63946;
    transform: scale(1.15);
}

.heart-btn.active {
    color: #e63946;
}

/* Expanded Detail — full-width row in the grid */
.work-detail {
    grid-column: 1 / -1;
    background: #141414;
    border: 1px solid #222;
    border-radius: 10px;
    padding: 24px;
    animation: detailFadeIn 0.35s ease;
}

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

.work-detail-inner {
    max-width: 800px;
    margin: 0 auto;
}

/* Main image container with blur-to-clear transition */
.work-detail-img-wrap {
    position: relative;
    width: 100%;
    margin-bottom: 16px;
    border-radius: 8px;
    overflow: hidden;
    background: #111;
}

.work-detail-img-wrap .img-preview {
    width: 100%;
    display: block;
    filter: blur(12px);
    transform: scale(1.05);
    transition: opacity 0.4s ease;
}

.work-detail-img-wrap .img-clear {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.work-detail-img-wrap .img-clear.loaded {
    opacity: 1;
}

.work-detail-img-wrap .img-preview.hidden {
    opacity: 0;
}

.work-detail-sub-thumbs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 16px;
}

.work-detail-sub-thumbs img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s, transform 0.2s;
    flex-shrink: 0;
}

.work-detail-sub-thumbs img.active {
    border-color: #e63946;
}

.work-detail-sub-thumbs img:hover {
    border-color: #e63946;
    transform: scale(1.05);
}

.work-detail-content {
    color: #ccc;
    line-height: 1.8;
    font-size: 0.95rem;
    white-space: pre-wrap;
}

.work-detail-close {
    float: right;
    background: none;
    border: 1px solid #333;
    color: #999;
    border-radius: 6px;
    padding: 4px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.work-detail-close:hover {
    background: #222;
    color: #fff;
}

/* Favorites Panel */
.favorites-panel {
    position: fixed;
    top: 0;
    right: -360px;
    width: 340px;
    height: 100vh;
    background: #1a1a1a;
    border-left: 1px solid #333;
    z-index: 100;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.favorites-panel.open {
    right: 0;
}

.favorites-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #333;
}

.favorites-panel-header h2 {
    font-size: 1.1rem;
    color: #fff;
}

.close-btn {
    background: none;
    border: none;
    color: #999;
    font-size: 1.5rem;
    cursor: pointer;
}

.favorites-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.favorites-list .empty-msg {
    color: #666;
    text-align: center;
    padding: 40px 0;
}

.fav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 8px;
    background: #222;
}

.fav-item img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
}

.fav-item-info {
    flex: 1;
}

.fav-item-title {
    font-size: 0.85rem;
    color: #fff;
}

.fav-item-price {
    font-size: 0.8rem;
    color: #999;
}

.fav-item-remove {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 1.2rem;
}

.favorites-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    display: none;
}

.favorites-overlay.open {
    display: block;
}

/* Flying heart animation */
.flying-heart {
    position: fixed;
    font-size: 1.3rem;
    color: #e63946;
    pointer-events: none;
    z-index: 200;
    transition: all 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
    opacity: 1;
}

.flying-heart.fly {
    opacity: 0;
    transform: scale(0.3);
}

/* PWA Install Button */
.pwa-install-btn {
    position: fixed;
    bottom: 24px;
    left: 24px;
    padding: 10px 20px;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    box-shadow: 0 2px 12px rgba(0,0,0,0.3);
    z-index: 1000;
    transition: opacity 0.3s;
}
.pwa-install-btn:hover { background: #555; }

/* Placeholder image */
.placeholder-img {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #222;
    color: #555;
    font-size: 2rem;
}

/* Responsive */
@media (max-width: 600px) {
    .works-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        padding: 12px;
    }

    .gate-card {
        padding: 32px 24px;
    }

    .favorites-panel {
        width: 100%;
        right: -100%;
    }
}
