/* My Habit Journals — Design System
   Background: oklch(0.98 0.01 90) — warm off-white
   Text: oklch(0.15 0.02 260) — near-black
   Primary: oklch(0.55 0.15 250) — calm blue
   Secondary: oklch(0.45 0.12 160) — muted green
   Surface: oklch(0.97 0.005 90) — subtle cards
   Border: oklch(0.92 0.01 90)
*/

:root {
    --bg: oklch(0.98 0.01 90);
    --text: oklch(0.15 0.02 260);
    --primary: oklch(0.55 0.15 250);
    --primary-hover: oklch(0.5 0.15 250);
    --secondary: oklch(0.45 0.12 160);
    --surface: oklch(0.97 0.005 90);
    --border: oklch(0.92 0.01 90);
    --text-secondary: oklch(0.45 0.02 260);
    --text-muted: oklch(0.5 0.02 260);
    --text-subtle: oklch(0.55 0.02 260);
    --font-serif: 'Instrument Serif', Georgia, serif;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Base */
*, *::before, *::after {
    box-sizing: border-box;
}

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

body {
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text);
    background-color: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Typography — text-wrap: pretty on all text */
p, h1, h2, h3, h4, h5, h6, li, blockquote, figcaption, label, th, td, summary {
    text-wrap: pretty;
}

/* Font serif for headings */
h1, h2, h3, .font-serif {
    font-family: var(--font-serif);
}

/* Smooth transitions */
a, button, input, textarea, select {
    transition: all 150ms ease;
}

/* Links */
a {
    color: inherit;
    text-decoration: none;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
details summary:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Button styles */
button {
    cursor: pointer;
    font-family: inherit;
}

/* Form elements */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="url"],
input[type="tel"],
input[type="number"],
input[type="search"],
textarea,
select {
    font-family: var(--font-sans);
    font-size: 0.875rem;
    line-height: 1.5;
    -webkit-appearance: none;
    appearance: none;
}

input[type="text"]::placeholder,
input[type="email"]::placeholder,
input[type="password"]::placeholder,
textarea::placeholder {
    color: oklch(0.65 0.02 260);
}

/* Checkbox and radio */
input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 1rem;
    height: 1rem;
    border: 1.5px solid var(--border);
    border-radius: 4px;
    background-color: white;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 150ms ease;
}

input[type="checkbox"]:checked {
    background-color: var(--primary);
    border-color: var(--primary);
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3E%3C/svg%3E");
    background-size: 0.75rem;
    background-position: center;
    background-repeat: no-repeat;
}

/* Details/summary for FAQ */
details summary {
    cursor: pointer;
}

details summary::-webkit-details-marker {
    display: none;
}

/* Selection */
::selection {
    background-color: oklch(0.55 0.15 250 / 0.2);
    color: var(--text);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: oklch(0.85 0.02 90);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.97); }
    to { opacity: 1; transform: scale(1); }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

.slide-up {
    animation: slideUp 0.3s ease-out;
}

/* Card styles — clean borders without left accent */
.card {
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    background-color: var(--surface);
    padding: 1.5rem;
}

.card-hover {
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.card-hover:hover {
    border-color: oklch(0.88 0.02 90);
}

/* PWA install banner */
#pwa-install-banner {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.875rem;
}

#pwa-install-banner.show {
    display: flex;
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    background: var(--text);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    z-index: 100;
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.error {
    background: #dc2626;
}

.toast.success {
    background: var(--secondary);
}

/* Loading spinner */
.spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Empty states */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-subtle);
    font-size: 0.875rem;
}

/* Modal backdrop animation */
#entry-modal {
    animation: fadeIn 0.15s ease-out;
}

#entry-modal > div > div {
    animation: scaleIn 0.15s ease-out;
}

/* Habit color dot animation */
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.habit-dot-active {
    animation: pulse-dot 2s ease-in-out infinite;
}

/* Calendar day styles */
.calendar-day {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    border-radius: 4px;
    transition: background-color 150ms ease;
}

.calendar-day.today {
    font-weight: 600;
    color: var(--primary);
}

.calendar-day.has-habits {
    position: relative;
}

.calendar-day.has-habits::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: var(--primary);
}

/* Responsive helpers */
@media (max-width: 640px) {
    .container-px {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* Print */
@media print {
    nav, footer, .no-print {
        display: none !important;
    }
}
