/* =============================================================
   app.css — Travel Memory Map
   Design: Refined cartographic — warm parchment tones,
           deep ink typography, jewel-toned emotion accents.
   ============================================================= */

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

:root {
    /* Palette */
    --ink:        #1a1714;
    --ink-soft:   #3d3830;
    --muted:      #8a8075;
    --parchment:  #f5f0e8;
    --parchment2: #ede7d8;
    --parchment3: #e4dcc8;
    --white:      #fdfaf5;
    --border:     #d4caba;

    /* Accent */
    --gold:       #c9974a;
    --gold-dark:  #a07535;

    /* Emotions */
    --happy:       #f5c842;
    --love:        #e8637a;
    --adventure:   #4a9eda;
    --peaceful:    #5bbf85;
    --sad:         #6b8fc9;
    --achievement: #b07fd4;

    /* Layout */
    --nav-h:    60px;
    --radius:   10px;
    --shadow:   0 2px 16px rgba(26,23,20,.10);
    --shadow-lg:0 8px 40px rgba(26,23,20,.16);

    /* Typography */
    --font-display: 'Playfair Display', Georgia, serif;
    --font-body:    'DM Sans', system-ui, sans-serif;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    background: var(--parchment);
    color: var(--ink);
    min-height: 100vh;
    line-height: 1.6;
}

img { max-width: 100%; display: block; }
a   { color: var(--gold-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }

/* ── Emotion utility classes ────────────────────────────────── */
.emotion-happy       { --em-color: var(--happy);       --em-bg: #fff9e6; }
.emotion-love        { --em-color: var(--love);        --em-bg: #fef0f3; }
.emotion-adventure   { --em-color: var(--adventure);   --em-bg: #edf6fd; }
.emotion-peaceful    { --em-color: var(--peaceful);    --em-bg: #edf8f3; }
.emotion-sad         { --em-color: var(--sad);         --em-bg: #edf1fa; }
.emotion-achievement { --em-color: var(--achievement); --em-bg: #f6f0fc; }

/* ── Navbar ─────────────────────────────────────────────────── */
.navbar {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--nav-h);
    background: var(--white);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px;
    z-index: 1000;
    box-shadow: 0 1px 8px rgba(26,23,20,.06);
}

.nav-brand {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ink);
    display: flex; align-items: center; gap: 8px;
    text-decoration: none;
}
.nav-logo { color: var(--gold); font-size: 1.3rem; }

.nav-links {
    display: flex; align-items: center; gap: 8px;
}
.nav-links a {
    color: var(--ink-soft);
    font-size: .9rem;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 6px;
    transition: background .15s, color .15s;
    text-decoration: none;
}
.nav-links a:hover, .nav-links a.active {
    background: var(--parchment2);
    color: var(--ink);
}
.btn-logout {
    background: none; border: 1px solid var(--border);
    color: var(--muted); font-size: .85rem; font-weight: 500;
    padding: 6px 14px; border-radius: 6px;
    transition: border-color .15s, color .15s;
}
.btn-logout:hover { border-color: var(--ink-soft); color: var(--ink); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 22px;
    border-radius: var(--radius);
    font-size: .9rem; font-weight: 500;
    border: none; transition: all .15s;
    white-space: nowrap;
}
.btn-primary {
    background: var(--ink); color: var(--parchment);
}
.btn-primary:hover { background: var(--ink-soft); color: var(--white); text-decoration: none; }

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--ink-soft);
}
.btn-ghost:hover { border-color: var(--ink-soft); background: var(--parchment2); text-decoration: none; }

.btn-full { width: 100%; justify-content: center; }
.btn-icon { gap: 8px; }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: .9rem; }
.alert-error   { background: #fef0f0; border: 1px solid #f5c5c5; color: #b33; }
.alert-success { background: #edf8f3; border: 1px solid #a8dfc0; color: #2a7a50; }
.alert p + p { margin-top: 4px; }

/* ── Auth ────────────────────────────────────────────────────── */
.auth-page { background: var(--parchment); }

.auth-container {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 420px 1fr;
}
@media (max-width: 768px) {
    .auth-container { grid-template-columns: 1fr; }
    .auth-visual    { display: none; }
}

.auth-card {
    background: var(--white);
    padding: 48px 40px;
    display: flex; flex-direction: column; justify-content: center;
    border-right: 1px solid var(--border);
    min-height: 100vh;
}

.auth-brand {
    margin-bottom: 32px;
    text-align: center;
}
.auth-logo {
    display: block;
    font-size: 2.5rem;
    color: var(--gold);
    margin-bottom: 8px;
}
.auth-brand h1 {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--ink);
}
.auth-brand p { color: var(--muted); margin-top: 4px; }

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

.auth-switch {
    margin-top: 24px;
    text-align: center;
    font-size: .9rem;
    color: var(--muted);
}

/* Visual panel */
.auth-visual {
    background: var(--ink);
    display: flex; align-items: center; justify-content: center;
    padding: 40px;
    position: relative;
    overflow: hidden;
}
.auth-visual::before {
    content: '';
    position: absolute; inset: 0;
    background: radial-gradient(circle at 30% 50%, rgba(201,151,74,.15) 0%, transparent 60%),
                radial-gradient(circle at 80% 20%, rgba(91,191,133,.08) 0%, transparent 50%);
}
.auth-visual-inner { position: relative; z-index: 1; text-align: center; }

.pin-grid {
    display: grid;
    grid-template-columns: repeat(4, 32px);
    gap: 20px;
    justify-content: center;
    margin-bottom: 24px;
}
.mini-pin {
    width: 32px; height: 32px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    background: var(--em-color, var(--gold));
    opacity: 0;
    animation: pinPop .5s forwards;
}
@keyframes pinPop {
    to { opacity: .85; transform: rotate(-45deg) scale(1); }
    50% { transform: rotate(-45deg) scale(1.2); }
    from { transform: rotate(-45deg) scale(0); }
}
.auth-tagline { color: rgba(255,255,255,.5); font-size: .85rem; letter-spacing: .05em; }

/* ── Form elements (shared) ──────────────────────────────────── */
.field-group { display: flex; flex-direction: column; gap: 6px; }

.field-group label {
    font-size: .8rem;
    font-weight: 600;
    letter-spacing: .03em;
    text-transform: uppercase;
    color: var(--ink-soft);
}
.hint  { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--muted); }
.required { color: var(--love); }

.field-group input,
.field-group select,
.field-group textarea {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--ink);
    font-size: .95rem;
    font-family: var(--font-body);
    transition: border-color .15s, box-shadow .15s;
    width: 100%;
}
.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(201,151,74,.15);
}
.field-group textarea { resize: vertical; min-height: 80px; }

/* ── Map page ────────────────────────────────────────────────── */
.map-page .navbar { position: fixed; z-index: 1100; }

.map-wrapper {
    position: fixed;
    top: var(--nav-h); left: 0; right: 0; bottom: 0;
}

#map {
    width: 100%; height: 100%;
    z-index: 1;
}

/* Leaflet tile credits */
.leaflet-control-attribution { font-size: 10px !important; }

/* Map toolbar */
.map-toolbar {
    position: absolute;
    top: 16px; left: 50%;
    transform: translateX(-50%);
    z-index: 900;
    display: flex; align-items: center; gap: 12px;
    pointer-events: none;
}
.map-toolbar .btn { pointer-events: all; box-shadow: var(--shadow); }

.map-hint {
    background: rgba(26,23,20,.75);
    color: var(--parchment);
    padding: 7px 14px;
    border-radius: 20px;
    font-size: .8rem;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .3s, transform .3s;
    pointer-events: none;
    white-space: nowrap;
}
.map-hint.visible { opacity: 1; transform: translateY(0); }

/* Custom map pin markers */
.map-pin-icon {
    width: 28px; height: 28px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    border: 2.5px solid rgba(255,255,255,.9);
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
    cursor: pointer;
    transition: transform .15s;
}
.map-pin-icon:hover { transform: rotate(-45deg) scale(1.2); }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(26,23,20,.55);
    backdrop-filter: blur(3px);
    z-index: 2000;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
.modal-overlay.hidden { display: none; }

.modal {
    background: var(--white);
    border-radius: 16px;
    padding: 32px;
    width: 100%; max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-lg);
    animation: modalIn .25s ease-out;
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(16px) scale(.97); }
    to   { opacity: 1; transform: none; }
}

.modal h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    margin-bottom: 4px;
}
.modal-coords {
    font-size: .8rem;
    color: var(--muted);
    margin-bottom: 20px;
    font-family: monospace;
}
.modal-close {
    position: absolute; top: 16px; right: 16px;
    background: var(--parchment2);
    border: none;
    width: 30px; height: 30px;
    border-radius: 50%;
    font-size: .85rem;
    color: var(--muted);
    line-height: 1;
    transition: background .15s, color .15s;
}
.modal-close:hover { background: var(--parchment3); color: var(--ink); }

/* Modal form layout */
.form-row         { margin-bottom: 16px; }
.form-row-2       { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-check   { display: flex; align-items: center; }

.checkbox-label {
    display: flex; align-items: center; gap: 8px;
    font-size: .9rem; color: var(--ink-soft); cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
    width: 16px; height: 16px; cursor: pointer;
}

.form-actions {
    display: flex; align-items: center; justify-content: flex-end;
    gap: 12px; margin-top: 24px;
    padding-top: 16px; border-top: 1px solid var(--border);
}
.form-error {
    flex: 1;
    font-size: .85rem;
    color: #b33;
}
.btn-spinner { font-style: italic; }

/* Image upload */
.image-upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: border-color .15s;
    position: relative;
}
.image-upload-area:hover { border-color: var(--gold); }
.image-upload-area input[type="file"] {
    position: absolute; inset: 0;
    opacity: 0; cursor: pointer;
    padding: 0; border: none;
    z-index: 2;
}
.upload-placeholder {
    display: flex; flex-direction: column; align-items: center;
    gap: 4px; pointer-events: none;
    color: var(--muted); font-size: .85rem;
}
.upload-icon { font-size: 1.8rem; }

.image-previews {
    display: flex; flex-wrap: wrap; gap: 8px;
    margin-top: 8px;
}
.preview-thumb {
    width: 72px; height: 72px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid var(--border);
}

/* ── Memory popup (custom) ───────────────────────────────────── */
.memory-popup {
    position: fixed;
    bottom: 24px; right: 24px;
    width: 300px;
    background: var(--white);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 1500;
    animation: popupIn .25s ease-out;
}
.memory-popup.hidden { display: none; }

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

.popup-close {
    position: absolute; top: 10px; right: 10px;
    background: rgba(26,23,20,.45);
    border: none; color: #fff;
    width: 26px; height: 26px; border-radius: 50%;
    font-size: .75rem; z-index: 2;
}
.popup-image-wrap { height: 160px; overflow: hidden; background: var(--parchment2); }
.popup-image-wrap img { width: 100%; height: 100%; object-fit: cover; }
.popup-image-empty {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    font-size: 2.5rem;
    background: var(--em-bg, var(--parchment2));
}

.popup-body { padding: 14px 16px; }
.popup-emotion {
    font-size: .75rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--em-color, var(--muted));
    margin-bottom: 4px;
}
.popup-body h3 {
    font-family: var(--font-display);
    font-size: 1rem;
    margin-bottom: 4px;
}
.popup-location { font-size: .78rem; color: var(--muted); margin-bottom: 4px; }
.popup-desc { font-size: .85rem; color: var(--ink-soft); margin-bottom: 6px; }
.popup-date { font-size: .75rem; color: var(--muted); }

/* ── Feed ────────────────────────────────────────────────────── */
.feed-page body { padding-top: var(--nav-h); }
.feed-main {
    max-width: 1100px;
    margin: 0 auto;
    padding: calc(var(--nav-h) + 40px) 24px 60px;
}

.feed-header {
    margin-bottom: 40px;
    text-align: center;
}
.feed-header h1 {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 700;
}
.feed-header p { color: var(--muted); margin-top: 6px; }

.feed-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.memory-card {
    background: var(--white);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform .2s, box-shadow .2s;
    display: flex; flex-direction: column;
}
.memory-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.card-author {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 16px 0;
    text-decoration: none;
    color: var(--ink-soft);
    font-size: .85rem; font-weight: 500;
}
.card-author:hover { color: var(--ink); text-decoration: none; }
.author-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--parchment3);
    display: flex; align-items: center; justify-content: center;
    font-size: .75rem; font-weight: 700; color: var(--ink-soft);
    flex-shrink: 0;
}

.card-image {
    height: 200px; overflow: hidden;
    margin-top: 10px;
}
.card-image img { width: 100%; height: 100%; object-fit: cover; }
.card-image-placeholder {
    display: flex; align-items: center; justify-content: center;
    font-size: 3rem;
    background: var(--em-bg, var(--parchment2));
}

.card-body { padding: 16px; flex: 1; }
.card-meta {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px; flex-wrap: wrap; gap: 6px;
}

.emotion-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .75rem; font-weight: 600;
    background: var(--em-bg, var(--parchment2));
    color: var(--em-color, var(--muted));
    white-space: nowrap;
}

.card-date {
    font-size: .75rem; color: var(--muted);
}
.card-title {
    font-family: var(--font-display);
    font-size: 1.1rem; font-weight: 600;
    margin-bottom: 6px;
}
.card-location {
    font-size: .8rem; color: var(--muted);
    margin-bottom: 8px;
}
.card-desc { font-size: .85rem; color: var(--ink-soft); }

.pagination {
    display: flex; justify-content: center; gap: 12px;
    margin-top: 48px;
}

/* ── Profile ─────────────────────────────────────────────────── */
.profile-main {
    max-width: 900px;
    margin: 0 auto;
    padding: calc(var(--nav-h) + 40px) 24px 60px;
}

.profile-header {
    display: flex; align-items: center; gap: 28px;
    margin-bottom: 48px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.profile-avatar-large {
    width: 88px; height: 88px;
    border-radius: 50%;
    background: var(--parchment3);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display);
    font-size: 2.4rem; font-weight: 700;
    color: var(--ink-soft);
    flex-shrink: 0;
    border: 3px solid var(--border);
}
.profile-info h1 {
    font-family: var(--font-display);
    font-size: 2rem;
}
.profile-since { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.profile-stats {
    display: flex; gap: 24px; margin-top: 16px;
}
.stat { text-align: center; }
.stat-num { display: block; font-size: 1.4rem; font-weight: 700; color: var(--ink); }
.stat-label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.profile-map-section { margin-bottom: 48px; }
.profile-map-section h2,
.profile-memories h2 {
    font-family: var(--font-display);
    font-size: 1.4rem;
    margin-bottom: 20px;
    display: flex; align-items: center; gap: 12px;
}
.count-badge {
    background: var(--parchment2);
    color: var(--muted);
    font-size: .75rem; font-family: var(--font-body);
    padding: 2px 8px; border-radius: 20px;
}

#profile-map {
    height: 300px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}

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

.memory-list-item {
    display: flex; gap: 16px;
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}
.list-item-thumb {
    width: 80px; height: 80px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}
.list-item-thumb img { width: 100%; height: 100%; object-fit: cover; }
.list-item-thumb-empty {
    display: flex; align-items: center; justify-content: center;
    font-size: 1.8rem;
    background: var(--em-bg, var(--parchment2));
}

.list-item-body { flex: 1; min-width: 0; }
.list-item-meta {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
    margin-bottom: 6px;
}
.list-item-meta time { font-size: .75rem; color: var(--muted); }
.private-badge {
    font-size: .72rem; color: var(--muted);
    background: var(--parchment2);
    padding: 2px 8px; border-radius: 10px;
}
.list-item-body h3 { font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.list-location { font-size: .8rem; color: var(--muted); margin-bottom: 4px; }
.list-desc { font-size: .85rem; color: var(--ink-soft); }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 64px 24px;
    color: var(--muted);
}
.empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h2 { font-family: var(--font-display); color: var(--ink-soft); margin-bottom: 8px; }
.empty-state p { margin-bottom: 24px; }

/* ── Error page ──────────────────────────────────────────────── */
.error-page {
    min-height: 100vh;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    text-align: center;
    gap: 12px;
}
.error-page .error-icon { font-size: 4rem; }
.error-page h1 { font-family: var(--font-display); font-size: 4rem; color: var(--gold); }

/* ── Utilities ───────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 600px) {
    .modal { padding: 24px 18px; }
    .form-row-2 { grid-template-columns: 1fr; }
    .profile-header { flex-direction: column; text-align: center; }
    .profile-stats { justify-content: center; }
    .memory-list-item { flex-direction: column; }
    .list-item-thumb { width: 100%; height: 160px; }
    .navbar { padding: 0 16px; }
    .nav-links a { padding: 6px 8px; font-size: .85rem; }
    .map-toolbar { top: 8px; flex-direction: column; gap: 6px; }
    .memory-popup { right: 8px; bottom: 8px; width: calc(100vw - 16px); }
}
