/**
 * Min rytme — Rhythm Dashboard
 *
 * Activity overview page: streak, stats, calendar heatmap,
 * and reverse-chronological activity timeline with grouped events.
 *
 * @package enhed
 */

/* ==========================================================================
   Page wrapper
   ========================================================================== */

.rhythm-page {
    margin: 0 auto;
}

/* ==========================================================================
   Overview row — full-width streak + stats above grid
   ========================================================================== */

.rhythm-overview {
    margin-bottom: var(--space-8);
}

.rhythm-overview .rhythm-section__title {
    margin-bottom: var(--space-4);
}

/* ==========================================================================
   Two-column grid — calendar left, timeline right
   ========================================================================== */

.rhythm-grid {
    display: grid;
    gap: var(--space-6);
}

@media (min-width: 1024px) {
    .rhythm-grid {
        grid-template-columns: 1fr 1fr;
        align-items: start;
    }

    .rhythm-grid__calendar {
        position: sticky;
        top: 100px;
    }

    /* Timeline section matches calendar height via JS,
       uses flex to let scroll area fill remaining space */
    .rhythm-timeline-section {
        display: flex;
        flex-direction: column;
    }

    .rhythm-timeline-section .rhythm-timeline-scroll {
        flex: 1;
        min-height: 0;
    }
}

.rhythm-grid__calendar {
    min-width: 0;
}

.rhythm-grid__timeline {
    min-width: 0;
}

/* ==========================================================================
   Sections
   ========================================================================== */

.rhythm-section {
    padding: var(--space-8) var(--space-6);
}

.rhythm-section__title {
    font-family: var(--font-accent);
    font-size: var(--text-xl);
    font-weight: var(--font-normal);
    color: var(--color-text-primary);
    margin: 0 0 var(--space-6);
}

/* ==========================================================================
   Loading
   ========================================================================== */

.rhythm-loading {
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    padding: var(--space-8) 0;
    text-align: center;
}

/* ==========================================================================
   Streak Card
   ========================================================================== */

.rhythm-streak-card {
    display: flex;
    align-items: center;
    gap: var(--space-6);
    padding: var(--space-6) var(--space-8);
    background: var(--color-paper);
    border-radius: 5px;
    margin-bottom: var(--space-6);
}

.rhythm-streak-card__number {
    font-family: var(--font-accent);
    font-size: clamp(2.5rem, 6vw, 3.5rem);
    font-weight: var(--font-bold);
    color: var(--color-action);
    line-height: 1;
    flex-shrink: 0;
}

.rhythm-streak-card__text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rhythm-streak-card__text strong {
    font-family: var(--font-ui);
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    color: var(--color-text-primary);
}

.rhythm-streak-card__text span {
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
}

/* ==========================================================================
   Empty State Card
   ========================================================================== */

.rhythm-empty-card {
    padding: var(--space-8);
    background: var(--color-paper);
    border-radius: 5px;
    margin-bottom: var(--space-6);
}

.rhythm-empty-card__title {
    font-family: var(--font-accent);
    font-size: var(--text-xl);
    font-weight: var(--font-normal);
    color: var(--color-text-primary);
    margin: 0 0 var(--space-3);
}

.rhythm-empty-card__text {
    font-family: var(--font-body);
    font-size: var(--text-base);
    color: var(--color-text-secondary);
    line-height: var(--leading-relaxed);
    margin: 0 0 var(--space-6);
    max-width: 480px;
}

.rhythm-empty-card__actions {
    display: flex;
    gap: var(--space-4);
}

.rhythm-empty-card__link {
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--color-action);
    text-decoration: none;
    transition: color var(--transition);
}

.rhythm-empty-card__link:hover {
    color: var(--color-chokolade);
}

/* ==========================================================================
   Stats Grid (6 counters)
   ========================================================================== */

.rhythm-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-3);
}

@media (min-width: 768px) {
    .rhythm-stats-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

.rhythm-stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-5) var(--space-3);
    background: var(--color-paper);
    border: 1px solid var(--color-lines);
    border-radius: 5px;
    text-align: center;
    gap: var(--space-2);
}

.rhythm-stat-card__icon {
    color: var(--color-action);
    line-height: 1;
}

.rhythm-stat-card__value {
    font-family: var(--font-accent);
    font-size: var(--text-xl);
    font-weight: var(--font-bold);
    color: var(--color-text-primary);
    line-height: 1;
}

.rhythm-stat-card__label {
    font-family: var(--font-body);
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
}

/* ==========================================================================
   Calendar — Frosted Glass
   ========================================================================== */

.rhythm-calendar-section {
    background: linear-gradient(160deg,
        rgba(234, 197, 141, 0.15) 0%,
        rgba(168, 143, 122, 0.10) 40%,
        rgba(174, 113, 140, 0.08) 100%
    );
    border-radius: 5px;
    padding: var(--space-8);
}

/* Calendar header row — title + today button */
.rhythm-cal-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
}

.rhythm-cal-header-row .rhythm-section__title {
    margin-bottom: 0;
}

.rhythm-cal__today-btn {
    font-family: var(--font-ui);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    color: var(--color-action);
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(200, 148, 79, 0.25);
    border-radius: var(--radius-full);
    padding: var(--space-1) var(--space-4);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}

.rhythm-cal__today-btn:hover {
    background: rgba(200, 148, 79, 0.15);
    border-color: var(--color-action);
    color: var(--color-chokolade);
}

.rhythm-cal {
    margin-top: var(--space-4);
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(35px);
    -webkit-backdrop-filter: blur(35px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 5px;
    padding: var(--space-6);
    box-shadow:
        0 8px 40px rgba(61, 28, 15, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.rhythm-cal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-5);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid rgba(168, 143, 122, 0.15);
}

.rhythm-cal__month-label {
    font-family: var(--font-accent);
    font-size: var(--text-lg);
    font-weight: var(--font-normal);
    color: var(--color-text-primary);
    letter-spacing: 0.01em;
}

.rhythm-cal__nav {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    cursor: pointer;
    color: var(--color-text-secondary);
    transition: all var(--transition);
}

.rhythm-cal__nav:hover {
    color: var(--color-action);
    background: rgba(255, 255, 255, 0.35);
    border-color: rgba(200, 148, 79, 0.3);
}

.rhythm-cal__weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0;
    margin-bottom: var(--space-3);
}

.rhythm-cal__weekday {
    text-align: center;
    font-family: var(--font-ui);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    color: var(--color-greige);
    padding: var(--space-2) 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.rhythm-cal__grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}

.rhythm-cal__day {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    border-radius: 8px;
    position: relative;
    gap: 3px;
    min-height: 48px;
    background: rgba(255, 255, 255, 0.06);
    transition: background var(--transition-fast), box-shadow var(--transition-fast);
}

.rhythm-cal__day--empty {
    visibility: hidden;
    background: none;
}

.rhythm-cal__day--future {
    opacity: 0.3;
    background: none;
    cursor: default !important;
}

.rhythm-cal__day--today {
    background: rgba(255, 255, 255, 0.18);
    box-shadow:
        inset 0 0 0 1.5px var(--color-sand),
        0 0 12px rgba(234, 197, 141, 0.12);
}

.rhythm-cal__day--today .rhythm-cal__day-num {
    font-weight: var(--font-semibold);
    color: var(--color-action);
}

/* Calendar highlight from scroll spy */
.rhythm-cal__day--timeline-active {
    background: rgba(200, 148, 79, 0.2);
    box-shadow: inset 0 0 0 2px var(--color-action);
}

.rhythm-cal__day--has-activity {
    cursor: pointer;
}

.rhythm-cal__day--has-activity:hover {
    background: rgba(255, 255, 255, 0.22);
    box-shadow: 0 2px 12px rgba(234, 197, 141, 0.1);
}

.rhythm-cal__day-num {
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--color-text-primary);
    line-height: 1;
}

.rhythm-cal__dots {
    display: flex;
    gap: 3px;
    justify-content: center;
    min-height: 7px;
}

.rhythm-cal__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.08);
}

/* ==========================================================================
   Legend — Frosted Glass
   ========================================================================== */

.rhythm-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-5);
    margin-top: var(--space-4);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 5px;
}

.rhythm-legend__item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.rhythm-legend__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.06);
}

.rhythm-legend__label {
    font-family: var(--font-body);
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
}

/* ==========================================================================
   Activity Timeline — Contained scroll area with frosted glass
   ========================================================================== */

.rhythm-timeline-section {
    background: linear-gradient(160deg,
        rgba(234, 197, 141, 0.15) 0%,
        rgba(168, 143, 122, 0.10) 40%,
        rgba(174, 113, 140, 0.08) 100%
    );
    border-radius: 5px;
    padding: var(--space-6);
}

/* Scroll container — confines timeline scrolling to this area */
.rhythm-timeline-scroll {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    overscroll-behavior: contain;
    position: relative;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(35px);
    -webkit-backdrop-filter: blur(35px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 5px;
    padding: var(--space-6);
    box-shadow:
        0 8px 40px rgba(61, 28, 15, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

/* Custom scrollbar — subtle, matching the design */
.rhythm-timeline-scroll::-webkit-scrollbar {
    width: 6px;
}

.rhythm-timeline-scroll::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 3px;
}

.rhythm-timeline-scroll::-webkit-scrollbar-thumb {
    background: rgba(168, 143, 122, 0.3);
    border-radius: 3px;
    transition: background 0.2s;
}

.rhythm-timeline-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(168, 143, 122, 0.5);
}

/* Firefox scrollbar */
.rhythm-timeline-scroll {
    scrollbar-width: thin;
    scrollbar-color: rgba(168, 143, 122, 0.3) transparent;
}

.rhythm-timeline {
    position: relative;
}

/* Vertical spine line */
.rhythm-timeline::before {
    content: "";
    position: absolute;
    left: 5px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--color-lines);
    border-radius: 1px;
}

/* Loading spinner — three bouncing dots at top of scroll area */
.rhythm-timeline__loader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: var(--space-3) 0;
}

.rhythm-timeline__loader-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-greige);
    opacity: 0.5;
    animation: rhythm-loader-bounce 1.2s ease-in-out infinite;
}

.rhythm-timeline__loader-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.rhythm-timeline__loader-dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes rhythm-loader-bounce {
    0%, 80%, 100% { transform: scale(1); opacity: 0.4; }
    40% { transform: scale(1.4); opacity: 1; }
}

/* Day group */
.rhythm-timeline__day {
    position: relative;
    padding-left: var(--space-8);
    margin-bottom: var(--space-6);
}

.rhythm-timeline__day:last-child {
    margin-bottom: 0;
}

/* Flash highlight when scrolled to from calendar click */
.rhythm-timeline__day--active {
    animation: rhythm-flash 1.2s ease-out;
}

@keyframes rhythm-flash {
    0%   { background: rgba(200, 148, 79, 0.15); border-radius: 5px; }
    100% { background: transparent; }
}

/* Date header — sticky within the scroll container */
.rhythm-timeline__date-header {
    position: sticky;
    top: 0;
    z-index: 2;
    background: rgba(239, 231, 222, 0.9);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    padding: var(--space-2) var(--space-3);
    margin-bottom: var(--space-3);
    margin-left: calc(-1 * var(--space-8));
    padding-left: var(--space-8);
    border-bottom: 1px solid rgba(168, 143, 122, 0.15);
}

.rhythm-timeline__date-text {
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--color-text-primary);
}

/* Single grouped event card */
.rhythm-timeline__event {
    display: flex;
    gap: var(--space-3);
    align-items: flex-start;
    padding: var(--space-3) 0;
    border-bottom: 1px solid rgba(168, 143, 122, 0.08);
}

.rhythm-timeline__event:last-child {
    border-bottom: none;
}

/* Colored dot */
.rhythm-timeline__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 4px;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.08);
}

.rhythm-timeline__event-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

/* Type label */
.rhythm-timeline__event-type {
    font-family: var(--font-ui);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    color: var(--color-greige);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* Count badge */
.rhythm-timeline__count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 10px;
    font-weight: var(--font-bold);
    color: var(--color-paper);
    background: var(--color-greige);
    border-radius: var(--radius-full);
    text-transform: none;
    letter-spacing: 0;
}

/* Event detail text */
.rhythm-timeline__event-detail {
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--color-text-primary);
    line-height: var(--leading-relaxed);
}

.rhythm-timeline__event-detail--label {
    font-family: var(--font-ui);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    color: var(--color-action);
}

/* Journal excerpt — truncated to 2 lines by default */
.rhythm-timeline__event-excerpt {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.rhythm-timeline__event-excerpt--expanded {
    display: block;
    -webkit-line-clamp: unset;
    overflow: visible;
}

/* Content links */
.rhythm-timeline__event-link {
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--color-action);
    text-decoration: none;
    transition: color var(--transition);
    display: block;
}

.rhythm-timeline__event-link:hover {
    color: var(--color-chokolade);
    text-decoration: underline;
}

/* Expand/collapse toggle */
.rhythm-timeline__expand-toggle {
    background: none;
    border: none;
    padding: var(--space-1) 0;
    font-family: var(--font-ui);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    color: var(--color-action);
    cursor: pointer;
    text-align: left;
    transition: color var(--transition);
}

.rhythm-timeline__expand-toggle:hover {
    color: var(--color-chokolade);
}

/* Expandable content container */
.rhythm-timeline__expand-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding-top: var(--space-2);
}

.rhythm-timeline__expand-content[hidden] {
    display: none;
}

/* Expand entry separator (for journals) */
.rhythm-timeline__expand-entry {
    padding-top: var(--space-2);
    border-top: 1px dashed var(--color-lines);
}

.rhythm-timeline__expand-entry:first-child {
    border-top: none;
    padding-top: 0;
}

/* Timeline empty state */
.rhythm-timeline__empty {
    text-align: center;
    padding: var(--space-8) 0;
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
}

.rhythm-timeline__empty .rhythm-empty-card__actions {
    justify-content: center;
    margin-top: var(--space-4);
}

/* ==========================================================================
   Mobile
   ========================================================================== */

@media (max-width: 767px) {
    .rhythm-section {
        padding: var(--space-6) var(--space-4);
    }

    .rhythm-stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .rhythm-streak-card {
        flex-direction: column;
        text-align: center;
        padding: var(--space-5);
    }

    .rhythm-calendar-section {
        padding: var(--space-5);
    }

    .rhythm-cal {
        padding: var(--space-4);
    }

    .rhythm-cal__day {
        min-height: 38px;
        border-radius: 6px;
    }

    .rhythm-legend {
        gap: var(--space-3);
        padding: var(--space-3) var(--space-4);
    }

    .rhythm-timeline-section {
        padding: var(--space-4);
    }

    .rhythm-timeline-scroll {
        max-height: 60vh;
        padding: var(--space-4);
    }
}

/* ==========================================================================
   Standalone page body
   ========================================================================== */

.standalone-page-body {
    padding: var(--space-8) 0 var(--space-16);
}

/* Override archive-header flex layout — no controls on this page */
.site-main > .archive-header .container {
    display: block;
    text-align: center;
}
.site-main > .archive-header .archive-description {
    max-width: 600px;
    margin: 0 auto;
}
