/* ============================================================
   Life Timeline — Stylesheet
   Aesthetic: Warm editorial / archival — like a beautiful diary
   Fonts: Playfair Display (headings) + DM Sans (body)
   ============================================================ */

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
    --bg:           #f7f4ef;
    --bg-card:      #fdfbf8;
    --bg-dark:      #1c1814;
    --ink:          #1c1814;
    --ink-mid:      #4a4540;
    --ink-light:    #8c857d;
    --border:       #ddd8d0;
    --accent:       #b5522a;
    --accent-soft:  #f0e6e0;
    --accent-2:     #3d6b5e;
    --gold:         #c9a84c;
    --line:         #d4cec6;
    --shadow-sm:    0 1px 3px rgba(28,24,20,.08);
    --shadow-md:    0 4px 16px rgba(28,24,20,.10);
    --radius:       8px;
    --font-head:    'Playfair Display', Georgia, serif;
    --font-body:    'DM Sans', system-ui, sans-serif;
    --topbar-h:     60px;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ── Typography ────────────────────────────────────────────── */
h1, h2, h3 { font-family: var(--font-head); font-weight: 700; line-height: 1.2; }
h1 { font-size: 2rem; }
h2 { font-size: 1.55rem; }
h3 { font-size: 1.2rem; }
p  { line-height: 1.65; color: var(--ink-mid); }
small { font-size: .8rem; color: var(--ink-light); }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem 1.2rem;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: .9rem;
    font-weight: 500;
    cursor: pointer;
    border: 1.5px solid transparent;
    transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
    text-decoration: none !important;
    white-space: nowrap;
}
.btn-primary {
    background: var(--ink);
    color: #fff;
    border-color: var(--ink);
}
.btn-primary:hover { background: #2e2820; }

.btn-accent {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-accent:hover { background: #9e4422; }

.btn-ghost {
    background: transparent;
    color: var(--ink-mid);
    border-color: var(--border);
}
.btn-ghost:hover { background: var(--border); }

.btn-sm  { padding: .38rem .85rem; font-size: .82rem; }
.btn-full { width: 100%; justify-content: center; }

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--topbar-h);
    background: var(--bg-dark);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.topbar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-family: var(--font-head);
    font-size: 1.15rem;
    color: #fff;
    letter-spacing: .01em;
}
.topbar-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.topbar-user {
    font-size: .88rem;
    color: #b0a898;
}

/* ── Brand icon ────────────────────────────────────────────── */
.brand-icon {
    font-size: 1.4rem;
    color: var(--gold);
    line-height: 1;
}

/* ── Page header ───────────────────────────────────────────── */
.page-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 1.5rem 2rem;
}
.page-header-inner {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.page-header h2 { font-size: 1.6rem; }
.subtitle { font-size: .88rem; color: var(--ink-light); margin-top: .2rem; }
.header-actions { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.view-toggle { display: flex; gap: .3rem; }

/* ── Main content ──────────────────────────────────────────── */
.main-content {
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 2rem;
}

/* ── Auth pages ────────────────────────────────────────────── */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem 1rem;
    background:
        radial-gradient(ellipse at 20% 80%, rgba(181,82,42,.08) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(201,168,76,.07) 0%, transparent 60%),
        var(--bg);
}
.auth-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-md);
}
.auth-panel--wide { max-width: 560px; }

.auth-brand {
    text-align: center;
    margin-bottom: 2rem;
}
.auth-brand .brand-icon {
    display: block;
    font-size: 2.5rem;
    color: var(--gold);
    margin-bottom: .5rem;
}
.auth-brand h1 {
    font-size: 1.5rem;
    color: var(--ink);
    margin-bottom: .25rem;
}
.auth-brand p { font-size: .9rem; }
.auth-switch {
    text-align: center;
    margin-top: 1.25rem;
    font-size: .88rem;
    color: var(--ink-light);
}

/* ── Forms ─────────────────────────────────────────────────── */
.auth-form, .form-card form { display: flex; flex-direction: column; gap: 1rem; }

.field { display: flex; flex-direction: column; gap: .35rem; }
.field label {
    font-size: .82rem;
    font-weight: 500;
    color: var(--ink-mid);
    letter-spacing: .03em;
    text-transform: uppercase;
}
.field input,
.field select {
    padding: .6rem .85rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: .95rem;
    color: var(--ink);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}
.field input:focus,
.field select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(181,82,42,.12);
}
.field input::placeholder { color: var(--ink-light); }

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .85rem;
}

/* Date fields */
.date-fields { align-items: end; }
.field-year  { flex: 1.2; }
.field-month { flex: 2; }
.field-day   { flex: 1; }

/* Precision tabs */
.precision-tabs {
    display: flex;
    gap: .4rem;
    flex-wrap: wrap;
}
.precision-tab {
    cursor: pointer;
}
.precision-tab input[type="radio"] { display: none; }
.precision-tab span {
    display: inline-block;
    padding: .4rem .9rem;
    border: 1.5px solid var(--border);
    border-radius: 20px;
    font-size: .83rem;
    font-weight: 500;
    color: var(--ink-mid);
    transition: all .15s;
    user-select: none;
}
.precision-tab input:checked + span {
    background: var(--ink);
    border-color: var(--ink);
    color: #fff;
}
.precision-tab span:hover { border-color: var(--ink-mid); }

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
    margin-top: .5rem;
}

/* Form card container */
.form-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 2rem;
    max-width: 640px;
    margin: 0 auto;
    box-shadow: var(--shadow-sm);
}

/* ── Alerts ────────────────────────────────────────────────── */
.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    font-size: .9rem;
    line-height: 1.5;
}
.alert-error {
    background: #fdf0ec;
    border: 1px solid #e8b8a8;
    color: #7a2e10;
}
.alert-success {
    background: #eef5f2;
    border: 1px solid #a8ccbf;
    color: #1e4d3d;
}

/* ── Empty state ───────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-card);
    border: 1px dashed var(--border);
    border-radius: 12px;
}
.empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3 { margin-bottom: .5rem; }
.empty-state p  { margin-bottom: 1.5rem; }

/* ── Timeline View ─────────────────────────────────────────── */
.timeline {
    position: relative;
    padding-left: 3rem;
}

/* The vertical line */
.timeline::before {
    content: '';
    position: absolute;
    left: 1.1rem;
    top: 0;
    bottom: 2rem;
    width: 2px;
    background: linear-gradient(to bottom, var(--gold) 0%, var(--line) 100%);
}

/* Year marker */
.timeline-year-marker {
    position: relative;
    margin: 1.75rem 0 .75rem -3rem;
    padding-left: 3rem;
}
.timeline-year-marker::before {
    content: '';
    position: absolute;
    left: .65rem;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    background: var(--gold);
    border-radius: 50%;
    border: 3px solid var(--bg);
    box-shadow: 0 0 0 2px var(--gold);
}
.timeline-year-marker span {
    font-family: var(--font-head);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--ink);
    background: var(--bg);
    padding: 0 .6rem 0 0;
    position: relative;
    z-index: 1;
}

/* Timeline item */
.timeline-item {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: .9rem;
}

/* Dot on the line */
.timeline-dot {
    position: absolute;
    left: -2.05rem;
    top: .7rem;
    width: 10px;
    height: 10px;
    background: var(--accent);
    border: 2px solid var(--bg);
    border-radius: 50%;
    flex-shrink: 0;
}

/* Card */
.timeline-card {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .7rem 1rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .15s, transform .15s;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.timeline-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateX(2px);
}
.timeline-date {
    font-size: .8rem;
    font-weight: 500;
    color: var(--accent);
    white-space: nowrap;
    min-width: 130px;
    font-variant-numeric: tabular-nums;
}
.timeline-title {
    flex: 1;
    font-size: .97rem;
    color: var(--ink);
}
.timeline-actions {
    display: flex;
    gap: .8rem;
    font-size: .82rem;
    white-space: nowrap;
}

/* ── List View ─────────────────────────────────────────────── */
.list-view {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.events-table {
    width: 100%;
    border-collapse: collapse;
}
.events-table th {
    background: var(--bg-dark);
    color: #ccc;
    font-family: var(--font-body);
    font-weight: 500;
    font-size: .78rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    padding: .7rem 1.1rem;
    text-align: left;
}
.events-table td {
    padding: .75rem 1.1rem;
    border-top: 1px solid var(--border);
    font-size: .93rem;
    vertical-align: middle;
}
.events-table tr:hover td { background: var(--accent-soft); }

.date-cell {
    white-space: nowrap;
    color: var(--accent);
    font-size: .85rem;
    font-weight: 500;
    width: 170px;
}
.col-actions { width: 110px; }
.actions-cell {
    display: flex;
    gap: .8rem;
    font-size: .83rem;
}

/* Danger link */
.danger-link { color: #c0392b !important; }
.danger-link:hover { color: #922b21 !important; }

/* ── Category badges ───────────────────────────────────────── */
.cat-badge {
    display: inline-block;
    padding: .18rem .65rem;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    background: color-mix(in srgb, var(--cat-color) 14%, white);
    color: var(--cat-color);
    border: 1px solid color-mix(in srgb, var(--cat-color) 30%, white);
    white-space: nowrap;
}

/* ── Category filter bar ───────────────────────────────────── */
.cat-filter-bar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: .6rem 2rem;
}
.cat-filter-inner {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    gap: .45rem;
    flex-wrap: wrap;
    align-items: center;
}
.cat-pill {
    display: inline-block;
    padding: .28rem .85rem;
    border-radius: 20px;
    font-size: .8rem;
    font-weight: 500;
    border: 1.5px solid var(--border);
    color: var(--ink-mid);
    background: transparent;
    transition: all .15s;
    text-decoration: none !important;
}
.cat-pill:hover { border-color: var(--ink-mid); color: var(--ink); }
.cat-pill.active {
    background: var(--cat-color, var(--ink));
    border-color: var(--cat-color, var(--ink));
    color: #fff;
}

/* ── Category picker (form) ────────────────────────────────── */
.cat-picker {
    display: flex;
    gap: .4rem;
    flex-wrap: wrap;
}
.cat-pick-item input[type="radio"] { display: none; }
.cat-pick-label {
    display: inline-block;
    padding: .32rem .9rem;
    border-radius: 20px;
    font-size: .83rem;
    font-weight: 500;
    border: 1.5px solid var(--border);
    color: var(--ink-mid);
    cursor: pointer;
    transition: all .15s;
    user-select: none;
}
.cat-pick-label:hover { border-color: var(--cat-color); color: var(--cat-color); }
.cat-pick-item input:checked + .cat-pick-label {
    background: var(--cat-color);
    border-color: var(--cat-color);
    color: #fff;
}

/* ── Updated timeline card ─────────────────────────────────── */
.timeline-card {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .7rem 1rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .15s, transform .15s;
}
.timeline-card:hover { box-shadow: var(--shadow-md); transform: translateX(2px); }
.timeline-card-top {
    display: flex;
    align-items: center;
    gap: .7rem;
    flex-wrap: wrap;
}
.timeline-title { flex: 1; font-size: .97rem; color: var(--ink); }
.timeline-actions { display: flex; gap: .8rem; font-size: .82rem; white-space: nowrap; }

/* ── Photo gallery (timeline + shared view) ────────────────── */
.photo-gallery {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    margin-top: .65rem;
    padding-top: .65rem;
    border-top: 1px solid var(--border);
}
.photo-thumb {
    display: block;
    width: 80px;
    height: 80px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border);
    flex-shrink: 0;
    cursor: zoom-in;
    transition: transform .15s, box-shadow .15s;
}
.photo-thumb:hover { transform: scale(1.06); box-shadow: var(--shadow-md); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ── Upload area ───────────────────────────────────────────── */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    position: relative;
}
.upload-area:hover, .upload-area.drag-over {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.upload-input {
    position: absolute; inset: 0; width: 100%; height: 100%;
    opacity: 0; cursor: pointer;
}
.upload-placeholder { pointer-events: none; }
.upload-icon { font-size: 1.8rem; display: block; margin-bottom: .4rem; }
.upload-placeholder span { display: block; font-size: .9rem; color: var(--ink-mid); }
.upload-placeholder small { margin-top: .25rem; }

.photo-preview-row {
    display: flex;
    gap: .4rem;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: .75rem;
}
.preview-thumb {
    width: 70px; height: 70px;
    object-fit: cover;
    border-radius: 5px;
    border: 1px solid var(--border);
}

/* Existing photos in edit form */
.existing-photos {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
    margin-bottom: .75rem;
}
.existing-photo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .3rem;
}
.existing-photo img {
    width: 80px; height: 80px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
}
.photo-delete-check { font-size: .78rem; cursor: pointer; display: flex; align-items: center; gap: .25rem; }
.photo-delete-check input { cursor: pointer; accent-color: #c0392b; }

/* Photo count in list view */
.photo-count { font-size: .82rem; color: var(--ink-mid); white-space: nowrap; }

/* ── Lightbox ──────────────────────────────────────────────── */
.lightbox {
    display: none;
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,.88);
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}
.lightbox.open { display: flex; }
.lightbox img {
    max-width: 92vw;
    max-height: 90vh;
    border-radius: 6px;
    box-shadow: 0 8px 40px rgba(0,0,0,.6);
    object-fit: contain;
}
.lightbox-close {
    position: absolute; top: 1.2rem; right: 1.5rem;
    background: none; border: none; color: #fff;
    font-size: 1.6rem; cursor: pointer; line-height: 1;
    opacity: .7; transition: opacity .15s;
}
.lightbox-close:hover { opacity: 1; }

/* ── Shares page ───────────────────────────────────────────── */
.shares-list { display: flex; flex-direction: column; gap: 1rem; }
.share-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.2rem;
    display: flex;
    align-items: center;
    gap: 1.2rem;
    flex-wrap: wrap;
    box-shadow: var(--shadow-sm);
}
.share-info { flex: 1; min-width: 160px; }
.share-label { font-weight: 600; font-size: .95rem; margin-bottom: .15rem; }
.share-email { font-size: .82rem; color: var(--ink-mid); }
.share-created { font-size: .78rem; color: var(--ink-light); margin-top: .2rem; }
.share-link-row { display: flex; gap: .4rem; align-items: center; flex: 2; min-width: 220px; }
.share-link-input {
    flex: 1; font-size: .8rem; padding: .45rem .7rem;
    border: 1.5px solid var(--border); border-radius: var(--radius);
    font-family: monospace; color: var(--ink-mid);
    background: var(--bg); cursor: text;
}
.share-delete-form { margin: 0; }
.shared-badge {
    background: var(--accent-soft);
    color: var(--accent);
    padding: .25rem .75rem;
    border-radius: 20px;
    font-size: .8rem;
    font-weight: 500;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 640px) {
    .topbar { padding: 0 1rem; }
    .page-header { padding: 1.1rem 1rem; }
    .page-header-inner { flex-direction: column; align-items: flex-start; }
    .main-content { padding: 0 1rem; margin: 1.25rem auto; }
    .field-row { grid-template-columns: 1fr; }
    .date-fields { flex-direction: column; }
    .timeline { padding-left: 2.25rem; }
    .timeline-card-top { flex-direction: column; align-items: flex-start; gap: .35rem; }
    .timeline-dot { left: -1.3rem; }
    .form-card { padding: 1.25rem; }
    .share-card { flex-direction: column; align-items: flex-start; }
    .cat-filter-bar { padding: .5rem 1rem; }
}
