:root {
    --font-family: "Hiragino Kaku Gothic Pro", "ヒラギノ角ゴ Pro W3", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --text-color: #333;
    --bg-color: #fff;
    --border-color: #eee;
    --metric-bg: #f5f5f5;
    --media-grid-gap: 16px;
    --media-grid-cols: 3;
}

@media (prefers-color-scheme: dark) {
    :root {
        --text-color: #cccccc;
        --bg-color: #0d0d0d;
        --border-color: #222;
        --metric-bg: #1a1a1a;
    }
}

@font-face {
    font-family: "Hiragino Kaku Gothic Pro";
    src: url("fonts/ヒラギノ角ゴ Pro W6.woff2") format("woff2");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Hiragino Kaku Gothic Pro";
    src: url("fonts/ヒラギノ角ゴ Pro W3.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    color: var(--text-color);
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    text-align: left;
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 20px;
}

a:link {
    color: var(--text-color);
    transition: color 0.10s;
}

a:visited {
    color: var(--text-color);
}

a:hover {
    color: var(--text-color);
}

.header {
    width: 100%;
    margin-bottom: 20px;
}

.date {
    font-size: 0.9rem;
    color: #666;
}

h1 {
    font-size: 2rem;
    font-weight: 600;
    margin: 0;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.home-title {
    margin: unset;
}

.metrics {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.metric {
    background: var(--metric-bg);
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.metric::before {
    content: "🏃";
    font-size: 1rem;
}

.content {
    width: 100%;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(var(--media-grid-cols), 1fr);
    gap: var(--media-grid-gap);
    margin: 20px 0 30px 0;
    position: relative;
}

.media-grid img,
.media-grid video {
    width: 100%;
    height: 250px;
    object-fit: cover;
    border-radius: 8px;
}

.media-grid img {
    opacity: 0;
    transition: opacity 0.2s ease-in;
}

p {
    line-height: 1.8;
    font-size: 1.1rem;
    margin: 0;
    white-space: pre-wrap;
}

@media (max-width: 768px) {
    :root {
        --media-grid-cols: 2;
    }

    body {
        padding: 20px 15px;
    }

    h1 {
        font-size: 1.5rem;
    }

    .media-grid img,
    .media-grid video {
        height: auto;
    }
}

.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1000;
    cursor: pointer;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.2s ease-in;
}

.lightbox.active {
    display: flex;
    opacity: 1;
}

.lightbox img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 8px;
    transform: scale(0.8);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.lightbox.active img {
    transform: scale(1);
    opacity: 1;
}

.media-grid img,
.media-grid video,
.media-grid picture {
    cursor: pointer;
}

/* Home page journal rows */
.journal-list {
    width: 100%;
}

.journal-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 20px;
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 16px;
    text-decoration: none;
    color: inherit;
    transition: background-color 0.2s ease;
    opacity: 0;
    animation: fadeIn 0.4s ease forwards;
}

.journal-row.visible {
    opacity: 1;
}

.journal-row.hidden {
    display: none;
}

.journal-row:hover {
    background-color: var(--metric-bg);
}

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

.journal-date {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 8px;
}

.journal-text {
    font-size: 1rem;
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    line-clamp: 3;
}

.journal-thumbnails {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* Base image style */
.journal-thumbnails img,
.journal-thumbnails video {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #fff;
    transition: transform 0.25s ease, z-index 0.25s ease;
}

/* Overlap effect */
.journal-thumbnails img:not(:first-child),
.journal-thumbnails video:not(:first-child) {
    margin-left: -10px;
}

/* Size variation */
.journal-thumbnails img:nth-child(1) {
    width: 120px;
    height: 120px;
}

.journal-thumbnails img:nth-child(2) {
    width: 70px;
    height: 70px;
}

.journal-thumbnails img:nth-child(3) {
    width: 100px;
    height: 100px;
}

.journal-thumbnails img:nth-child(4) {
    width: 65px;
    height: 65px;
}

.journal-thumbnails img:nth-child(5) {
    width: 90px;
    height: 90px;
}

/* Rotation + offsets + scale */
.journal-thumbnails img:nth-child(1) {
    transform: rotate(-5deg) translateY(8px) scale(1.08);
}

.journal-thumbnails img:nth-child(2) {
    transform: rotate(3deg) translateY(-12px) translateX(-5px) scale(0.95);
}

.journal-thumbnails img:nth-child(3) {
    transform: rotate(-2deg) translateY(4px) scale(1.02);
}

.journal-thumbnails img:nth-child(4) {
    transform: rotate(4deg) translateY(-6px) translateX(8px) scale(0.92);
}

.journal-thumbnails img:nth-child(5) {
    transform: rotate(-1deg) translateY(10px) scale(1.05);
}

/* Hover effect */
.journal-thumbnails img:hover,
.journal-thumbnails video:hover {
    transform: scale(1.2) rotate(0deg) !important;
    z-index: 10;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

/* Layout Variants: give each row a distinct thumbnail arrangement */
.journal-thumbnails.layout-2 img:nth-child(1) {
    width: 140px;
    height: 140px;
    transform: rotate(-4deg) translateY(6px) scale(1.04);
}
.journal-thumbnails.layout-2 img:nth-child(2) {
    width: 60px;
    height: 60px;
    transform: rotate(6deg) translateY(-4px);
}
.journal-thumbnails.layout-2 img:nth-child(3) {
    width: 110px;
    height: 110px;
    transform: rotate(-2deg) translateY(2px);
}
.journal-thumbnails.layout-2 img:nth-child(4) {
    width: 70px;
    height: 70px;
    transform: rotate(3deg) translateY(-2px);
}
.journal-thumbnails.layout-2 img:nth-child(5) {
    width: 90px;
    height: 90px;
    transform: rotate(-1deg) translateY(4px);
}

.journal-thumbnails.layout-3 img:nth-child(1) {
    width: 120px;
    height: 120px;
    transform: rotate(0deg) translateY(6px) scale(1.05);
}
.journal-thumbnails.layout-3 img:nth-child(2) {
    width: 100px;
    height: 100px;
    transform: rotate(-3deg) translateY(-6px) scale(0.95);
}
.journal-thumbnails.layout-3 img:nth-child(3) {
    width: 90px;
    height: 90px;
    transform: rotate(5deg) translateY(2px);
}
.journal-thumbnails.layout-3 img:nth-child(4) {
    width: 70px;
    height: 70px;
    transform: rotate(-6deg) translateY(-4px);
}
.journal-thumbnails.layout-3 img:nth-child(5) {
    width: 80px;
    height: 80px;
    transform: rotate(2deg) translateY(6px);
}

.journal-thumbnails.layout-4 img:not(:first-child) {
    margin-left: -14px;
}
.journal-thumbnails.layout-4 img:nth-child(1) {
    width: 130px;
    height: 130px;
}
.journal-thumbnails.layout-4 img:nth-child(2) {
    width: 60px;
    height: 60px;
}
.journal-thumbnails.layout-4 img:nth-child(3) {
    width: 110px;
    height: 110px;
}
.journal-thumbnails.layout-4 img:nth-child(4) {
    width: 70px;
    height: 70px;
}
.journal-thumbnails.layout-4 img:nth-child(5) {
    width: 90px;
    height: 90px;
}

.journal-thumbnails.layout-5 img:hover {
    transform: scale(1.25) rotate(0deg);
}

@media (max-width: 600px) {
    .journal-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .journal-thumbnails {
        width: 100%;
    }

    .journal-thumbnails img,
    .journal-thumbnails video {
        width: calc(25% - 6px);
        height: 60px;
    }
}

.journal-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    width: 100%;
    margin: 12px 0 16px 0;
}

.journal-controls input,
.journal-controls select {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    font-family: var(--font-family);
    font-size: 0.9rem;
    background: var(--bg-color);
    color: var(--text-color);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.journal-controls input:focus,
.journal-controls select:focus {
    outline: none;
    border-color: var(--text-color);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}
