:root {
    --bg-pomodoro-1: #A7BFE8; /* Soft Blue */
    --bg-pomodoro-2: #619AD6; /* Slightly Deeper Blue */

    --bg-break-1: #C9F0D2; /* Soft Mint Green */
    --bg-break-2: #84D9A0; /* Slightly Deeper Green */

    /* Light Theme Variables */
    --primary-text-color-light: #333333;
    --secondary-text-color-light: #666666;
    --card-bg-light: rgba(255, 255, 255, 0.7);
    --card-border-light: rgba(200, 200, 200, 0.5);
    --button-bg-light: rgba(0, 0, 0, 0.1);
    --button-active-bg-light: rgba(0, 0, 0, 0.25);

    /* Dark Theme Variables */
    --primary-text-color-dark: #E0E0E0;
    --secondary-text-color-dark: #A0A0A0;
    --card-bg-dark: rgba(0, 0, 0, 0.5);
    --card-border-dark: rgba(70, 70, 70, 0.5);
    --button-bg-dark: rgba(255, 255, 255, 0.1);
    --button-active-bg-dark: rgba(255, 255, 255, 0.25);

    /* General Variables mapped to current theme */
    --text-color: var(--primary-text-color-light);
    --glass-bg: var(--card-bg-light);
    --glass-border: var(--card-border-light);
    --button-active-bg: var(--button-active-bg-light);

    --font-family: 'Pretendard', sans-serif;
    --digit-height: clamp(4rem, 20vw, 6rem);
}

html[data-theme="light"] {
    --text-color: var(--primary-text-color-light);
    --glass-bg: var(--card-bg-light);
    --glass-border: var(--card-border-light);
    --button-active-bg: var(--button-active-bg-light);
}

html[data-theme="dark"] {
    --text-color: var(--primary-text-color-dark);
    --glass-bg: var(--card-bg-dark);
    --glass-border: var(--card-border-dark);
    --button-active-bg: var(--button-active-bg-dark);
}

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

body {
    font-family: var(--font-family);
    color: var(--text-color);
    display: flex;
    flex-direction: column; /* Changed to column to allow content flow */
    justify-content: flex-start; /* Changed to flex-start for normal content flow */
    align-items: center;
    min-height: 100vh;
    background: #1a1a1a; /* Darker fallback */
    transition: color 0.3s ease, background-color 0.3s ease; /* Smooth transition for text color and background */
    padding-bottom: 8rem; /* Added padding to prevent content from being hidden by fixed footer */
    padding-top: 5rem; /* Added padding to push content down from the top */
}

/* Base style for both background layers */
.background {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    z-index: -1;
    background-size: 400% 400%;
    animation: gradient-flow 45s ease infinite; /* Slower animation for a calmer feel */
    transition: opacity 1s ease-in-out; /* Smooth transition for opacity */
    opacity: 0; /* Hidden by default */
}

.background.active {
    opacity: 1; /* Visible when active */
}

/* Specific gradients for each mode */
.background-pomodoro {
    background: linear-gradient(45deg, var(--bg-pomodoro-1), var(--bg-pomodoro-2), var(--bg-pomodoro-1), var(--bg-pomodoro-2));
}

.background-short-break {
    background: linear-gradient(45deg, var(--bg-break-1), var(--bg-break-2), var(--bg-break-1), var(--bg-break-2));
}


@keyframes gradient-flow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.app-container {
    position: relative;
    width: 100%;
    /* height: 100%; Removed to allow content to dictate height */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1; /* Bring app-container above background elements */
}

.timer-card {
    background: var(--glass-bg);
    backdrop-filter: blur(30px); /* Increased blur */
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid var(--glass-border);
    border-radius: 28px; /* Slightly more rounded */
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.15), inset 0 1px 1px rgba(255,255,255,0.1); /* Deeper shadow + inner highlight */
    width: clamp(320px, 90vw, 420px);
    transition: background 0.3s ease, border-color 0.3s ease; /* Smooth transition */
}

.timer-display {
    display: flex;
    align-items: center;
    font-size: var(--digit-height);
    font-weight: 700;
    letter-spacing: -2px;
    margin: 1rem 0 2rem;
    height: var(--digit-height);
    overflow: hidden;
}

.digit-container {
    height: 100%;
}

.digit-reel {
    transition: transform 0.8s cubic-bezier(0.65, 0, 0.35, 1);
}

.digit-reel span {
    display: block;
    height: var(--digit-height);
    line-height: var(--digit-height);
}

.divider {
    margin: 0 0.5rem;
    animation: blink 1.5s infinite ease-in-out;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.timer-modes {
    display: flex;
    background-color: var(--button-bg); /* Use theme variable */
    border-radius: 20px;
    padding: 0.4rem;
    margin-bottom: 2.5rem;
    transition: background-color 0.3s ease; /* Smooth transition */
}

.mode-btn {
    background: transparent;
    border: none;
    color: var(--text-color);
    font-family: var(--font-family);
    font-size: 0.9rem;
    padding: 0.6rem 1.2rem;
    border-radius: 16px;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease; /* Smooth transition */
    font-weight: 700;
}

.mode-btn.active {
    background-color: var(--button-active-bg);
}

.timer-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem; /* Use gap for consistent spacing */
}

.control-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    width: 70px;
    height: 70px;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.3s ease, border-color 0.3s ease; /* Smooth transition */
    
    /* Flex properties for centering content */
    display: flex;
    justify-content: center;
    align-items: center;
}

.control-btn:hover {
    background-color: var(--glass-border);
    transform: scale(1.05);
}

.control-btn:active {
    transform: scale(0.95);
}

/* Primary Play/Pause Button */
.play-btn::before {
    content: '';
    display: block;
    width: 0;
    height: 0;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-left: 18px solid var(--text-color); /* Use theme variable */
    margin-left: 5px; /* Nudge for optical centering of triangle */
    transition: all 0.2s ease;
}

.play-btn.paused::before {
    border: none;
    width: 16px;
    height: 18px;
    border-left: 6px solid var(--text-color); /* Use theme variable */
    border-right: 6px solid var(--text-color); /* Use theme variable */
    margin-left: 0; /* Reset nudge for pause icon */
}

/* Secondary Reset Button - Consistent size, different style */
.reset-btn {
    background: transparent; /* Less prominent */
}

.reset-btn::before {
    content: '';
    display: block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--text-color); /* Use theme variable */
    border-radius: 50%;
    border-right-color: transparent;
    transition: transform 0.4s ease;
}

.reset-btn:hover::before {
    transform: rotate(-180deg);
}

.total-focus-time {
    margin-top: 2rem; /* Added margin to separate from timer card */
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 0.6rem 1rem;
    border-radius: 12px;
    font-size: 0.8rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border: 1px solid var(--glass-border);
    color: var(--text-color); /* Use theme variable */
    transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease; /* Smooth transition */
}

.theme-toggle-btn {
    position: relative; /* Change to relative within flex container */
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    padding: 0.5rem 1rem;
    border-radius: 15px;
    cursor: pointer;
    font-family: var(--font-family);
    font-size: 0.9rem;
    z-index: 1000;
    transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.theme-toggle-btn:hover {
    background-color: var(--button-active-bg);
}

.header-controls {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px; /* Space between buttons */
    z-index: 1000;
}

.about-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    padding: 0.5rem 1rem;
    border-radius: 15px;
    cursor: pointer;
    font-family: var(--font-family);
    font-size: 0.9rem;
    transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.about-link:hover {
    background-color: var(--button-active-bg);
}

/* About Section Styling */
.about-section {
    width: 90%;
    max-width: 600px;
    margin: 3rem auto 2rem auto; /* Top margin for spacing, auto for horizontal centering */
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    padding: 2rem;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    color: var(--text-color);
    transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.about-section h2,
.about-section h3 {
    color: var(--text-color);
    margin-bottom: 1rem;
    font-weight: 700;
}

.about-section h2 {
    font-size: 1.8rem;
    text-align: center;
}

.about-section h3 {
    font-size: 1.3rem;
    margin-top: 1.5rem;
}

.about-section p {
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.about-section ul {
    list-style: inside;
    margin-bottom: 1rem;
    padding-left: 1.2rem;
}

.about-section ul li {
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.about-section ul li strong {
    color: var(--text-color); /* Ensure strong tags inherit text color */
}

/* Footer Styling */
footer {
    position: fixed; /* Changed to fixed */
    bottom: 0; /* Pin to bottom */
    left: 0;
    right: 0;
    width: 100%;
    padding: 2rem 1rem;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--glass-border);
    color: var(--text-color);
    text-align: center;
    font-size: 0.85rem;
    z-index: 1000; /* Ensure it stays on top */
    transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.footer-nav {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.footer-nav a {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-nav a:hover {
    color: #A7BFE8; /* A subtle highlight color */
}

