/* ======================== */
/* CSS Variables & Theming  */
/* ======================== */

:root {
    /* Monochrome palette */
    --color-primary: #000000;
    --color-secondary: #ffffff;
    --color-accent: #000000;
    --color-text: #000000;
    --color-text-light: #666666;
    --color-clean: #ffffff;
    --color-dirty: #000000;
    
    /* Per-task background images (override in HTML or JS) */
    --task-bg-image: none;
    --task-bg-offset: 100%;
    
    --transition-speed: 0.6s;
    --shadow-sm: 0 0 0 rgba(0,0,0,0);
    --shadow-md: 0 0 0 rgba(0,0,0,0);
}

/* ======================== */
/* Reset & Base Styles      */
/* ======================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--color-text);
    background: var(--color-secondary);
    position: relative;
}

/* ======================== */
/* Background Dirtiness     */
/* ======================== */

.background-layers { display: none; }

.bg-base {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #fef7f0 0%, #f5ede1 100%);
    transition: background var(--transition-speed) ease;
    z-index: 1;
}

/* Heavy dust layer - most visible when dirty */
.bg-dust-heavy {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity var(--transition-speed) ease;
    z-index: 2;
    background: 
        radial-gradient(circle at 15% 20%, rgba(139, 111, 71, 0.4) 0%, transparent 50%),
        radial-gradient(circle at 85% 30%, rgba(160, 130, 100, 0.35) 0%, transparent 45%),
        radial-gradient(circle at 25% 75%, rgba(139, 111, 71, 0.3) 0%, transparent 40%),
        radial-gradient(circle at 80% 85%, rgba(120, 100, 80, 0.35) 0%, transparent 45%),
        radial-gradient(circle at 50% 50%, rgba(180, 150, 120, 0.25) 0%, transparent 50%),
        repeating-linear-gradient(45deg, rgba(139, 111, 71, 0.08) 0px, rgba(139, 111, 71, 0.08) 2px, transparent 2px, transparent 4px),
        repeating-linear-gradient(-45deg, rgba(160, 130, 100, 0.06) 0px, rgba(160, 130, 100, 0.06) 3px, transparent 3px, transparent 6px);
}

/* Medium dust layer */
.bg-dust-medium {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity var(--transition-speed) ease;
    z-index: 3;
    background: 
        radial-gradient(circle at 10% 10%, rgba(200, 170, 140, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 90% 15%, rgba(180, 150, 120, 0.25) 0%, transparent 45%),
        radial-gradient(circle at 30% 90%, rgba(200, 170, 140, 0.28) 0%, transparent 40%),
        radial-gradient(circle at 75% 70%, rgba(180, 150, 120, 0.22) 0%, transparent 35%),
        repeating-linear-gradient(30deg, rgba(200, 170, 140, 0.05) 0px, rgba(200, 170, 140, 0.05) 1px, transparent 1px, transparent 3px);
}

/* Light dust layer */
.bg-dust-light {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity var(--transition-speed) ease;
    z-index: 4;
    background: 
        radial-gradient(circle at 20% 30%, rgba(220, 190, 160, 0.2) 0%, transparent 50%),
        radial-gradient(circle at 70% 60%, rgba(210, 180, 150, 0.15) 0%, transparent 45%),
        radial-gradient(circle at 45% 15%, rgba(220, 190, 160, 0.18) 0%, transparent 40%),
        repeating-linear-gradient(60deg, rgba(210, 180, 150, 0.04) 0px, rgba(210, 180, 150, 0.04) 1px, transparent 1px, transparent 3px);
}

/* Speckles - tiny dust particles */
.bg-speckles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity var(--transition-speed) ease;
    z-index: 5;
    background-image: 
        radial-gradient(1px 1px at 5% 8%, rgba(100, 80, 60, 0.6), transparent),
        radial-gradient(1px 1px at 12% 25%, rgba(120, 95, 75, 0.5), transparent),
        radial-gradient(1px 1px at 22% 35%, rgba(110, 85, 65, 0.55), transparent),
        radial-gradient(1px 1px at 35% 12%, rgba(130, 100, 80, 0.5), transparent),
        radial-gradient(1px 1px at 42% 45%, rgba(100, 80, 60, 0.6), transparent),
        radial-gradient(1px 1px at 65% 15%, rgba(120, 95, 75, 0.5), transparent),
        radial-gradient(1px 1px at 78% 38%, rgba(110, 85, 65, 0.55), transparent),
        radial-gradient(1px 1px at 88% 55%, rgba(130, 100, 80, 0.5), transparent),
        radial-gradient(1px 1px at 15% 72%, rgba(100, 80, 60, 0.6), transparent),
        radial-gradient(1px 1px at 48% 82%, rgba(120, 95, 75, 0.5), transparent),
        radial-gradient(1px 1px at 72% 68%, rgba(110, 85, 65, 0.55), transparent),
        radial-gradient(1px 1px at 92% 75%, rgba(130, 100, 80, 0.5), transparent),
        radial-gradient(1px 1px at 28% 55%, rgba(100, 80, 60, 0.6), transparent),
        radial-gradient(1px 1px at 55% 25%, rgba(120, 95, 75, 0.5), transparent),
        radial-gradient(1px 1px at 68% 90%, rgba(110, 85, 65, 0.55), transparent);
    background-size: 100% 100%;
    background-repeat: repeat;
}

/* ======================== */
/* Container & Layout       */
/* ======================== */

.container {
    position: relative;
    z-index: 5;
    max-width: 600px;
    margin: 0 auto;
    padding: 40px 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    margin-bottom: 40px;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 600;
    color: var(--color-accent);
    margin-bottom: 20px;
    letter-spacing: 1px;
}

header h1 {
    background-image: url('assets/logo_bg.png');
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
}

header h1 img {
    max-height: 140px;
    height: auto;
    display: block;
    margin: 0 auto;
}

.header-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    flex-wrap: nowrap; /* Changed from wrap to nowrap */
}

.cleanliness-indicator {
    background: transparent;
    padding: 8px 12px;
    border-radius: 9999px;
    border: 1px solid var(--color-text);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--color-text);
    min-width: 80px;
    text-align: center;
    transition: background 0.15s ease;
}

.lang-toggle {
    background: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-text);
    padding: 8px 12px;
    border-radius: 9999px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.15s ease;
    display: none;
}

.lang-toggle:hover {
    background: rgba(0,0,0,0.04);
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

/* ======================== */
/* Tasks List               */
/* ======================== */

.tasks-container {
    width: 100%;
}

.tasks-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.task-item {
    background: var(--color-secondary);
    padding: 16px;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: none;
    transition: background 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
    border: 1px dashed rgba(0,0,0,0.12);
    position: relative;
    overflow: hidden;
}

/* Background image layer (slides from right to left) */
.task-item::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    background-image: var(--task-bg-image);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.85;
    transform: translateX(var(--task-bg-offset));
    transition: transform 0.6s ease;
    z-index: 0;
    pointer-events: none;

    -webkit-mask-image: linear-gradient(
    to left,
    rgba(0,0,0,1) 60%,
    rgba(0,0,0,0) 100%
    );
    mask-image: linear-gradient(
        to left,
        rgba(0,0,0,1) 60%,
        rgba(0,0,0,0) 100%
    );
}

/* Ensure content (label, date, checkbox) stays above background */
.task-item {
    z-index: 1;
}

.task-checkbox,
.task-content,
.task-label,
.task-date {
    position: relative;
    z-index: 2;
}

.task-item:hover {
    background: var(--color-secondary);
    border-color: rgba(0,0,0,0.9);
    box-shadow: 0 1px 0 rgba(0,0,0,0.06);
}

/* keyboard focus / checkbox focus inside */
.task-item:focus-within {
    border-color: rgba(0,0,0,1);
}

.task-item.completed {
    opacity: 0.85;
}

/* Checkbox Custom Styling */
.task-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--color-primary);
    flex-shrink: 0;
    margin-left: auto;
}

.task-checkbox:checked {
    accent-color: var(--color-accent);
}

.task-content {
    
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    background-color: #fff;
    padding: 5px 10px;
    border-radius: 15px;
}

.task-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
}

.task-item.completed .task-label {
    text-decoration: line-through;
    color: var(--color-text-light);
    text-shadow: none;
}

.task-date {
    font-size: 0.85rem;
    color: var(--color-text-light);
    font-style: italic;
    margin-left: auto;
}

.task-date-empty {
    display: none;
}

/* ======================== */
/* Per-Task Background Images */
/* ======================== */

.task-item.cleanToilet::before {
    background-image: url("assets/muszla.webp");
}

.task-item.cleanSink::before {
    background-image: url("assets/zlew.webp");
}

.task-item.cleanWashbasin::before {
    background-image: url("assets/osad.webp");
}

.task-item.vacuum::before {
    background-image: url("assets/kurz.webp");
}

.task-item.deepVacuum::before {
    background-image: url("assets/kurz_dokladnie.webp");
}

.task-item.dust::before {
    background-image: url("assets/polka.webp");
    background-position: 0 55%;
}

.task-item.wipeKitchenCounter::before {
    background-image: url("assets/blat.webp");
}

footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid rgba(0,0,0,0.08);
}

.footer-text {
    font-size: 0.95rem;
    color: var(--color-text-light);
    font-style: italic;
}

/* ======================== */
/* Responsive Design        */
/* ======================== */

@media (max-width: 768px) {
    .container {
        padding: 20px 16px;
    }

    header h1 {
        font-size: 2rem;
        margin-bottom: 16px;
    }

    .task-item {
        padding: 14px;
    }

    .task-label {
        font-size: 0.95rem;
    }

    .header-controls {
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 16px 12px;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .header-controls {
        flex-direction: row; /* Ensure they stay in a row */
        gap: 10px;
    }

    .cleanliness-indicator {
        min-width: auto;
        flex-shrink: 0; /* Prevent shrinking */
    }

    .task-item {
        padding: 12px;
        gap: 10px;
    }

    .task-label {
        font-size: 0.9rem;
    }
}

/* ======================== */
/* State-based Backgrounds  */
/* ======================== */

body.dirtiness-0 .bg-dust-heavy { opacity: 0; }
body.dirtiness-0 .bg-dust-medium { opacity: 0; }
body.dirtiness-0 .bg-dust-light { opacity: 0; }
body.dirtiness-0 .bg-speckles { opacity: 0; }

body.dirtiness-1 .bg-dust-heavy { opacity: 0.1; }
body.dirtiness-1 .bg-dust-medium { opacity: 0.08; }
body.dirtiness-1 .bg-dust-light { opacity: 0.06; }
body.dirtiness-1 .bg-speckles { opacity: 0.15; }

body.dirtiness-2 .bg-dust-heavy { opacity: 0.15; }
body.dirtiness-2 .bg-dust-medium { opacity: 0.12; }
body.dirtiness-2 .bg-dust-light { opacity: 0.1; }
body.dirtiness-2 .bg-speckles { opacity: 0.25; }

body.dirtiness-3 .bg-dust-heavy { opacity: 0.2; }
body.dirtiness-3 .bg-dust-medium { opacity: 0.17; }
body.dirtiness-3 .bg-dust-light { opacity: 0.14; }
body.dirtiness-3 .bg-speckles { opacity: 0.35; }

body.dirtiness-4 .bg-dust-heavy { opacity: 0.25; }
body.dirtiness-4 .bg-dust-medium { opacity: 0.22; }
body.dirtiness-4 .bg-dust-light { opacity: 0.18; }
body.dirtiness-4 .bg-speckles { opacity: 0.45; }

body.dirtiness-5 .bg-dust-heavy { opacity: 0.3; }
body.dirtiness-5 .bg-dust-medium { opacity: 0.27; }
body.dirtiness-5 .bg-dust-light { opacity: 0.23; }
body.dirtiness-5 .bg-speckles { opacity: 0.55; }

body.dirtiness-6 .bg-dust-heavy { opacity: 0.38; }
body.dirtiness-6 .bg-dust-medium { opacity: 0.34; }
body.dirtiness-6 .bg-dust-light { opacity: 0.3; }
body.dirtiness-6 .bg-speckles { opacity: 0.65; }

body.dirtiness-7 .bg-dust-heavy { opacity: 0.45; }
body.dirtiness-7 .bg-dust-medium { opacity: 0.41; }
body.dirtiness-7 .bg-dust-light { opacity: 0.36; }
body.dirtiness-7 .bg-speckles { opacity: 0.75; }

body.dirtiness-8 .bg-dust-heavy { opacity: 0.52; }
body.dirtiness-8 .bg-dust-medium { opacity: 0.48; }
body.dirtiness-8 .bg-dust-light { opacity: 0.43; }
body.dirtiness-8 .bg-speckles { opacity: 0.85; }

body.dirtiness-9 .bg-dust-heavy { opacity: 0.6; }
body.dirtiness-9 .bg-dust-medium { opacity: 0.56; }
body.dirtiness-9 .bg-dust-light { opacity: 0.5; }
body.dirtiness-9 .bg-speckles { opacity: 0.95; }

body.dirtiness-10 .bg-dust-heavy { opacity: 0.68; }
body.dirtiness-10 .bg-dust-medium { opacity: 0.64; }
body.dirtiness-10 .bg-dust-light { opacity: 0.58; }
body.dirtiness-10 .bg-speckles { opacity: 1; }

/* ================================ */
/* Debug Mode Styles                */
/* ================================ */

#debugToggle {
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background-color: #ffffff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    display: none;
}

#debugToggle:hover {
    background-color: #f5f5f5;
    border-color: rgba(0, 0, 0, 0.2);
}

#debugToggle.active {
    background-color: #000000;
    color: #ffffff;
    border-color: #000000;
}

.debug-panel {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 380px;
    max-height: 70vh;
    background-color: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.debug-panel.hidden {
    display: none;
}

.debug-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background-color: #f9f9f9;
}

.debug-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #000000;
}

#debugClose {
    background: none;
    border: none;
    font-size: 20px;
    color: rgba(0, 0, 0, 0.5);
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

#debugClose:hover {
    color: rgba(0, 0, 0, 0.8);
}

.debug-content {
    overflow-y: auto;
    padding: 16px;
    flex: 1;
}

.debug-task-group {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.debug-task-group:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.debug-task-label {
    font-size: 12px;
    font-weight: 600;
    color: #000000;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.debug-button-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 8px;
}

.debug-button-group.full {
    grid-template-columns: 1fr;
}

.debug-btn {
    padding: 8px 12px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background-color: #ffffff;
    color: #000000;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.debug-btn:hover {
    background-color: #f0f0f0;
    border-color: rgba(0, 0, 0, 0.2);
}

.debug-btn.active {
    background-color: #000000;
    color: #ffffff;
    border-color: #000000;
}

.debug-info {
    font-size: 11px;
    color: rgba(0, 0, 0, 0.6);
    margin-top: 8px;
    font-style: italic;
}

.debug-reset-btn {
    width: 100%;
    padding: 10px;
    margin-top: 8px;
    background-color: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    color: #000000;
    transition: all 0.2s ease;
}

.debug-reset-btn:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

