/* ====================================================
   ЛИНИЯ ЖИЗНИ — Page Styles
   ==================================================== */

/* ---- Hero ---- */
.page-hero {
    text-align: center;
    margin-bottom: 28px;
}

.page-hero .section-title {
    font-size: 3rem;
    margin-bottom: 8px;
}

.page-hero p {
    font-size: 1rem;
    color: #666;
    max-width: 620px;
    margin: 0 auto;
    line-height: 1.7;
}

@media (max-width: 600px) {
    .page-hero .section-title {
        font-size: 2rem;
    }
}

/* ---- Mode switcher ---- */
.mode-switcher {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

@media (max-width: 600px) {
    .mode-switcher {
        grid-template-columns: 1fr;
    }
}

.mode-card {
    border: 2px solid rgba(78, 79, 115, 0.2);
    border-radius: 14px;
    padding: 20px 24px;
    cursor: pointer;
    transition: all 0.22s;
    background: #fff;
    text-align: left;
}

.mode-card:hover {
    border-color: var(--primary-dark);
    box-shadow: 0 4px 16px rgba(78, 79, 115, 0.1);
}

.mode-card.active {
    border-color: var(--primary-dark);
    background: #f4f4f9;
    box-shadow: 0 4px 20px rgba(78, 79, 115, 0.12);
}

.mode-card-icon {
    font-size: 1.8rem;
    margin-bottom: 8px;
}

.mode-card-title {
    font-family: 'Lithium', serif;
    font-size: 1.4rem;
    color: var(--primary-dark);
    margin-bottom: 6px;
}

.mode-card-desc {
    font-size: 0.88rem;
    color: #777;
    line-height: 1.5;
}

.mode-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 9px;
    border-radius: 10px;
    margin-bottom: 8px;
    letter-spacing: 0.05em;
}

.badge-a {
    background: #eef0f8;
    color: var(--primary-dark);
}

.badge-b {
    background: #eafaf1;
    color: #1a7a44;
}

/* ---- Card ---- */
.ll-card {
    background: #fff;
    border-radius: 16px;
    padding: 22px 26px;
    box-shadow: 0 4px 18px rgba(78, 79, 115, 0.07);
    border: 1px solid rgba(78, 79, 115, 0.1);
    margin-bottom: 20px;
}

.ll-card h2 {
    font-family: 'Lithium', serif;
    font-size: 1.5rem;
    color: var(--primary-dark);
    margin-bottom: 16px;
}

/* ---- Form grid ---- */
.ll-form-grid {
    display: grid;
    grid-template-columns: 240px 1fr 280px;
    gap: 18px;
    align-items: start;
}

@media (max-width: 750px) {
    .ll-form-grid {
        grid-template-columns: 1fr;
    }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-weight: 700;
    font-size: 0.78rem;
    color: var(--text-dark);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-input {
    width: 100%;
    padding: 10px 13px;
    border: 1.5px solid rgba(78, 79, 115, 0.22);
    border-radius: 8px;
    font-family: 'OpenSans', sans-serif;
    font-size: 0.95rem;
    color: var(--text-dark);
    background: #fafafa;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    box-sizing: border-box;
}

.form-input:focus {
    border-color: var(--primary-dark);
    box-shadow: 0 0 0 3px rgba(78, 79, 115, 0.09);
    background: #fff;
}

textarea.form-input {
    resize: vertical;
    min-height: 70px;
}

/* ---- Score picker ---- */
.score-row {
    display: none;
    margin-top: 16px;
}

.score-row.visible {
    display: block;
}

.score-picker {
    display: grid;
    grid-template-columns: repeat(21, 1fr);
    gap: 4px;
}

.score-btn {
    /* width/height controlled by grid now */
    aspect-ratio: 1;
    border-radius: 8px;
    border: 2px solid transparent;
    font-family: 'OpenSans', sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    min-width: 0;
    /* allow shrink inside grid cell */
}

.score-btn.neg {
    background: #fdecea;
    color: #c0392b;
}

.score-btn.neu {
    background: #f0f2f5;
    color: #7f8c8d;
}

.score-btn.pos {
    background: #eafaf1;
    color: #1e8449;
}

.score-btn:hover {
    transform: scale(1.12);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.13);
}

.score-btn.active.neg {
    background: #e74c3c;
    color: #fff;
    border-color: #c0392b;
    transform: scale(1.18);
}

.score-btn.active.neu {
    background: #7f8c8d;
    color: #fff;
    border-color: #555;
    transform: scale(1.18);
}

.score-btn.active.pos {
    background: #27ae60;
    color: #fff;
    border-color: #1a7a44;
    transform: scale(1.18);
}

/* Score hint — 3-column grid so labels align exactly under −10, 0, +10 */
.score-hint {
    display: grid;
    /* 10 negative buttons | 1 zero button | 10 positive buttons */
    /* Each button is 38px, gap 5px → one "unit" = 43px                */
    /* Proportions: left col covers buttons 1-10, mid = button 11, right = 12-21 */
    grid-template-columns: 10fr 1fr 10fr;
    margin-top: 6px;
}

.score-hint-col {
    display: flex;
}

.score-hint-left {
    justify-content: flex-start;
}

.score-hint-mid {
    justify-content: center;
}

.score-hint-right {
    justify-content: flex-end;
}

.score-hint span {
    font-size: 0.73rem;
    white-space: nowrap;
}

/* ---- Collapsible example section ---- */
.example-summary {
    /* Looks like an h2 but is clickable */
    font-family: 'Lithium', serif;
    font-size: 2rem;
    color: var(--primary-dark);
    cursor: pointer;
    list-style: none;
    /* hide default triangle in Firefox */
    display: flex;
    align-items: center;
    gap: 10px;
    user-select: none;
    margin-bottom: 0;
    padding-bottom: 4px;
}

/* Hide default WebKit disclosure triangle */
.example-summary::-webkit-details-marker {
    display: none;
}

/* Custom chevron */
.example-summary::after {
    content: '›';
    display: inline-block;
    font-size: 1.6rem;
    line-height: 1;
    color: rgba(78, 79, 115, 0.4);
    transition: transform 0.25s ease;
    margin-left: 4px;
}

.example-details[open]>.example-summary::after {
    transform: rotate(90deg);
}

.example-details[open]>.example-summary {
    margin-bottom: 6px;
}

/* ---- Color grid ---- */
.color-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 2px;
}

.color-option {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
}

.color-option:hover {
    transform: scale(1.15);
}

.color-option.selected {
    border-color: #222;
    transform: scale(1.12);
}

/* ---- Color legend editor ---- */
.legend-editor-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1px dashed rgba(78, 79, 115, 0.3);
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 0.82rem;
    color: #888;
    cursor: pointer;
    font-family: 'OpenSans', sans-serif;
    transition: all 0.2s;
    margin-top: 6px;
}

.legend-editor-toggle:hover {
    background: var(--primary-dark);
    color: #fff;
    border-color: var(--primary-dark);
}

.legend-editor-panel {
    display: none;
    margin-top: 14px;
    background: #f8f9fa;
    border-radius: 12px;
    padding: 16px 18px;
}

.legend-editor-panel.open {
    display: block;
}

.legend-editor-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #999;
    margin-bottom: 12px;
}

.legend-editor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
}

.legend-editor-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-color-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-label-input {
    flex: 1;
    padding: 5px 9px;
    border: 1.5px solid rgba(78, 79, 115, 0.2);
    border-radius: 6px;
    font-family: 'OpenSans', sans-serif;
    font-size: 0.82rem;
    color: var(--text-dark);
    background: #fff;
    outline: none;
    transition: border-color 0.2s;
}

.legend-label-input:focus {
    border-color: var(--primary-dark);
}

.legend-label-input::placeholder {
    color: #ccc;
}

/* Chip color-name tag */
.chip-tag {
    display: inline-block;
    font-size: 0.72rem;
    padding: 1px 7px;
    border-radius: 10px;
    margin-left: 4px;
    font-weight: 600;
    opacity: 0.85;
    vertical-align: middle;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 22px;
    border-radius: 8px;
    font-size: 0.93rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.22s;
    font-family: 'OpenSans', sans-serif;
    text-decoration: none;
    border: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary-dark);
    color: #fff;
}

.btn-primary:hover {
    background: #3d3e5c;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(78, 79, 115, 0.3);
}

.btn-outline {
    background: #fff;
    color: var(--primary-dark);
    border: 2px solid var(--primary-dark);
}

.btn-outline:hover {
    background: var(--primary-dark);
    color: #fff;
    transform: translateY(-1px);
}

.btn-danger {
    background: #fff;
    color: #c0392b;
    border: 2px solid #c0392b;
}

.btn-danger:hover {
    background: #c0392b;
    color: #fff;
}

/* Larger download button modifier */
.btn-lg {
    padding: 14px 20px;
    font-size: 1rem;
    width: 100%;
}

.age-month-row {
    display: flex;
    gap: 10px;
}

#inputAge {
    flex: 0 0 85px;
    /* Fixed width for age/year */
}

.month-select {
    flex: 1;
    /* Month takes the rest */
    min-width: 0;
}

/* ---- Color ideas block ---- */
.color-ideas {
    background: #f8f9ff;
    border: 1px solid rgba(78, 79, 115, 0.12);
    border-radius: 14px;
    padding: 20px 24px;
    margin-bottom: 28px;
}

.color-ideas-title {
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--primary-dark);
    margin-bottom: 16px;
}

.color-ideas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 18px;
}

.color-idea-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: #bbb;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.color-idea-items {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* CSS custom-property pill — works in modern browsers */
.color-idea-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px 3px 7px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: default;
    /* Fallback for older browsers */
    background: rgba(78, 79, 115, 0.08);
    color: #555;
    border: 1.5px solid rgba(78, 79, 115, 0.15);
}

/* Colour dot before pill text */
.color-idea-pill::before {
    content: '';
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--c, #4E4F73);
    flex-shrink: 0;
}

.form-add-row {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.form-error {
    color: #e74c3c;
    font-size: 0.84rem;
    display: none;
}

/* ---- Birth year bar ---- */
.birth-year-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8f9fa;
    border-radius: 10px;
    padding: 10px 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.birth-year-bar label {
    font-size: 0.85rem;
    color: #777;
    white-space: nowrap;
}

.birth-year-bar input {
    width: 100px;
    padding: 6px 10px;
    border: 1.5px solid rgba(78, 79, 115, 0.22);
    border-radius: 7px;
    font-family: 'OpenSans', sans-serif;
    font-size: 0.9rem;
    outline: none;
    background: #fff;
    transition: border-color 0.2s;
}

.birth-year-bar input:focus {
    border-color: var(--primary-dark);
}

.birth-year-note {
    font-size: 0.8rem;
    color: #aaa;
    font-style: italic;
}

.age-year-hint {
    font-size: 0.75rem;
    color: #27ae60;
    margin-top: 4px;
    min-height: 14px;
}

/* ---- Chart ---- */
.ll-chart-card {
    background: #fff;
    border-radius: 16px;
    padding: 18px 22px;
    box-shadow: 0 4px 18px rgba(78, 79, 115, 0.07);
    border: 1px solid rgba(78, 79, 115, 0.1);
    margin-bottom: 20px;
}

#lifeLineCanvas {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 6px;
}

.chart-hint {
    font-size: 0.8rem;
    color: #ccc;
    text-align: center;
    margin-top: 6px;
}

/* ---- Bottom grid ---- */
.ll-bottom {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 20px;
    align-items: start;
}

@media (max-width: 650px) {
    .ll-bottom {
        grid-template-columns: 1fr;
    }
}

.ll-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ll-actions h2 {
    font-size: 1.1rem;
    margin-bottom: 10px;
}

/* ---- Events list ---- */
.events-card {
    max-height: 380px;
    overflow-y: auto;
    padding: 18px 20px !important;
}

.events-card h2 {
    font-size: 1.3rem !important;
    margin-bottom: 10px !important;
    position: sticky;
    top: 0;
    background: #fff;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(78, 79, 115, 0.1);
}

.events-card::-webkit-scrollbar {
    width: 4px;
}

.events-card::-webkit-scrollbar-thumb {
    background: rgba(78, 79, 115, 0.2);
    border-radius: 4px;
}

.event-chip {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 9px 11px;
    border-radius: 9px;
    margin-bottom: 7px;
    background: #f8f9fa;
    font-size: 0.87rem;
    line-height: 1.4;
    transition: background 0.2s;
}

.event-chip:hover {
    background: #eef0f6;
}

.event-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 3px;
}

.event-chip-body {
    flex: 1;
}

.event-chip-meta {
    font-weight: 700;
    color: var(--primary-dark);
}

.event-chip-text {
    color: #555;
    margin-top: 2px;
}

.event-chip-score {
    font-weight: 800;
    font-size: 0.93rem;
    flex-shrink: 0;
}

.event-chip-delete {
    background: none;
    border: none;
    cursor: pointer;
    color: #ccc;
    font-size: 1.1rem;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
    flex-shrink: 0;
}

.event-chip-delete:hover {
    color: #e74c3c;
}

.events-empty {
    text-align: center;
    padding: 22px;
    color: #ccc;
    font-size: 0.88rem;
}

/* ============================================
   EXAMPLE SECTION (below bottom panel)
   ============================================ */
.example-section {
    margin-top: 36px;
    padding-top: 36px;
    border-top: 2px dashed rgba(78, 79, 115, 0.12);
}

.example-section h2 {
    font-family: 'Lithium', serif;
    font-size: 2rem;
    color: var(--primary-dark);
    margin-bottom: 6px;
}

.example-section p.subtitle {
    font-size: 0.93rem;
    color: #888;
    margin-bottom: 24px;
}

.example-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    align-items: start;
}

@media (max-width: 700px) {
    .example-layout {
        grid-template-columns: 1fr;
    }
}

/* Example text block */
.example-text-block {
    background: #fffcf5;
    border: 1px solid rgba(244, 196, 48, 0.35);
    border-radius: 14px;
    padding: 22px 26px;
}

.example-text-block h3 {
    font-family: 'Lithium', serif;
    font-size: 1.2rem;
    color: var(--primary-dark);
    margin-bottom: 14px;
}

.example-event-list {
    list-style: none;
    padding: 0;
}

.example-event-item {
    display: flex;
    gap: 10px;
    align-items: baseline;
    padding: 6px 0;
    border-bottom: 1px solid rgba(78, 79, 115, 0.06);
    font-size: 0.88rem;
    line-height: 1.5;
}

.example-event-item:last-child {
    border-bottom: none;
}

.ex-age {
    font-weight: 700;
    color: var(--primary-dark);
    white-space: nowrap;
    min-width: 52px;
}

.ex-text {
    color: #555;
}

.ex-score {
    font-weight: 800;
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* Example chart block */
.example-chart-block {
    background: #fff;
    border: 1px solid rgba(78, 79, 115, 0.1);
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 3px 12px rgba(78, 79, 115, 0.06);
}

.example-chart-block h3 {
    font-family: 'Lithium', serif;
    font-size: 1.2rem;
    color: var(--primary-dark);
    margin-bottom: 10px;
}

#exampleCanvas {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 6px;
}

/* ================================================================
   ONBOARDING / TOUR
   ================================================================ */
/* Onboarding backdrop (dark dimming) */
.onboarding-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(14, 15, 31, 0.65);
    backdrop-filter: blur(3px);
    z-index: 5000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.onboarding-backdrop.active {
    opacity: 1;
}

/* Onboarding overlay wrapper (holds the card above the highlight) */
.onboarding-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 40px;
}

.onboarding-overlay.active {
    opacity: 1;
}

.onboarding-overlay.align-top {
    align-items: flex-start;
    padding-top: 40px;
    padding-bottom: 0;
}

.onboarding-card {
    background: #fff;
    width: 95%;
    max-width: 440px;
    padding: 24px 32px;
    border-radius: 28px;
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.4);
    position: relative;
    transform: translateY(30px);
    transition: transform 0.5s cubic-bezier(0.19, 1, 0.22, 1);
    text-align: center;
    pointer-events: auto;
    z-index: 5100;
    /* Above overlay shadow */
}

.onboarding-overlay.active .onboarding-card {
    transform: translateY(0);
}

.onboarding-title {
    font-family: 'Lithium', serif;
    font-size: 1.6rem;
    color: var(--primary-dark);
    margin-bottom: 8px;
}

.onboarding-text {
    font-size: 0.95rem;
    color: #444;
    line-height: 1.5;
    margin-bottom: 20px;
}

.onboarding-footer {
    display: flex;
    justify-content: center;
}

.tour-highlight {
    position: relative;
    z-index: 5050 !important;
    pointer-events: auto !important;
    outline: 4px solid var(--primary-dark);
    outline-offset: 4px;
    background: #fff;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
    border-radius: inherit;
    scroll-margin-top: 80px;
}

/* Onboarding / Peeking Panda Widget */
.onboarding-help-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 110px;
    height: 110px;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 6000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* The glass circle behind panda */
.onboarding-help-btn::before {
    content: '';
    position: absolute;
    bottom: 5px;
    width: 70px;
    height: 70px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(8px);
    border-radius: 50%;
    box-shadow: 0 10px 30px rgba(78, 79, 115, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.4);
    z-index: -1;
    transition: all 0.4s ease;
    animation: helpPulse 3s infinite;
}

.onboarding-help-btn:hover {
    transform: translateY(-8px) scale(1.05);
}

.onboarding-help-btn:hover::before {
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 15px 40px rgba(78, 79, 115, 0.25);
    transform: scale(1.1);
}

.panda-icon {
    width: 90px;
    height: 90px;
    object-fit: contain;
    filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.1));
    transition: transform 0.4s ease;
}

.onboarding-help-btn:hover .panda-icon {
    transform: rotate(-5deg) translateY(-3px);
}

.onboarding-help-text {
    position: absolute;
    bottom: -4px;
    font-family: 'OpenSans', sans-serif;
    font-size: 0.95rem;
    /* Larger and clearer */
    font-weight: 700;
    color: #fff;
    /* White text for better contrast */
    background: #5d4037;
    /* Dark brown background */
    padding: 4px 16px;
    border-radius: 20px;
    box-shadow: 0 6px 15px rgba(93, 64, 55, 0.3);
    white-space: nowrap;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.onboarding-help-btn:hover .onboarding-help-text {
    transform: translateY(-4px) scale(1.05);
    background: var(--primary-dark);
    /* Changes to primary on hover */
    box-shadow: 0 8px 20px rgba(78, 79, 115, 0.4);
}

/* Subtle pulse for the shadow */
@keyframes helpPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(78, 79, 115, 0.2);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(78, 79, 115, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(78, 79, 115, 0);
    }
}

/* Hide help button when tour is open */
.onboarding-overlay.active~.onboarding-help-btn {
    display: none;
}

@media (max-width: 768px) {
    .onboarding-overlay {
        padding-bottom: 20px;
    }

    .onboarding-overlay.align-top {
        padding-top: 20px;
    }

    .onboarding-card {
        padding: 24px 20px;
    }
}