/* =====================================================
   XMEGA PAY — payment gateway
   "Security certificate" direction: the amount card reads
   like an engraved banknote (guilloché frame, seal, serif
   numerals, ledger reference) — everything else stays quiet
   so that one element carries the weight.
===================================================== */
/* Fonts are self-hosted offline via /assets/css/fonts.css */

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background-color: #0A0D13;
    min-height: 100%;
    overflow-x: hidden;
}

.gateway-page {
    --ink: #0A0D13;
    --surface: #12161F;
    --surface-2: #191F2B;
    --line: #262E3D;
    --text: #EDEFF5;
    --text-dim: #8891A6;
    --brass: #BE9A54;
    --brass-strong: #D8B872;
    --brass-wash: rgba(190, 154, 84, 0.12);
    --emerald: #2FA179;
    --danger: #E15B4C;

    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'Inter', -apple-system, sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;

    display: block;
    min-height: 100vh;
    background: var(--ink);
    background-image:
        radial-gradient(ellipse at 20% -10%, rgba(190, 154, 84, 0.07), transparent 40%),
        radial-gradient(ellipse at 100% 20%, rgba(47, 161, 121, 0.05), transparent 45%);
    color: var(--text);
    font-family: var(--font-body);
    padding: 56px 18px 90px;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Page loader ---------- */

.gateway-loader {
    min-height: 70vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.loader-circle {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 3px solid var(--line);
    border-top-color: var(--brass);
    animation: spin .9s linear infinite;
    margin-bottom: 22px;
}

.gateway-loader h2 {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.gateway-loader p {
    color: var(--text-dim);
    font-size: 13.5px;
}

.loader-steps {
    margin-top: 18px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.loader-steps span {
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--emerald);
    opacity: 0;
    animation: fadeIn .4s ease forwards;
}

.loader-steps span:nth-child(1) { animation-delay: .2s; }
.loader-steps span:nth-child(2) { animation-delay: .6s; }
.loader-steps span:nth-child(3) { animation-delay: 1.0s; }

/* ---------- Container / header ---------- */

.gateway-container {
    max-width: 560px;
    margin: 0 auto;
    animation: rise .5s cubic-bezier(.16,1,.3,1);
}

.gateway-header {
    text-align: center;
    margin-bottom: 30px;
}

.gateway-logo {
    display: inline-flex;
    align-items: baseline;
    gap: 7px;
    font-family: var(--font-mono);
    font-size: 19px;
    font-weight: 600;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    margin-bottom: 26px;
}

.gateway-logo span { color: var(--brass); }

.gateway-header h1 {
    font-family: var(--font-display);
    font-size: 27px;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin-bottom: 9px;
}

.gateway-header p {
    color: var(--text-dim);
    font-size: 14px;
    max-width: 380px;
    margin: 0 auto;
}

/* ---------- Unified gateway box ----------
   Everything — order amount, token picker, and payment details —
   lives inside ONE continuous card instead of several stacked boxes.
   Sections inside are separated with a hairline divider, not a gap. */

.gateway-box {
    position: relative;
    background: linear-gradient(175deg, var(--surface-2), var(--surface) 55%);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 6px 24px 26px;
    overflow: hidden;
}

.box-section {
    padding: 24px 0;
}

.token-section,
.network-loader,
.payment-details {
    border-top: 1px solid var(--line);
}

.amount-section {
    text-align: center;
    padding-top: 30px;
}

/* ---------- Signature element: certificate frame ---------- */

.cert-frame {
    position: absolute;
    left: 0;
    right: 0;
    height: 15px;
    opacity: 0.55;
    background-repeat: repeat-x;
    background-size: 76px 15px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='76' height='15' viewBox='0 0 76 15'%3E%3Cg fill='none' stroke='%23BE9A54' stroke-width='0.7'%3E%3Cpath d='M0 7.5 Q9.5 -2 19 7.5 T38 7.5 T57 7.5 T76 7.5'/%3E%3Cpath d='M0 7.5 Q9.5 17 19 7.5 T38 7.5 T57 7.5 T76 7.5' opacity='0.55'/%3E%3C/g%3E%3C/svg%3E");
}

.cert-frame-top { top: 0; }
.cert-frame-bottom { bottom: 0; }

.cert-seal {
    width: 34px;
    height: 34px;
    margin: 4px auto 14px;
    border-radius: 50%;
    border: 1px solid var(--brass);
    color: var(--brass-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    box-shadow: 0 0 0 4px var(--brass-wash);
}

.amount-label {
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.amount-section h2 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 46px;
    letter-spacing: -0.01em;
    margin: 4px 0 14px;
}

.amount-section h2::before {
    content: "$";
}

.cert-ref {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    border: 1px solid var(--line);
    border-radius: 100px;
    padding: 5px 14px;
}

/* ---------- Token grid ---------- */

.token-section h3 {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
}

.token-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(102px, 1fr));
    gap: 10px;
}

.token {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 94px;
    background: #141923;
    border: 1px solid #262E3D;
    border-radius: 12px;
    color: var(--text);
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    padding: 10px 6px 10px;
    transition: transform .15s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.token:hover {
    transform: translateY(-2px);
    border-color: var(--brass);
    background: #1B2230;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.token-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #FFFFFF;
    border: 1px solid rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
    transition: transform .2s ease, box-shadow .2s ease;
}

.token:hover .token-icon {
    transform: scale(1.08);
    box-shadow: 0 4px 14px rgba(255, 255, 255, 0.25);
}

.token-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* ---------- Network / connecting loader ---------- */

.network-loader {
    text-align: center;
}

.network-loader .loader-circle {
    margin: 0 auto 18px;
}

.network-loader h3 {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 6px;
}

.network-loader p {
    color: var(--text-dim);
    font-size: 12.5px;
    margin: 2px 0;
}

/* ---------- Payment details ---------- */

.payment-details {
    display: flex;
    flex-direction: column;
    gap: 18px;
    animation: rise .35s cubic-bezier(.16,1,.3,1);
}

.selected-token {
    text-align: center;
}

.selected-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 10px;
    object-fit: contain;
    background: #FFFFFF;
    border-radius: 50%;
    padding: 7px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.25);
    display: block;
}

.selected-token h2 {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 600;
    margin: 0;
}

/* ---------- Token Rate Pill ---------- */

.token-rate-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: var(--ink);
    border: 1px solid var(--line);
    padding: 5px 14px;
    border-radius: 999px;
    margin-top: 9px;
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--text-dim);
}

.rate-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--emerald);
    box-shadow: 0 0 0 3px rgba(47, 161, 121, 0.18);
    flex-shrink: 0;
    animation: ratePulse 2s infinite ease-in-out;
}

@keyframes ratePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.55; transform: scale(0.85); }
}

.rate-text {
    letter-spacing: 0.02em;
}

.rate-text strong {
    color: var(--text);
    font-weight: 600;
}

/* ---------- Payment Field Cards (Amount & Wallet) ---------- */

.pay-field-box {
    display: flex;
    flex-direction: column;
}

.pay-field-label {
    display: block;
    font-family: var(--font-mono);
    color: var(--text-dim);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.pay-field-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: var(--ink);
    border: 1px solid var(--line);
    padding: 13px 15px;
    border-radius: 10px;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.pay-field-card:hover {
    border-color: rgba(190, 154, 84, 0.4);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

.pay-field-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
}

.pay-crypto-val {
    font-family: var(--font-mono);
    font-size: 16.5px;
    font-weight: 700;
    color: var(--text);
    word-break: break-all;
    line-height: 1.3;
}

.pay-fiat-val {
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--brass-strong);
    opacity: 0.95;
    letter-spacing: 0.02em;
}

.pay-wallet-addr {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text);
    word-break: break-all;
    line-height: 1.45;
}

.copy-btn {
    background: var(--surface-2);
    color: var(--brass);
    border: 1px solid var(--line);
    padding: 8px 14px;
    border-radius: 8px;
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    flex-shrink: 0;
    cursor: pointer;
    transition: border-color .2s ease, color .2s ease, background-color .2s ease;
}

.copy-btn:hover {
    border-color: var(--brass);
    color: var(--brass-bright, #e8c878);
    background: rgba(190, 154, 84, 0.08);
}

.copy-btn.copied {
    color: var(--emerald);
    border-color: var(--emerald);
    background: rgba(47, 161, 121, 0.1);
}

.network-info {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-dim);
}

.network-info strong { color: var(--text); }

.qr-box {
    text-align: center;
    background: var(--ink);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 20px;
}

.qr-image {
    width: 168px;
    height: 168px;
    margin: 0 auto;
    border-radius: 10px;
    background: #fff;
    padding: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-image img, .qr-image canvas {
    width: 100%;
    height: 100%;
}

.qr-box p {
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-dim);
}

/* ---------- Timer ---------- */

.timer-box {
    padding: 14px;
    text-align: center;
    border-radius: 12px;
    font-size: 12.5px;
    color: var(--text-dim);
    transition: background .3s ease, border-color .3s ease;
}

.timer-box strong {
    margin-left: 6px;
    font-family: var(--font-mono);
    font-size: 14px;
    transition: color .3s ease;
}

.timer-box.state-green {
    background: rgba(47, 161, 121, 0.08);
    border: 1px solid rgba(47, 161, 121, 0.25);
}
.timer-box.state-green strong { color: var(--emerald); }

.timer-box.state-yellow {
    background: rgba(216, 184, 66, 0.09);
    border: 1px solid rgba(216, 184, 66, 0.28);
}
.timer-box.state-yellow strong { color: #D8B842; }

.timer-box.state-orange {
    background: rgba(224, 142, 66, 0.09);
    border: 1px solid rgba(224, 142, 66, 0.28);
}
.timer-box.state-orange strong { color: #E08E42; }

.timer-box.state-red {
    background: rgba(225, 91, 76, 0.09);
    border: 1px solid rgba(225, 91, 76, 0.28);
}
.timer-box.state-red strong { color: var(--danger); }

/* ---------- Actions ---------- */

.pay-confirm {
    width: 100%;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--brass);
    background: linear-gradient(135deg, var(--brass-strong), var(--brass));
    color: #14120A;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease;
}

.pay-confirm:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px -12px rgba(190, 154, 84, 0.4);
}

.pay-confirm:disabled {
    opacity: .6;
    cursor: not-allowed;
    transform: none;
}

.payment-details-footer { margin-top: 0; }

.change-coin-btn {
    width: 100%;
    background: transparent;
    border: 1px solid var(--line);
    color: var(--text-dim);
    font-size: 13px;
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: border-color .2s ease, color .2s ease;
}

.change-coin-btn:hover { border-color: var(--brass); color: var(--brass); }

/* ---------- Modal ---------- */

.pc-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 13, 19, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    padding: 20px;
}

.pc-modal {
    width: 100%;
    max-width: 340px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 26px 24px;
    text-align: center;
}

.pc-modal h3 {
    font-family: var(--font-display);
    font-size: 17px;
    margin-bottom: 8px;
}

.pc-modal p {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 20px;
}

.pc-modal-actions {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.pc-modal-actions button {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--line);
}

.pc-modal-change { background: var(--surface-2); color: var(--text); }
.pc-modal-change:hover { border-color: var(--brass); color: var(--brass); }

.pc-modal-cancel {
    background: rgba(225, 91, 76, 0.1);
    border-color: rgba(225, 91, 76, 0.3);
    color: var(--danger);
}
.pc-modal-cancel:hover { background: rgba(225, 91, 76, 0.16); }

.pc-modal-dismiss {
    background: transparent;
    color: var(--text-dim);
    border-color: transparent;
    font-weight: 500;
}
.pc-modal-dismiss:hover { color: var(--text); }

/* ---------- Confirmation page ---------- */

.confirm-box {
    margin-top: 8px;
}

.confirm-section {
    text-align: center;
    padding-top: 34px;
    padding-bottom: 6px;
}

.confirm-seal {
    width: 52px;
    height: 52px;
    font-size: 22px;
    border-color: var(--emerald);
    color: var(--emerald);
    box-shadow: 0 0 0 6px rgba(47, 161, 121, 0.12);
    margin-bottom: 20px;
}

.confirm-title {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 600;
    margin-bottom: 14px;
}

.confirm-text {
    color: var(--text-dim);
    font-size: 14px;
    line-height: 1.7;
    max-width: 420px;
    margin: 0 auto 26px;
}

.confirm-text strong {
    color: var(--text);
    font-family: var(--font-mono);
    font-weight: 600;
}

.confirm-link {
    display: inline-block;
    color: var(--brass-strong);
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: 0.02em;
    text-decoration: none;
    border-bottom: 1px solid var(--brass);
    padding-bottom: 3px;
    transition: color .2s ease, border-color .2s ease;
}

.confirm-link:hover {
    color: var(--brass-strong);
    border-color: var(--brass-strong);
}

/* ---------- Utility ---------- */

.hidden { display: none !important; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (max-width: 600px) {
    .gateway-page { padding: 40px 14px 70px; }
    .gateway-header h1 { font-size: 22px; }
    .amount-section h2 { font-size: 36px; }
    .gateway-box { padding: 6px 18px 20px; }
    .box-section { padding: 20px 0; }
    .token-grid { grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); }
    .token { height: 80px; }
    .pay-crypto-val { font-size: 15px; }
    .pay-field-card { padding: 11px 12px; }
}

@media (prefers-reduced-motion: reduce) {
    .gateway-container, .payment-details { animation: none; }
    .loader-circle { animation-duration: 2s; }
}