/* ==========================================
   Practice Streaks - Native & Refined Design
   ========================================== */

:root {
    /* Shared orange accent; dark mode inherits the same colour. */
    --streak-primary: #fb8b3d;
    --streak-primary-hover: var(--streak-primary);
    --streak-border: #666;            /* 3.1:1 non-text on white */
    --streak-card-bg: #ffffff;
    --streak-muted: #525252;          /* secondary text 7.8:1 */
    /* Calendar kept days match activity level 3 in vars-default.scss.
     * The current-streak number uses the same orange in both themes. */
    --streak-cell-empty: #ddd;
    --streak-cell-kept: #2f9c4c;
    --streak-on-kept: #0f0f0f;
    --streak-count: var(--streak-primary);
    --streak-calendar-accent: #213a58;
    --streak-calendar-on-accent: #fff;
    --streak-future-border: #808080;
    --streak-fill: var(--streak-primary);
    --streak-fill-hover: var(--streak-primary);
    --streak-on-fill: #0f0f0f;
    --streak-status-kept: #047857;
    --streak-status-pending: var(--streak-primary);
    --streak-status-updating: #075985;
    --streak-focus: #41729f;
    --streak-today-ring: #132d46;
}

.streak-page {
    max-width: 1100px;
    margin: 0 auto;
}

/* Two-layer flame. Light mode deepens the outer layer to reach 3.6:1 on white;
 * streaks-dark.css restores the original fills (6.3:1 on dark surfaces).
 * Attribute fills on the paths remain the no-CSS fallback. */
.streak-flame {
    display: inline-block;
    vertical-align: -0.2em;
    flex: none;
}

.streak-flame path:nth-of-type(1) { fill: #ea580c; }
.streak-flame path:nth-of-type(2) { fill: #fdce01; }

/* Base Card Surfaces */
.streak-card {
    border: 1px solid var(--streak-border);
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 20px;
    background: var(--streak-card-bg);
}

.streak-card h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.01em;
}

.streak-heading-icon {
    color: var(--streak-primary);
    font-size: 1em;
}

.streak-card p {
    line-height: 1.5;
    margin: 4px 0 0;
}

.streak-note, .streak-eyebrow {
    font-size: 0.8rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--streak-muted);
}

.streak-note {
    text-transform: none;
    font-weight: 400;
    color: var(--streak-muted);
}

/* Hero Summary Section */
.streak-summary {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px 32px;
    background: var(--streak-card-bg);
    border-left: 4px solid var(--streak-primary);
}

.streak-summary-main {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    min-width: 240px;
}

.streak-hero-icon {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: rgba(251, 139, 61, 0.1);
    color: var(--streak-primary);
    flex: none;
}

.streak-hero-info {
    display: flex;
    flex-direction: column;
}

.streak-hero-count {
    font-size: 0.95rem;
    margin: 2px 0 4px !important;
}

.streak-hero-count strong {
    margin-right: 6px;
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    color: var(--streak-count);
}

/* Status Badges */
.streak-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 16px;
    font-size: 0.775rem;
    font-weight: 600;
    line-height: 1.4;
}

.status-kept {
    background: rgba(16, 185, 129, 0.12);
    color: var(--streak-status-kept);
    border: 1px solid rgba(16, 185, 129, 0.35);
}

.status-pending {
    background: rgba(251, 139, 61, 0.12);
    color: var(--streak-status-pending);
    border: 1px solid rgba(251, 139, 61, 0.35);
}

.status-updating {
    background: rgba(14, 165, 233, 0.12);
    color: var(--streak-status-updating);
    border: 1px solid rgba(14, 165, 233, 0.35);
}

/* Record Section */
.streak-best {
    border-left: 1px solid var(--streak-border);
    padding-left: 28px;
    display: flex;
    flex-direction: column;
}

.streak-best-count {
    margin: 2px 0 0 !important;
}

.streak-best-count strong {
    margin-right: 4px;
    font-size: 1.65rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.streak-summary-note {
    flex-basis: 100%;
}

/* Help Accordion */
.streak-help {
    border: 1px solid var(--streak-border);
    border-radius: 10px;
    background: rgba(136, 136, 136, 0.03);
    padding: 10px 16px;
    margin: -6px 0 20px;
    font-size: 0.85rem;
}

.streak-help summary {
    cursor: pointer;
    font-weight: 600;
    user-select: none;
    outline: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.streak-help summary:hover {
    color: var(--streak-primary);
}

.streak-help-icon {
    color: var(--streak-primary);
}

.streak-help p {
    max-width: none;
    line-height: 1.6;
    margin: 8px 0 4px;
    color: var(--streak-muted);
}

/* Calendar Header & Switcher */
.streak-heading, .streak-calendar-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.streak-calendar-toolbar {
    margin: 16px 0 12px;
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--streak-border);
}

.streak-card nav {
    position: static;
    display: flex;
    align-items: center;
    gap: 10px;
}

.streak-card nav strong {
    font-size: 1.05rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.streak-calendar-toolbar nav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    color: inherit;
    border-radius: 6px;
    border: 1px solid var(--streak-border);
    background: rgba(136, 136, 136, 0.05);
    transition: all 0.15s ease;
}

.streak-calendar-toolbar nav a:hover {
    background: var(--streak-calendar-accent);
    color: var(--streak-calendar-on-accent) !important;
    border-color: var(--streak-calendar-accent);
}

/* View Switcher */
.streak-view-switch {
    display: flex;
    padding: 3px;
    background: rgba(136, 136, 136, 0.15);
    border: 1px solid var(--streak-border);
    border-radius: 8px;
    gap: 4px;
}

.streak-view-switch button {
    appearance: none;
    background: none;
    border: 0;
    border-radius: 6px;
    color: inherit !important;
    font: inherit;
    font-size: 0.825rem;
    font-weight: 600;
    padding: 5px 12px;
    min-height: 32px;
    cursor: pointer;
    box-shadow: none;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.streak-view-switch button[aria-pressed="true"] {
    background: var(--streak-calendar-accent);
    color: var(--streak-calendar-on-accent) !important;
}

.streak-month-picker {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
}

.streak-month-picker select {
    min-height: 34px;
    max-width: 160px;
    font: inherit;
    border-radius: 6px;
    border: 1px solid var(--streak-border);
    padding: 4px 8px;
    background: var(--streak-card-bg);
}

/* Heatmap Grid */
.streak-heat-scroll {
    overflow-x: auto;
    padding: 6px 2px;
    scrollbar-width: thin;
}

.streak-heat-months, .streak-heat-grid {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 13px;
    column-gap: 3px;
}

.streak-heat-months {
    margin-left: 30px;
    height: 22px;
}

.streak-heat-months span {
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
    white-space: nowrap;
    color: var(--streak-muted);
}

.streak-heat-body {
    display: flex;
    gap: 6px;
}

.streak-heat-days {
    display: grid;
    grid-template-rows: repeat(7, 13px);
    row-gap: 3px;
    width: 24px;
    flex: none;
    font-size: 10px;
    font-weight: 600;
    line-height: 13px;
    color: var(--streak-muted);
}

.streak-heat-grid {
    grid-template-rows: repeat(7, 13px);
    row-gap: 3px;
}

.streak-heat-cell {
    display: block;
    width: 13px;
    height: 13px;
    border-radius: 3px;
    background: var(--streak-cell-empty);
    transition: transform 0.1s ease, background-color 0.15s ease;
    cursor: pointer;
}

.streak-heat-cell:hover:not(.blank) {
    transform: scale(1.2);
    z-index: 2;
}

.streak-heat-cell.blank {
    background: transparent;
    cursor: default;
}

.streak-heat-cell.kept, .streak-day.kept {
    background: var(--streak-cell-kept);
    color: var(--streak-on-kept);
}

.streak-heat-cell.future {
    background: transparent;
    box-shadow: inset 0 0 0 1.5px var(--streak-future-border);
    cursor: default;
}

/* Card-colored gap + text-colored ring stays within the 3px cell gap and leaves
 * the outline free for the selected-day marker. */
.streak-heat-cell.today, .streak-day.today {
    box-shadow: 0 0 0 1px var(--streak-card-bg), 0 0 0 3px var(--streak-today-ring);
    position: relative;
    z-index: 1;
}

/* Month Grid View */
.streak-months {
    display: none;
}

.streak-month {
    max-width: 500px;
    margin: 0 auto;
}

.streak-month h3 {
    margin: 14px 0;
    font-size: 1.05rem;
    font-weight: 700;
    text-align: center;
}

.streak-month-grid, .streak-weekdays {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
}

.streak-weekdays {
    text-align: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--streak-muted);
    margin-bottom: 4px;
}

.streak-day {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: inherit;
    text-decoration: none;
    font-variant-numeric: tabular-nums;
    border: 1px solid var(--streak-border);
    background: var(--streak-cell-empty);
    transition: all 0.15s ease;
}

.streak-day.blank {
    visibility: hidden;
    border: 0;
    background: transparent;
}

.streak-day.kept {
    font-weight: 700;
    border-color: var(--streak-cell-kept);
    background: var(--streak-cell-kept);
    color: var(--streak-on-kept);
}

.streak-day.future {
    opacity: 0.55;
    cursor: default;
}

.streak-day.selected, .streak-heat-cell.selected {
    outline: 2px solid var(--streak-focus) !important;
    outline-offset: 2px;
}

.streak-page a:focus-visible, .streak-page button:focus-visible, .streak-page select:focus-visible, .streak-help summary:focus-visible {
    outline: 2px solid var(--streak-focus);
    outline-offset: 2px;
}

.streak-day:not(.kept):not(.future):hover {
    background-color: var(--streak-cell-empty);
    text-decoration: underline;
}

.streak-contrib-link:hover .streak-contrib-prob {
    text-decoration: underline;
}

.streak-page a.kept:hover {
    background-color: var(--streak-cell-kept);
    text-decoration: underline;
}

/* Legend / Scale */
.streak-scale {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 20px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px dashed var(--streak-border);
    font-size: 0.8rem;
    font-weight: 600;
}

.streak-scale > span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.streak-scale .streak-heat-cell {
    flex: none;
    cursor: default;
}

/* Daily Progress Items */
.streak-contributions {
    list-style: none;
    padding: 0;
    margin: 14px 0 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.streak-contrib-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--streak-border);
    background: rgba(136, 136, 136, 0.03);
}

.streak-contrib-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: inherit;
    text-decoration: none;
}

.streak-contrib-prob {
    color: var(--streak-primary);
}

.streak-contrib-subid {
    font-size: 0.8rem;
    color: var(--streak-muted);
    font-variant-numeric: tabular-nums;
}

.streak-contrib-score {
    font-size: 0.85rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(16, 185, 129, 0.1);
    color: var(--streak-status-kept);
}

.streak-contrib-empty {
    padding: 10px 0;
    color: var(--streak-muted);
}

/* History Timeline */
.streak-history {
    list-style: none;
    padding: 0;
    margin: 14px 0 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.streak-history-item {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 16px;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid var(--streak-border);
    background: rgba(136, 136, 136, 0.02);
}

.streak-run-length {
    min-width: 80px;
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
}

.streak-run-length strong {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--streak-primary);
}

.streak-run-dates {
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--streak-muted);
}

.streak-record {
    background: rgba(251, 139, 61, 0.15);
    color: var(--streak-primary);
    border: 1px solid var(--streak-primary);
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.streak-run-state {
    margin-left: auto;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(136, 136, 136, 0.1);
}

.streak-run-state.active {
    background: rgba(16, 185, 129, 0.12);
    color: var(--streak-status-kept);
    border: 1px solid rgba(16, 185, 129, 0.25);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.streak-history-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
}

.streak-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--streak-border);
    font-size: 0.825rem;
    font-weight: 600;
    color: inherit;
    text-decoration: none;
    transition: all 0.15s ease;
}

.streak-nav-btn:hover {
    background: var(--streak-fill);
    color: var(--streak-on-fill) !important;
    border-color: var(--streak-fill);
}

/* Header Badge */
.streak-header-badge {
    font-size: 13px;
    padding: 3px 9px;
    margin-left: 8px;
    vertical-align: middle;
    border-radius: 12px;
}

/* Leave room between the full-width sidebar card and the main profile content.
 * The original profile layout only left a gap beside the narrower avatar. */
.user-info-page.has-streak {
    align-items: flex-start;
    gap: 24px;
}

.user-info-page.has-streak > .user-sidebar {
    flex: 0 0 150px;
}

.user-info-page.has-streak > .user-content {
    min-width: 0;
}

/* Sidebar Public Streak Card: contained within the 150px profile sidebar. */
.streak-public-card {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(136, 136, 136, 0.35);
    color: inherit;
    background: rgba(136, 136, 136, 0.04);
}

.streak-public-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.3;
    color: inherit;
}

.streak-public-hero {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
}

.streak-public-hero strong {
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    color: var(--streak-count);
}

.streak-public-unit {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    line-height: 1.3;
    color: inherit;
}

.streak-public-record {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(136, 136, 136, 0.3);
    font-size: 12px;
}

.streak-public-record > span {
    white-space: nowrap;
}

.streak-public-record > span:first-child {
    color: inherit;
}

.streak-public-record i {
    margin-right: 3px;
}

.streak-public-record strong {
    font-size: 14px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.streak-public-empty {
    margin-top: 6px;
    font-size: 12px;
    font-style: italic;
    color: inherit;
}

/* Submission/Leaderboard Streak Badge: soft tinted chips for the rating-style
 * ladder (text >=4.8:1), gradients mark the two elite tiers; streaks-dark.css
 * swaps in dark variants. */
.streak-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 0.35em;
    padding: 1px 8px 1px 6px;
    border-radius: 999px;
    background: var(--streak-chip-bg);
    color: var(--streak-chip-fg);
    border: 1px solid var(--streak-chip-border);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.5;
    vertical-align: middle;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.streak-badge .streak-flame {
    width: 14px;
    height: 14px;
    flex: none;
}

.streak-badge, .streak-badge.streak-gray {  /* 1-2 days */
    --streak-chip-bg: #f5f5f5; --streak-chip-fg: #525252; --streak-chip-border: #d4d4d4;
}
.streak-badge.streak-green {  /* 3-6 days */
    --streak-chip-bg: #f0fdf4; --streak-chip-fg: #15803d; --streak-chip-border: #86efac;
}
.streak-badge.streak-cyan {  /* 7-13 days */
    --streak-chip-bg: #ecfeff; --streak-chip-fg: #0e7490; --streak-chip-border: #67e8f9;
}
.streak-badge.streak-blue {  /* 14-29 days */
    --streak-chip-bg: #eff6ff; --streak-chip-fg: #1d4ed8; --streak-chip-border: #93c5fd;
}
.streak-badge.streak-violet {  /* 30-59 days */
    --streak-chip-bg: #f5f3ff; --streak-chip-fg: #6d28d9; --streak-chip-border: #c4b5fd;
}
.streak-badge.streak-orange {  /* 60-99 days */
    --streak-chip-bg: #fff7ed; --streak-chip-fg: #c2410c; --streak-chip-border: #fdba74;
}
.streak-badge.streak-red {  /* 100-199 days */
    --streak-chip-bg: #fef2f2; --streak-chip-fg: #b91c1c; --streak-chip-border: #fca5a5;
}
.streak-badge.streak-crimson {  /* 200-364 days */
    --streak-chip-bg: linear-gradient(135deg, #fdf2f8, #fce7f3);
    --streak-chip-fg: #be185d; --streak-chip-border: #f9a8d4;
}
.streak-badge.streak-legend {  /* 365+ days */
    --streak-chip-bg: linear-gradient(135deg, #fefce8, #fef08a);
    --streak-chip-fg: #854d0e; --streak-chip-border: #eab308;
}
.streak-badge.streak-muted {
    --streak-chip-bg: #f5f5f5; --streak-chip-fg: #525252; --streak-chip-border: #d4d4d4;
}

/* Deeper outer flame keeps >=4.4:1 on every light chip. */
.streak-badge .streak-flame path:nth-of-type(1) { fill: #c2410c; }

.streak-unit {
    display: block;
    font-size: 10px;
    font-weight: 400;
}

.tabs .streak-flame {
    margin-right: 0.3em;
}

/* Visibility Control */
.streak-page [hidden] {
    display: none !important;
}

.streak-page[data-view="month"] .streak-year-panel {
    display: none;
}

.streak-page[data-view="month"] .streak-months {
    display: block;
}

/* Responsive Mobile Rules */
@media (max-width: 600px) {
    .streak-card {
        padding: 16px;
        border-radius: 10px;
    }
    .streak-summary {
        gap: 14px;
    }
    .streak-hero-icon {
        width: 48px;
        height: 48px;
    }
    .streak-hero-count strong {
        font-size: 2rem;
    }
    .streak-best {
        padding: 12px 0 0;
        border-left: 0;
        border-top: 1px dashed var(--streak-border);
        width: 100%;
        flex-direction: row;
        align-items: baseline;
        justify-content: space-between;
    }
    .streak-best-count {
        margin: 0 !important;
    }
    .streak-history-item {
        gap: 6px 10px;
    }
    .streak-run-state {
        margin-left: 0;
    }
}

@media (max-width: 599px) {
    .user-info-page.has-streak > .user-sidebar {
        padding-left: 0;
        margin: 0 auto 24px;
    }
}
