/* ——— Reset & base ——— */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #141416;            /* Deep carbon black background */
    --fg: #f2efe9;            /* Raw rice paper white */
    --fg-secondary: #a6a59e;  /* Diluted silver wash */
    --fg-muted: #6b6b68;      /* Faint soot wash */
    --border: #2c2c30;        /* Deep charcoal border */
    --accent: #f2efe9;        /* Silver white accent */
    --surface: #1c1c1f;       /* Soot block layer */
    --hover-surface: #26262b; /* Wet gray wash hover */
    --serif: 'EB Garamond', Georgia, 'Times New Roman', serif;
    --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --radius: 0px;            /* Woodblock sharp square edges */
}

html, body {
    height: 100vh;
    overflow: hidden;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--sans);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--fg);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.12s ease;
}

a:visited {
    color: var(--fg);
}

a:hover {
    color: var(--fg-secondary);
}

body {
    padding: 0 1.5rem;
}

::selection {
    background: var(--fg);
    color: var(--bg);
}

/* Scrollbar styling (only used if items overflow slightly) */
::-webkit-scrollbar {
    width: 4px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

/* ——— Dashboard layout ——— */
.dashboard-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 0 1rem;
}

/* ——— Header ——— */
.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.site-header h1 {
    font-family: var(--serif);
    font-weight: 500;
    font-size: 1.8rem;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.tagline {
    font-size: 0.75rem;
    color: var(--fg-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 400;
    margin-top: 0.15rem;
}

/* ——— Day navigation ——— */
.week-nav {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
}

.day-btn {
    background: transparent;
    border: none;
    padding: 0.5rem 0.9rem;
    font-family: var(--sans);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--fg-secondary);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    position: relative;
}

.day-btn:not(:last-child) {
    border-right: 1px solid var(--border);
}

.day-btn:hover {
    background: var(--hover-surface);
}

.day-btn.active {
    background: var(--fg);
    color: var(--bg);
}

.day-btn.today::after {
    content: '';
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--fg-muted);
}

.day-btn.active.today::after {
    background: var(--bg);
}

/* ——— Main grid ——— */
.dashboard-grid {
    flex: 1;
    display: grid;
    grid-template-columns: 1.15fr 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 1rem;
    margin: 1rem 0;
    min-height: 0; /* Important for flex/grid children overflow */
    overflow: hidden;
}

.dashboard-grid.hidden, .rest-fullscreen-card.hidden {
    display: none !important;
}

/* ——— Grid cards ——— */
.grid-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.15rem;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.session-column-wrap {
    grid-column: 1;
    grid-row: span 2;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
    height: 100%;
}

.active-session-card {
    flex: 1;
    min-height: 0;
}

.card-header-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--fg-muted);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.4rem;
    margin-bottom: 0.65rem;
    flex-shrink: 0;
}

.card-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* ——— Session contents ——— */
.day-title {
    font-family: var(--serif);
    font-size: 1.4rem;
    font-weight: 500;
    margin-bottom: 0.1rem;
}

.day-subtitle {
    font-size: 0.78rem;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 1rem;
    border-bottom: 1px dashed var(--border);
    padding-bottom: 0.4rem;
}

.warmup-note {
    font-size: 0.8rem;
    color: var(--fg-secondary);
    font-style: italic;
    margin-bottom: 0.75rem;
}

/* Exercise table in session card */
.exercise-table {
    width: 100%;
    border-collapse: collapse;
}

.exercise-table th {
    text-align: left;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--fg-muted);
    padding: 0 0 0.4rem;
}

.exercise-table th:nth-child(2),
.exercise-table th:nth-child(3) {
    text-align: center;
    width: 50px;
}

.exercise-table td {
    padding: 0.45rem 0;
    border-top: 1px solid var(--border);
    font-size: 0.88rem;
    vertical-align: middle;
}

.exercise-table td:nth-child(2),
.exercise-table td:nth-child(3) {
    text-align: center;
    color: var(--fg-secondary);
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
}

.exercise-name {
    cursor: pointer;
    transition: color 0.15s;
}

.exercise-name:hover {
    color: var(--fg-secondary);
    text-decoration: underline;
}

/* Cardio lists */
.simple-list {
    list-style: none;
}

.simple-list li {
    padding: 0.5rem 0;
    border-top: 1px solid var(--border);
    font-size: 0.88rem;
}

.simple-list li:first-child {
    border-top: none;
}

.simple-list li .exercise-name {
    font-weight: 500;
}

/* ——— German table ——— */
.study-table {
    width: 100%;
    border-collapse: collapse;
}

.study-table td {
    padding: 0.42rem 0;
    border-top: 1px solid var(--border);
    font-size: 0.84rem;
    vertical-align: top;
    line-height: 1.4;
}

.study-table td:first-child {
    width: 45px;
    color: var(--fg-muted);
    font-weight: 500;
}

.study-table tr:first-child td {
    border-top: none;
}

/* ——— Jaw table ——— */
.jaw-table {
    width: 100%;
    border-collapse: collapse;
}

.jaw-table td {
    padding: 0.42rem 0;
    border-top: 1px solid var(--border);
    font-size: 0.84rem;
    vertical-align: top;
    line-height: 1.4;
}

.jaw-table td:first-child {
    width: 110px;
    font-weight: 500;
}

.jaw-table tr:first-child td {
    border-top: none;
}

/* ——— Habits & Commitments ——— */
.habits-summary {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
}

.habit-item {
    font-size: 0.84rem;
    color: var(--fg-secondary);
    border-bottom: 1px dashed var(--border);
    padding-bottom: 0.4rem;
    margin-bottom: 0.4rem;
    line-height: 1.4;
}

.habit-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

.habit-item a {
    color: var(--fg);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.fun-item {
    font-style: italic;
}

.fun-item::before {
    content: 'French rec: ';
    font-style: normal;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--fg-muted);
    display: block;
    margin-bottom: 0.15rem;
}

/* ——— Track tab switchers ——— */
.track-tabs-header {
    display: flex;
    gap: 0.8rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.4rem;
    margin-bottom: 0.65rem;
    flex-shrink: 0;
}

.track-tab-btn {
    background: transparent;
    border: none;
    font-family: var(--sans);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--fg-muted);
    cursor: pointer;
    padding-bottom: 0.2rem;
    transition: color 0.15s;
    position: relative;
}

.track-tab-btn:hover {
    color: var(--fg-secondary);
}

.track-tab-btn.active {
    color: var(--fg);
}

.track-tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -0.45rem;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--fg);
}

.track-tab-content {
    display: flex;
    flex-direction: column;
}

.progression-step {
    font-size: 0.82rem;
    color: var(--fg-secondary);
    padding: 0.42rem 0;
    border-top: 1px solid var(--border);
    line-height: 1.45;
}

.progression-step:first-child {
    border-top: none;
}

.progression-step strong {
    color: var(--fg);
    font-weight: 600;
}

/* ——— Wednesday rest fullscreen screen ——— */
.rest-fullscreen-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 1rem 0;
    padding: 2rem;
}

.rest-fullscreen-card h2 {
    font-family: var(--serif);
    font-size: 2.8rem;
    font-weight: 500;
    margin-bottom: 0.15rem;
}

.rest-fullscreen-card .subtitle {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--fg-muted);
    margin-bottom: 1.5rem;
}

.rest-fullscreen-card .message {
    font-family: var(--serif);
    font-size: 1.25rem;
    font-style: italic;
    color: var(--fg-secondary);
    max-width: 440px;
    line-height: 1.5;
}

/* ——— Footer ——— */
.site-footer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--fg-muted);
    letter-spacing: 0.04em;
    font-style: italic;
    flex-shrink: 0;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

/* ——— Exercise hover preview ——— */
.exercise-preview {
    position: fixed;
    z-index: 1000;
    width: 290px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0,0,0,0.06), 0 2px 6px rgba(0,0,0,0.03);
    pointer-events: none;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    overflow: hidden;
}

.exercise-preview.visible {
    opacity: 1;
    transform: translateY(0);
}

.preview-gif-wrap {
    width: 100%;
    height: 160px;
    background: #faf9f5;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.preview-gif-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

.preview-no-gif {
    font-family: var(--serif);
    font-size: 1.6rem;
    color: var(--fg-muted);
}

.preview-body {
    padding: 0.85rem 1rem 1rem;
}

.preview-body h4 {
    font-family: var(--serif);
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.2rem;
}

.preview-muscles {
    font-size: 0.7rem;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.5rem;
}

.preview-steps {
    padding-left: 0.95rem;
    font-size: 0.78rem;
    color: var(--fg-secondary);
    line-height: 1.45;
}

.preview-steps li {
    margin-bottom: 0.2rem;
}

.german-column-wrap {
    grid-column: 2;
    grid-row: span 2;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
    height: 100%;
}

#german-card {
    flex: 1;
    min-height: 0;
}

#career-tracks-card {
    flex-shrink: 0;
}

.career-tracks-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    overflow-y: auto;
}

.track-section {
    border-top: 1px solid var(--border);
    padding-top: 0.5rem;
}

.track-section:first-child {
    border-top: none;
    padding-top: 0;
}

.track-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--fg-muted);
    margin-bottom: 0.25rem;
}

#jaw-card {
    flex-shrink: 0;
}

.habits-column-wrap {
    grid-column: 3;
    grid-row: span 2;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
    height: 100%;
}

#rope-card {
    flex-shrink: 0;
}

#habits-card {
    flex: 1;
    min-height: 0;
}

/* ——— Responsive ——— */
@media (max-width: 1366px) and (min-width: 601px) {
    html, body {
        height: auto;
        overflow: auto;
    }

    .dashboard-container {
        height: auto;
    }

    .dashboard-grid {
        grid-template-columns: 1.15fr 1fr;
        grid-template-rows: auto;
        height: auto;
        overflow: visible;
    }
    
    .german-column-wrap {
        grid-column: 1;
        grid-row: span 2;
        height: auto;
    }
    
    .session-column-wrap {
        grid-column: 2;
        grid-row: 1;
        height: auto;
    }
    
    .habits-column-wrap {
        grid-column: 2;
        grid-row: 2;
        height: auto;
    }

    .grid-card {
        padding: 0.85rem;
        height: auto;
        overflow: visible;
        flex: none !important;
    }

    #german-card, .active-session-card, #habits-card, #career-tracks-card, #jaw-card, #rope-card {
        flex: none !important;
        height: auto !important;
    }

    #german-card .study-table td {
        padding: 0.45rem 0;
    }

    .career-tracks-list {
        gap: 0.5rem;
        overflow-y: visible;
    }

    .track-section {
        padding-top: 0.4rem;
    }

    .habit-item {
        padding: 0.45rem 0;
    }
}

@media (max-width: 600px) {
    html, body {
        height: auto;
        overflow: auto;
    }
    
    .dashboard-container {
        height: auto;
        padding: 1rem 0;
    }
    
    .site-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .week-nav {
        width: 100%;
        overflow-x: auto;
    }
    
    .day-btn {
        flex: 1;
        padding: 0.5rem 0;
        text-align: center;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        height: auto;
        overflow: visible;
        margin: 1.5rem 0;
    }

    .session-column-wrap, .german-column-wrap, .habits-column-wrap {
        display: contents;
    }

    .active-session-card, #german-card, #career-tracks-card, #rope-card, #jaw-card, .track-card, #habits-card {
        grid-column: auto;
        grid-row: auto;
    }
    
    #german-card .study-table td {
        padding: 0.42rem 0;
    }

    .grid-card {
        height: auto;
        overflow: visible;
    }
    
    .exercise-preview {
        width: calc(100vw - 2rem);
        left: 1rem !important;
        right: 1rem !important;
        bottom: 1rem !important;
        top: auto !important;
    }
}
