/* Pebble - Personal Feed & Pebbling Tool
   Warm, clean aesthetic. Designed for daily browsing. */

/* --- Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,300;0,8..60,400;0,8..60,600;1,8..60,400&family=DM+Sans:wght@400;500;600&display=swap');

/* --- Variables --- */
:root {
    --bg: #faf8f5;
    --bg-card: #ffffff;
    --bg-hover: #f5f2ee;
    --text-primary: #2c2825;
    --text-secondary: #7a7168;
    --text-muted: #a8a097;
    --accent: #c47a4a;
    --accent-light: #f0ddd0;
    --accent-hover: #b06835;
    --border: #e8e4de;
    --border-light: #f0ece6;
    --tag-bg: #f5e8c2;
    --tag-text: #7a5c18;
    --friend-badge: #5b8a72;
    --friend-badge-light: #ddeee5;
    --star-color: #d4a843;
    --shadow-sm: 0 1px 3px rgba(44, 40, 37, 0.06);
    --shadow-md: 0 4px 12px rgba(44, 40, 37, 0.08);
    --radius: 8px;
    --radius-lg: 12px;
    --font-serif: 'Source Serif 4', Georgia, serif;
    --font-sans: 'DM Sans', -apple-system, sans-serif;
    --max-width: 680px;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* --- Layout --- */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 16px;
}

/* --- Header --- */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg);
    border-bottom: 1px solid var(--border-light);
    padding: 12px 0;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 16px;
}

.logo {
    font-family: var(--font-serif);
    font-size: 22px;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    letter-spacing: -0.5px;
}

nav {
    display: flex;
    gap: 8px;
    align-items: center;
}

nav a {
    font-family: var(--font-serif);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: var(--radius);
    transition: all 0.15s ease;
}

nav a:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

nav a.active {
    color: var(--accent);
    background: none;
}

/* --- Filter Bar --- */
.filter-bar {
    padding: 12px 0;
    display: flex;
    gap: 8px;
    align-items: center;
    overflow: visible;
}

.filter-chip {
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 500;
    padding: 5px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.filter-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.filter-chip.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* --- Tag multi-select --- */
.tag-select-wrap {
    position: relative;
    flex: 1;
    min-width: 120px;
}

.tag-select-field {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    min-height: 34px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg-card);
    cursor: text;
    transition: border-color 0.15s ease;
}

.tag-select-field:focus-within {
    border-color: var(--accent);
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 13px;
    font-weight: 500;
    padding: 2px 4px 2px 9px;
    border-radius: 12px;
    background: var(--accent);
    color: white;
}

.tag-chip button {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    padding: 0 3px;
    opacity: 0.8;
}

.tag-chip button:hover { opacity: 1; }

.friend-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 500;
    padding: 2px 4px 2px 5px;
    border-radius: 12px;
    background: var(--friend-badge);
    color: white;
}

.friend-chip .initial {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    font-size: 10px;
    font-weight: 600;
}

.friend-chip button {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    padding: 0 3px;
    opacity: 0.8;
}

.friend-chip button:hover { opacity: 1; }

.source-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 13px;
    font-weight: 500;
    padding: 2px 4px 2px 9px;
    border-radius: 12px;
    background: #5b6e8a;
    color: white;
}

.source-chip button {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    padding: 0 3px;
    opacity: 0.8;
}

.source-chip button:hover { opacity: 1; }

.tag-option.source-option {
    color: #5b6e8a;
}

.tag-option-section {
    padding: 6px 12px 2px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.tag-option.friend-option {
    color: var(--friend-badge);
}

.tag-select-field input {
    border: none;
    outline: none;
    background: none;
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--text-primary);
    flex: 1;
    min-width: 80px;
}

.tag-select-field input::placeholder {
    color: var(--text-muted);
}

.tag-options-panel {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 200px;
    max-width: 300px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    max-height: 240px;
    overflow-y: auto;
    z-index: 200;
    padding: 4px;
}

.tag-options-panel.open { display: block; }

.tag-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    transition: background 0.1s ease;
}

.tag-option:hover { background: var(--bg-hover); }

.tag-option-count {
    font-size: 12px;
    color: var(--text-muted);
}

.tag-option-empty {
    padding: 10px 12px;
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
}

/* --- Article Card --- */
.article-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    margin-bottom: 8px;
    transition: all 0.15s ease;
    position: relative;
}

.article-card:hover {
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
}

.article-card.is-read {
    opacity: 0.6;
}

.article-card.is-read:hover {
    opacity: 0.85;
}

.article-source {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.article-title {
    font-family: var(--font-serif);
    font-size: 17px;
    font-weight: 400;
    line-height: 1.4;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.article-title a {
    color: inherit;
    text-decoration: none;
}

.article-title a:hover {
    color: var(--accent);
}

.article-summary {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 10px;
}

.article-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.article-tags {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.tag {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--tag-bg);
    color: var(--tag-text);
    cursor: pointer;
    transition: all 0.15s ease;
}

.tag:hover {
    background: var(--accent-light);
    color: var(--accent);
}

.tag.tag-active {
    background: var(--accent);
    color: white;
}

.article-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: var(--radius);
    font-size: 16px;
    color: var(--text-muted);
    transition: all 0.15s ease;
    line-height: 1;
}

.action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.action-btn.starred {
    color: var(--star-color);
}

/* --- Friend Badges on Articles --- */
.friend-matches {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
}

.friend-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 14px;
    background: var(--friend-badge-light);
    color: var(--friend-badge);
    cursor: pointer;
    transition: all 0.15s ease;
}

.friend-badge .initial {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--friend-badge);
    color: white;
    font-size: 10px;
    font-weight: 600;
}

@media (hover: hover) {
    .friend-badge:hover {
        background: var(--friend-badge);
        color: white;
    }

    .friend-badge:hover .initial {
        background: rgba(255,255,255,0.3);
    }
}

.friend-badge:active {
    background: var(--friend-badge);
    color: white;
}

.friend-badge.temp-warm {
    background: #f5ead0;
    color: #7a5e18;
}
.friend-badge.temp-warm .initial { background: #7a5e18; }
@media (hover: hover) {
    .friend-badge.temp-warm:hover { background: #7a5e18; color: white; }
}
.friend-badge.temp-warm:active { background: #7a5e18; color: white; }

.friend-badge.temp-cold {
    background: #f5ddd9;
    color: #8a3c30;
}
.friend-badge.temp-cold .initial { background: #8a3c30; }
@media (hover: hover) {
    .friend-badge.temp-cold:hover { background: #8a3c30; color: white; }
}
.friend-badge.temp-cold:active { background: #8a3c30; color: white; }

.friend-badge.temp-grey {
    background: #e8e4e0;
    color: #7a7570;
}
.friend-badge.temp-grey .initial { background: #7a7570; }
@media (hover: hover) {
    .friend-badge.temp-grey:hover { background: #7a7570; color: white; }
}
.friend-badge.temp-grey:active { background: #7a7570; color: white; }

.friend-badge.shared {
    opacity: 0.45;
}

.friend-badge .shared-date {
    font-size: 10px;
    font-weight: 400;
    opacity: 0.8;
}

/* --- Friends Page --- */
.page-title {
    font-family: var(--font-serif);
    font-size: 28px;
    font-weight: 600;
    margin: 24px 0 16px;
    color: var(--accent);
}

.friend-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    margin-bottom: 8px;
    transition: all 0.15s ease;
}

.friend-card:hover {
    box-shadow: var(--shadow-sm);
}

.friend-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 6px;
}

.friend-name {
    font-family: var(--font-serif);
    font-size: 18px;
    font-weight: 600;
}

.friend-city {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.friend-note {
    font-size: 14px;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 8px;
}

.friend-temperature {
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 10px;
    font-weight: 500;
}

.temp-warm { background: #ddeee5; color: #3d7a5a; }
.temp-cool { background: #fef3cd; color: #8a6d3b; }
.temp-cold { background: #f8d7da; color: #8b3a3a; }
.temp-unknown { background: var(--tag-bg); color: var(--tag-text); }

/* --- Sources Page --- */
.source-url {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
    word-break: break-all;
}

.source-status {
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 10px;
    cursor: pointer;
    flex-shrink: 0;
    user-select: none;
}

.status-on  { background: #ddeee5; color: #3d7a5a; }
.status-off { background: var(--tag-bg); color: var(--tag-text); }

/* --- Forms & Modals --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(44, 40, 37, 0.4);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-md);
    transform: translateY(8px);
    transition: transform 0.2s ease;
}

.modal-overlay.visible .modal {
    transform: translateY(0);
}

.modal h2 {
    font-family: var(--font-serif);
    font-size: 22px;
    margin-bottom: 16px;
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    font-size: 14px;
    font-family: var(--font-sans);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text-primary);
    transition: border-color 0.15s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.form-group textarea {
    resize: vertical;
    min-height: 60px;
}

.tag-select {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 4px;
}

.tag-select .filter-chip {
    font-size: 12px;
    padding: 3px 10px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    padding: 8px 20px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
}

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

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

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

.btn-secondary:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-danger {
    background: none;
    color: #b55454;
    border-color: transparent;
}

.btn-danger:hover {
    background: #fdf0f0;
}

.btn-group {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

/* --- Add Friend Button --- */
.add-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
    background: none;
    border: 1px dashed var(--accent);
    border-radius: var(--radius-lg);
    padding: 12px 18px;
    cursor: pointer;
    transition: all 0.15s ease;
    width: 100%;
    justify-content: center;
    margin-bottom: 16px;
}

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

/* --- Toast / Notification --- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--text-primary);
    color: white;
    font-size: 14px;
    font-weight: 500;
    padding: 10px 20px;
    border-radius: 24px;
    box-shadow: var(--shadow-md);
    z-index: 300;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

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

/* --- Loading --- */
.loading {
    text-align: center;
    padding: 40px 0;
    color: var(--text-muted);
    font-size: 14px;
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state h3 {
    font-family: var(--font-serif);
    font-size: 20px;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

/* --- Responsive --- */
@media (max-width: 480px) {
    .header-inner { padding: 0 12px; }
    .container { padding: 0 12px; }
    .article-card { padding: 14px; }
    .article-title { font-size: 16px; }
    .modal { padding: 18px; }
}

/* --- Scrollbar styling --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
