/* Patch — Field Journal for Living Things */
/* Earthy, warm, field-notebook feel */

:root {
    --font-heading: 'DM Serif Display', serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'Space Mono', monospace;
}

[data-theme="warm"] {
    --bg: #F2F0EB;
    --bg-card: #FAFAF7;
    --bg-card-hover: #F5F3EE;
    --text: #2C2C2C;
    --text-muted: #6B6B6B;
    --text-light: #999;
    --border: #E0DDD6;
    --accent: #2d5016;
    --accent-light: #4a7a2e;
    --accent-bg: #e8f0e0;
    --danger: #c44;
    --shadow: rgba(0,0,0,0.06);
}

[data-theme="dark"] {
    --bg: #111117;
    --bg-card: #1a1a22;
    --bg-card-hover: #222230;
    --text: #E8E6E1;
    --text-muted: #999;
    --text-light: #666;
    --border: #2a2a35;
    --accent: #6aaf3f;
    --accent-light: #7ec45a;
    --accent-bg: #1a2a14;
    --danger: #e55;
    --shadow: rgba(0,0,0,0.3);
}

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

html {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

body {
    min-height: 100vh;
    padding-bottom: 4rem;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left { display: flex; align-items: center; gap: 12px; }
.header-right { display: flex; align-items: center; gap: 12px; }

.logo {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    color: var(--accent);
    font-weight: 400;
}

.back-link {
    font-size: 1.2rem;
    color: var(--text-muted);
    text-decoration: none;
}

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

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-muted);
    padding: 4px;
}

/* Container */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px 16px;
}

/* Capture */
.capture-section { margin-bottom: 24px; }

.capture-card {
    background: var(--bg-card);
    border: 2px dashed var(--border);
    border-radius: 16px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.capture-card:hover {
    border-color: var(--accent);
    background: var(--bg-card-hover);
}

.capture-card-small {
    padding: 16px;
}

.capture-icon { font-size: 3rem; margin-bottom: 12px; }

.capture-text {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    color: var(--text);
    margin-bottom: 4px;
}

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

.capture-preview {
    max-width: 100%;
    max-height: 400px;
    border-radius: 12px;
    object-fit: contain;
}

.capture-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 16px;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 24px;
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
}

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

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover { background: var(--accent-light); }

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--bg-card-hover); }

/* Loading */
.loading-section { text-align: center; padding: 40px 0; }

.loading-card {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.pulse-ring {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 3px solid var(--accent);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.5; }
}

.loading-text {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: var(--text-muted);
}

/* Result */
.result-section { margin-bottom: 24px; }

.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.result-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-new { background: var(--accent-bg); color: var(--accent); }
.badge-returning { background: #e8e0f0; color: #6a4fa0; }

[data-theme="dark"] .badge-returning { background: #2a2040; color: #a088cc; }

.health-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.result-name {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    margin-bottom: 2px;
}

.result-common {
    font-style: italic;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.meta-tag {
    font-size: 0.75rem;
    font-family: var(--font-mono);
    padding: 2px 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
}

.result-summary {
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 12px;
}

.result-concerns {
    font-size: 0.85rem;
    color: var(--danger);
    margin-bottom: 8px;
}

.result-actions {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.result-actions ul {
    margin-top: 4px;
    padding-left: 20px;
}

.result-actions li { margin-bottom: 2px; }

.result-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.result-next {
    font-size: 0.8rem;
    color: var(--text-light);
}

.result-error {
    color: var(--danger);
    text-align: center;
    padding: 20px;
}

/* Change block */
.change-block {
    background: var(--accent-bg);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
}

.change-block h4 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent);
    margin-bottom: 6px;
}

.change-block p {
    font-size: 0.9rem;
    line-height: 1.5;
}

.change-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    margin-top: 6px;
    display: inline-block;
}

.change-improving { background: #d4edda; color: #155724; }
.change-stable { background: #fff3cd; color: #856404; }
.change-declining { background: #f8d7da; color: #721c24; }

[data-theme="dark"] .change-improving { background: #1a3a1a; color: #6aaf3f; }
[data-theme="dark"] .change-stable { background: #3a3520; color: #d4a634; }
[data-theme="dark"] .change-declining { background: #3a1a1a; color: #e55; }

/* Collection */
.collection-section { margin-top: 32px; }

.section-title {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    margin-bottom: 16px;
}

.subject-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.subject-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    text-decoration: none;
    color: var(--text);
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: background 0.2s, border-color 0.2s;
    position: relative;
}

.subject-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
    text-decoration: none;
}

.subject-thumb {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 8px;
}

.subject-thumb-placeholder {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    background: var(--bg);
    border-radius: 8px;
}

.subject-info { display: flex; flex-direction: column; gap: 2px; }

.subject-name {
    font-family: var(--font-heading);
    font-size: 0.95rem;
}

.subject-type {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.subject-card .health-dot {
    position: absolute;
    top: 8px;
    right: 8px;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 40px 20px;
}

/* Subject page */
.subject-header-section { margin-bottom: 20px; }

.subject-meta-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.subject-common {
    font-style: italic;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.subject-first-seen {
    font-size: 0.8rem;
    color: var(--text-light);
}

.add-obs-section { margin-bottom: 24px; }

/* Health colors in meta tags */
.health-thriving { color: #2d7a2d !important; border-color: #2d7a2d !important; }
.health-healthy { color: #4a8c3f !important; border-color: #4a8c3f !important; }
.health-fair { color: #8a7a2d !important; border-color: #8a7a2d !important; }
.health-stressed { color: #b8860b !important; border-color: #b8860b !important; }
.health-declining { color: #c44 !important; border-color: #c44 !important; }
.health-critical { color: #922 !important; border-color: #922 !important; }

/* Timeline */
.timeline-section { margin-top: 24px; }

.timeline { display: flex; flex-direction: column; gap: 16px; }

.timeline-entry { display: flex; gap: 12px; }

.timeline-date {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-light);
    min-width: 80px;
    padding-top: 12px;
}

.timeline-card {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    gap: 12px;
}

.timeline-thumb {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}

.timeline-content { flex: 1; }

.timeline-summary {
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 8px;
}

.timeline-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.health-score {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Login */
.login-section {
    display: flex;
    justify-content: center;
    padding-top: 60px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px;
    max-width: 400px;
    width: 100%;
}

.login-card h2 {
    font-family: var(--font-heading);
    margin-bottom: 8px;
}

.login-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

#loginForm {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#loginForm input {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
}

#loginForm input:focus {
    outline: none;
    border-color: var(--accent);
}

.login-status {
    font-size: 0.85rem;
    margin-top: 12px;
    text-align: center;
}

.login-status.success { color: var(--accent); }
.login-status.error { color: var(--danger); }

/* Content pages */
.content-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px;
}

.content-section h2 {
    font-family: var(--font-heading);
    margin-bottom: 16px;
}

.content-section p {
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 12px;
}

.content-section ul {
    padding-left: 20px;
    margin-bottom: 16px;
}

.content-section li {
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 4px;
}

/* Responsive */
@media (max-width: 480px) {
    .timeline-date { min-width: 60px; font-size: 0.7rem; }
    .timeline-thumb { width: 60px; height: 60px; }
    .subject-grid { grid-template-columns: repeat(2, 1fr); }
}
