/* ==========================================================================
   Квиз «О деньгах и людях» — общие токены и компоненты.
   Палитра из айдентики музея: белый, графит, сливочный, песочный, золото, серебро.
   Шрифты по ТЗ: PT Serif — заголовки и цифры, PT Sans — интерфейс.
   ========================================================================== */

:root {
    --paper:      #FFFFFF;
    --cream:      #FBF2E9;
    --ink:        #1B1D1E;
    --ink-soft:   #3E4143;
    --muted:      #716B63;
    --sand:       #D4BB97;
    --sand-soft:  #F1E6D6;
    --gold:       #FFCA78;
    --gold-deep:  #E3A24A;
    --gold-soft:  #FFF1D9;
    --silver:     #DBDBDB;

    --ok:         #2B7249;
    --ok-soft:    #E3F0E7;
    --bad:        #AD3528;
    --bad-soft:   #F8E3DF;

    --line:        rgba(27, 29, 30, .13);
    --line-strong: rgba(27, 29, 30, .30);

    --serif: "PT Serif", Georgia, "Times New Roman", serif;
    --sans:  "PT Sans", "Helvetica Neue", Arial, sans-serif;

    --r-sm: 10px;
    --r:    14px;
    --r-lg: 22px;

    --shadow: 0 1px 2px rgba(27, 29, 30, .06), 0 10px 30px -12px rgba(27, 29, 30, .18);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--cream);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 17px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    font-family: var(--serif);
    font-weight: 700;
    line-height: 1.12;
    margin: 0;
    text-wrap: balance;
}

p { margin: 0; }
a { color: var(--ink); }
img { max-width: 100%; }

:focus-visible {
    outline: 3px solid var(--gold-deep);
    outline-offset: 2px;
}

.num { font-variant-numeric: tabular-nums; }
.serif { font-family: var(--serif); }
.muted { color: var(--muted); }
.caption { font-family: var(--serif); font-style: italic; color: var(--muted); }

.eyebrow {
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted);
}

/* ---------- кнопки ---------- */

.btn {
    -webkit-appearance: none;
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 12px 22px;
    border: 2px solid var(--ink);
    border-radius: var(--r);
    background: var(--ink);
    color: #fff;
    font: 700 16px/1.2 var(--sans);
    text-decoration: none;
    cursor: pointer;
    transition: transform .08s ease, background-color .15s ease, opacity .15s ease;
    touch-action: manipulation;
}

.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .38; cursor: not-allowed; }

.btn--gold { background: var(--gold); color: var(--ink); border-color: var(--gold-deep); }
.btn--gold:hover:not(:disabled) { background: #ffbf5c; }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn--ghost:hover:not(:disabled) { border-color: var(--ink); }
.btn--danger { background: transparent; color: var(--bad); border-color: rgba(173, 53, 40, .45); }
.btn--danger:hover:not(:disabled) { background: var(--bad-soft); }
.btn--sm { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: var(--r-sm); border-width: 1.5px; }
.btn--lg { min-height: 60px; font-size: 18px; border-radius: 16px; }
.btn--block { display: flex; width: 100%; }

/* ---------- поля ---------- */

.field { display: flex; flex-direction: column; gap: 6px; }

.label {
    font-size: 14px;
    font-weight: 700;
    color: var(--ink-soft);
}

.input, .select, .textarea {
    width: 100%;
    min-height: 50px;
    padding: 12px 14px;
    border: 2px solid var(--line-strong);
    border-radius: var(--r);
    background: var(--paper);
    color: var(--ink);
    font: 400 17px/1.3 var(--sans);
}

.textarea { min-height: 96px; resize: vertical; line-height: 1.45; }

.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--ink);
    box-shadow: 0 0 0 4px rgba(255, 202, 120, .55);
}

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

/* ---------- сообщения ---------- */

.alert {
    padding: 13px 16px;
    border-radius: var(--r);
    font-size: 15.5px;
    border: 1.5px solid;
}

.alert--error { background: var(--bad-soft); border-color: rgba(173, 53, 40, .35); color: #7d2419; }
.alert--ok { background: var(--ok-soft); border-color: rgba(43, 114, 73, .35); color: #1e5535; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 11px;
    border-radius: 99px;
    background: var(--sand-soft);
    color: var(--ink-soft);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.chip--gold { background: var(--gold); color: var(--ink); }
.chip--ink { background: var(--ink); color: #fff; }
.chip--ok { background: var(--ok-soft); color: var(--ok); }
.chip--bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- монета-жетон (ставки, места) ---------- */

.coin {
    position: relative;
    display: grid;
    place-items: center;
    aspect-ratio: 1;
    border-radius: 50%;
    background: radial-gradient(circle at 34% 30%, #FFE3B0 0%, var(--gold) 46%, #F0B55E 100%);
    box-shadow: inset 0 0 0 2px rgba(150, 98, 28, .45), inset 0 -4px 10px rgba(150, 98, 28, .25);
    color: var(--ink);
    font-family: var(--serif);
    font-weight: 700;
}

/* внутренний гурт монеты */
.coin::before {
    content: "";
    position: absolute;
    inset: 9%;
    border-radius: 50%;
    border: 2px dotted rgba(90, 58, 14, .45);
    pointer-events: none;
}

.coin--silver {
    background: radial-gradient(circle at 34% 30%, #FFFFFF 0%, #E4E4E4 50%, #BDBDBD 100%);
    box-shadow: inset 0 0 0 2px rgba(80, 80, 80, .35), inset 0 -4px 10px rgba(80, 80, 80, .18);
}

.coin--silver::before { border-color: rgba(60, 60, 60, .35); }

.toast {
    position: fixed;
    left: 50%;
    bottom: 22px;
    z-index: 50;
    transform: translate(-50%, 20px);
    max-width: calc(100% - 32px);
    padding: 12px 18px;
    border-radius: var(--r);
    background: var(--ink);
    color: #fff;
    font-size: 15px;
    box-shadow: var(--shadow);
    opacity: 0;
    transition: opacity .2s ease, transform .2s ease;
    pointer-events: none;
}

.toast.is-shown { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: var(--bad); }

/* ---------- узор брендбука: песочные волны ----------
   Один SVG, цвет задаёт маска: песок на сливочном, белый на золоте, золото на графите. */

.waves {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: var(--waves-color, var(--sand));
    opacity: var(--waves-opacity, .38);
    -webkit-mask: url("../img/waves.svg") center / cover no-repeat;
    mask: url("../img/waves.svg") center / cover no-repeat;
    transition: opacity .8s ease, background-color .8s ease;
    animation: waves-drift 40s ease-in-out infinite alternate;
}

@keyframes waves-drift {
    from { transform: scale(1.06) translate3d(-1.5%, 0, 0); }
    to   { transform: scale(1.06) translate3d(1.5%, -1%, 0); }
}

/* ---------- общие движения ---------- */

@keyframes rise-in {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: none; }
}

@keyframes pop-in {
    0%   { opacity: 0; transform: scale(.82); }
    70%  { opacity: 1; transform: scale(1.04); }
    100% { opacity: 1; transform: none; }
}

@keyframes coin-flip-in {
    from { opacity: 0; transform: perspective(600px) rotateY(-100deg) scale(.8); }
    to   { opacity: 1; transform: perspective(600px) rotateY(0) scale(1); }
}

@keyframes coin-spin {
    from { transform: perspective(600px) rotateY(0); }
    to   { transform: perspective(600px) rotateY(360deg); }
}

@keyframes shake {
    0%, 100% { transform: none; }
    20% { transform: translateX(-9px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(3px); }
}

@keyframes shine {
    from { transform: translateX(-120%) skewX(-18deg); }
    to   { transform: translateX(260%) skewX(-18deg); }
}

@keyframes glow-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(255, 202, 120, .75); }
    100% { box-shadow: 0 0 0 16px rgba(255, 202, 120, 0); }
}

@keyframes float-bob {
    0%, 100% { transform: translateY(0) rotate(-4deg); }
    50%      { transform: translateY(-10px) rotate(4deg); }
}

/* блик, пробегающий по золоту */
.has-shine { position: relative; overflow: hidden; }
.has-shine::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 40%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .75), transparent);
    animation: shine 1.1s .25s ease-out both;
    pointer-events: none;
}

/* ---------- дождь монет ---------- */

.coin-rain {
    position: fixed;
    inset: 0;
    z-index: 60;
    overflow: hidden;
    pointer-events: none;
}

.coin-rain img {
    position: absolute;
    top: -80px;
    filter: drop-shadow(0 6px 8px rgba(27, 29, 30, .25));
    animation-name: coin-fall;
    animation-timing-function: cubic-bezier(.35, .1, .7, 1);
    animation-fill-mode: both;
}

@keyframes coin-fall {
    from { transform: translate3d(0, 0, 0) rotate(0); opacity: 1; }
    85%  { opacity: 1; }
    to   { transform: translate3d(var(--drift, 0), 110vh, 0) rotate(var(--spin, 540deg)); opacity: 0; }
}

/* всплывающая разница банка */
.float-delta {
    position: fixed;
    z-index: 55;
    transform: translateX(-50%);
    font: 700 22px/1 var(--serif);
    pointer-events: none;
    animation: delta-up 1.5s ease-out both;
}

.float-delta.is-plus { color: var(--ok); }
.float-delta.is-minus { color: var(--bad); }

@keyframes delta-up {
    0%   { opacity: 0; transform: translate(-50%, 6px) scale(.8); }
    15%  { opacity: 1; transform: translate(-50%, 0) scale(1.1); }
    100% { opacity: 0; transform: translate(-50%, -46px) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
