/* LifeOS — Early Apple dark aesthetic */

:root {
    --bg: #000000;
    --card: #1c1c1e;
    --card-hover: #2c2c2e;
    --text: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-tertiary: #636366;
    --accent: #007AFF;
    --accent-dim: #0055cc;
    --border: rgba(255, 255, 255, 0.08);
    --input-bg: #1c1c1e;
    --green: #30d158;
    --orange: #FF9500;
    --separator: rgba(255, 255, 255, 0.05);
}

/* === Reset === */

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
        "Helvetica Neue", Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    overflow-x: hidden;
    overscroll-behavior-y: contain;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    letter-spacing: -0.01em;
}

/* === App Shell === */

#app {
    max-width: 500px;
    margin: 0 auto;
    padding: 0 20px;
}

main { padding-bottom: 80px; }

/* === Header === */

#header {
    text-align: center;
    padding: 36px 0 24px;
}

#header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text);
}

#header p {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-top: 6px;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

#loading {
    color: var(--text-tertiary);
    font-size: 0.875rem;
    padding: 80px 0;
}

/* === Sections === */

.section {
    background: var(--card);
    border-radius: 14px;
    margin-bottom: 16px;
    overflow: hidden;
    transition: opacity 0.35s ease;
}

.section.section-all-done {
    display: none;
}

.section h2 {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 16px 20px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.section-body {
    padding: 0 20px 16px;
}

.section.collapsed .section-body { display: none; }

/* === Checklist Items === */

.item {
    position: relative;
    border-bottom: 1px solid var(--separator);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    min-height: 48px;
    transition: opacity 0.35s ease, max-height 0.4s ease,
                margin 0.4s ease, border-color 0.4s ease;
    max-height: 120px;
    overflow: hidden;
}

.item:last-child { border-bottom: none; }

/* Inner content wrapper — slides for swipe-to-skip */
.item-content {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 0;
    background: var(--card);
    position: relative;
    z-index: 1;
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Skip action revealed behind content on swipe left */
.skip-action {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 80px;
    background: var(--orange);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
    letter-spacing: 0.02em;
    z-index: 0;
    cursor: pointer;
}

/* Hide skip action on revealed completed items */
.item.revealed .skip-action { visibility: hidden; }

/* Completed: animate out */
.item.hiding {
    opacity: 0;
    max-height: 0;
    min-height: 0;
    margin: 0;
    border-color: transparent;
}

.item.completed.revealed {
    opacity: 0.35;
    max-height: 120px;
}

.item.completed.revealed .main-text {
    text-decoration: line-through;
    text-decoration-color: var(--text-tertiary);
}

/* Skipped revealed items — orange strikethrough */
.item.skipped.revealed .main-text {
    text-decoration: line-through;
    text-decoration-color: var(--orange);
}

/* Dragging source (hidden while clone visible) */
.item.dragging-source {
    opacity: 0;
    max-height: 0;
    min-height: 0;
    overflow: hidden;
    margin: 0;
    border-color: transparent;
}

/* === Checkbox === */

.check {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid var(--text-tertiary);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 6px;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.check.done {
    background: var(--accent);
    border-color: var(--accent);
    transform: scale(1.15);
}

.check.pop {
    transform: scale(1.35);
}

.check.done::after {
    content: '';
    width: 7px;
    height: 12px;
    border: solid white;
    border-width: 0 2.5px 2.5px 0;
    transform: rotate(45deg) translateY(-1px);
}

/* Skipped checkbox — orange dash */
.check.skipped {
    background: var(--orange);
    border-color: var(--orange);
    transform: scale(1.15);
}

.check.skipped::after {
    content: '';
    width: 12px;
    height: 0;
    border: solid white;
    border-width: 0 0 2.5px 0;
}

/* === Item text === */

.item-text {
    flex: 1;
    min-width: 0;
}

.main-text {
    display: block;
    font-size: 0.9375rem;
    line-height: 1.45;
    font-weight: 400;
}

.sub-text {
    display: block;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 3px;
    line-height: 1.3;
}


/* Floating clone for item drag */
.item-drag-clone {
    position: fixed;
    z-index: 999;
    pointer-events: none;
    background: var(--card);
    border-radius: 14px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    transform: scale(1.03);
    opacity: 0.92;
    overflow: hidden;
}

/* Drop placeholder for item drag */
.item-drag-placeholder {
    height: 3px;
    background: var(--accent);
    border-radius: 2px;
    margin: -1px 0;
    pointer-events: none;
}

/* === Workout block (nested accent bar) === */

.workout-block {
    border-left: 2.5px solid var(--accent);
    margin: 10px 0;
    padding-left: 14px;
    transition: margin 0.4s ease, padding 0.4s ease, border-color 0.4s ease;
}

/* Collapsed block when all items hidden */
.workout-block.all-hidden {
    margin: 0;
    padding: 0;
    border-color: transparent;
    overflow: hidden;
}

/* Subheader hidden when its items are all done */
.subheader.all-hidden {
    overflow: hidden;
    max-height: 0;
    padding: 0;
    transition: max-height 0.4s ease, padding 0.4s ease;
}

/* === Subheaders === */

.subheader {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    padding: 14px 0 6px;
    max-height: 50px;
    overflow: hidden;
    transition: max-height 0.4s ease, padding 0.4s ease;
}

/* === Global show completed toggle === */

.global-show-completed-btn {
    display: block;
    width: 100%;
    background: none;
    border: none;
    color: var(--accent);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 16px 0;
    cursor: pointer;
    text-align: center;
    letter-spacing: 0.01em;
}

.global-show-completed-btn:active { opacity: 0.6; }

/* === Empty state === */

.empty-note {
    color: var(--text-tertiary);
    font-size: 0.875rem;
    padding: 8px 0;
}

/* === Tomorrow Tasks Form === */

.tomorrow-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.task-row {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    transition: opacity 0.2s ease;
}

.task-row.dragging-source {
    opacity: 0;
    height: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
}


.task-input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    font-size: 1rem;
    color: var(--text);
    outline: none;
    flex: 1;
    min-width: 0;
    min-height: 48px;
    transition: border-color 0.2s ease;
    letter-spacing: -0.01em;
}

.task-input::placeholder { color: var(--text-tertiary); }
.task-input:focus { border-color: var(--accent); }

.task-delete {
    flex-shrink: 0;
    width: 28px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 1.125rem;
    cursor: pointer;
    padding: 0;
    transition: color 0.15s ease;
}

.task-delete:active { color: #ff453a; }

/* Desktop-only reorder arrows */
.task-move {
    display: none;
}

@media (hover: hover) {
    .task-move {
        flex-shrink: 0;
        display: flex;
        flex-direction: column;
        gap: 0;
        opacity: 0;
        transition: opacity 0.15s ease;
    }
    .task-row:hover .task-move { opacity: 1; }

    .task-move-up,
    .task-move-down {
        background: none;
        border: none;
        color: var(--text-tertiary);
        font-size: 0.6875rem;
        cursor: pointer;
        padding: 2px 4px;
        line-height: 1;
    }
    .task-move-up:active,
    .task-move-down:active { color: var(--accent); }
}

/* Drag clone (floating card) */
.dragging-clone {
    position: fixed;
    z-index: 999;
    pointer-events: none;
    background: var(--card);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    transform: scale(1.03);
    opacity: 0.92;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 8px;
}

/* Drop placeholder bar */
.task-row-placeholder {
    height: 3px;
    background: var(--accent);
    border-radius: 2px;
    margin: -2px 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.submit-btn {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 16px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    min-height: 50px;
    transition: all 0.15s ease;
    letter-spacing: -0.01em;
}

.submit-btn:active {
    background: var(--accent-dim);
    transform: scale(0.98);
}

.confirm-msg {
    color: var(--green);
    font-size: 0.875rem;
    text-align: center;
    padding: 10px 0;
    font-weight: 500;
}

/* === Recharge Overlay === */

.recharge-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.recharge-overlay.visible { opacity: 1; }

.recharge-battery {
    position: relative;
    width: 80px;
    height: 140px;
    border: 3px solid var(--text-tertiary);
    border-radius: 12px;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.recharge-battery.visible { opacity: 1; }

/* Battery terminal tab */
.recharge-battery::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 10px;
    background: var(--text-tertiary);
    border-radius: 4px 4px 0 0;
}

.recharge-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 0%;
    background: linear-gradient(to top, var(--accent), var(--green));
    animation: chargeFill 3s ease-out forwards;
    animation-play-state: paused;
}

.recharge-fill.charging {
    animation-play-state: running;
}

@keyframes chargeFill {
    0%   { height: 0%; }
    100% { height: 100%; }
}

/* Glow on battery when full */
.recharge-battery.charged {
    border-color: var(--green);
    animation: glowPulse 2s ease-in-out infinite;
}

@keyframes glowPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(48, 209, 88, 0.3); }
    50%      { box-shadow: 0 0 40px rgba(48, 209, 88, 0.6); }
}

/* Lightning bolt inside battery */
.recharge-bolt {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 28px;
    height: 40px;
    opacity: 0;
    z-index: 1;
    transition: opacity 0.4s ease;
}

.recharge-bolt.visible { opacity: 1; }

.recharge-bolt svg {
    width: 100%;
    height: 100%;
    fill: white;
    filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.5));
}

/* "Time to Recharge" text */
.recharge-text {
    margin-top: 40px;
    font-size: 1.375rem;
    font-weight: 300;
    letter-spacing: 0.02em;
    color: var(--text);
    opacity: 0;
}

.recharge-text.visible {
    animation: fadeInUp 0.8s ease forwards;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* "Back to checklist" link */
.recharge-back {
    position: absolute;
    bottom: 48px;
    color: var(--text-tertiary);
    font-size: 0.8125rem;
    font-weight: 400;
    text-decoration: none;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.4s ease, color 0.2s ease;
}

.recharge-back.visible { opacity: 1; }
.recharge-back:active { color: var(--text-secondary); }

/* Fade out main content for recharge */
#app.fading-out {
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

/* === Day Navigation (fixed bottom) === */

.day-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    background: rgba(28, 28, 30, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--separator);
    z-index: 100;
}

.day-nav-btn {
    color: var(--accent);
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
    padding: 10px 0;
    cursor: pointer;
}

.day-nav-btn:active { opacity: 0.6; }

.day-nav-today {
    color: var(--accent);
    font-size: 0.8125rem;
    font-weight: 600;
    text-decoration: none;
    padding: 10px 16px;
    cursor: pointer;
}

.day-nav-today.current {
    color: var(--text-tertiary);
    cursor: default;
}

.day-nav-today:active:not(.current) { opacity: 0.6; }

/* === Safe area === */

@supports (padding-top: env(safe-area-inset-top)) {
    #header { padding-top: calc(36px + env(safe-area-inset-top)); }
    main { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
    .day-nav { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
}
