/* Global box-sizing for consistency */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden; /* prevent horizontal scroll */
}

/* Background image directly on body */
body {
    min-height: 100%;
    background-image: url('../../bg.jpg');
    background-size: cover;      /* cover entire viewport */
    background-position: center; /* center image */
    background-repeat: no-repeat;

    /* iOS Safari safe area */
    height: -webkit-fill-available;
}

/* Remove full-screen blur overlay */
body::before {
    display: none;
}

/* Apply blur only to cards */
.tasks-container,
.task-container,
.task {
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

@keyframes ambient-bg {
    0% { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}

.topnav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000; /* Ensure topnav stays above other elements */
    background-color: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.topnav h2 {
    color: #ffffff;
    font-size: 20px;
    font-weight: 100;
    margin: 0;
    font-family: 'Lucida Sans', 'Verdana', sans-serif;
}

#WarningLabel {
    color: #ffffff;
    font-size: 16px;
    margin: 0;
}

.tasks-container {
    position: relative;
    margin: 20px auto;
    max-width: 90%;
    width: auto;
    display: flex;
    flex-direction: row;       /* horizontal flow */
    flex-wrap: wrap;           /* allow wrapping to next row */
    align-items: flex-start;
    justify-content: flex-start;
    gap: 16px;                 /* spacing between containers */
    overflow-x: hidden;        /* remove horizontal scroll */
    -webkit-overflow-scrolling: touch;
    padding: 0 10px;
    min-height: 0;
}

.task-container {
    flex: 0 0 250px; /* Fixed width for Trello-like columns */
    min-width: 300px; /* Explicit min-width to prevent overlap */
    background: rgba(44, 44, 44, 0.5); /* Background on task cards */
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    text-align: center;
    min-height: 0; /* Fix overflow in Safari */

    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);

}

.task-container h3 {
    color: #ffffff;
    font-size: 25px;
    font-family: 'Nunito', sans-serif;

    margin-bottom: 20px;
}

.task-list-create {
    flex: 0 0 250px; /* Fixed width for Trello-like columns */
    min-width: 300px; /* Explicit min-width to prevent overlap */
    background: rgba(44, 44, 44, 0.5); /* Background on task cards */
    border-radius: 8px;
    padding: 12px;
    margin-top: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    text-align: center;
    min-height: 0; /* Fix overflow in Safari */

    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);

    color: #ffffff;
    font-size: 25px;
    font-family: 'Nunito', sans-serif;
    border: none;
}

.task-list-create:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}


.name-tag {
    margin: 0 0 10px 0;
    font-size: 1.5rem;
    font-family: 'Courier New', Courier, monospace;
}

.task {
    background: rgba(255, 255, 255, 0.1); /* Distinct background for tasks */
    border-radius: 4px;
    padding: 6px 8px; /* Reduced padding for compactness */
    margin: 6px auto; /* Centered with auto margins */
    text-align: left;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    width: 90%; /* Slightly less than full width for better centering */
    max-width: 300px; /* Cap width to prevent stretching */

    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.task:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.task h3 {
    margin: 0;
    font-size: 0.95rem; /* Slightly smaller font for compactness */
    color: #ffffff;
    font-family: 'Nunito', sans-serif;
    font-weight: 100;
    line-height: 1.4; /* Improved readability */
}

.check-btn{
    border: none;
    padding: 4px 8px;
    font-size: 14px;
    border-radius: 5%;
    margin-top: 10px;
    cursor: pointer;
    transition: background 0.3s;
    color: white;

    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.check-btn {
    background-color: #4cad4f; /* green */
}

.check-btn:hover {
    background-color: #39853d;
}


.task-create {
    border: none;
    background: rgba(255, 255, 255, 0.1); /* Distinct background for tasks */
    border-radius: 4px;
    padding: 6px 8px; /* Reduced padding for compactness */
    margin: 6px auto; /* Centered with auto margins */
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    width: 90%; /* Slightly less than full width for better centering */
    max-width: 300px; /* Cap width to prevent stretching */

    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.task-create:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.task-create {
    margin: 0;
    font-size: 0.95rem; /* Slightly smaller font for compactness */
    color: #ffffff;
    line-height: 1.4; /* Improved readability */

    font-family: 'Nunito', sans-serif;
    font-weight: 100;
    
}

.name-tag {
    word-break: break-word;       /* Break long words to fit container */
    overflow-wrap: break-word;    /* Extra support for wrapping */
    white-space: normal;          /* Normal wrapping for single-line title */
    text-align: center;           /* Keep it centered */
}

.name-tag-edit-input {
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;        /* Preserve line breaks but wrap */
    text-align: center;           /* Keep text centered when editing */
}

.task {
    word-break: break-word;       /* Break long words to fit container */
    overflow-wrap: break-word;    /* Same, extra support */
}

.task-edit-input {
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;        /* Preserve line breaks but wrap */
}

/* iOS safe area adjustment */
@supports (padding-top: env(safe-area-inset-top)) {
    body {
        padding-top: calc(env(safe-area-inset-top) + 80px);
    }
}

/* Mobile adjustments */
@media (max-width: 600px) {
    body {
        padding-top: 60px; /* Adjusted padding for mobile */
    }

    @supports (padding-top: env(safe-area-inset-top)) {
        body {
            padding-top: calc(env(safe-area-inset-top) + 60px);
        }
    }

    .topnav {
        padding: 8px 12px;
    }

    .topnav h2 {
        font-size: 16px;
    }

    #WarningLabel {
        font-size: 14px;
    }

    .tasks-container {
        margin: 10px auto;
        flex-direction: column; /* Stack top to bottom on mobile */
        flex-wrap: wrap; /* Allow wrapping if needed */
        align-items: center;
        justify-content: center; /* Center containers on mobile */
        overflow-x: hidden; /* No horizontal scroll on mobile */
        gap: 12px;
    }

    .task-container {
        flex: 0 0 auto;
        width: 90%; /* Slightly less than full width for better aesthetics */
        max-width: 90vw; /* Fit viewport */
        min-width: 0; /* Allow shrinking if needed */
        padding: 10px; /* Slightly less padding for compactness */
        margin-bottom: 10px;
    }

    .name-tag {
        font-size: 1.2rem;
    }

    .task {
        padding: 5px 6px; /* Further reduced for mobile */
        margin: 5px auto; /* Centered with auto margins */
        width: 95%; /* Adjusted for better centering */
        max-width: 280px; /* Slightly smaller max-width for mobile */
        margin-bottom: 10px;
    }

    .task h3 {
        font-size: 0.85rem; /* Smaller font for mobile */
        line-height: 1.3; /* Tighter line height for compactness */
    }
}  

@media (max-width: 600px) {
    .tasks-container {
        min-height: 150px; /* ensure container is visible */
    }
}