/* Мероприятия ДеМарк - афиша для сотрудников (Telegram Mini App + тизер в браузере).
   Две темы: светлая по умолчанию, тёмная по теме Telegram или системы. */

:root {
    color-scheme: light;
    --ground: #F1F3F8;
    --card: #FFFFFF;
    --ink: #12151C;
    --ink-2: #4A5265;
    --ink-3: #7B8497;
    --line: #DFE3EC;
    --accent: #F0452E;          /* афишный красный: дата и главное действие */
    --accent-ink: #FFFFFF;
    --accent-soft: #FDE9E5;
    --ok: #1B7F4B;
    --ok-soft: #E2F4EA;
    --wait: #A35B00;
    --wait-soft: #FBEFD9;
    --shadow: 0 18px 40px rgba(18, 21, 28, 0.16);
    --display: "Unbounded", "Golos Text", system-ui, sans-serif;
    --body: "Golos Text", "Segoe UI", system-ui, -apple-system, sans-serif;
    --radius: 16px;
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --ground: #0F1116;
    --card: #191C24;
    --ink: #F1F3F8;
    --ink-2: #B3BACB;
    --ink-3: #7F889C;
    --line: #2A2F3B;
    --accent: #FF5A43;
    --accent-ink: #14100F;
    --accent-soft: #3A1D18;
    --ok: #5BD08F;
    --ok-soft: #14301F;
    --wait: #F1B355;
    --wait-soft: #33260F;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--ground); color: var(--ink); font-family: var(--body); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; min-height: 100dvh; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.page { max-width: 1080px; margin: 0 auto; padding: 28px 16px calc(40px + env(safe-area-inset-bottom)); }

/* Шапка */
.masthead { margin-bottom: 24px; }
.masthead-kicker { font-size: 13px; color: var(--ink-3); margin-bottom: 6px; min-height: 19px; }
.masthead h1 { font-family: var(--display); font-weight: 700; font-size: clamp(26px, 7vw, 44px); line-height: 1.08; letter-spacing: -0.02em; text-wrap: balance; }
.masthead-sub { margin-top: 10px; color: var(--ink-2); max-width: 56ch; }

/* Месяц и вид */
.controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.month-switch { display: flex; align-items: center; gap: 6px; }
.month-switch h2 { font-family: var(--display); font-weight: 500; font-size: 17px; min-width: 9.5em; text-align: center; text-transform: capitalize; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: inline-grid; place-items: center; background: var(--card); border: 1px solid var(--line); transition: border-color 150ms, transform 100ms; }
.icon-btn:hover { border-color: var(--ink-3); }
.icon-btn:active { transform: scale(0.96); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.view-switch { display: inline-flex; padding: 4px; gap: 4px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.view-switch button { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; border-radius: 10px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); transition: background 150ms, color 150ms; }
.view-switch button[aria-selected="true"] { background: var(--ink); color: var(--ground); }

/* Афиша */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card { position: relative; display: flex; flex-direction: column; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; transition: transform 160ms ease-out, border-color 160ms; }
.card:hover { transform: translateY(-2px); border-color: var(--ink-3); }
.card.is-past { opacity: 0.6; }
.card-media { position: relative; aspect-ratio: 16 / 10; background: var(--accent-soft); overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-media.no-image { display: grid; place-items: center; aspect-ratio: 16 / 6; }
.card-media.no-image::after { content: attr(data-initial); font-family: var(--display); font-weight: 700; font-size: 56px; color: var(--accent); opacity: 0.35; }
.date-badge { position: absolute; left: 12px; top: 12px; display: grid; justify-items: center; min-width: 58px; padding: 7px 10px 8px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); line-height: 1; }
.date-badge b { font-family: var(--display); font-weight: 700; font-size: 24px; font-variant-numeric: tabular-nums; }
.date-badge span { margin-top: 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.card-body { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px 16px; flex: 1; }
.card-title { font-weight: 700; font-size: 17px; line-height: 1.25; text-wrap: balance; }
.card-meta { display: flex; flex-direction: column; gap: 3px; color: var(--ink-2); font-size: 13.5px; }
.card-meta span { display: flex; align-items: center; gap: 7px; min-width: 0; }
.card-meta span > em { font-style: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta svg.i { width: 15px; height: 15px; color: var(--ink-3); }
.card-foot { margin-top: auto; padding-top: 6px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--ground); color: var(--ink-2); }
.pill svg.i { width: 14px; height: 14px; stroke-width: 2.4; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.wait { background: var(--wait-soft); color: var(--wait); }
.pill.hot { background: var(--accent-soft); color: var(--accent); }

/* Календарь */
.calendar { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-head span { padding: 10px 4px; text-align: center; font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); border-bottom: 1px solid var(--line); }
.cal-day { min-height: 92px; padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day.out { background: var(--ground); }
.cal-day .num { font-size: 12.5px; font-weight: 600; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.cal-day.today .num { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: var(--ground); }
.cal-event { display: block; width: 100%; text-align: left; padding: 3px 6px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-size: 11.5px; font-weight: 600; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-event.mine { background: var(--ok-soft); color: var(--ok); }
.cal-event.past { background: var(--ground); color: var(--ink-3); }

.empty { text-align: center; padding: 56px 16px; color: var(--ink-2); }
.empty-title { font-family: var(--display); font-weight: 500; font-size: 18px; color: var(--ink); margin-bottom: 6px; }
.empty button { margin-top: 14px; }

/* Кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px; border-radius: 14px; font-weight: 600; font-size: 15px; background: var(--card); border: 1px solid var(--line); text-decoration: none; transition: filter 150ms, transform 100ms, border-color 150ms; touch-action: manipulation; }
.btn:hover { border-color: var(--ink-3); }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.05); border-color: var(--accent); }
.btn-quiet { background: var(--ground); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }

/* Карточка события */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(10, 12, 18, 0.55); animation: fade 200ms ease-out; }
.sheet-panel { position: relative; width: 100%; max-width: 640px; max-height: 94dvh; overflow-y: auto; background: var(--card); border-radius: 22px 22px 0 0; box-shadow: var(--shadow); animation: rise 240ms cubic-bezier(0.2, 0.8, 0.2, 1); padding-bottom: env(safe-area-inset-bottom); }
.sheet-close { position: absolute; right: 12px; top: 12px; z-index: 2; }
.sheet-media { aspect-ratio: 16 / 9; background: var(--accent-soft); }
.sheet-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sheet-body { padding: 20px 20px 28px; display: flex; flex-direction: column; gap: 16px; }
.sheet-body h2 { font-family: var(--display); font-weight: 700; font-size: clamp(20px, 5.4vw, 26px); line-height: 1.15; letter-spacing: -0.01em; text-wrap: balance; padding-right: 36px; }
.ev-status { align-self: flex-start; }
.ev-facts { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.ev-facts li { display: flex; gap: 10px; align-items: flex-start; color: var(--ink-2); }
.ev-facts svg.i { margin-top: 2px; color: var(--ink-3); }
.ev-facts a { color: var(--accent); text-underline-offset: 3px; }
.ev-description { white-space: pre-wrap; word-break: break-word; max-width: 62ch; }
.ev-description a { color: var(--accent); text-underline-offset: 3px; }
.ev-description:empty { display: none; }
.ev-seats-line { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; color: var(--ink-2); margin-bottom: 6px; }
.ev-seats-line span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
.ev-seats-bar { height: 8px; border-radius: 999px; background: var(--ground); overflow: hidden; }
.ev-seats-bar span { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width 300ms ease-out; }
.ev-actions { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.ev-note { font-size: 13px; color: var(--ink-3); margin-top: -6px; }
.ev-note:empty { display: none; }
.ev-people h3 { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; margin: 4px 0 10px; }
.ev-people h3 svg.i { color: var(--ink-3); }
.ev-people ul { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 16px; margin-bottom: 14px; }
.ev-people li { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 12.5px; font-weight: 700; background: var(--accent-soft); color: var(--accent); }
.person { min-width: 0; line-height: 1.25; }
.person b { display: block; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person small { display: block; font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Вход не из Telegram */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.gate-card { width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 22px; }
.gate-card h2 { font-family: var(--display); font-weight: 500; font-size: 19px; line-height: 1.2; text-wrap: balance; }
.gate-card p { color: var(--ink-2); }
.gate-poster { margin: -22px -22px 4px; border-radius: 22px 22px 0 0; overflow: hidden; background: var(--accent); color: var(--accent-ink); }
.gate-poster img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; }
.gate-poster-body { padding: 18px 22px 20px; }
.gate-poster h1 { font-family: var(--display); font-weight: 700; font-size: 24px; line-height: 1.12; text-wrap: balance; }
.gate-date { font-weight: 600; margin-bottom: 6px; color: inherit !important; opacity: 0.9; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 80; max-width: calc(100vw - 32px); padding: 11px 16px; border-radius: 12px; background: var(--ink); color: var(--ground); font-weight: 500; font-size: 14px; box-shadow: var(--shadow); animation: rise 200ms ease-out; }
.toast.error { background: var(--accent); color: var(--accent-ink); }
.loader { position: fixed; inset: 0; display: grid; place-items: center; background: var(--ground); z-index: 90; }
.loader span { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 800ms linear infinite; }
.loader.done { display: none; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { animation-name: toast-rise; }
@keyframes toast-rise { from { opacity: 0; transform: translate(-50%, 12px); } }

@media (min-width: 720px) {
    .sheet { align-items: center; padding: 24px; }
    .sheet-panel { border-radius: 22px; max-height: 90dvh; }
}
@media (max-width: 560px) {
    .controls { justify-content: center; }
    .month-switch { width: 100%; justify-content: space-between; }
    .view-switch { width: 100%; }
    .view-switch button { flex: 1; justify-content: center; }
    .cal-day { min-height: 64px; padding: 4px; }
    .cal-event { font-size: 10.5px; padding: 2px 4px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
