/* Tell My Memories: warm paper and ink, readable long text. */

:root,
[data-bs-theme=light] {
    --tm-bg: #f7f2ea;
    --tm-surface: #fffdf9;
    --tm-ink: #2d2620;
    --tm-muted: #6f655b;
    --tm-border: #e4d9c8;
    --tm-chip: #efe5d6;
    --tm-accent: #9c4f27;
    --tm-accent-hover: #833f1c;
    --tm-accent-ink: #ffffff;
    --tm-accent-soft: #f5e3d6;

    /* Timeline parts of life: checked for colorblind separation on --tm-surface */
    --tl-c0: #9a9087;
    --tl-c1: #2a78d6;
    --tl-c2: #eb6834;
    --tl-c3: #1baf7a;
    --tl-c4: #eda100;
    --tl-c5: #e87ba4;
    --tl-c6: #008300;
    --tl-c7: #6250d6;
    --tl-c8: #e34948;
    --tl-grid: #f1e9dd;

    --bs-body-bg: var(--tm-bg);
    --bs-body-color: var(--tm-ink);
    --bs-secondary-color: var(--tm-muted);
    --bs-border-color: var(--tm-border);
    --bs-link-color-rgb: 156, 79, 39;
    --bs-link-hover-color-rgb: 131, 63, 28;
    --bs-font-sans-serif: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

[data-bs-theme=dark] {
    --tm-bg: #1b1815;
    --tm-surface: #25211d;
    --tm-ink: #ece4d8;
    --tm-muted: #b0a493;
    --tm-border: #3b342c;
    --tm-chip: #332c25;
    --tm-accent: #e3915f;
    --tm-accent-hover: #eda57a;
    --tm-accent-ink: #1b1815;
    --tm-accent-soft: #3a2a1f;

    --tl-c0: #7d7368;
    --tl-c1: #3987e5;
    --tl-c2: #d95926;
    --tl-c3: #199e70;
    --tl-c4: #c98500;
    --tl-c5: #d55181;
    --tl-c6: #0ca30c;
    --tl-c7: #9085e9;
    --tl-c8: #e66767;
    --tl-grid: #2e2924;

    --bs-body-bg: var(--tm-bg);
    --bs-body-color: var(--tm-ink);
    --bs-secondary-color: var(--tm-muted);
    --bs-border-color: var(--tm-border);
    --bs-link-color-rgb: 227, 145, 95;
    --bs-link-hover-color-rgb: 237, 165, 122;
}

body {
    background: var(--tm-bg);
    color: var(--tm-ink);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3, .serif {
    font-family: 'Lora', Georgia, serif;
}

a {
    text-underline-offset: 2px;
}

/* ------------------------------------------------------------ layout */

.site-nav {
    background: var(--tm-surface);
    border-bottom: 1px solid var(--tm-border);
}

.site-nav .navbar-brand {
    font-family: 'Lora', Georgia, serif;
    font-weight: 600;
    font-size: 1.35rem;
    color: var(--tm-ink);
}

.site-nav .navbar-brand em {
    color: var(--tm-accent);
}

.site-nav .nav-link {
    color: var(--tm-muted);
    font-weight: 500;
}

.site-nav .nav-link:hover,
.site-nav .nav-link.active {
    color: var(--tm-ink);
}

.site-nav .nav-link.active {
    text-decoration: underline;
    text-decoration-color: var(--tm-accent);
    text-decoration-thickness: 2px;
    text-underline-offset: 6px;
}

.site-main {
    flex: 1;
    padding-top: 2rem;
    padding-bottom: 3rem;
    max-width: 960px;
}

.site-footer {
    border-top: 1px solid var(--tm-border);
    color: var(--tm-muted);
    font-size: 0.875rem;
    padding: 1.25rem 0;
}

/* ------------------------------------------------------------ pieces */

.panel {
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    border-radius: 16px;
    padding: 1.75rem;
}

@media (max-width: 576px) {
    .panel {
        padding: 1.25rem;
    }
}

.btn-accent {
    background: var(--tm-accent);
    border-color: var(--tm-accent);
    color: var(--tm-accent-ink);
    font-weight: 500;
}

.btn-accent:hover,
.btn-accent:focus {
    background: var(--tm-accent-hover);
    border-color: var(--tm-accent-hover);
    color: var(--tm-accent-ink);
}

.btn-quiet {
    border: 1px solid var(--tm-border);
    color: var(--tm-ink);
    background: transparent;
}

.btn-quiet:hover {
    background: var(--tm-chip);
    color: var(--tm-ink);
}

.form-control,
.form-select {
    background-color: var(--tm-surface);
    border-color: var(--tm-border);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--tm-accent);
    box-shadow: 0 0 0 0.2rem var(--tm-accent-soft);
}

.page-title {
    font-size: 1.9rem;
    margin-bottom: 0.25rem;
}

.lead-muted {
    color: var(--tm-muted);
    margin-bottom: 1.5rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: var(--tm-chip);
    color: var(--tm-ink);
    border-radius: 999px;
    padding: 0.2rem 0.75rem;
    font-size: 0.875rem;
    text-decoration: none;
    margin: 0 0.35rem 0.4rem 0;
}

a.chip:hover {
    background: var(--tm-accent-soft);
    color: var(--tm-ink);
}

.chip small {
    color: var(--tm-muted);
}

.meta {
    color: var(--tm-muted);
    font-size: 0.925rem;
}

.material-icons-outlined {
    font-size: 1.15em;
    vertical-align: -0.2em;
}

/* ------------------------------------------------------------ recording */

.record-text {
    font-family: 'Lora', Georgia, serif;
    font-size: 1.15rem;
    line-height: 1.7;
    min-height: 240px;
}

.mic-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: var(--tm-accent);
    color: var(--tm-accent-ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.mic-btn .material-icons-outlined {
    font-size: 1.6rem;
    vertical-align: 0;
}

.mic-btn.listening {
    background: #c0392b;
    color: #fff;
    animation: tm-pulse 1.5s infinite;
}

.mic-btn:disabled {
    opacity: 0.45;
}

@keyframes tm-pulse {
    0% { box-shadow: 0 0 0 0 rgba(192, 57, 43, 0.6); }
    70% { box-shadow: 0 0 0 14px rgba(192, 57, 43, 0); }
    100% { box-shadow: 0 0 0 0 rgba(192, 57, 43, 0); }
}

.prompt-box {
    background: var(--tm-accent-soft);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    font-family: 'Lora', Georgia, serif;
    font-style: italic;
}

/* ------------------------------------------------------------ memories */

.memory-item {
    display: block;
    padding: 1.1rem 0;
    border-bottom: 1px solid var(--tm-border);
    color: inherit;
    text-decoration: none;
}

.memory-item:last-child {
    border-bottom: none;
}

.memory-item:hover .memory-item-title {
    color: var(--tm-accent);
}

.memory-item-title {
    font-family: 'Lora', Georgia, serif;
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.15rem;
}

.story {
    font-family: 'Lora', Georgia, serif;
    font-size: 1.15rem;
    line-height: 1.8;
    max-width: 68ch;
}

.story p {
    margin-bottom: 1.1em;
}

.own-words {
    white-space: pre-wrap;
    color: var(--tm-muted);
    font-size: 0.95rem;
    border-left: 3px solid var(--tm-border);
    padding-left: 1rem;
}

.timeline-decade {
    font-family: 'Lora', Georgia, serif;
    font-size: 1.6rem;
    margin: 2rem 0 0.5rem;
}

.timeline-year {
    display: flex;
    gap: 1.25rem;
    border-left: 2px solid var(--tm-border);
    margin-left: 0.5rem;
    padding: 0.4rem 0 0.4rem 1.25rem;
}

.timeline-year-label {
    flex: 0 0 4.5rem;
    font-weight: 600;
    color: var(--tm-accent);
}

/* The chart: years left to right, one mark per memory (drawn by app.js) */

.tl-panel {
    position: relative;
    padding-bottom: 0.75rem;
}

.tl-c0 { --tl-color: var(--tl-c0); }
.tl-c1 { --tl-color: var(--tl-c1); }
.tl-c2 { --tl-color: var(--tl-c2); }
.tl-c3 { --tl-color: var(--tl-c3); }
.tl-c4 { --tl-color: var(--tl-c4); }
.tl-c5 { --tl-color: var(--tl-c5); }
.tl-c6 { --tl-color: var(--tl-c6); }
.tl-c7 { --tl-color: var(--tl-c7); }
.tl-c8 { --tl-color: var(--tl-c8); }

.tl-legend {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1.1rem;
    padding: 0;
    margin: 0 0 1rem;
    font-size: 0.875rem;
    color: var(--tm-muted);
}

.tl-legend li {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.tl-key {
    flex: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--tl-color);
}

.tl-key-hollow {
    background: transparent;
    border: 2px solid var(--tm-muted);
}

.tl-scroll {
    overflow-x: auto;
    overflow-y: hidden;
}

.tl-chart {
    position: relative;
}

.tl-plot {
    position: relative;
}

.tl-grid {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--tl-grid);
}

.tl-item {
    position: absolute;
    height: 30px;
    display: flex;
    align-items: center;
    gap: 6px;              /* GAP in app.js */
    color: var(--tm-ink);
    text-decoration: none;
    font-size: 0.85rem;
    white-space: nowrap;
}

.tl-item.tl-left {
    flex-direction: row-reverse;
}

.tl-mark {
    flex: none;
    height: 10px;
    border-radius: 5px;
    background: var(--tl-color);
    box-shadow: 0 0 0 2px var(--tm-surface);
}

.tl-est .tl-mark {
    background: var(--tm-surface);
    border: 2px solid var(--tl-color);
}

.tl-label {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.tl-item:hover .tl-label,
.tl-item:focus-visible .tl-label {
    color: var(--tm-accent);
    text-decoration: underline;
}

.tl-item:focus-visible {
    outline: 2px solid var(--tm-accent);
    outline-offset: 2px;
    border-radius: 4px;
}

.tl-axis {
    position: relative;
    height: 44px;
    border-top: 1px solid var(--tm-border);
    font-size: 0.8rem;
    color: var(--tm-muted);
    font-variant-numeric: tabular-nums;
}

.tl-tick,
.tl-age {
    position: absolute;
    transform: translateX(-50%);
    white-space: nowrap;
}

.tl-tick {
    top: 5px;
}

.tl-age {
    top: 23px;
    font-size: 0.75rem;
}

.tl-tip {
    position: absolute;
    z-index: 5;
    max-width: 260px;
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    border-radius: 10px;
    padding: 0.5rem 0.75rem;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    font-size: 0.85rem;
    pointer-events: none;
}

.tl-tip strong {
    display: block;
    font-weight: 600;
}

.tl-tip span {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--tm-muted);
}

.tl-tip i {
    flex: none;
    width: 12px;
    height: 2px;
    background: var(--tl-color);
}

/* ------------------------------------------------------------ book */

.book-title-page {
    text-align: center;
    padding: 3rem 0 2rem;
}

.book-title-page h1 {
    font-size: 2.6rem;
}

.book-memory {
    padding: 2rem 0;
    border-top: 1px solid var(--tm-border);
}

.book-memory h2 {
    font-size: 1.5rem;
    margin-bottom: 0.2rem;
}

@media print {
    .no-print {
        display: none !important;
    }

    body,
    .panel {
        background: #fff !important;
        color: #000 !important;
        border: none !important;
    }

    .site-main {
        max-width: none;
        padding: 0;
    }

    .story {
        font-size: 12pt;
        max-width: none;
    }

    .book-title-page {
        break-after: page;
        padding-top: 30vh;
    }

    .book-memory {
        border: none;
        break-before: page;
    }

    .meta {
        color: #444 !important;
    }
}
