/* Promo (promo.*) — статистика книг на внешних площадках.
   Цвета — из variables.css основного сайта (светлая/тёмная тема через data-theme). */

.promo {
    --promo-bg: var(--bg-primary, #fafaf9);
    --promo-surface: var(--bg-surface, var(--card-bg, #ffffff));
    --promo-surface-2: var(--bg-secondary, #f4f4f2);
    --promo-text: var(--color-text-primary, var(--color-text, #1a1a1a));
    --promo-muted: var(--color-text-secondary, var(--color-text-muted, #6b6b6b));
    --promo-border: var(--color-border, #e5e5e2);
    --promo-accent: var(--color-primary, #4f46e5);
    --promo-ok: var(--color-success, #16a34a);
    --promo-danger: var(--color-danger, #dc2626);
    --promo-radius: var(--radius-lg, 12px);

    /* Графики (палитра dataviz: слоты 1–3 в фиксированном порядке; жанр — нейтральный серый) */
    --viz-views: #2a78d6;
    --viz-saved: #eb6834;
    --viz-library: #1baf7a;
    --viz-grid: rgba(0, 0, 0, 0.07);
    --viz-band: rgba(82, 81, 78, 0.14);
    --viz-median: #8a8984;

    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--promo-bg);
    color: var(--promo-text);
    font-family: var(--font-family, 'Inter', system-ui, -apple-system, sans-serif);
    font-size: 15px;
    line-height: 1.5;
}

[data-theme="dark"] .promo {
    --viz-views: #3987e5;
    --viz-saved: #d95926;
    --viz-library: #199e70;
    --viz-grid: rgba(255, 255, 255, 0.08);
    --viz-band: rgba(195, 194, 183, 0.16);
    --viz-median: #9d9c93;
}

.promo *, .promo *::before, .promo *::after { box-sizing: border-box; }
.promo a { color: var(--promo-accent); text-decoration: none; }
.promo a:hover { text-decoration: underline; }

.promo-container { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.promo-main { flex: 1; padding: 28px 0 48px; }

/* ---------- header / footer ---------- */
.promo-header { border-bottom: 1px solid var(--promo-border); background: var(--promo-surface); }
.promo-header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; }
.promo-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--promo-text) !important; text-decoration: none !important; }
.promo-brand-mark {
    display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
    background: var(--promo-accent); color: #fff; font-size: 15px;
}
.promo-brand-sub { color: var(--promo-muted); font-weight: 500; }
.promo-nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; font-size: 14px; }
.promo-nav a { color: var(--promo-muted); }
.promo-nav a.is-active { color: var(--promo-text); font-weight: 600; }
.promo-user { color: var(--promo-muted); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.promo-footer { border-top: 1px solid var(--promo-border); padding: 18px 0; font-size: 13px; color: var(--promo-muted); }

/* ---------- basics ---------- */
.promo h1 { font-size: 28px; line-height: 1.2; margin: 0 0 8px; }
.promo h2 { font-size: 19px; margin: 0 0 14px; }
.promo h3 { font-size: 15px; margin: 0 0 10px; }
.promo-muted { color: var(--promo-muted); }
.promo-small { font-size: 13px; }
.promo-section { margin-top: 32px; }
.promo-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.promo-section-head h2 { margin: 0; }

.promo-card {
    background: var(--promo-surface); border: 1px solid var(--promo-border);
    border-radius: var(--promo-radius); padding: 20px;
}

.promo-flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-size: 14px; border: 1px solid; }
.promo-flash-ok { border-color: color-mix(in srgb, var(--promo-ok) 40%, transparent); background: color-mix(in srgb, var(--promo-ok) 10%, transparent); }
.promo-flash-err { border-color: color-mix(in srgb, var(--promo-danger) 40%, transparent); background: color-mix(in srgb, var(--promo-danger) 10%, transparent); }

/* ---------- forms / buttons ---------- */
.promo-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px; border-radius: 9px; border: 1px solid var(--promo-accent);
    background: var(--promo-accent); color: #fff !important; font: inherit; font-weight: 600; font-size: 14px;
    cursor: pointer; text-decoration: none !important; white-space: nowrap;
}
.promo-btn:hover { filter: brightness(1.08); }
.promo-btn-sm { padding: 6px 12px; font-size: 13px; }
.promo-btn-ghost { background: transparent; color: var(--promo-text) !important; border-color: var(--promo-border); }
.promo-btn-ghost:hover { background: var(--promo-surface-2); filter: none; }
.promo-btn-danger { background: transparent; color: var(--promo-danger) !important; border-color: color-mix(in srgb, var(--promo-danger) 45%, transparent); }
.promo-link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--promo-muted); cursor: pointer; font-size: 13px; }
.promo-link-btn:hover { color: var(--promo-danger); }

.promo-inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.promo-input {
    flex: 1 1 260px; min-width: 0; padding: 9px 12px; border-radius: 9px;
    border: 1px solid var(--promo-border); background: var(--promo-bg); color: var(--promo-text); font: inherit; font-size: 14px;
}
.promo-input:focus { outline: 2px solid color-mix(in srgb, var(--promo-accent) 50%, transparent); outline-offset: 1px; }

/* ---------- landing ---------- */
.promo-hero { padding: 40px 0 8px; max-width: 720px; }
.promo-hero h1 { font-size: 36px; }
.promo-hero p { font-size: 17px; color: var(--promo-muted); margin: 10px 0 24px; }
.promo-features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 36px; }
.promo-features .promo-card p { margin: 0; color: var(--promo-muted); font-size: 14px; }

/* ---------- account ---------- */
.promo-steps { margin: 12px 0 16px; padding-left: 20px; }
.promo-steps li { margin-bottom: 8px; }
.promo-code {
    display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-family-mono, ui-monospace, monospace);
    background: var(--promo-surface-2); border: 1px dashed var(--promo-border); border-radius: 8px; padding: 4px 10px; font-size: 15px;
}
.promo-account-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.promo-badge {
    display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
    background: var(--promo-surface-2); color: var(--promo-muted); border: 1px solid var(--promo-border);
}
.promo-badge-ok { color: var(--promo-ok); border-color: color-mix(in srgb, var(--promo-ok) 40%, transparent); }

/* ---------- book cards ---------- */
.promo-books { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.promo-book { display: flex; flex-direction: column; gap: 12px; }
.promo-book-title { font-weight: 600; font-size: 16px; line-height: 1.3; color: var(--promo-text) !important; }
.promo-book-meta { font-size: 13px; color: var(--promo-muted); }
.promo-book-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: auto; font-size: 12px; color: var(--promo-muted); }

.promo-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.promo-metric { background: var(--promo-surface-2); border-radius: 9px; padding: 8px 10px; min-width: 0; }
.promo-metric-label { font-size: 12px; color: var(--promo-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.promo-metric-value { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.promo-delta { font-size: 12px; font-weight: 600; color: var(--promo-muted); font-variant-numeric: tabular-nums; }
.promo-delta-up { color: var(--promo-ok); }

.promo-empty { text-align: center; padding: 28px 16px; color: var(--promo-muted); }

/* ---------- work page ---------- */
.promo-back { font-size: 14px; display: inline-block; margin-bottom: 14px; }
.promo-work-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.promo-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.promo-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 22px; }
.promo-kpi .promo-metric-value { font-size: 24px; }
.promo-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }

.promo-chart-wrap { position: relative; height: 240px; }
.promo-chart-note { font-size: 12px; color: var(--promo-muted); margin-top: 8px; }

.promo-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; height: 90px; margin-top: 12px; }
.promo-weekday { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; font-size: 11px; color: var(--promo-muted); }
.promo-weekday-bar { width: 70%; min-height: 2px; background: var(--viz-views); border-radius: 4px 4px 0 0; }

.promo-stat-list { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; font-size: 14px; }
.promo-stat-list dt { color: var(--promo-muted); }
.promo-stat-list dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

.promo-table-wrap { overflow-x: auto; }
.promo-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.promo-table th, .promo-table td { padding: 7px 10px; border-bottom: 1px solid var(--promo-border); text-align: right; white-space: nowrap; }
.promo-table th:first-child, .promo-table td:first-child { text-align: left; }
.promo-table th { color: var(--promo-muted); font-weight: 600; font-size: 12px; }
.promo-table td.promo-left { text-align: left; white-space: normal; }

.promo details > summary { cursor: pointer; font-weight: 600; }

@media (max-width: 600px) {
    .promo-hero h1 { font-size: 28px; }
    .promo h1 { font-size: 23px; }
    .promo-nav { gap: 12px; }
    .promo-user { display: none; }
    .promo-books { grid-template-columns: 1fr; }
}

/* ---------- work page: шапка ---------- */
.promo-work-side { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; text-align: right; }
.promo-top-now { margin-top: 10px; font-size: 14px; font-weight: 600; color: var(--promo-ok); }

/* ---------- среди ровесников ---------- */
.promo-peer { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--promo-muted); }
.promo-peer.is-up { color: var(--promo-ok); }
.promo-peer-bar { flex: 0 0 64px; height: 6px; border-radius: 3px; background: var(--promo-surface-2); overflow: hidden; }
.promo-peer-bar span { display: block; height: 100%; background: currentColor; border-radius: 3px; }

.promo-peers { display: flex; flex-direction: column; gap: 16px; }
.promo-peer-head { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.promo-peer-head b { font-variant-numeric: tabular-nums; }
.promo-peer-scale {
    position: relative; height: 8px; margin: 8px 0 4px; border-radius: 4px;
    background: linear-gradient(90deg, var(--promo-surface-2) 0 25%, var(--viz-band) 25% 75%, var(--promo-surface-2) 75% 100%);
}
.promo-peer-mid { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; background: var(--viz-median); }
.promo-peer-dot {
    position: absolute; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%;
    background: var(--viz-views); border: 2px solid var(--promo-surface);
}
.promo-peer-foot { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--promo-muted); }

/* ---------- советы ---------- */
.promo-recs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.promo-rec { border-left: 3px solid var(--promo-border); padding: 4px 0 4px 12px; }
.promo-rec-warn { border-left-color: var(--color-warning, #d97706); }
.promo-rec-tip { border-left-color: var(--promo-accent); }
.promo-rec-good { border-left-color: var(--promo-ok); }
.promo-rec-level { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--promo-muted); }
.promo-rec-title { font-weight: 600; margin: 2px 0; }
.promo-rec-text { font-size: 14px; color: var(--promo-muted); }

/* ---------- структура библиотеки ---------- */
.promo-stack { display: flex; gap: 2px; height: 12px; margin-top: 8px; border-radius: 4px; overflow: hidden; }
.promo-stack span { display: block; height: 100%; }
.promo-stack-reading { background: var(--viz-views); }
.promo-stack-saved { background: var(--viz-saved); }
.promo-stack-finished { background: var(--viz-library); }
.promo-stack-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-size: 12px; color: var(--promo-muted); }
.promo-stack-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* ---------- лента событий ---------- */
.promo-timeline { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; }
.promo-event { display: grid; grid-template-columns: 24px 52px 1fr; gap: 8px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--promo-border); font-size: 14px; }
.promo-event:last-child { border-bottom: 0; }
.promo-event-icon { text-align: center; color: var(--promo-muted); }
.promo-event-date { color: var(--promo-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.promo-event-top_in .promo-event-icon, .promo-event-milestone .promo-event-icon, .promo-event-spike .promo-event-icon { color: var(--promo-ok); }
.promo-event-top_out .promo-event-icon { color: var(--promo-danger); }

/* ---------- рынок ---------- */
.promo-genres { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 4px; }
.promo-genres a { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--promo-border); font-size: 13px; color: var(--promo-muted); }
.promo-genres a.is-active { background: var(--promo-accent); border-color: var(--promo-accent); color: #fff; }
.promo-compare { width: 100%; border-collapse: collapse; font-size: 14px; }
.promo-compare th, .promo-compare td { padding: 8px 10px; border-bottom: 1px solid var(--promo-border); text-align: right; }
.promo-compare th:first-child, .promo-compare td:first-child { text-align: left; }
.promo-compare th { font-size: 12px; color: var(--promo-muted); font-weight: 600; }
.promo-compare td.is-strong { font-weight: 700; }
.promo-bars { display: flex; flex-direction: column; gap: 6px; }
.promo-bars-row { display: grid; grid-template-columns: 110px 1fr 48px; gap: 8px; align-items: center; font-size: 13px; }
.promo-bars-track { height: 10px; border-radius: 3px; background: var(--promo-surface-2); overflow: hidden; }
.promo-bars-track span { display: block; height: 100%; background: var(--viz-views); border-radius: 0 3px 3px 0; }
.promo-bars-row b { text-align: right; font-variant-numeric: tabular-nums; }
.promo-locked { text-align: center; padding: 36px 20px; }
.promo-locked p { color: var(--promo-muted); max-width: 520px; margin: 8px auto 0; }

/* ---------- лендинг-заглушка (гость) ---------- */
.pl-hero { display: grid; grid-template-columns: 1.05fr 1fr; gap: 48px; align-items: center; padding: 36px 0 20px; }
.pl-pill {
    display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
    background: color-mix(in srgb, var(--promo-accent) 10%, transparent); color: var(--promo-accent);
    animation: pl-rise .7s ease both;
}
.pl-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pl-pulse 1.8s ease-in-out infinite; }
.pl-title { font-size: 46px !important; line-height: 1.08 !important; letter-spacing: -0.02em; margin: 18px 0 16px !important; animation: pl-rise .8s .1s ease both; }
.pl-accent {
    background: linear-gradient(90deg, var(--viz-views), var(--viz-library), var(--viz-views));
    background-size: 200% auto; -webkit-background-clip: text; background-clip: text; color: transparent;
    animation: pl-shine 6s linear infinite;
}
.pl-lead { font-size: 17px; color: var(--promo-muted); max-width: 540px; margin: 0 0 26px; animation: pl-rise .8s .2s ease both; }
.pl-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; animation: pl-rise .8s .3s ease both; }
.pl-soon { margin-top: 26px; font-size: 13px; color: var(--promo-muted); animation: pl-rise .8s .4s ease both; }

.pl-visual { position: relative; animation: pl-rise .9s .15s ease both; }
.pl-panel {
    position: relative; z-index: 1; background: var(--promo-surface); border: 1px solid var(--promo-border); border-radius: 18px;
    padding: 20px; box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .25);
    animation: pl-float 7s ease-in-out infinite;
}
.pl-panel-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin-bottom: 14px; }
.pl-panel-title { font-weight: 600; }
.pl-live { display: inline-flex; align-items: center; gap: 6px; color: var(--promo-ok); font-size: 12px; }
.pl-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pl-kpi { background: var(--promo-surface-2); border-radius: 10px; padding: 8px 10px; min-width: 0; }
.pl-kpi span { display: block; font-size: 11px; color: var(--promo-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-kpi b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.pl-kpi em { font-style: normal; font-size: 11px; color: var(--promo-ok); }

.pl-chart { width: 100%; height: 150px; margin-top: 16px; color: var(--viz-views); overflow: visible; }
.pl-grid line { stroke: var(--viz-grid); stroke-width: 1; }
.pl-band { fill: var(--viz-band); opacity: 0; animation: pl-fade .8s .6s ease forwards; }
.pl-median { fill: none; stroke: var(--viz-median); stroke-width: 1.5; stroke-dasharray: 5 4; opacity: 0; animation: pl-fade .8s .8s ease forwards; }
.pl-line {
    fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round;
    stroke-dasharray: 600; stroke-dashoffset: 600; animation: pl-draw 2.2s .9s cubic-bezier(.6, .1, .2, 1) forwards;
}
.pl-area { fill: url(#plFill); opacity: 0; animation: pl-fade 1s 2.4s ease forwards; }
.pl-point { fill: currentColor; stroke: var(--promo-surface); stroke-width: 3; opacity: 0; transform-origin: 400px 14px; animation: pl-pop .5s 3s ease forwards, pl-ping 2.4s 3.5s ease-in-out infinite; }
.pl-legend { display: flex; gap: 16px; font-size: 11px; color: var(--promo-muted); margin-top: 4px; }
.pl-legend i { display: inline-block; width: 14px; height: 3px; margin-right: 6px; vertical-align: middle; border-radius: 2px; }
.pl-leg-line { background: var(--viz-views); }
.pl-leg-band { background: var(--viz-band); height: 8px !important; }

.pl-events { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.pl-events li {
    display: flex; gap: 8px; align-items: baseline; font-size: 13px; padding: 7px 10px; border-radius: 9px; background: var(--promo-surface-2);
    opacity: 0; animation: pl-slide .6s ease forwards; animation-delay: calc(3.2s + var(--d) * .45s);
}
.pl-events li span { color: var(--promo-ok); width: 14px; text-align: center; }

.pl-orb { position: absolute; border-radius: 50%; filter: blur(40px); opacity: .35; z-index: 0; }
.pl-orb-1 { width: 220px; height: 220px; background: var(--viz-views); top: -40px; right: -30px; animation: pl-drift 12s ease-in-out infinite; }
.pl-orb-2 { width: 180px; height: 180px; background: var(--viz-library); bottom: -30px; left: -30px; animation: pl-drift 14s ease-in-out infinite reverse; }

.pl-features { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin-top: 44px; }
.pl-feature { opacity: 0; animation: pl-rise .7s ease forwards; animation-delay: calc(.5s + var(--d) * .12s); transition: transform .2s ease, border-color .2s ease; }
.pl-feature:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--promo-accent) 40%, var(--promo-border)); }
.pl-feature p { margin: 0; color: var(--promo-muted); font-size: 14px; }

@keyframes pl-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pl-fade { to { opacity: 1; } }
@keyframes pl-draw { to { stroke-dashoffset: 0; } }
@keyframes pl-pop { from { opacity: 0; transform: scale(.2); } to { opacity: 1; transform: scale(1); } }
@keyframes pl-ping { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.35); } }
@keyframes pl-slide { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }
@keyframes pl-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes pl-drift { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-20px, 16px); } }
@keyframes pl-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes pl-shine { to { background-position: 200% center; } }

@media (max-width: 900px) {
    .pl-hero { grid-template-columns: 1fr; gap: 32px; }
    .pl-title { font-size: 34px !important; }
}
@media (prefers-reduced-motion: reduce) {
    .pl-hero *, .pl-features * , .pl-feature { animation: none !important; opacity: 1 !important; stroke-dashoffset: 0 !important; transform: none !important; }
}

/* ---------- тепловая карта ленты (одна шкала синего: светлее — тише) ---------- */
.promo-heat { display: grid; grid-template-columns: 28px repeat(24, minmax(10px, 1fr)); gap: 2px; margin-top: 12px; font-size: 11px; color: var(--promo-muted); }
.promo-heat-h { text-align: left; }
.promo-heat-d { align-self: center; }
.promo-heat-c {
    height: 18px; border-radius: 3px;
    background: color-mix(in srgb, var(--viz-views) calc(var(--a) * 100%), var(--promo-surface-2));
}
@media (max-width: 600px) { .promo-heat { grid-template-columns: 22px repeat(24, minmax(6px, 1fr)); gap: 1px; } }
