/* ============================================
   Stretch It — Mobile-First Styles
   ============================================ */

:root {
    --color-bg: #f5f7fa;
    --color-surface: #ffffff;
    --color-text: #1a2332;
    --color-text-secondary: #5a6b7d;
    --color-accent: #3b82f6;
    --color-accent-light: rgba(59, 130, 246, 0.12);
    --color-highlight: rgba(59, 130, 246, 0.25);
    --color-border: #e2e8f0;
    --color-zone-hover: rgba(59, 130, 246, 0.15);
    --color-zone-active: rgba(59, 130, 246, 0.35);
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1), 0 12px 32px rgba(0,0,0,0.08);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #0f1419;
        --color-surface: #1a2332;
        --color-text: #e8edf2;
        --color-text-secondary: #8899aa;
        --color-accent: #60a5fa;
        --color-accent-light: rgba(96, 165, 250, 0.15);
        --color-highlight: rgba(96, 165, 250, 0.3);
        --color-border: #2a3a4a;
        --color-zone-hover: rgba(96, 165, 250, 0.15);
        --color-zone-active: rgba(96, 165, 250, 0.35);
        --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 4px 12px rgba(0,0,0,0.2);
        --shadow-lg: 0 4px 12px rgba(0,0,0,0.3), 0 12px 32px rgba(0,0,0,0.25);
    }
}

/* ---- Reset & Base ---- */

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    overflow-x: hidden;
    min-height: 100vh;
    min-height: 100dvh;
}

/* ---- App Layout ---- */

.app {
    max-width: 430px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* ---- Header ---- */

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.01em;
}

.view-toggle {
    display: flex;
    background: var(--color-bg);
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
}

.view-toggle button {
    font-family: var(--font);
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.view-toggle button.active {
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ---- Body Map (Image + SVG Overlay) ---- */

.body-map-container {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 16px;
    overflow-y: auto;
}

.body-map-wrapper {
    position: relative;
    width: 100%;
    max-width: 350px;
}

.body-img {
    display: none;
    width: 100%;
    height: auto;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}

.body-img.active {
    display: block;
}

.body-map-wrapper svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
}

.body-map-wrapper .zone {
    cursor: pointer;
    pointer-events: all;
    -webkit-tap-highlight-color: rgba(59, 130, 246, 0.2);
}

/* highlighted fill is managed by JS pulseZones() animation */

.instruction-hint {
    text-align: center;
    padding: 8px 16px;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    transition: opacity 0.5s ease, max-height 0.5s ease, padding 0.5s ease;
    max-height: 50px;
    overflow: hidden;
}

.instruction-hint.hidden {
    opacity: 0;
    max-height: 0;
    padding: 0 16px;
}

/* ---- Bottom Sheet ---- */

.sheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sheet-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.bottom-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 85vh;
    max-height: 85dvh;
    background: var(--color-surface);
    border-radius: 16px 16px 0 0;
    box-shadow: var(--shadow-lg);
    z-index: 300;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding-bottom: var(--safe-bottom);
}

.bottom-sheet.open {
    transform: translateY(0);
}

.sheet-handle {
    display: flex;
    justify-content: center;
    padding: 10px 0 6px;
    flex-shrink: 0;
}

.sheet-handle::after {
    content: '';
    width: 36px;
    height: 4px;
    background: var(--color-border);
    border-radius: 2px;
}

.sheet-header {
    display: flex;
    align-items: center;
    padding: 0 16px 12px;
    flex-shrink: 0;
}

.sheet-back {
    font-family: var(--font);
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--color-accent);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px 4px 0;
    margin-right: 8px;
}

.sheet-back .arrow {
    font-size: 1.1rem;
    line-height: 1;
}

.sheet-back.hidden {
    display: none;
}

.sheet-title {
    font-size: 1.125rem;
    font-weight: 700;
    flex: 1;
}

.sheet-close {
    font-family: var(--font);
    background: var(--color-bg);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    color: var(--color-text-secondary);
    cursor: pointer;
    flex-shrink: 0;
}

.sheet-content {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 16px 16px;
    flex: 1;
}

/* ---- Muscle List ---- */

.muscle-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.muscle-card {
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    padding: 14px;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

.muscle-card:active {
    background: var(--color-accent-light);
    border-color: var(--color-accent);
}

.muscle-card-name {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 2px;
}

.muscle-card-group {
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    margin-bottom: 6px;
}

.muscle-card-desc {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    line-height: 1.45;
}

.muscle-card-arrow {
    float: right;
    color: var(--color-text-secondary);
    font-size: 1.25rem;
    margin-top: -2px;
}

/* ---- Stretch List ---- */

.muscle-detail-header {
    margin-bottom: 16px;
}

.muscle-detail-name {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.muscle-detail-group {
    font-size: 0.875rem;
    color: var(--color-accent);
    font-weight: 600;
    margin-bottom: 8px;
}

.muscle-detail-desc {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    line-height: 1.5;
    margin-bottom: 8px;
}

.muscle-detail-link {
    font-size: 0.8125rem;
    color: var(--color-accent);
    text-decoration: none;
}

.stretches-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-secondary);
    margin-bottom: 10px;
}

.stretch-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.stretch-card {
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    padding: 14px;
    border: 1px solid var(--color-border);
}

.stretch-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
}

.stretch-card-name {
    font-weight: 600;
    font-size: 0.9375rem;
}

.stretch-card-difficulty {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 8px;
    border-radius: 4px;
    flex-shrink: 0;
    margin-left: 8px;
}

.stretch-card-difficulty.beginner {
    background: #dcfce7;
    color: #166534;
}

.stretch-card-difficulty.intermediate {
    background: #fef3c7;
    color: #92400e;
}

.stretch-card-difficulty.advanced {
    background: #fee2e2;
    color: #991b1b;
}

@media (prefers-color-scheme: dark) {
    .stretch-card-difficulty.beginner {
        background: rgba(34, 197, 94, 0.15);
        color: #4ade80;
    }
    .stretch-card-difficulty.intermediate {
        background: rgba(245, 158, 11, 0.15);
        color: #fbbf24;
    }
    .stretch-card-difficulty.advanced {
        background: rgba(239, 68, 68, 0.15);
        color: #f87171;
    }
}

.stretch-card-meta {
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
}

.stretch-card-instructions {
    font-size: 0.875rem;
    line-height: 1.5;
    margin-bottom: 10px;
}

.stretch-card-source {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8125rem;
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 500;
}

.stretch-card-source:hover {
    text-decoration: underline;
}

/* ---- Side Indicator ---- */

.side-indicator {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--color-accent-light);
    color: var(--color-accent);
    margin-left: 8px;
}

/* ---- Loading State ---- */

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
}

.loading::before {
    content: '';
    width: 18px;
    height: 18px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 10px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---- Empty State ---- */

.empty-state {
    text-align: center;
    padding: 32px 16px;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
}

/* ---- Bottom Sheet Swipe ---- */

.bottom-sheet.dragging {
    transition: none;
}

