/* ==========================================================================
   1. RESET & DESIGN TOKENS (CSS VARIABLES)
   ========================================================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding:0;
}

:root {
    /* Default: Pastel Theme Palette (Soft Pink & Soft Blue) */
    --bg-main: #f7f9fc;
    --card-bg: #ffffff;
    --card-border: #e2e8f0;
    --text-primary: #2d3748;
    --text-muted: #718096;
    --accent-pink: #fbcfe8;
    --accent-pink-dark: #f472b6;
    --accent-blue: #bae6fd;
    --accent-blue-dark: #38bdf8;
    --accent-primary: #f472b6;
    --accent-glow: rgba(244, 114, 182, 0.25);
    --success: #34d399;
    --radius: 16px;
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.04), 0 8px 10px -6px rgba(0, 0, 0, 0.02);
    --transition-speed: 0.3s;
}

/* Hide pure CSS state radio/checkbox inputs completely */
.state-control {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem 1rem;
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
}

/* ==========================================================================
   2. PURE CSS THEME ENGINE (Sibling Combinators)
   ========================================================================== */
/* Dark Slate Theme */
#theme-dark:checked ~ .dashboard-container {
    --bg-main: #0f172a;
    --card-bg: #1e293b;
    --card-border: #334155;
    --text-primary: #f1f5f9;
    --text-muted: #94a3b8;
    --accent-primary: #38bdf8;
    --accent-glow: rgba(56, 189, 248, 0.2);
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
}

/* Highlight active theme picker button */
#theme-pastel:checked ~ .dashboard-container .pastel-btn,
#theme-dark:checked ~ .dashboard-container .dark-btn,
#theme-light:checked ~ .dashboard-container .light-btn {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
    transform: scale(1.15);
}

/* ==========================================================================
   3. LAYOUT & CONTAINER
   ========================================================================== */
.dashboard-container {
    width: 100%;
    max-width: 1050px;
    background-color: var(--bg-main);
    border-radius: var(--radius);
    transition: all var(--transition-speed) ease;
}

/* Header */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 0.5rem 2rem 0.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-brand h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.status-indicator {
    width: 12px;
    height: 12 px;
    background-color: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.3);
    animation: pulse-dot 2.5s infinite;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

/* Theme Picker Swatches */
.theme-picker {
    display: flex;
    gap: 0.5rem;
    background: var(--card-bg);
    padding: 0.35rem 0.6rem;
    border-radius: 30px;
    border: 1px solid var(--card-border);
}

.theme-btn {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.pastel-btn { background: linear-gradient(135deg, var(--accent-pink-dark), var(--accent-blue-dark)); }
.dark-btn { background: #1e293b; }
.light-btn { background: #e2e8f0; }

/* Action Links & Ambient Toggle */
.ambient-btn,
.settings-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.9rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--card-border);
    transition: all 0.2s ease;
}

.ambient-btn:hover,
.settings-link:hover {
    border-color: var(--accent-primary);
}

/* ==========================================================================
   4. BENTO DASHBOARD GRID
   ========================================================================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1.5rem;
}

.card {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: transform 0.2s ease, border-color var(--transition-speed) ease, background-color var(--transition-speed) ease;
}

.card:hover {
    border-color: var(--accent-primary);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.card-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.card-badge,
.card-count {
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    background-color: var(--bg-main);
    color: var(--text-muted);
    font-weight: 600;
    border: 1px solid var(--card-border);
}

/* Grid Cell Placements */
.widget-timer { grid-column: span 5; }
.widget-tasks { grid-column: span 7; }
.widget-resources { grid-column: span 7; }
.widget-momentum { grid-column: span 5; }

/* Responsive break for tablet/mobile */
@media (max-width: 860px) {
    .widget-timer,
    .widget-tasks,
    .widget-resources,
    .widget-momentum {
        grid-column: span 12;
    }
}

/* ==========================================================================
   5. WIDGET SPECIFIC STYLING
   ========================================================================== */

/* --- Widget 1: Focus Rhythm (Breathing Circle) --- */
.timer-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 0;
    gap: 1.25rem;
}

.breathing-circle-container {
    position: relative;
    width: 140px;
    height: 140px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.breathing-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent-pink) 0%, var(--accent-blue) 100%);
    opacity: 0.4;
    filter: blur(8px);
}

.breathing-core {
    position: relative;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background-color: var(--card-bg);
    border: 2px solid var(--accent-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 15px var(--accent-glow);
}

.pacer-text {
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.timer-caption {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Pure CSS Breathing Animation when Ambient Mode is checked */
#ambient-mode-toggle:checked ~ .dashboard-container .breathing-ring {
    animation: breathe-ring 8s ease-in-out infinite;
}

#ambient-mode-toggle:checked ~ .dashboard-container .breathing-core {
    animation: breathe-core 8s ease-in-out infinite;
}

#ambient-mode-toggle:checked ~ .dashboard-container .ambient-btn {
    background-color: var(--accent-primary);
    color: #ffffff;
    border-color: var(--accent-primary);
}

/* --- Widget 2: Habit / Task List (Pure CSS Checkbox Hack) --- */
.task-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.task-item input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.task-label {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    background-color: var(--bg-main);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.task-label:hover {
    border-color: var(--accent-primary);
    transform: translateX(3px);
}

.custom-checkbox {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 2px solid var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.task-text {
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

/* Checked state transitions */
.task-item input:checked + .task-label {
    opacity: 0.65;
    background: transparent;
}

.task-item input:checked + .task-label .custom-checkbox {
    background-color: var(--success);
    border-color: var(--success);
}

.task-item input:checked + .task-label .custom-checkbox::after {
    content: "✓";
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: bold;
}

.task-item input:checked + .task-label .task-text {
    text-decoration: line-through;
    color: var(--text-muted);
}

/* --- Widget 3: Collapsible Reference Drawers (<details>) --- */
.accordian-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.accordion-item {
    border: 1px solid var(--card-border);
    border-radius: 10px;
    overflow: hidden;
    background-color: var(--bg-main);
    transition: border-color 0.2s ease;
}

.accordion-item[open] {
    border-color: var(--accent-primary);
}

.accordion-header {
    padding: 0.85rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.accordion-header::-webkit-details-marker {
    display: none;
}

.chevron {
    font-size: 1.2rem;
    line-height: 1;
    transition: transform 0.25s ease;
}

.accordion-content {
    padding: 0.5rem 1rem 1rem 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* --- Widget 4: Momentum Tracker Bars --- */
.momentum-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.5rem;
    align-items: flex-end;
    height: 140px;
    padding-top: 1rem;
}

.day-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    height: 100%;
    justify-content: flex-end;
}

.bar {
    width: 100%;
    max-width: 22px;
    background: linear-gradient(180deg, var(--accent-pink-dark), var(--accent-blue-dark));
    border-radius: 6px;
    transition: height 0.3s ease;
}

.bar-40 { height: 40%; }
.bar-50 { height: 50%; }
.bar-60 { height: 60%; }
.bar-75 { height: 75%; }
.bar-80 { height: 80%; }
.bar-90 { height: 90%; }
.bar-100 { height: 100%; }

.day-slot span {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* Footer */
.dashboard-footer {
    text-align: center;
    padding: 2.5rem 0 1rem 1;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ==========================================================================
   6. PURE CSS MODAL (:target Implementation)
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
}

/* When the URL hash matches #settings-modal */
.modal-backdrop:target {
    opacity: 1;
    pointer-events: auto;
}

.modal-dialog {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    width: 90%;
    max-width: 460px;
    padding: 1.75rem;
    box-shadow: var(--shadow);
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3m 1);
}

.modal-backdrop:target .modal-dialog {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.modal-close {
    text-decoration: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    line-height: 1;
}

.modal-body {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.modal-divider {
    border: none;
    height: 1px;
    background-color: var(--card-border);
    margin: 1rem 0;
}

.modal-list {
    margin-top: 0.5rem;
    padding-left: 1.2rem;
}

.modal-list code {
    background: var(--bg-main);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--text-primary);
}

.modal-footer {
    margin-top: 1.5rem;
    display: flex;
    justify-content: flex-end;
}

.btn-primary {
    display: inline-block;
    text-decoration: none;
    background-color: var(--accent-primary);
    color: #ffffff;
    padding: 0.5rem 1.25rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* ==========================================================================
   7. KEYFRAME ANIMATIONS
   ========================================================================== */
@keyframes pulse-dot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.25); opacity: 0.7; }
}

@keyframes breathe-ring {
    0%, 100% { transform: scale(0.9); opacity: 0.3; }
    50% { transform: scale(1.35); opacity: 0.75; }
}

@keyframes breathe-core {
    0%, 100% { transform: scale(0.95); }
    50% { transform: scale(1.1); box-shadow: 0 0 25px var(--accent-glow); }
}