/* =====================================================================
   Gym Log — editorial redesign
   Palette: warm dark, earthy terracotta accent, muted secondary.
   Type: Fraunces (serif) for display numbers, Inter for UI,
         JetBrains Mono for data/metadata.
   ===================================================================== */

:root {
    /* Warm, not-quite-black background — has subtle green-olive warmth */
    --bg:          #0D100F;
    --bg-lift:    rgba(255, 253, 245, 0.02);   /* barely-there surface lift */
    --rule:       rgba(255, 253, 245, 0.07);    /* horizontal rules, dividers */
    --rule-soft:  rgba(255, 253, 245, 0.04);

    /* Text */
    --ink:        #ECEAE0;                      /* warm off-white */
    --ink-dim:    #8D8F87;                      /* muted, readable */
    --ink-faint:  #5A5C55;                      /* metadata, dates */

    /* Single accent — terracotta/peach, not tech-purple */
    --accent:     #E8A87C;
    --accent-ink: #C2865F;                      /* darker shade for contrast */

    /* Semantic pair — earthy, not alarm colors */
    --pos:        #849B7A;                      /* muted olive-sage */
    --neg:        #D47765;                      /* dusty red */

    /* Muscle colors — all muted, not neon */
    --m-back:       #8B7EC7;  /* muted violet */
    --m-legs:       #6BA38F;  /* sage green */
    --m-chest:      #D47765;  /* dusty red */
    --m-arms:       #D4A574;  /* soft gold */
    --m-biceps:     #C89A65;  /* bronze */
    --m-triceps:    #BF7E70;  /* muted coral */
    --m-shoulders:  #7BA5A5;  /* dusty teal */
    --m-cardio:     #9590B3;  /* muted lavender */
    --m-core:       #C08FA3;  /* dusty pink */
    --m-other:      #6E6E66;

    /* Fonts */
    --serif: 'Fraunces', 'Charter', Georgia, serif;
    --sans:  'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --mono:  'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html { background: var(--bg); }

body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    font-feature-settings: "cv11", "ss01";
}

/* =====================================================================
   LAYOUT
   ===================================================================== */

#dashboard-view, #exercise-view {
    max-width: 580px;
    margin: 0 auto;
    padding: 0 1.5rem 3rem;
}

/* Desktop layout: two-column grid with narrow text, wider data */
@media (min-width: 900px) {
    #dashboard-view {
        max-width: 1100px;
        padding: 0 2rem 3rem;
        display: grid;
        grid-template-columns: 340px 1fr;
        gap: 3rem;
        align-items: start;
    }
    #dashboard-view > .masthead,
    #dashboard-view > .footer {
        grid-column: 1 / -1;
    }
    #dashboard-view > .lead {
        position: sticky;
        top: 2rem;
        grid-column: 1;
        grid-row: 2 / span 10;
        border-bottom: none;
        padding: 1rem 0;
    }
    #dashboard-view > .section {
        grid-column: 2;
    }
    /* Remove row borders on desktop-right column — rely on spacing */
    #dashboard-view > .section:first-of-type {
        padding-top: 0;
    }
}

.masthead {
    padding-top: calc(1.5rem + env(safe-area-inset-top));
    padding-bottom: 1rem;
}

.masthead-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--rule);
    padding-bottom: 1rem;
}

.brand {
    font-family: var(--serif);
    font-weight: 600;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
    color: var(--ink);
}

.date-stamp, .back-link {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--ink-faint);
    text-transform: lowercase;
    letter-spacing: 0.02em;
    font-weight: 500;
}

.back-link {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--ink-dim);
    padding: 0;
    font-family: var(--mono);
}

.back-link:hover { color: var(--accent); }

/* =====================================================================
   LEAD — the hero section
   ===================================================================== */

.lead {
    padding: 2.5rem 0 2rem;
    border-bottom: 1px solid var(--rule);
}

.lead-label {
    font-family: var(--mono);
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--ink-faint);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 0.75rem;
}

.lead-number {
    font-family: var(--serif);
    font-weight: 400;
    font-size: clamp(3.5rem, 15vw, 5.5rem);
    line-height: 0.95;
    letter-spacing: -0.04em;
    color: var(--ink);
    font-variant-numeric: tabular-nums oldstyle-nums;
    margin-bottom: 0.75rem;
    font-feature-settings: "ss01", "tnum";
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lead-sub {
    font-family: var(--sans);
    font-size: 0.9rem;
    color: var(--ink-dim);
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

.lead-dot {
    color: var(--ink-faint);
}

.delta.pos { color: var(--pos); font-weight: 500; }
.delta.neg { color: var(--neg); font-weight: 500; }
.delta.flat { color: var(--ink-faint); }

.lead-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    border-top: 1px solid var(--rule);
    padding-top: 1.25rem;
}

.lead-stat {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.125rem;
    padding-right: 1rem;
    border-right: 1px solid var(--rule);
}

.lead-stat:last-child { border-right: none; }

.stat-num {
    font-family: var(--serif);
    font-weight: 500;
    font-size: 1.75rem;
    line-height: 1;
    color: var(--ink);
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.stat-lab {
    font-family: var(--mono);
    font-size: 0.65rem;
    color: var(--ink-faint);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 500;
}

/* =====================================================================
   SECTIONS — editorial, no cards
   ===================================================================== */

.section {
    padding: 2rem 0;
    border-bottom: 1px solid var(--rule);
}

.section:last-of-type { border-bottom: none; }

.section-label {
    font-family: var(--mono);
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--ink-faint);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.section-meta {
    font-size: 0.65rem;
    color: var(--ink-faint);
    text-transform: none;
    letter-spacing: 0.02em;
}

/* =====================================================================
   PROSE (insights as a paragraph)
   ===================================================================== */

.prose {
    font-family: var(--serif);
    font-size: 1.05rem;
    line-height: 1.55;
    color: var(--ink);
    font-weight: 400;
    letter-spacing: -0.005em;
}

.prose strong {
    font-weight: 600;
    color: var(--ink);
}

.prose em {
    font-style: italic;
    color: var(--ink-dim);
}

.prose .good { color: var(--pos); font-weight: 500; font-style: normal; }
.prose .warn { color: var(--accent-ink); font-weight: 500; font-style: normal; }
.prose .bad { color: var(--neg); font-weight: 500; font-style: normal; }

/* =====================================================================
   PR LIST — leaderboard style
   ===================================================================== */

.pr-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.pr-item {
    display: grid;
    grid-template-columns: 24px 1fr auto;
    gap: 1rem;
    padding: 0.9rem 0;
    border-bottom: 1px solid var(--rule-soft);
    cursor: pointer;
    align-items: baseline;
    transition: background 0.15s;
}

.pr-item:last-child { border-bottom: none; }

.pr-item:hover {
    background: var(--bg-lift);
}

.pr-rank {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--ink-faint);
    font-weight: 500;
}

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

.pr-name {
    font-family: var(--sans);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--ink);
    letter-spacing: -0.005em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pr-detail {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--ink-faint);
    font-weight: 400;
}

.pr-right {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.15rem;
}

.pr-1rm {
    font-family: var(--serif);
    font-weight: 500;
    font-size: 1.2rem;
    color: var(--accent);
    line-height: 1;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}

.pr-gain {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--pos);
    font-weight: 500;
}

/* =====================================================================
   HEATMAP
   Cell size scales with --hm-cell (set in JS based on viewport)
   ===================================================================== */

.heatmap-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    --hm-cell-w: 18px;
    --hm-cell-h: 18px;
    --hm-gap: 4px;
    --hm-label-width: 36px;
}

.heatmap-months {
    font-family: var(--mono);
    font-size: 0.65rem;
    color: var(--ink-faint);
    padding-left: var(--hm-label-width);
    letter-spacing: 0.05em;
    height: 14px;
    position: relative;
    overflow: hidden;
}

.heatmap-grid-wrap {
    display: flex;
    gap: 0;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--rule) transparent;
}

.heatmap-grid-wrap::-webkit-scrollbar { height: 3px; }
.heatmap-grid-wrap::-webkit-scrollbar-thumb { background: var(--rule); }

.heatmap-days {
    display: grid;
    grid-template-rows: repeat(7, var(--hm-cell-h));
    gap: var(--hm-gap);
    font-family: var(--mono);
    font-size: 0.6rem;
    color: var(--ink-faint);
    padding-right: 6px;
    width: var(--hm-label-width);
    align-items: center;
    flex-shrink: 0;
    letter-spacing: 0.05em;
}

.heatmap-container {
    display: grid;
    grid-template-rows: repeat(7, var(--hm-cell-h));
    grid-auto-flow: column;
    grid-auto-columns: var(--hm-cell-w);
    gap: var(--hm-gap);
    flex-shrink: 0;
}

.heatmap-day {
    width: var(--hm-cell-w);
    height: var(--hm-cell-h);
    background: var(--rule-soft);
    border-radius: 3px;
    position: relative;
    transition: transform 0.15s ease;
}

.heatmap-day.weekend {
    background: rgba(255, 253, 245, 0.025);
}

.heatmap-day.has-session { cursor: pointer; }
.heatmap-day.has-session:hover {
    transform: scale(1.6);
    z-index: 2;
}

.heatmap-day.today {
    outline: 1px solid var(--accent);
    outline-offset: 1px;
}

.heatmap-day .tooltip {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--ink);
    color: var(--bg);
    padding: 5px 9px;
    border-radius: 4px;
    font-family: var(--mono);
    font-size: 0.65rem;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    z-index: 10;
    transition: opacity 0.2s;
    font-weight: 500;
}

.heatmap-day:hover .tooltip { opacity: 1; }

.heatmap-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.2rem;
    padding-top: 1rem;
    margin-top: 0.75rem;
    border-top: 1px solid var(--rule-soft);
    font-family: var(--mono);
    font-size: 0.65rem;
    color: var(--ink-dim);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    text-transform: lowercase;
    font-weight: 500;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
}

/* =====================================================================
   STRENGTH BY MUSCLE — sparkline rows
   ===================================================================== */

.muscle-strength {
    display: flex;
    flex-direction: column;
}

.muscle-row {
    padding: 1rem 0;
    border-bottom: 1px solid var(--rule-soft);
}

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

.muscle-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.4rem;
}

.muscle-name {
    font-family: var(--mono);
    font-size: 0.85rem;
    color: var(--ink);
    text-transform: lowercase;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.muscle-value {
    font-family: var(--serif);
    font-weight: 500;
    font-size: 1.35rem;
    color: var(--ink);
    line-height: 1;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}

.muscle-spark {
    width: 100%;
    height: 28px;
    margin-bottom: 0.4rem;
}

.muscle-spark svg {
    display: block;
    width: 100%;
    height: 100%;
}

.muscle-foot {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
}

.muscle-top {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--ink-dim);
    font-weight: 400;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.muscle-meta {
    font-family: var(--mono);
    font-size: 0.7rem;
    display: flex;
    gap: 0.75rem;
    align-items: baseline;
    font-weight: 500;
    flex-shrink: 0;
}

.muscle-delta {
    font-variant-numeric: tabular-nums;
}

.muscle-delta.pos { color: var(--pos); }
.muscle-delta.neg { color: var(--neg); }
.muscle-delta.flat { color: var(--ink-faint); }

.muscle-days {
    color: var(--ink-faint);
    font-weight: 400;
}

/* =====================================================================
   CHARTS — inline
   ===================================================================== */

.chart-inline {
    position: relative;
    width: 100%;
    height: 180px;
}

.inline-legend {
    display: flex;
    gap: 1.25rem;
    padding-top: 0.75rem;
    font-family: var(--mono);
    font-size: 0.65rem;
    color: var(--ink-dim);
    font-weight: 500;
}

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

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.dot.dashed {
    border-radius: 1px;
    width: 12px;
    height: 2px;
}

/* =====================================================================
   CATEGORY FILTER
   ===================================================================== */

.cat-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1.25rem;
}

.cat-chip {
    padding: 0.3rem 0.75rem;
    background: transparent;
    border: 1px solid var(--rule);
    border-radius: 100px;
    font-family: var(--mono);
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--ink-dim);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    text-transform: lowercase;
    letter-spacing: 0.02em;
}

.cat-chip.active {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(232, 168, 124, 0.06);
}

.cat-chip:hover:not(.active) {
    border-color: var(--ink-dim);
    color: var(--ink);
}

/* =====================================================================
   EXERCISE TABLE
   ===================================================================== */

.ex-table {
    display: flex;
    flex-direction: column;
}

.ex-cat-group {
    margin-bottom: 1.5rem;
}

.ex-cat-group:last-child { margin-bottom: 0; }

.ex-cat-title {
    font-family: var(--mono);
    font-size: 0.65rem;
    color: var(--ink-faint);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.ex-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: baseline;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--rule-soft);
    cursor: pointer;
    transition: background 0.15s;
}

.ex-row:hover {
    background: var(--bg-lift);
}

.ex-name {
    font-family: var(--sans);
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--ink);
    letter-spacing: -0.005em;
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.ex-trend {
    font-family: var(--mono);
    font-size: 0.6rem;
    font-weight: 500;
    text-transform: lowercase;
    letter-spacing: 0.05em;
    padding: 2px 0;
}

.ex-trend.pr          { color: var(--accent); }
.ex-trend.progressing { color: var(--pos); }
.ex-trend.stalled     { color: var(--accent-ink); }
.ex-trend.plateau     { color: var(--ink-faint); }
.ex-trend.regressing  { color: var(--neg); }
.ex-trend.new         { color: var(--ink-dim); }

.ex-meta {
    font-family: var(--mono);
    font-size: 0.65rem;
    color: var(--ink-faint);
    margin-top: 0.2rem;
    font-weight: 400;
}

.ex-right {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.125rem;
}

.ex-value {
    font-family: var(--serif);
    font-weight: 500;
    font-size: 1.1rem;
    color: var(--ink);
    line-height: 1;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}

.ex-value-sub {
    font-family: var(--mono);
    font-size: 0.65rem;
    color: var(--ink-faint);
    font-weight: 400;
}

/* =====================================================================
   SET LOG (deep dive)
   ===================================================================== */

.set-log {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.set-log-session {
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--rule-soft);
}

.set-log-session:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.set-log-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.75rem;
}

.set-log-date {
    font-family: var(--sans);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink);
}

.set-log-meta {
    font-family: var(--mono);
    font-size: 0.65rem;
    color: var(--ink-faint);
    font-weight: 500;
}

.set-log-table {
    display: grid;
    grid-template-columns: 20px 1fr 1fr 1fr;
    gap: 0.5rem 1rem;
    font-family: var(--mono);
}

.set-log-th {
    font-size: 0.6rem;
    color: var(--ink-faint);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--rule);
    font-weight: 500;
}

.set-log-td {
    font-size: 0.8rem;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    font-weight: 400;
}

.set-log-td.dim {
    color: var(--ink-faint);
}

/* =====================================================================
   FOOTER
   ===================================================================== */

.footer {
    padding: 2rem 0 1rem;
    font-family: var(--mono);
    font-size: 0.65rem;
    color: var(--ink-faint);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    text-transform: lowercase;
    letter-spacing: 0.02em;
}

.footer-sub {
    color: var(--ink-faint);
    opacity: 0.7;
}

/* =====================================================================
   RESPONSIVE
   ===================================================================== */

@media (min-width: 700px) {
    #exercise-view {
        padding: 0 2rem 3rem;
    }
    .lead {
        padding: 3rem 0 2.5rem;
    }
    .chart-inline {
        height: 220px;
    }
    .stat-num {
        font-size: 2rem;
    }
}

/* Handle very small screens */
@media (max-width: 360px) {
    .lead-stats {
        grid-template-columns: 1fr 1fr;
    }
    .lead-stat:nth-child(3) {
        display: none;
    }
}
