/* ============================================================
   KJV Bible Reader — Dashboard
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
    --font-primary:       'EB Garamond', Georgia, 'Times New Roman', serif;
    --color-bg:           #fdfcf8;
    --color-text:         #2c2416;
    --color-text-muted:   #6b5c4a;
    --color-header-bg:    #f5f3ee;
    --color-border:       #e0dcd3;
    --color-link:         #7b5e3a;
    --color-accent:       #d4a84b;
    --color-accent-light: rgba(212, 168, 75, 0.12);
    --max-width:          860px;
}

html { font-size: 18px; }

body {
    font-family: var(--font-primary);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--color-link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navigation ───────────────────────────────────────────── */
.dash-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 2rem;
    background: var(--color-header-bg);
    border-bottom: 1px solid var(--color-border);
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-text);
    font-size: 1.05rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    text-decoration: none;
}
.nav-logo:hover { color: var(--color-link); text-decoration: none; }
.logo-mark { color: var(--color-accent); }

.nav-links { display: flex; align-items: center; gap: 1.25rem; }

.nav-user {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    font-style: italic;
    text-decoration: none;
}
.nav-user:hover { color: var(--color-text); text-decoration: none; }

.nav-link {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    text-decoration: none;
}
.nav-link:hover { color: var(--color-text); text-decoration: none; }

.btn-nav {
    display: inline-block;
    font-family: var(--font-primary);
    font-size: 0.9rem;
    padding: 0.4rem 1.1rem;
    border-radius: 4px;
    background: var(--color-link);
    color: #fff;
    text-decoration: none;
    border: 1px solid transparent;
    transition: background 150ms ease;
}
.btn-nav:hover { background: #6a5132; text-decoration: none; color: #fff; }

.nav-signout {
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font-primary);
    font-size: 0.9rem;
    color: var(--color-text-muted);
    padding: 0;
}
.nav-signout:hover { color: var(--color-text); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn-primary {
    display: inline-block;
    font-family: var(--font-primary);
    font-size: 1rem;
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    background: var(--color-link);
    color: #fff;
    border: 1px solid var(--color-link);
    cursor: pointer;
    text-decoration: none;
    transition: background 150ms ease;
}
.btn-primary:hover { background: #6a5132; text-decoration: none; color: #fff; }

.btn-secondary {
    display: inline-block;
    font-family: var(--font-primary);
    font-size: 1rem;
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    background: transparent;
    color: var(--color-link);
    border: 1px solid var(--color-link);
    text-decoration: none;
    transition: background 150ms ease;
}
.btn-secondary:hover { background: var(--color-accent-light); text-decoration: none; }

/* ── Main layout ──────────────────────────────────────────── */
.dash-main {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 3rem 2rem 5rem;
}

.dash-heading {
    margin-bottom: 2.5rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--color-border);
}

.dash-title {
    font-size: 2rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.dash-date {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}

/* ── Summary cards ────────────────────────────────────────── */
.dash-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.dash-card {
    background: var(--color-header-bg);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.card-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--color-text-muted);
}

.card-value {
    font-size: 1.9rem;
    font-weight: 500;
    line-height: 1.15;
    color: var(--color-text);
}
.card-value.due-nonzero    { color: var(--color-link); }
.card-value.streak-nonzero { color: var(--color-link); }

.card-sub {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    min-height: 1.25em;
}

.card-action { margin-top: 0.85rem; align-self: flex-start; }

/* ── Section ──────────────────────────────────────────────── */
.dash-section { margin-bottom: 2.5rem; }

.section-header {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border);
}

.section-title { font-size: 1.1rem; font-weight: 500; }

.section-badge {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    background: var(--color-header-bg);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 0.05rem 0.55rem;
}

/* ── Queue list ───────────────────────────────────────────── */
.queue-list { display: flex; flex-direction: column; }

.queue-row {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    align-items: center;
    gap: 1.25rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--color-border);
}
.queue-row:last-child { border-bottom: none; }

.queue-ref { font-size: 1rem; }

.queue-mastery {
    font-size: 0.85rem;
    letter-spacing: 0.12em;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.queue-due {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    white-space: nowrap;
    min-width: 7rem;
    text-align: right;
}
.queue-due.is-due {
    color: var(--color-link);
    font-style: italic;
}

.queue-practice-btn {
    font-family: var(--font-primary);
    font-size: 0.85rem;
    padding: 0.25rem 0.85rem;
    border-radius: 4px;
    border: 1px solid var(--color-border);
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 150ms ease, color 150ms ease;
}
.queue-practice-btn:hover { border-color: var(--color-link); color: var(--color-link); }

.queue-empty {
    padding: 2rem 0;
    color: var(--color-text-muted);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
}

.queue-empty kbd {
    font-family: var(--font-primary);
    font-size: 0.85em;
    background: var(--color-header-bg);
    border: 1px solid var(--color-border);
    border-radius: 3px;
    padding: 0.05em 0.35em;
}

/* ── Featured Passages ─────────────────────────────────────── */
.section-sub {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    font-style: italic;
}

.featured-list { display: flex; flex-direction: column; }

.featured-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 1.25rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--color-border);
}
.featured-row:last-child { border-bottom: none; }

.featured-title {
    font-size: 1rem;
    font-weight: 500;
}

.featured-ref {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.featured-add-btn {
    font-family: var(--font-primary);
    font-size: 0.85rem;
    padding: 0.25rem 0.85rem;
    border-radius: 4px;
    border: 1px solid var(--color-link);
    background: transparent;
    color: var(--color-link);
    cursor: pointer;
    white-space: nowrap;
    transition: background 150ms ease, color 150ms ease;
    min-width: 5.5rem;
    text-align: center;
}
.featured-add-btn:hover:not(:disabled) {
    background: var(--color-accent-light, #f0ebe3);
}
.featured-add-btn.is-added,
.featured-add-btn:disabled {
    border-color: var(--color-border);
    color: var(--color-text-muted);
    cursor: default;
    background: transparent;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 640px) {
    .dash-main { padding: 2rem 1.25rem 4rem; }
    .dash-nav  { padding: 0.75rem 1.25rem; }
    .dash-cards { grid-template-columns: 1fr; }

    .queue-row {
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        row-gap: 0.4rem;
    }
    .queue-ref          { grid-column: 1; grid-row: 1; }
    .queue-practice-btn { grid-column: 2; grid-row: 1; }
    .queue-mastery      { grid-column: 1; grid-row: 2; }
    .queue-due          { grid-column: 2; grid-row: 2; text-align: right; }

    .featured-row {
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        row-gap: 0.25rem;
    }
    .featured-title   { grid-column: 1; grid-row: 1; }
    .featured-add-btn { grid-column: 2; grid-row: 1; }
    .featured-ref     { grid-column: 1; grid-row: 2; }
}

/* ── Review History Dots ──────────────────────────────────────────────────── */

.queue-history {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 4px;
    padding-bottom: 0.35rem;
}

.hist-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.hist-good  { background: #5a9e6a; }   /* muted green  — Good / Easy */
.hist-hard  { background: #c8893a; }   /* muted orange — Hard        */
.hist-again { background: #b85050; }   /* muted red    — Again       */

/* ── Reading Plans ────────────────────────────────────────────────────────── */

.plans-list {
    display: flex;
    flex-direction: column;
}

.plan-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 0;
    border-bottom: 1px solid var(--color-border);
}

.plan-row:last-child {
    border-bottom: none;
}

.plan-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.plan-title {
    font-weight: 500;
    font-size: 1rem;
    color: var(--color-text);
}

.plan-progress {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.plan-progress.plan-unenrolled {
    font-style: italic;
}

.plan-progress.plan-finished {
    color: var(--color-accent);
    font-weight: 500;
}

.plan-progress-track {
    height: 4px;
    background: var(--color-border);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 0.3rem;
}

.plan-progress-fill {
    height: 100%;
    background: var(--color-accent);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.plan-day-label {
    font-size: 0.875rem;
    color: var(--color-link);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.plan-day-label:hover {
    text-decoration: underline;
}

.plan-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.plan-done-label {
    font-size: 0.875rem;
    color: var(--color-accent);
    font-style: italic;
}

/* ── Plans — Mobile (≤640px) ──────────────────────────────────────────────── */

@media (max-width: 640px) {
    .plan-row {
        grid-template-columns: 1fr;
        row-gap: 0.6rem;
    }

    .plan-actions {
        flex-wrap: wrap;
    }
}

/* ── Activity Heatmap ─────────────────────────────────────────────────────── */

.heatmap-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.5rem;
}

/* Month labels row */
.heatmap-months {
    position: relative;
    height: 1.25rem;
    margin-left: 2.5rem; /* align with grid (matches .heatmap-days width) */
    margin-bottom: 0.2rem;
}

.heatmap-month-label {
    position: absolute;
    font-size: 0.72rem;
    color: var(--color-text-muted);
    white-space: nowrap;
}

/* Grid row: day labels + cell grid side by side */
.heatmap-body {
    display: flex;
    align-items: flex-start;
    gap: 0.35rem;
}

/* Day-of-week labels (Sun–Sat) */
.heatmap-days {
    display: grid;
    grid-template-rows: repeat(7, 11px);
    gap: 2px;
    flex-shrink: 0;
    width: 2.2rem;
}

.heatmap-days span {
    font-size: 0.65rem;
    color: var(--color-text-muted);
    line-height: 11px;
    text-align: right;
}

/* Cell grid */
.heatmap-grid {
    display: grid;
    grid-template-rows: repeat(7, 11px);
    grid-auto-flow: column;
    gap: 2px;
}

/* Individual cells */
.heat-cell {
    width: 11px;
    height: 11px;
    border-radius: 2px;
}

.heat-future { background: transparent; }
.heat-0 { background: var(--color-border); }
.heat-1 { background: color-mix(in srgb, var(--color-accent) 30%, var(--color-border)); }
.heat-2 { background: color-mix(in srgb, var(--color-accent) 55%, var(--color-border)); }
.heat-3 { background: color-mix(in srgb, var(--color-accent) 78%, var(--color-border)); }
.heat-4 { background: var(--color-accent); }

/* Legend */
.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 3px;
    margin-top: 0.6rem;
    margin-left: 2.5rem;
}

.heatmap-legend span {
    font-size: 0.72rem;
    color: var(--color-text-muted);
    margin: 0 0.15rem;
}

/* Mobile: allow horizontal scroll, hide day labels to save space */
@media (max-width: 640px) {
    .heatmap-days { display: none; }
    .heatmap-months { margin-left: 0; }
    .heatmap-legend { margin-left: 0; }
}
