/* Layout */
.moments-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 3rem;
    align-items: start;
    margin: 2rem 0;
}

/* Sidebar with Calendar */
.moments-sidebar {
    position: sticky;
    top: 2rem;
}

.calendar-widget {
    background: #fafafa;
    border: 1px solid #dcdcdc;
    border-radius: 8px;
    padding: 1rem;
}

[data-theme=dark] .calendar-widget {
    background: #1b1c1d;
    border-color: #4e4e57;
}

@media (prefers-color-scheme: dark) {
    .calendar-widget {
        background: #1b1c1d;
        border-color: #4e4e57;
    }
}

[data-theme=light] .calendar-widget {
    background: #fafafa;
    border-color: #dcdcdc;
}

/* Main Content Area */
.moments-main {
    min-width: 0;
}

.moments-title {
    text-align: center;
    font-family: "Inter UI", "Roboto", "LXGW WenKai Screen", "Segoe UI", Helvetica, Arial, sans-serif;
    font-weight: 600;
    font-size: 2.625rem;
}

/* View Toggle & Controls */
.moments-controls {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin: 2rem 0 1rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.view-toggle {
    display: flex;
    gap: 0.5rem;
}

.view-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #fafafa;
    border: 1px solid #dcdcdc;
    border-radius: 6px;
    color: #222;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
}

[data-theme=dark] .view-btn {
    background: #1b1c1d;
    border-color: #4e4e57;
    color: #a9a9b3;
}

@media (prefers-color-scheme: dark) {
    .view-btn {
        background: #1b1c1d;
        border-color: #4e4e57;
        color: #a9a9b3;
    }
}

[data-theme=light] .view-btn {
    background: #fafafa;
    border-color: #dcdcdc;
    color: #222;
}

.view-btn:hover {
    border-color: #3eb0ef;
}

.view-btn.active {
    background: #3eb0ef;
    color: #fff;
    border-color: #3eb0ef;
}

/* Calendar Widget - Compact */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.calendar-title {
    font-weight: 600;
    font-size: 0.875rem;
}

.calendar-nav {
    display: flex;
    gap: 0.25rem;
}

.calendar-nav-btn {
    padding: 0.25rem 0.5rem;
    background: #fafafa;
    border: 1px solid #dcdcdc;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.75rem;
}

[data-theme=dark] .calendar-nav-btn {
    background: #3b3d42;
    border-color: #4e4e57;
}

@media (prefers-color-scheme: dark) {
    .calendar-nav-btn {
        background: #3b3d42;
        border-color: #4e4e57;
    }
}

[data-theme=light] .calendar-nav-btn {
    background: #fafafa;
    border-color: #dcdcdc;
}

.calendar-nav-btn:hover {
    background: #3eb0ef;
    color: #fff;
    border-color: #3eb0ef;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.125rem;
}

.calendar-day-header {
    text-align: center;
    font-size: 0.625rem;
    color: #999;
    padding: 0.25rem 0;
    font-weight: 500;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.calendar-day:hover {
    background: rgba(0, 0, 0, 0.05);
}

[data-theme=dark] .calendar-day:hover {
    background: rgba(255, 255, 255, 0.1);
}

@media (prefers-color-scheme: dark) {
    .calendar-day:hover {
        background: rgba(255, 255, 255, 0.1);
    }
}

[data-theme=light] .calendar-day:hover {
    background: rgba(0, 0, 0, 0.05);
}

.calendar-day.today {
    background: #3eb0ef;
    color: #fff;
    font-weight: 600;
}

.calendar-day.has-moments {
    background: rgba(254, 81, 134, 0.1);
    font-weight: 500;
}

.calendar-day.has-moments::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 3px;
    height: 3px;
    background: #3eb0ef;
    border-radius: 50%;
}

.calendar-day.other-month {
    opacity: 0.3;
}

/* Timeline View */
.moments-timeline {
    display: none;
    text-align: left;
}

.moments-timeline.view-active {
    display: block;
}

.moments-feed {
    display: none;
}

.moments-feed.view-active {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 2rem;
}

.timeline-day {
    margin-bottom: 2rem;
    text-align: left;
}

.timeline-date-header {
    margin-bottom: 1rem;
    text-align: left;
}

.timeline-date-full {
    font-size: 1.5rem;
    font-weight: 700;
    color: #3eb0ef;
    display: block;
    margin-bottom: 0.5rem;
}

.timeline-entry {
    margin-bottom: 1rem;
    text-align: left;
}

.timeline-content-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.timeline-content {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    transition: all 0.2s;
    text-align: left;
}

.timeline-content-link:hover {
    opacity: 0.7;
}

.timeline-text {
    line-height: 1.7;
    margin-bottom: 0.5rem;
    text-align: left;
    color: inherit;
    font-family: "Inter UI", "Roboto", "LXGW WenKai Screen", "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 1rem;
    font-display: auto;
}

.timeline-text p {
    margin: 0;
    color: inherit;
    font-family: inherit;
}

.timeline-tags {
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
}

/* Card View (original styles) */
.moments-feed.view-active {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 2rem;
    text-align: left;
}

.moment-card {
    background: #fafafa;
    border: 1px solid #dcdcdc;
    border-radius: 8px;
    padding: 1.5rem;
    transition: all 0.2s;
    text-align: left;
    overflow: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

[data-theme=dark] .moment-card {
    background: #3b3d42;
    border-color: #4e4e57;
}

@media (prefers-color-scheme: dark) {
    .moment-card {
        background: #3b3d42;
        border-color: #4e4e57;
    }
}

[data-theme=light] .moment-card {
    background: #fafafa;
    border-color: #dcdcdc;
}

.moment-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.moment-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #3eb0ef;
}

.moment-header {
    margin-bottom: 1.5rem;
}

.moment-date {
    font-size: 1.5rem;
    font-weight: 700;
    color: #3eb0ef;
    display: block;
    line-height: 1.2;
    pointer-events: none;
}

.moment-card:hover .moment-date {
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
}

.moment-content {
    line-height: 1.7;
    margin-bottom: 1rem;
    color: inherit;
    font-family: "Inter UI", "Roboto", "LXGW WenKai Screen", "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 1rem;
    font-display: auto;
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.moment-content p {
    margin-bottom: 0.75rem;
    color: inherit;
    font-family: inherit;
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

/* Ensure links and inline elements wrap properly on mobile */
.moment-card .moment-content a,
.moment-card .moment-content strong,
.moment-card .moment-content em {
    display: inline;
    white-space: normal;
    max-width: 100%;
}

.moment-content p:last-child {
    margin-bottom: 0;
}

/* Embedded content (iframes, videos, music players) */
.moment-content iframe {
    max-width: 100%;
    border-radius: 8px;
    display: block;
    margin: 1rem 0;
}

/* Make iframes more compact and elegant in cards */
.moment-card .moment-content iframe {
    max-width: 600px;
    width: 100%;
}

.moment-tags {
    margin-top: 1rem;
    font-size: 0.875rem;
    pointer-events: none;
}

.moment-images-list {
    margin-bottom: 1rem;
    display: grid;
    gap: 0.5rem;
    max-width: 600px;
}

.moment-images-list:has(.moment-image-list:first-child:nth-last-child(1)) {
    grid-template-columns: 1fr;
}

.moment-images-list:has(.moment-image-list:first-child:nth-last-child(2)) {
    grid-template-columns: repeat(2, 1fr);
}

.moment-images-list:has(.moment-image-list:first-child:nth-last-child(n+3)) {
    grid-template-columns: repeat(3, 1fr);
}

.moment-image-list {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 6px;
    transition: transform 0.2s;
}

.moment-image-list:hover {
    transform: scale(1.02);
}

/* Wiki link styles */
.backlink {
    color: #3eb0ef;
    text-decoration: none;
    border-bottom: 1px dotted #3eb0ef;
    padding: 0 2px;
    transition: all 0.2s;
}

.backlink:hover {
    background: #3eb0ef;
    color: #fff;
}

.backlink-missing {
    color: #999;
    opacity: 0.7;
    border-bottom: 1px dotted #999;
}

@media (max-width: 768px) {
    .moments-layout {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .moments-sidebar {
        position: static;
    }

    .timeline-date-full {
        font-size: 1.125rem;
    }

    .timeline-images:has(.timeline-image:first-child:nth-last-child(n+3)) {
        grid-template-columns: repeat(2, 1fr);
    }

    .moment-card {
        padding: 1rem;
    }

    .moment-images-list:has(.moment-image-list:first-child:nth-last-child(n+3)) {
        grid-template-columns: repeat(2, 1fr);
    }

    .calendar-day {
        font-size: 0.625rem;
    }

    .moment-card .moment-content iframe {
        max-width: 100%;
    }
}

.moment-single {
    max-width: 700px;
    margin: 0 auto;
}

.moment-header-single {
    margin-bottom: 2rem;
}

.moment-date-single {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: #3eb0ef;
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.moment-title-single {
    font-size: 1.125rem;
    font-weight: 500;
    color: #999;
    margin: 0;
    line-height: 1.4;
}

.moment-content-single {
    font-size: 1.125rem;
    line-height: 1.8;
    color: inherit;
    font-family: "Inter UI", "Roboto", "LXGW WenKai Screen", "Segoe UI", Helvetica, Arial, sans-serif;
    font-display: auto;
}

.moment-meta {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #dcdcdc;
}

[data-theme=dark] .moment-meta {
    border-color: #4e4e57;
}

@media (prefers-color-scheme: dark) {
    .moment-meta {
        border-color: #4e4e57;
    }
}

[data-theme=light] .moment-meta {
    border-color: #dcdcdc;
}

.moment-tags-single {
    margin-bottom: 1rem;
}

.moment-location {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #999;
    font-size: 0.875rem;
}

.moment-location svg {
    flex-shrink: 0;
}

.moment-back-button {
    margin-top: 2rem;
    margin-bottom: 2rem;
}

.back-to-moments {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #fafafa;
    border: 1px solid #dcdcdc;
    border-radius: 6px;
    color: #222;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
    font-weight: 500;
}

[data-theme=dark] .back-to-moments {
    background: #1b1c1d;
    border-color: #4e4e57;
    color: #a9a9b3;
}

@media (prefers-color-scheme: dark) {
    .back-to-moments {
        background: #1b1c1d;
        border-color: #4e4e57;
        color: #a9a9b3;
    }
}

[data-theme=light] .back-to-moments {
    background: #fafafa;
    border-color: #dcdcdc;
    color: #222;
}

.back-to-moments:hover {
    border-color: #3eb0ef;
}

.back-to-moments svg {
    width: 16px;
    height: 16px;
}

.moment-images {
    margin-bottom: 2rem;
    display: grid;
    gap: 1rem;
}

.moment-images:has(.moment-image:first-child:nth-last-child(1)) {
    grid-template-columns: 1fr;
}

.moment-images:has(.moment-image:first-child:nth-last-child(2)) {
    grid-template-columns: repeat(2, 1fr);
}

.moment-images:has(.moment-image:first-child:nth-last-child(n+3)) {
    grid-template-columns: repeat(3, 1fr);
}

.moment-image {
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: cover;
    border-radius: 8px;
    transition: transform 0.2s;
}

.moment-image:hover {
    transform: scale(1.01);
}

@media (max-width: 768px) {
    .moment-images:has(.moment-image:first-child:nth-last-child(n+3)) {
        grid-template-columns: 1fr;
    }
}

/* Twikoo Comments Styling */
#tcomment {
    margin-top: 2rem;
}

/* Backlinks section styles */
.backlinks-section {
    margin-top: 3rem;
    padding: 1.5rem;
    background: #fafafa;
    border: 1px solid #dcdcdc;
    border-radius: 8px;
}

[data-theme=dark] .backlinks-section {
    background: #3b3d42;
    border-color: #4e4e57;
}

@media (prefers-color-scheme: dark) {
    .backlinks-section {
        background: #3b3d42;
        border-color: #4e4e57;
    }
}

[data-theme=light] .backlinks-section {
    background: #fafafa;
    border-color: #dcdcdc;
}

.backlinks-section h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.backlinks-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.backlink-item {
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 6px;
    transition: background 0.2s;
}

[data-theme=dark] .backlink-item {
    background: rgba(255, 255, 255, 0.05);
}

@media (prefers-color-scheme: dark) {
    .backlink-item {
        background: rgba(255, 255, 255, 0.05);
    }
}

[data-theme=light] .backlink-item {
    background: rgba(0, 0, 0, 0.02);
}

.backlink-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

[data-theme=dark] .backlink-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

@media (prefers-color-scheme: dark) {
    .backlink-item:hover {
        background: rgba(255, 255, 255, 0.1);
    }
}

[data-theme=light] .backlink-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

.backlink-item-title {
    font-weight: 600;
    color: #3eb0ef;
    text-decoration: none;
}

.backlink-item-date {
    display: block;
    font-size: 0.875rem;
    color: #999;
    margin-top: 0.25rem;
}
