/* OM EVENT theme — premium gold on light */
:root {
    --color-bg: var(--tg-theme-bg-color, #FAFAF7);
    --color-text: var(--tg-theme-text-color, #2D2D2D);
    /* v4.55.4: было #9A9A9A (2.85:1 на #FAFAF7 — FAIL WCAG AA);
       поднято до #6B6B6B (5.7:1) — проходит AA для normal text. */
    --color-hint: var(--tg-theme-hint-color, #6B6B6B);
    /* --color-accent fallback chain (Run 4 closure, 2026-06-03):

       SISTER TOKEN: `--gold` in `/frontend/src/app/globals.css` (the
       omevent.space Next.js app). Holds the same #7A551F literal under a
       different name because the two surfaces have independent
       stylesheets. ALWAYS change both files atomically when bumping this
       value — grep #7A551F (or the new literal) across both repos before
       commit. v4.56.X drift incident: changing one and forgetting the
       other reintroduces axe-core contrast SERIOUS on the missed surface.

       Telegram theme overrides via --tg-theme-button-color when set;
       fallback applies when Mini App is opened outside Telegram (the
       Run 4 error-state path) or theme is unset.
       Fallback #7A551F = 6.67:1 on white (passes WCAG AA). Reuses
       --color-gold-dark literal — readable-text and legacy-dark halves
       now collapse to one value, matching frontend/--gold.
       History: #C8963E (v4.55.x, 2.54:1, FAIL) → #A0712A (v4.56.0,
       claimed ≈4.8:1, actual axe 4.29:1, still FAIL by 0.21) → #7A551F.
       Ratios in this file are axe-core-measured, not estimated. */
    --color-accent: var(--tg-theme-button-color, #7A551F);
    --color-accent-text: var(--tg-theme-button-text-color, #ffffff);
    --color-surface: var(--tg-theme-secondary-bg-color, #F5F4F0);
    --color-error: var(--tg-theme-destructive-text-color, #c0392b);
    --color-border: #E8E4DC;
    /* Gold tokens cleanup (Run 4 closure tail, 2026-06-03):
       Both webapp custom gold tokens removed — neither had a runtime
       call-site. --color-gold (#C8963E) was defined as "decorative
       reserve" but unused (and at 2.54:1 a contrast trap if reached
       for). --color-gold-dark (#7A551F) was used by .btn-primary:active
       which got rewritten to use `opacity: 0.8` in this cycle (works
       regardless of whether --color-accent comes from Telegram theme
       or the fallback). All readable-text/CTA gold now flows through
       --color-accent. Future "soft gold accent" wants explicit hex
       with /* WCAG-fail decorative */ inline annotation, not a token. */

    /* Spacing scale: 8px base */
    --s1: 8px;
    --s2: 16px;
    --s3: 24px;
    --s4: 32px;
    --s6: 48px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

#app {
    padding: var(--s2);
    /* v4.55.4: на desktop карточка раньше растягивалась на полную ширину viewport
       (1280px+), CTA выглядел как футер-бар. Ограничиваем + центрируем.
       v4.56.X (Run 4 P3): 480 → 580px — на 480px русское «Telegram Desktop /
       Web» в error-state hint разрывалось посередине фразы. 580px удерживает
       Cyrillic line-length в ~72ch (верхний край комфортного диапазона). */
    max-width: 580px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    text-align: center;
    padding: var(--s3) 0 var(--s2);
}

.method-label {
    /* v4.55.4: теперь это <h1>; ресет дефолтных h1-стилей + наш заголовок-каплок. */
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);   /* было --color-hint (slabbo); теперь полноценный заголовок */
    margin: 0 0 var(--s1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.amount {
    font-size: 36px;
    font-weight: 700;
    line-height: 1.2;
}

/* States */
.state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* v4.56.0 P1-3 / P2-5: было justify-content: center — на длинных мобильных
       viewport'ах header (h1+amount) приклеивался к верху, форма прыгала на
       центр, action-area (margin-top: auto) шла в самый низ → ~1500px пустоты
       между формой и CTA на iPhone. Теперь form state выравнивается к началу
       (header→форма→CTA — компактная вертикальная композиция). Non-form
       states (loading/success/error/expired/processing) центрируются ниже —
       у них основной контент это spinner/status-icon, для них центр нужен. */
    justify-content: flex-start;
    gap: var(--s2);
    padding: var(--s3) 0;
}

/* Non-form states retain vertical centering (spinner, status icons).
   v4.56.X (Run 4 P1-1): #stateError removed from this list — on Pixel-7
   (412×915, aspect 2.22) full-viewport centering pushed the error icon
   to mid-screen with ~40% empty space above. Inheriting flex-start from
   .state base puts icon + title + hint + CTAs in the upper third where
   the user's first scan lands them. Other non-form states stay centered:
   their content is spinner/status-icon only, where centre reads
   intentional rather than abandoned. If #stateExpired ever ships a hint
   block and CTA stack like Error, reconsider its centering here. */
#stateLoading,
#stateProcessing,
#stateSuccess,
#stateExpired {
    justify-content: center;
}

/* Run 4 P3: drop status-hint inside #stateError under the status-text
   header so the longer instruction renders at .status-hint weight
   (normal 400 + --color-hint) instead of inheriting the bold
   .status-text the caller previously stuffed it into. */
#stateError .status-hint {
    margin-top: var(--s1);
    max-width: 480px;
}
#stateError .status-hint:empty {
    display: none;
}

.hidden {
    display: none !important;
}

/* JS template wrappers */
.amount-input-wrapper {
    padding: var(--s3) 0;
    width: 100%;
}

.method-selection-wrapper {
    display: flex;
    flex-direction: column;
    gap: var(--s1);
    width: 100%;
    padding: var(--s2) 0;
}

/* Status indicators */
.status-icon {
    margin-bottom: var(--s1);
}

.status-text {
    font-size: 18px;
    font-weight: 600;
    text-align: center;
}

.status-hint {
    font-size: 14px;
    color: var(--color-hint);
    text-align: center;
    max-width: 280px;
}

/* Pulse animation — CSS only */
.pulse {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Success animation */
.success-icon {
    animation: scaleIn 200ms ease-out;
}

@keyframes scaleIn {
    from { transform: scale(0.6); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Buttons */
.action-area {
    width: 100%;
    /* v4.56.0 P1-3: было margin-top: auto — создавало dead-space между формой
       и CTA на длинных мобильных viewport'ах. Теперь CTA сидит прямо под
       формой с разумным отступом. Если контент превышает viewport, обычный
       scroll работает как ожидается. */
    margin-top: var(--s3);
    padding-top: 0;
    display: flex;
    flex-direction: column;
    gap: var(--s1);
}

.btn-primary {
    width: 100%;
    padding: var(--s2);
    border: none;
    border-radius: 12px;
    background: var(--color-accent);
    color: var(--color-accent-text);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 200ms, opacity 150ms;
    letter-spacing: 0.3px;
}

.btn-primary:active {
    /* v4.56.X (Run 4 cleanup tail): использует opacity вместо смены цвета.
       --color-accent может прийти из Telegram-темы (любой цвет) или из
       fallback (#7A551F = --color-gold-dark до удаления токена). opacity:
       0.8 даёт перцептивную press-feedback независимо от источника. */
    opacity: 0.8;
}

.btn-primary:disabled,
.btn-primary[aria-disabled="true"] {
    /* v4.56.0 P1-2: aria-disabled поддержан помимо нативного disabled чтобы
       JS мог поймать клик и показать подсказку (нативный disabled блокирует
       click event целиком — нет шанса focus()/scrollIntoView() на инпут). */
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    width: 100%;
    /* v4.56.X (Run 4 P2-4): когда .btn-secondary стоит после .btn-primary
       в error-state, --color-surface #F5F4F0 на --color-bg #FAFAF7 —
       всего ~5 пунктов lightness разницы. 1px outline возвращает чёткую
       аффордансность контрола без конкуренции с primary-кнопкой по весу. */
    padding: calc(var(--s2) - 1px);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 16px;
    cursor: pointer;
    transition: opacity 150ms;
}

.btn-secondary:active {
    opacity: 0.8;
}

/* QR code container */
.qr-container {
    background: var(--color-surface);
    padding: var(--s2);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 343px;
    aspect-ratio: 1;
    margin: 0 auto;
}

.qr-container img,
.qr-container canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Wallet address */
.address-field {
    background: var(--color-surface);
    border-radius: 12px;
    padding: var(--s2);
    width: 100%;
    display: flex;
    align-items: center;
    gap: var(--s1);
}

.address-text {
    flex: 1;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    word-break: break-all;
    overflow: hidden;
    text-overflow: ellipsis;
}

.address-truncated {
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

.btn-copy {
    flex-shrink: 0;
    padding: var(--s1) var(--s2);
    border: none;
    border-radius: 8px;
    background: var(--color-accent);
    color: var(--color-accent-text);
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 150ms;
}

/* SBP link button */
.btn-sbp-link {
    width: 100%;
    padding: var(--s2);
    border: none;
    border-radius: 12px;
    background: var(--color-accent);
    color: var(--color-accent-text);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: block;
    text-align: center;
}

/* Card — iframe/redirect container */
.card-frame {
    width: 100%;
    flex: 1;
    min-height: 400px;
    border: none;
    border-radius: 12px;
}

/* Crypto amount info */
.crypto-info {
    text-align: center;
    padding: var(--s2) 0;
}

.crypto-amount {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: var(--s1);
}

.crypto-currency {
    font-size: 14px;
    color: var(--color-hint);
}

/* Amount input */
.input-label {
    font-size: 14px;
    color: var(--color-hint);
    margin-bottom: var(--s1);
}

.amount-input-row {
    display: flex;
    align-items: center;
    gap: var(--s1);
    background: var(--color-surface);
    border-radius: 12px;
    padding: var(--s2);
}

.amount-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 28px;
    font-weight: 700;
    color: var(--color-text);
    outline: none;
    width: 100%;
    -moz-appearance: textfield;
}

.amount-input::-webkit-outer-spin-button,
.amount-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.amount-input::placeholder {
    /* v4.56.0 P3-5: добавлен курсив чтобы placeholder «от 100 ₽» визуально
       отличался от введённой суммы (28px bold non-italic). Без курсива на
       fast scan можно принять placeholder за уже введённое значение. */
    color: var(--color-hint);
    font-weight: 400;
    font-size: 18px;
    font-style: italic;
}

.amount-input.input-error {
    color: var(--color-error);
}

.amount-currency {
    font-size: 28px;
    font-weight: 700;
    color: var(--color-hint);
}

.quick-amounts {
    display: flex;
    gap: var(--s1);
    margin-top: var(--s2);
    flex-wrap: wrap;
}

.btn-quick {
    flex: 1;
    min-width: 60px;
    padding: var(--s1) var(--s2);
    border: 1px solid var(--color-border, var(--color-surface));
    border-radius: 8px;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: border-color 200ms;
}

.btn-quick:active {
    border-color: var(--color-accent);
    background: var(--color-surface);
}

/* Method selection buttons */
.btn-method {
    width: 100%;
    padding: var(--s2);
    border: 1px solid var(--color-border, var(--color-surface));
    border-radius: 12px;
    background: var(--color-bg);
    color: var(--color-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--s2);
    text-align: left;
    transition: border-color 200ms, box-shadow 200ms;
}

.btn-method:active {
    border-color: var(--color-accent);
    box-shadow: 0 2px 12px rgba(200, 150, 62, 0.12);
}

.btn-method-icon {
    font-size: 28px;
    flex-shrink: 0;
    width: 40px;
    text-align: center;
}

.btn-method-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.btn-method-title {
    font-size: 16px;
    font-weight: 600;
}

.btn-method-desc {
    font-size: 13px;
    color: var(--color-hint);
}

/* Back link */
.method-back {
    font-size: 14px;
    color: var(--color-accent);
    cursor: pointer;
    padding: var(--s1) 0;
    margin-bottom: var(--s1);
}

/* Amount display — serif for premium feel */
.amount {
    font-family: 'Georgia', 'Times New Roman', serif;
}

/* Dismiss hint for long waits */
.dismiss-hint {
    font-size: 13px;
    color: var(--color-hint);
    text-align: center;
    padding: var(--s2);
    line-height: 1.4;
}

/* v4.56.0 P3-4: desktop card wrapper. На широких экранах форма раньше
   плавала ~480px шириной без визуальной границы — стандартный паттерн
   для платёжных форм это card с тенью на фоне. На мобильных оставляем
   без изменений (card-стиль был бы лишним рамком на маленьком экране). */
@media (min-width: 600px) {
    #app {
        margin-top: var(--s6);
        margin-bottom: var(--s6);
        padding: var(--s4);
        background: #ffffff;
        border-radius: 16px;
        box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    }
}
