/* Kasvilista — Plant Information Site */
/* Matches kartta.munmuudle.eu visual style */

:root {
    --color-primary: #2a6fb5;
    --color-primary-dark: #1e5a99;
    --color-bg: #f5f7fa;
    --color-surface: #ffffff;
    --color-text: #333333;
    --color-muted: #888888;
    --color-border: #e0e0e0;
    --color-hover: #f0f4f8;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.12);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.16);
    --max-width: 1200px;
    --nav-height: 48px;
    --header-height: 80px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Header */
#site-header {
    background: var(--color-primary);
    color: white;
    padding: 16px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    align-items: baseline;
    gap: 16px;
    flex-wrap: wrap;
}

.site-title {
    font-size: 24px;
    font-weight: 600;
}

.site-subtitle {
    font-size: 14px;
    opacity: 0.85;
}

/* Category Navigation */
#category-nav {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: var(--header-height);
    z-index: 90;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.nav-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    gap: 4px;
    padding: 8px 16px;
    min-width: max-content;
}

.cat-btn {
    border: 2px solid transparent;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    background: transparent;
    color: var(--color-text);
    transition: all 0.2s;
    white-space: nowrap;
    min-height: 44px;
}

.cat-btn:hover {
    background: var(--color-hover);
}

.cat-btn.active {
    color: white;
    border-color: transparent;
}

.cat-btn .cat-count {
    font-size: 12px;
    opacity: 0.7;
    margin-left: 4px;
}

/* Search */
#search-bar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 8px 16px;
    position: sticky;
    top: calc(var(--header-height) + var(--nav-height));
    z-index: 80;
}

.search-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

#search-input {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 16px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

#search-input:focus {
    border-color: var(--color-primary);
}

.search-count {
    font-size: 13px;
    color: var(--color-muted);
    white-space: nowrap;
}

/* Plant Grid */
#plant-grid {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 16px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

@media (min-width: 768px) {
    #plant-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
    #plant-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Plant Card */
.plant-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    overflow: hidden;
    border-left: 4px solid var(--cat-color, var(--color-primary));
}

.plant-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.plant-card:active {
    transform: translateY(0);
}

.card-image {
    width: 100%;
    height: 160px;
    object-fit: cover;
    background: #e8e8e8;
    display: block;
}

.card-image-placeholder {
    width: 100%;
    height: 160px;
    background: linear-gradient(135deg, #e8e8e8, #f5f5f5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: #ccc;
}

.card-body {
    padding: 12px 16px;
}

.card-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 2px;
}

.card-latin {
    font-size: 13px;
    font-style: italic;
    color: var(--color-muted);
    margin-bottom: 8px;
}

.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.card-tag {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 12px;
    background: var(--color-hover);
    color: var(--color-muted);
}

.card-tag.kartta {
    background: #e3f2fd;
    color: var(--color-primary);
}

/* Detail Overlay */
#plant-detail-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 1;
    transition: opacity 0.2s;
}

#plant-detail-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#plant-detail {
    background: var(--color-surface);
    border-radius: 12px;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-lg);
}

.detail-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(0,0,0,0.5);
    color: white;
    font-size: 24px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.detail-close-btn:hover {
    background: rgba(0,0,0,0.7);
}

.detail-image-container {
    width: 100%;
    max-height: 400px;
    overflow: hidden;
    position: relative;
}

.detail-image {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
    display: block;
}

.detail-image-placeholder {
    width: 100%;
    height: 200px;
    background: linear-gradient(135deg, #e8e8e8, #f5f5f5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 72px;
    color: #ccc;
}

.detail-body {
    padding: 24px;
}

.detail-header {
    margin-bottom: 16px;
}

.detail-name-fi {
    font-size: 28px;
    font-weight: 700;
    color: var(--color-text);
}

.detail-name-latin {
    font-size: 18px;
    font-style: italic;
    color: var(--color-muted);
    margin-top: 2px;
}

.detail-family {
    font-size: 14px;
    color: var(--color-muted);
    margin-top: 4px;
}

.detail-section {
    margin-bottom: 20px;
}

.detail-section h3 {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-muted);
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--color-border);
}

.detail-section p {
    font-size: 15px;
    line-height: 1.7;
}

/* Info grid for hardiness/soil/shade */
.detail-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.detail-info-item {
    background: var(--color-bg);
    padding: 12px;
    border-radius: var(--radius);
}

.detail-info-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-muted);
    margin-bottom: 4px;
}

.detail-info-value {
    font-size: 15px;
    font-weight: 500;
}

/* Links */
.detail-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.detail-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.detail-link.kartta-link {
    background: var(--color-primary);
    color: white;
}

.detail-link.kartta-link:hover {
    background: var(--color-primary-dark);
}

.detail-link.laji-link {
    background: #e8f5e9;
    color: #2e7d32;
}

.detail-link.laji-link:hover {
    background: #c8e6c9;
}

/* Image attribution */
.detail-image-credit {
    padding: 8px 24px 16px;
    font-size: 12px;
    color: var(--color-muted);
    background: var(--color-bg);
}

.detail-image-credit a {
    color: var(--color-primary);
    text-decoration: none;
}

.detail-image-credit a:hover {
    text-decoration: underline;
}

/* Footer */
#site-footer {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: 20px;
    text-align: center;
    font-size: 13px;
    color: var(--color-muted);
    margin-top: 40px;
}

#site-footer a {
    color: var(--color-primary);
    text-decoration: none;
}

#site-footer a:hover {
    text-decoration: underline;
}

#site-footer p + p {
    margin-top: 4px;
}

/* No results */
.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 48px 16px;
    color: var(--color-muted);
    font-size: 16px;
}

/* Loading */
.loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 48px 16px;
    color: var(--color-muted);
}

/* Inline editing */
.detail-edit-bar {
    margin-top: 16px;
    text-align: right;
}

.edit-toggle-btn {
    background: none;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 13px;
    cursor: pointer;
    color: var(--color-muted);
    transition: all 0.2s;
}

.edit-toggle-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.edit-toggle-btn.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.editable {
    transition: background 0.15s;
    border-radius: 4px;
}

.editable.edit-mode {
    cursor: pointer;
    background: #fffde7;
    outline: 1px dashed #ffc107;
    outline-offset: 2px;
}

.editable.edit-mode:hover {
    background: #fff9c4;
}

.edit-placeholder {
    color: #bbb;
    font-style: italic;
    font-size: 0.9em;
}

.inline-edit-input,
.inline-edit-textarea {
    width: 100%;
    border: 2px solid var(--color-primary);
    border-radius: 4px;
    padding: 6px 8px;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    background: #fff;
    color: var(--color-text);
    outline: none;
    box-sizing: border-box;
}

.inline-edit-textarea {
    min-height: 80px;
    resize: vertical;
}
