/* ============================================
   Project Detail Page
   ============================================ */

.project-detail {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 24px;
    position: relative;
    z-index: 1;
}

.project-detail .project-header {
    margin-bottom: 32px;
}

.project-detail h1 {
    font-size: 2rem;
    margin-bottom: 12px;
}

.project-meta {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.project-hero-image {
    width: 100%;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
    margin-bottom: 32px;
}

/* YouTube / video hero — 16:9 responsive wrapper */
.project-hero-video {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    margin-bottom: 32px;
    background: #000;
}

.project-hero-video iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* YouTube in carousel slides — fixed height matching carousel */
.carousel-video-wrap {
    position: relative;
    width: 100%;
    height: 420px;
    background: #000;
}

.carousel-video-wrap iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* YouTube in gallery grid — 16:9 responsive */
.gallery-video-wrap {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    background: #000;
}

.gallery-video-wrap iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.project-content {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-primary);
}

.project-content h2 {
    margin-top: 32px;
    margin-bottom: 12px;
}

.project-content h3 {
    margin-top: 24px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.project-content p {
    margin-bottom: 16px;
}

.project-content ol,
.project-content ul {
    padding-left: 2.5em;
    margin-bottom: 16px;
}

.project-content li {
    margin-bottom: 6px;
}

.project-content li .ql-ui {
    display: none;
}

.project-content a {
    color: var(--neon-blue);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.project-content img {
    max-width: 100%;
    border-radius: 6px;
    margin: 16px 0;
}

.project-content code {
    background: rgba(0, 212, 255, 0.08);
    color: var(--neon-blue);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.9em;
}

.project-content blockquote {
    border-left: 3px solid var(--accent-gold);
    padding-left: 16px;
    margin: 16px 0;
    color: var(--text-secondary);
    font-style: italic;
}

.project-content hr {
    border: none;
    border-top: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
    margin: 32px 0;
}

.project-technologies {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-subtle);
}

.project-technologies h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* Insights traffic light table */
.project-insights {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-subtle);
}

.project-insights h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.insights-traffic-table {
    width: 100%;
    border-collapse: collapse;
}

.insights-traffic-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
    vertical-align: middle;
}

.insights-traffic-table .insight-light {
    width: 28px;
    text-align: center;
}

.insights-traffic-table .insight-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.insight-dot.insight-win { background: #2ecc40; box-shadow: 0 0 6px rgba(46, 204, 64, 0.4); }
.insight-dot.insight-loss { background: #ff2d95; box-shadow: 0 0 6px rgba(255, 45, 149, 0.4); }
.insight-dot.insight-takeaway { background: #d4a855; box-shadow: 0 0 6px rgba(212, 168, 85, 0.4); }

.insights-traffic-table .insight-type {
    width: 90px;
    font-family: var(--font-heading, 'Space Mono', monospace);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.insight-win-text { color: #2ecc40; }
.insight-loss-text { color: #ff2d95; }
.insight-takeaway-text { color: #d4a855; }

.insights-traffic-table .insight-boxes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.insight-box {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--text-primary, #e8e0d4);
}

.insight-box-win {
    background: rgba(46, 204, 64, 0.1);
    border: 1px solid rgba(46, 204, 64, 0.25);
}

.insight-box-loss {
    background: rgba(255, 45, 149, 0.1);
    border: 1px solid rgba(255, 45, 149, 0.25);
}

.insight-box-takeaway {
    background: rgba(212, 168, 85, 0.1);
    border: 1px solid rgba(212, 168, 85, 0.25);
}

/* Related projects */
.related-projects {
    margin-top: 48px;
    padding-top: 32px;
    border-top: 1px solid var(--border-subtle);
}

.related-projects h2 {
    margin-bottom: 20px;
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.related-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 0;
    overflow: hidden;
    transition: border-color 0.3s;
}

/* Related card image — must always show when available */
.related-card-image-link {
    display: block;
}

.related-card-image {
    width: 100%;
    height: 120px;
    object-fit: cover;
}

.related-card:hover {
    border-color: var(--accent-gold-dim);
}

.related-card h4 {
    font-size: 0.9rem;
    margin-bottom: 4px;
    padding: 12px 16px 0;
}

.related-card h4 a {
    color: var(--text-primary);
}

.related-card h4 a:hover {
    color: var(--neon-blue);
}

.related-card .year {
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding: 0 16px 4px;
    display: block;
}

.related-card .views {
    font-size: 0.7rem;
    color: var(--text-secondary);
    padding: 0 16px 12px;
    display: block;
    opacity: 0.5;
    font-family: var(--font-heading);
}

/* Image Carousel */
.img-carousel {
    position: relative;
    margin: 24px 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    background: rgba(0, 0, 0, 0.3);
}

.carousel-track {
    position: relative;
    width: 100%;
}

.carousel-slide {
    display: none;
}

.carousel-slide.active {
    display: block;
}

.carousel-slide img {
    width: 100% !important;
    max-width: 100% !important;
    height: 420px;
    object-fit: cover;
    display: block;
    margin: 0;
    border-radius: 0;
}

.carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.15);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 2;
    line-height: 1;
    padding: 0 0 2px 0;
}

.carousel-arrow:hover {
    background: rgba(0, 0, 0, 0.85);
    border-color: var(--accent-gold-dim);
    color: var(--accent-gold);
}

.carousel-prev { left: 10px; }
.carousel-next { right: 10px; }

.carousel-counter {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: rgba(255, 255, 255, 0.8);
    padding: 3px 12px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-family: var(--font-heading);
    letter-spacing: 0.05em;
    z-index: 2;
}

/* Gallery carousel (project hero) */
.project-gallery-carousel {
    margin-bottom: 32px;
    max-height: 420px;
    overflow: hidden;
}

.project-gallery-carousel .carousel-slide img {
    height: 420px;
    object-fit: cover;
}

/* Gallery grid — masonry / mosaic layout */
.project-gallery-grid {
    columns: 2;
    column-gap: 12px;
    margin-bottom: 32px;
}

.project-gallery-grid .gallery-grid-item {
    break-inside: avoid;
    margin-bottom: 12px;
}

.gallery-grid-item img {
    width: 100%;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
    display: block;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.3s;
}

.gallery-grid-item img:hover {
    border-color: var(--accent-gold-dim);
    transform: scale(1.02);
}

/* In-body image grid — masonry / mosaic layout (from content editor) */
.img-grid {
    columns: 2;
    column-gap: 12px;
    margin: 24px 0;
}

.img-grid-item {
    break-inside: avoid;
    margin-bottom: 12px;
}

.img-grid-item img {
    width: 100%;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
    display: block;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.3s;
}

.img-grid-item img:hover {
    border-color: var(--accent-gold-dim);
    transform: scale(1.02);
}

/* In-body filmstrip (carousel images side by side, scrollable, equal height) */
.img-filmstrip {
    display: flex;
    flex-wrap: nowrap;
    gap: 3px;
    margin: 24px 0;
    border-radius: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    border: 1px solid var(--border-subtle);
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.img-filmstrip::-webkit-scrollbar { height: 0; display: none; }
.img-filmstrip { scrollbar-width: none; }

.img-filmstrip img {
    flex: 0 0 auto;
    width: auto !important;
    max-width: none !important;
    height: 300px;
    object-fit: cover;
    display: block;
    margin: 0 !important;
    border-radius: 0 !important;
    scroll-snap-align: start;
}

/* Filmstrip sizes */
.img-filmstrip[data-size="small"] img { height: 180px; }
.img-filmstrip[data-size="medium"] img { height: 300px; }
.img-filmstrip[data-size="large"] img { height: 450px; }

/* Content image sizing (per-image data-size attribute) */
.project-content img[data-size="small"] { max-width: 33%; }
.project-content img[data-size="medium"] { max-width: 50%; }
.project-content img[data-size="large"] { max-width: 100%; }

@media (max-width: 1024px) {
    .project-gallery-carousel { max-height: 340px; }
    .project-gallery-carousel .carousel-slide img { height: 340px; }
    .carousel-slide img { height: 340px; }
    .carousel-video-wrap { height: 340px; }
    .img-filmstrip img { height: 240px; }
    .img-filmstrip[data-size="small"] img { height: 140px; }
    .img-filmstrip[data-size="medium"] img { height: 240px; }
    .img-filmstrip[data-size="large"] img { height: 360px; }
}

/* External embed iframe */
.embed-wrap {
    width: 100%;
    overflow: hidden;
}

.project-external-embed {
    width: 100%;
    height: 80vh; /* initial guess, JS will resize to exact content height */
    border: none;
    background: transparent;
    display: block;
    overflow: hidden;
}

@media (max-width: 768px) {

    .project-detail h1 {
        font-size: 1.6rem;
    }

    .project-gallery-carousel { max-height: 260px; }
    .project-gallery-carousel .carousel-slide img { height: 260px; }
    .carousel-slide img { height: 260px; }
    .carousel-video-wrap { height: 260px; }

    .carousel-arrow {
        width: 30px;
        height: 30px;
        font-size: 1.2rem;
    }

    .carousel-prev { left: 6px; }
    .carousel-next { right: 6px; }

    .project-gallery-grid {
        columns: 1;
        column-gap: 8px;
    }

    .img-grid {
        columns: 1;
        column-gap: 8px;
    }

    .img-filmstrip img { height: 160px; }
    .img-filmstrip[data-size="small"] img { height: 100px; }
    .img-filmstrip[data-size="medium"] img { height: 160px; }
    .img-filmstrip[data-size="large"] img { height: 240px; }
}

    /* On mobile, small/medium images go full width */
    .project-content img[data-size="small"],
    .project-content img[data-size="medium"] { max-width: 100%; }
}
