/**
 * Meditation Counter — Landing Page Styles
 * 
 * Supplements the counter-landing layout with meditation-specific
 * components: breathing ring, pattern bar, controls, stats, settings panel.
 * Inherits --counter-color from the counter-landing wrapper.
 */

/* ============================================
   Custom Properties
   ============================================ */

.meditation-card {
    --ring-color: var(--counter-color, #7c3aed);
}

/* Disable counter-card hover lift on landing page */
.meditation-hero-wrapper .meditation-card {
    cursor: default;
}
.meditation-hero-wrapper .meditation-card:hover {
    transform: none;
    box-shadow: initial;
}

/* Override counter-card ::before accent bar with ring color */
.meditation-card::before {
    background: var(--ring-color) !important;
}

/* Center content inside counter-main */
.meditation-card .counter-main {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem 0;
}

/* Footer stats spacing */
.meditation-footer {
    padding-top: 0.5rem;
}

/* ============================================
   Hero Wrapper — wider than standard counter card
   ============================================ */

.meditation-hero-wrapper {
    max-width: 420px;
}

/* ============================================
   Ring Area — centered square container
   ============================================ */

.meditation-ring-area {
    position: relative;
    width: 280px;
    height: 280px;
    margin: 0 auto 0.75rem;
}

.breathing-ring-container {
    width: 100%;
    height: 100%;
}

.breathing-ring-svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Overlay: phase + count centered on ring */
.meditation-ring-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 2;
}

/* ============================================
   Phase Label - positioned below ring
   ============================================ */

.breathing-phase {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1rem;
    padding: 0.75rem 1.5rem;
    background: var(--bg-tertiary, rgba(255,255,255,0.06));
    border-radius: 2rem;
    min-width: 200px;
}

.phase-text {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary, #fff);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    transition: all 0.3s ease;
}

.phase-text i {
    font-size: 1rem;
}

.phase-timer {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--ring-color);
    min-width: 2ch;
    text-align: center;
    line-height: 1;
}

/* Phase-specific styling - bright colors for visibility */
.meditation-card[data-phase="inhale"] .phase-text { 
    color: #34d399; /* Bright green for inhale */
}
.meditation-card[data-phase="inhale"] .phase-text i { 
    animation: inhaleArrow 4s ease-in-out infinite;
}
@keyframes inhaleArrow {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

.meditation-card[data-phase="holdIn"] .phase-text,
.meditation-card[data-phase="holdOut"] .phase-text { 
    color: #fbbf24; /* Amber for hold - visible on dark */
}
.meditation-card[data-phase="holdIn"] .phase-text i,
.meditation-card[data-phase="holdOut"] .phase-text i { 
    animation: holdPulse 1s ease-in-out infinite;
}
@keyframes holdPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.meditation-card[data-phase="exhale"] .phase-text { 
    color: #93c5fd; /* Light blue for exhale */
}
.meditation-card[data-phase="exhale"] .phase-text i { 
    animation: exhaleArrow 6s ease-in-out infinite;
}
@keyframes exhaleArrow {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(4px); }
}

/* ============================================
   Counter Value (centered on ring)
   ============================================ */

#meditation-count {
    text-align: center;
}

.count-value {
    display: block;
    font-size: 3.5rem;
    font-weight: 800;
    color: #ffffff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    line-height: 1;
    transition: transform 0.3s ease;
}

.count-label {
    display: block;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-top: 4px;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* Bump animation on increment */
.count-bump {
    animation: countBump 0.4s ease;
}

@keyframes countBump {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* ============================================
   Pattern Selector Bar
   ============================================ */

.meditation-pattern-bar {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.pattern-chip {
    padding: 0.35rem 0.75rem;
    background: var(--bg-tertiary, rgba(255,255,255,0.06));
    border: 2px solid transparent;
    border-radius: 2rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pattern-chip:hover {
    background: var(--bg-secondary, rgba(255,255,255,0.1));
    color: var(--text-primary);
}

.pattern-chip.active {
    border-color: var(--ring-color);
    color: var(--text-primary);
    background: rgba(124, 58, 237, 0.12);
}

/* ============================================
   Controls — override counter-card defaults
   ============================================ */

.meditation-controls {
    gap: 1rem;
    margin-top: 0.25rem;
}

/* Primary start/pause button: wider, ring-colored */
.meditation-controls .increment-btn {
    padding: 0.75rem 2rem;
    border-radius: 2rem;
    background: var(--ring-color);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    gap: 0.5rem;
    min-width: 140px;
}

.meditation-controls .increment-btn:hover {
    filter: brightness(1.15);
    transform: scale(1.03);
}

/* Reset & tap buttons — compact circular */
.meditation-controls .decrement-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    padding: 0;
}

/* ============================================
   Session Stats
   ============================================ */

.session-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
}

.stat {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    display: block;
    font-size: 0.6rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* ============================================
   Settings Panel (Slide-up)
   ============================================ */

.meditation-settings {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none; /* Hidden by default */
    align-items: flex-end;
    justify-content: center;
}

/* Show when not hidden */
.meditation-settings:not([hidden]) {
    display: flex;
}

.settings-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
    cursor: pointer;
}

.meditation-settings.is-open .settings-backdrop {
    opacity: 1;
}

.settings-panel {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 480px;
    max-height: 75vh;
    background: var(--bg-primary, #14141e);
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 1.25rem 1.25rem 0 0;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.meditation-settings.is-open .settings-panel {
    transform: translateY(0);
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.06));
}

.settings-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.settings-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: var(--bg-tertiary, rgba(255,255,255,0.06));
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.settings-close-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.settings-body {
    padding: 1rem 1.25rem 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Setting group */
.setting-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.setting-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Pattern preset buttons (settings) */
.pattern-presets {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.preset-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.6rem 0.25rem;
    background: var(--bg-tertiary, rgba(255,255,255,0.06));
    border: 2px solid transparent;
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.preset-btn:hover {
    background: var(--bg-secondary, rgba(255,255,255,0.1));
}

.preset-btn.active {
    border-color: var(--ring-color);
    color: var(--text-primary);
    background: rgba(124, 58, 237, 0.1);
}

.preset-name {
    font-size: 0.85rem;
    font-weight: 700;
}

.preset-desc {
    font-size: 0.6rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Custom duration grid */
.duration-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.duration-field {
    text-align: center;
}

.duration-field label {
    display: block;
    font-size: 0.6rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.duration-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary, rgba(255,255,255,0.06));
    border-radius: 8px;
    overflow: hidden;
}

.duration-stepper button {
    width: 28px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

.duration-stepper button:hover {
    background: var(--bg-secondary, rgba(255,255,255,0.1));
}

.duration-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 20px;
}

/* Mode toggle */
.mode-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 0.65rem;
    background: var(--bg-tertiary, rgba(255,255,255,0.06));
    border: 2px solid transparent;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-btn:hover {
    background: var(--bg-secondary, rgba(255,255,255,0.1));
}

.mode-btn.active {
    border-color: var(--ring-color);
    color: var(--text-primary);
    background: rgba(124, 58, 237, 0.1);
}

.mode-hint {
    font-size: 0.6rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Target buttons */
.target-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.target-btn {
    padding: 0.4rem 0.8rem;
    background: var(--bg-tertiary, rgba(255,255,255,0.06));
    border: 2px solid transparent;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.target-btn:hover {
    background: var(--bg-secondary, rgba(255,255,255,0.1));
}

.target-btn.active {
    border-color: var(--ring-color);
    color: var(--text-primary);
}

/* Color swatches */
.color-options {
    display: flex;
    gap: 0.5rem;
}

.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid transparent;
    background: var(--swatch);
    cursor: pointer;
    transition: all 0.2s ease;
}

.color-swatch:hover {
    transform: scale(1.15);
}

.color-swatch.active {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 2px var(--swatch);
}

/* Toggle switches */
.toggle-row {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.toggle-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.toggle-switch {
    position: relative;
    width: 40px;
    height: 22px;
    display: inline-block;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 11px;
    cursor: pointer;
    transition: background 0.2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    left: 3px;
    top: 3px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--ring-color);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(18px);
}

/* ============================================
   Target Reached Celebration
   ============================================ */

.meditation-card.target-reached .count-value {
    animation: targetCelebrate 0.6s ease;
    color: var(--ring-color);
}

.meditation-card.target-reached::after {
    content: 'Target Reached';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--ring-color);
    background: rgba(124, 58, 237, 0.15);
    padding: 0.5rem 1.5rem;
    border-radius: 12px;
    z-index: 50;
    animation: targetFade 3s ease forwards;
    pointer-events: none;
}

@keyframes targetCelebrate {
    0%   { transform: scale(1); }
    30%  { transform: scale(1.3); }
    60%  { transform: scale(0.95); }
    100% { transform: scale(1); }
}

@keyframes targetFade {
    0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    15%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    75%  { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -60%) scale(1); }
}

/* ============================================
   D3 Ring Specifics
   ============================================ */

.breathing-ring-fg {
    transition: none; /* D3 handles animation via rAF */
}

.breathing-pulse {
    transition: r 0.1s ease;
}

.breathing-glow {
    transition: r 0.1s ease;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 480px) {
    .meditation-ring-area {
        width: 240px;
        height: 240px;
    }

    .count-value {
        font-size: 2.25rem;
    }

    .meditation-pattern-bar {
        gap: 0.3rem;
    }

    .pattern-chip {
        padding: 0.3rem 0.6rem;
        font-size: 0.7rem;
    }

    .pattern-presets {
        grid-template-columns: repeat(2, 1fr);
    }

    .duration-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 768px) {
    .meditation-ring-area {
        width: 320px;
        height: 320px;
    }
}
