/* Ferðadagbók — Pinterest-style masonry feed (digital travel scrapbook) */

:root {
    --fj-bg: #ffffff;
    --fj-line: rgba(109, 112, 88, 0.22);
    --fj-text: #2a2a2a;
    --fj-muted: #6d6d6d;
    --fj-accent: #6d7058;
    --fj-card-radius: 4px;
    --fj-card-shadow: 0 2px 14px rgba(45, 42, 38, 0.08);
    --fj-card-shadow-hover: 0 6px 24px rgba(45, 42, 38, 0.12);
    --fj-masonry-gap: 22px;
}

.fj-page {
    background-color: var(--fj-bg);
    padding: 48px clamp(16px, 4vw, 36px) 88px;
    min-height: calc(100vh - 120px);
}

.fj-inner {
    width: 100%;
    max-width: 1320px;
    margin: 0 auto;
    padding: 0;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
}

.fj-header {
    text-align: center;
    margin: 0 0 40px;
    padding: 0 8px 32px;
    border-bottom: 1px solid var(--fj-line);
}

.fj-title {
    font-family: 'Playfair Display', serif;
    font-size: clamp(1.75rem, 4vw, 2.2rem);
    font-weight: 500;
    letter-spacing: 0.35em;
    text-transform: uppercase;
    color: #333333;
    margin: 0 0 10px 0;
}

.fj-intro {
    font-family: 'Playfair Display', serif;
    font-size: 0.85rem;
    color: #888888;
    margin: 0;
    letter-spacing: 0.1em;
    font-weight: 400;
}

/* Masonry feed: flex columns filled round-robin (newest top-left → right → down) */
.fj-masonry {
    display: flex;
    align-items: flex-start;
    gap: var(--fj-masonry-gap);
}

.fj-masonry-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--fj-masonry-gap);
}

/* Cards (shared base) */
.fj-card {
    display: block;
    margin: 0;
    background: #ffffff;
    border-radius: var(--fj-card-radius);
    box-shadow: var(--fj-card-shadow);
    overflow: hidden;
    transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.fj-card:hover {
    box-shadow: var(--fj-card-shadow-hover);
}

/* Media — natural aspect on desktop masonry; mobile overrides in ≤860px block */
.fj-card-media {
    position: relative;
    line-height: 0;
    overflow: hidden;
    background: rgba(109, 112, 88, 0.06);
}

.fj-card-image,
.fj-card-video,
.fj-video-thumb {
    width: 100%;
    display: block;
}

.fj-card-image {
    height: auto;
}

.fj-video-thumb {
    position: relative;
    cursor: pointer;
    border: none;
    padding: 0;
    background: transparent;
}

.fj-card-video {
    height: auto;
    object-fit: cover;
    pointer-events: none;
}

.fj-video-icon {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.9);
    background: rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    z-index: 2;
    pointer-events: none;
}

.fj-video-icon svg {
    width: 10px;
    height: 10px;
    margin-left: 1px;
}

.fj-card-image.fj-lightbox-trigger,
.fj-carousel-slide img.fj-lightbox-trigger {
    cursor: zoom-in;
}

/* Card header: town + date (always visible) */
.fj-card-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.fj-card-body--meta {
    padding: 14px 18px 16px;
}

.fj-card-body--meta .fj-card-town {
    font-size: 0.72rem;
}

.fj-card-body--meta .fj-card-date {
    margin-top: 0;
}

/* Card body (text, with or without photo above) */
.fj-card-body {
    padding: 16px 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fj-card-body .fj-card-header + .fj-card-text {
    margin-top: 2px;
}

.fj-card-town {
    margin: 0;
    font-family: 'Playfair Display', serif;
    font-size: 0.72rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--fj-accent);
}

.fj-card-date {
    flex-shrink: 0;
    font-family: 'Playfair Display', serif;
    font-size: 0.75rem;
    color: var(--fj-muted);
    letter-spacing: 0.06em;
    margin: 0;
}

.fj-card-text {
    font-family: 'Playfair Display', serif;
    font-size: 0.92rem;
    font-weight: 400;
    line-height: 1.6;
    color: var(--fj-text);
}

.fj-card-text p {
    margin: 0 0 0.6em 0;
    font-weight: 400;
}

.fj-card-text p:last-child {
    margin-bottom: 0;
}

/* Photo+text cards: clamp long captions; click to expand */
.fj-card-text--clamp {
    cursor: pointer;
}

.fj-card-text--clamp:not(.is-expanded) {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    overflow: hidden;
}

.fj-card-text--clamp.is-expanded {
    cursor: default;
}

/* Text-only cards: decorative opening quote, slightly more padded */
.fj-card--text .fj-card-body {
    padding: 50px 28px 22px;
    position: relative;
}

.fj-card--text .fj-card-text {
    font-style: italic;
    color: #3a3a3a;
    margin-top: 12px;
}

.fj-card--text .fj-card-body::before {
    content: '\201C';
    position: absolute;
    top: 14px;
    left: 26px;
    font-family: 'Playfair Display', serif;
    font-size: 4.25rem;
    line-height: 1;
    color: rgba(109, 112, 88, 0.2);
    pointer-events: none;
}

.fj-card--text .fj-card-header {
    margin-top: 12px;
}

/* Carousel inside a card */
.fj-carousel {
    position: relative;
    line-height: 0;
}

.fj-carousel-viewport {
    position: relative;
    overflow: hidden;
    background: rgba(109, 112, 88, 0.06);
}

.fj-carousel-slide {
    margin: 0;
    display: none;
}

.fj-carousel-slide.is-active {
    display: block;
    height: 100%;
}

.fj-carousel-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.fj-carousel-slide .fj-video-thumb {
    width: 100%;
    height: 100%;
    display: block;
}

.fj-carousel-slide .fj-video-thumb .fj-card-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.fj-carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(45, 42, 38, 0.88);
    color: #ffffff;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.16);
    transition: background 0.2s ease;
}

.fj-carousel-btn:hover {
    background: rgba(45, 42, 38, 0.96);
}

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

.fj-carousel-counter {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Playfair Display', serif;
    font-size: 0.7rem;
    color: #ffffff;
    letter-spacing: 0.08em;
    padding: 2px 8px;
    background: rgba(0, 0, 0, 0.45);
    border-radius: 999px;
    pointer-events: none;
}

.fj-empty {
    font-family: 'Playfair Display', serif;
    font-size: 0.95rem;
    color: #8a8a8a;
    text-align: center;
    letter-spacing: 0.06em;
    margin: 48px 0 0;
}

/* Lightbox — click image to view large, dark backdrop, close only */
body.fj-lightbox-open {
    overflow: hidden;
}

.fj-lightbox {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 1050;
}

.fj-lightbox[aria-hidden="false"] {
    display: block;
}

.fj-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
}

.fj-lightbox-inner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    z-index: 1;
    isolation: isolate;
}

.fj-lightbox-media-host {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: calc(100vh - 120px);
    position: relative;
    z-index: 2;
}

.fj-lightbox-media-host .fj-lightbox-image,
.fj-lightbox-media-host .fj-lightbox-video {
    max-width: 100%;
    max-height: calc(100vh - 120px);
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.fj-lightbox-media-host .fj-lightbox-video {
    background: #000;
}

.fj-lightbox-close {
    position: absolute;
    top: 14px;
    right: 18px;
    z-index: 30;
    border: none;
    background: transparent;
    font-size: 2rem;
    line-height: 1;
    color: #fff;
    text-shadow: 0 0 6px rgba(0, 0, 0, 0.8);
    cursor: pointer;
}

.fj-lightbox-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    padding: 0;
    transition: background 0.15s ease;
}

.fj-lightbox-arrow:hover,
.fj-lightbox-arrow:focus {
    background: rgba(0, 0, 0, 0.75);
    outline: none;
}

.fj-lightbox-arrow[hidden] {
    display: none !important;
}

.fj-lightbox-arrow--prev { left: 18px; }
.fj-lightbox-arrow--next { right: 18px; }

.fj-lightbox-counter {
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.8);
    font-family: 'Playfair Display', serif;
    font-size: 0.85rem;
    letter-spacing: 0.06em;
    z-index: 20;
    pointer-events: none;
}

@media (max-width: 640px) {
    .fj-lightbox-arrow {
        width: 36px;
        height: 36px;
        font-size: 1.35rem;
    }

    .fj-lightbox-arrow--prev { left: 10px; }
    .fj-lightbox-arrow--next { right: 10px; }
}

@media (max-width: 640px) {
    .fj-title {
        font-size: 1.75rem;
        letter-spacing: 0.2em;
    }

    .fj-page {
        padding-top: 36px;
        padding-bottom: 72px;
    }
}

/* ≤860px: original linear feed — no cards, chronological stack */
@media (max-width: 860px) {
    .fj-inner {
        max-width: 1100px;
    }

    .fj-masonry {
        display: block;
    }

    .fj-masonry-col {
        display: block;
    }

    .fj-masonry-col + .fj-masonry-col {
        margin-top: 0;
    }

    .fj-card {
        background: transparent;
        border-radius: 0;
        box-shadow: none;
        overflow: visible;
        padding: 28px 0;
        border-bottom: 1px solid rgba(109, 112, 88, 0.12);
    }

    .fj-card:first-child {
        padding-top: 0;
    }

    .fj-card:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }

    .fj-card:hover {
        box-shadow: none;
    }

    /* Mobile order: header → media → caption (photo+text); header → media (photo-only) */
    .fj-card--photo-text,
    .fj-card--photo {
        display: flex;
        flex-direction: column;
    }

    .fj-card--photo-text .fj-card-body {
        display: contents;
    }

    .fj-card--photo-text .fj-card-header {
        order: 1;
        padding: 0 0 8px;
    }

    .fj-card--photo-text .fj-card-media {
        order: 2;
        margin-bottom: 16px;
    }

    .fj-card--photo-text .fj-card-text {
        order: 3;
        margin: 0;
        padding-left: 1rem;
        border-left: 2px solid rgba(109, 112, 88, 0.35);
    }

    .fj-card--photo .fj-card-body--meta {
        order: 1;
        padding: 0 0 8px;
    }

    .fj-card--photo .fj-card-media {
        order: 2;
    }

    .fj-card--photo-text .fj-card-town {
        font-size: 0.95rem;
        font-weight: 600;
        letter-spacing: 0.04em;
        text-transform: none;
    }

    .fj-card--photo-text .fj-card-date {
        font-size: 0.82rem;
        font-weight: 500;
    }

    .fj-card--photo .fj-card-body--meta .fj-card-town {
        font-size: 0.95rem;
        font-weight: 600;
        letter-spacing: 0.04em;
        text-transform: none;
    }

    .fj-card--photo .fj-card-body--meta .fj-card-date {
        font-size: 0.82rem;
        font-weight: 500;
    }

    .fj-card-media {
        aspect-ratio: unset;
        max-width: min(100%, 800px);
        width: 100%;
        margin: 0 auto;
        overflow: visible;
        background: transparent;
    }

    .fj-card-image,
    .fj-card-video,
    .fj-video-thumb {
        height: auto;
    }

    .fj-card-image {
        object-fit: contain;
        border-radius: 4px;
        box-shadow: 0 2px 12px rgba(45, 42, 38, 0.06);
    }

    .fj-carousel {
        height: auto;
        max-width: min(100%, 800px);
        margin: 0 auto;
    }

    .fj-carousel-viewport {
        height: auto;
        border-radius: 4px;
        box-shadow: 0 2px 12px rgba(45, 42, 38, 0.06);
    }

    .fj-carousel-slide.is-active {
        height: 100%;
    }

    .fj-carousel-slide img,
    .fj-carousel-slide .fj-video-thumb .fj-card-video {
        height: 100%;
        object-fit: cover;
    }

    .fj-card--text {
        padding-top: 28px;
    }

    .fj-card--text .fj-card-body {
        padding: 0;
        position: relative;
    }

    .fj-card--text .fj-card-body::before {
        display: none;
    }

    .fj-card--text .fj-card-header {
        margin-top: 0;
    }

    .fj-card--text .fj-card-town {
        font-size: 0.95rem;
        font-weight: 600;
        letter-spacing: 0.04em;
        text-transform: none;
    }

    .fj-card--text .fj-card-date {
        font-size: 0.82rem;
        font-weight: 500;
    }

    .fj-card--text .fj-card-text {
        margin-top: 12px;
        padding-left: 1rem;
        border-left: 2px solid rgba(109, 112, 88, 0.35);
    }

    .fj-card--text .fj-card-text p {
        font-style: italic;
    }
}

/* Desktop masonry: gently crop only very tall phone shots (≈9:16) */
@media (min-width: 861px) {
    .fj-card-media--wide {
        aspect-ratio: 5 / 4;
        overflow: hidden;
    }

    .fj-card-media--wide .fj-card-image,
    .fj-card-media--wide .fj-card-video,
    .fj-card-media--wide .fj-carousel-viewport,
    .fj-card-media--wide .fj-carousel-slide.is-active,
    .fj-card-media--wide .fj-video-thumb {
        width: 100%;
        height: 100%;
    }

    .fj-card-media--wide .fj-card-image,
    .fj-card-media--wide .fj-card-video,
    .fj-card-media--wide .fj-carousel-slide img {
        height: 100%;
        object-fit: cover;
    }

    .fj-card-media--wide .fj-carousel {
        height: 100%;
    }

    .fj-card-media--tall {
        aspect-ratio: 7 / 10;
        overflow: hidden;
    }

    .fj-card-media--tall .fj-card-image,
    .fj-card-media--tall .fj-card-video,
    .fj-card-media--tall .fj-carousel-viewport,
    .fj-card-media--tall .fj-carousel-slide.is-active,
    .fj-card-media--tall .fj-video-thumb {
        width: 100%;
        height: 100%;
    }

    .fj-card-media--tall .fj-card-image,
    .fj-card-media--tall .fj-card-video,
    .fj-card-media--tall .fj-carousel-slide img {
        height: 100%;
        object-fit: cover;
    }

    .fj-card-media--tall .fj-carousel {
        height: 100%;
    }
}
