/* Global Resets and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px; /* Base font size for rem units */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center; /* Center content vertically */
    min-height: 100vh;
    background-color: #f0f2f5; /* Light grayish blue */
    color: #333;
    padding: 1rem; /* Padding for small screens */
    line-height: 1.6;
}

h1 {
    font-size: 1.8rem;
    color: #1c2938; /* Darker blue for heading */
    margin-bottom: 1rem;
    text-align: center;
}

/* Main Card Container */
#card-container {
    perspective: 1200px;
    margin-bottom: 1.5rem;
    width: 100%;
    max-width: 380px;
}

/* Task Card Styling */
#task-card {
    width: 100%;
    aspect-ratio: 3 / 4.5;
    position: relative;
    box-shadow: 0 6px 18px rgba(0,0,0,0.15);
    border-radius: 15px;
}

.card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.25, 0.8, 0.25, 1);
}

#task-card.is-flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    backface-visibility: hidden;
    border-radius: 15px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    overflow-y: auto;
}

.card-front {
    z-index: 2;
    background: linear-gradient(135deg, #4a90e2, #2c5282);
    color: white;
    font-size: 1.1rem;
}

.card-front p {
    font-size: 1.2rem;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.card-back {
    z-index: 1;
    background-color: white;
    color: #2d3748;
    transform: rotateY(180deg);
    justify-content: flex-start;
    text-align: left;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
    min-height: 400px;
}

.card-back h3 {
    font-size: 1.4rem; /* Slightly larger task title */
    color: #2c5282;
    margin-bottom: 0.75rem;
    text-align: center; /* Center title */
    width: 100%;
    font-weight: 600;
}

.card-back p {
    font-size: 0.95rem; /* Slightly larger base text */
    margin-bottom: 0.6rem; /* 10px */
    width: 100%; /* Ensure p takes full width for text-align */
    color: #4a5568;
}

.card-back p strong {
    color: #2c5282;
    font-weight: 600;
}

.card-back em {
    font-style: italic;
    color: #718096;
    font-size: 0.9rem;
    display: block; /* Make em block for better spacing */
    margin-top: 0.5rem;
}

/* YouTube Player Styling */
#youtube-player {
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
    min-height: 0;
    padding-bottom: 0;
    overflow: hidden;
    background-color: #edf2f7;
    border-radius: 8px;
    position: relative;
}

#youtube-player iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

#youtube-player p { /* Fallback message styling */
    padding: 1rem;
    text-align: center;
    font-size: 0.9rem;
    color: #4a5568;
}

/* Buttons Styling */
button, .button { /* General button class if needed */
    padding: 0.75rem 1.25rem; /* 12px 20px. More padding for easier tapping */
    font-size: 1rem;
    color: white;
    border: none;
    border-radius: 8px; /* More rounded buttons */
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    font-weight: 500;
}

button:hover, .button:hover {
    opacity: 0.9; /* Slight opacity change on hover */
    transform: translateY(-1px);
}

button:active, .button:active {
    transform: translateY(1px);
}

#draw-card-button {
    background-color: #4a90e2;
    display: block; /* Make it block to center with margin */
    margin: 0 auto 1rem auto; /* Center button */
    min-width: 200px; /* Ensure button is wide enough */
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#complete-task-button {
    background-color: #48bb78;
    margin-top: 1rem; /* More space above complete button */
    width: 100%; /* Make complete button full width of card padding */
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Timer Controls Styling */
#timer-controls {
    display: flex;
    flex-direction: column; /* Stack timer buttons vertically */
    align-items: stretch; /* Make buttons full width within controls */
    gap: 0.5rem; /* Space between timer elements */
    margin-top: 0.75rem;
    margin-bottom: 0.75rem;
    width: 100%;
}

#timer-display {
    font-size: 2.2rem; /* Larger timer display */
    font-weight: bold;
    color: #2d3748;
    padding: 0.5rem;
    background-color: #edf2f7;
    border-radius: 8px;
    text-align: center;
}

#start-timer-button, #stop-timer-button {
    font-size: 0.95rem;
    padding: 0.6rem 1rem; /* Slightly smaller padding for these */
}

#start-timer-button {
    background-color: #4299e1;
}

#stop-timer-button {
    background-color: #ed8936;
}

/* Feedback Area */
#completion-feedback {
    min-height: 40px; /* Adjust as needed */
    padding: 0.75rem;
    border-radius: 8px;
    background-color: #edf2f7;
    margin-top: 1.5rem;
    width: 100%;
    max-width: 400px; /* Match card container width */
    text-align: center;
    font-size: 0.9rem;
    color: #4a5568;
    line-height: 1.5;
}

#completion-feedback p {
    margin: 0.3rem 0;
}

/* User Info Display */
.user-info {
    position: fixed; /* Fixed position for user info */
    top: 10px;
    right: 10px; /* Position to the right */
    background-color: rgba(255, 255, 255, 0.85);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    z-index: 1000; /* Ensure it's above other elements */
}

/* Media Queries for Responsiveness */

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) {
    h1 {
        font-size: 2rem;
    }
    #card-container {
        max-width: 420px; /* Slightly wider card on larger screens */
    }
    .card-front p {
        font-size: 1.3rem;
    }
    .card-back h3 {
        font-size: 1.5rem;
    }
     .card-back p {
        font-size: 1rem;
    }
    button, .button {
        font-size: 1.05rem;
    }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) {
    h1 {
        font-size: 2.2rem;
    }
    #card-container {
        max-width: 480px; /* Even wider card */
    }
    #timer-controls {
        flex-direction: row; /* Timer buttons side-by-side */
        justify-content: space-around;
    }
    #start-timer-button, #stop-timer-button {
        width: auto; /* Auto width for side-by-side */
        flex-grow: 1; /* Allow them to grow equally */
        margin: 0 0.25rem; /* Small margin between them */
    }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
    /* Potentially increase overall font size or spacing if needed */
    /* html { font-size: 17px; } */
    #card-container {
        max-width: 520px;
    }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    /* html { font-size: 18px; } */
    #card-container {
        max-width: 550px;
    }
}

/* Accessibility: Focus Visible (for keyboard navigation) */
:focus-visible {
  outline: 2px solid #007bff; /* Highlight focus for keyboard users */
  outline-offset: 2px;
}
#task-card:focus-visible { /* Remove outline from card itself if not interactive by focus */
    outline: none;
}

/* Print styles (basic) */
@media print {
  body {
    background-color: #fff;
    color: #000;
    padding: 0;
    font-size: 12pt;
  }
  h1, #card-container, button, .user-info, #completion-feedback {
    display: none; /* Hide non-essential elements for print */
  }
  /* Could add styles to print the card content if desired */
}
