/* ==================================================================
   MOTTO SWIPE — v2
   ------------------------------------------------------------------
   Motto-centric swipe deck. The card is the hero: huge, confident,
   quote-driven. Age / country are tiny supporting details on a pill
   at the bottom. The match moment gets its own confetti celebration
   and shows a real profile card of the matched person.
   ================================================================== */

/* ── Screen shell ───────────────────────────────────────────────── */
#mottoSwipeScreen {
    background:
        radial-gradient(120% 80% at 50% -10%, rgba(233, 30, 99, 0.16) 0%, rgba(233, 30, 99, 0) 55%),
        radial-gradient(100% 80% at 90% 110%, rgba(124, 77, 255, 0.14) 0%, rgba(124, 77, 255, 0) 55%),
        linear-gradient(180deg, #140a22 0%, #0a0612 100%);
    flex-direction: column;
    overflow: hidden;
}

#mottoSwipeScreen.active {
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0));
}

/* ── Header ─────────────────────────────────────────────────────── */
.ms-header {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* Top padding clears iOS status bar / Dynamic Island in PWA mode. */
    padding: calc(22px + env(safe-area-inset-top, 0px)) 18px 14px;
    background: linear-gradient(180deg, rgba(14, 9, 22, 0.94) 0%, rgba(14, 9, 22, 0) 100%);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.ms-back-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.ms-back-btn:active {
    transform: scale(0.92);
    background: rgba(255, 255, 255, 0.12);
}

.ms-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.ms-title-main {
    font-size: 18px;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.3px;
    background: linear-gradient(135deg, #ff5a8c 0%, #a078ff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.ms-title-sub {
    font-size: 10.5px;
    color: rgba(255, 255, 255, 0.42);
    letter-spacing: 1.4px;
    text-transform: uppercase;
    font-weight: 600;
}

.ms-header-spacer {
    width: 40px;
    height: 40px;
}

/* ── Stage ──────────────────────────────────────────────────────── */
.ms-stage {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px 10px;
    overflow: hidden;
}

.ms-card-stack {
    position: relative;
    width: 100%;
    max-width: 400px;
    aspect-ratio: 4 / 5.2;
    max-height: min(72vh, 640px);
}

/* ── Card ───────────────────────────────────────────────────────── */
.ms-card {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 44px 34px 30px;
    border-radius: 32px;
    background:
        radial-gradient(120% 70% at 50% 0%, rgba(233, 30, 99, 0.18) 0%, rgba(233, 30, 99, 0) 60%),
        radial-gradient(100% 60% at 50% 100%, rgba(124, 77, 255, 0.12) 0%, rgba(124, 77, 255, 0) 60%),
        linear-gradient(170deg, #221632 0%, #140b21 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow:
        0 36px 70px -24px rgba(0, 0, 0, 0.85),
        0 14px 40px -12px rgba(233, 30, 99, 0.22),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    touch-action: pan-y;
    will-change: transform, opacity;
    transition: transform 0.4s cubic-bezier(0.2, 0.85, 0.2, 1),
                opacity 0.4s ease;
    overflow: hidden;
}

.ms-card::before {
    /* subtle inner glow ring */
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(140% 80% at 50% 0%, rgba(255, 255, 255, 0.04), transparent 55%);
    pointer-events: none;
}

.ms-card:active { cursor: grabbing; }
.ms-card.ms-drag { transition: none; }

.ms-card.ms-pos-0 { z-index: 3; }
.ms-card.ms-pos-1 {
    z-index: 2;
    transform: scale(0.94) translateY(14px);
    opacity: 0.72;
}
.ms-card.ms-pos-2 {
    z-index: 1;
    transform: scale(0.88) translateY(26px);
    opacity: 0.42;
}

.ms-card.ms-gone-right {
    transform: translateX(145%) translateY(-8%) rotate(22deg);
    opacity: 0;
}

.ms-card.ms-gone-left {
    transform: translateX(-145%) translateY(-8%) rotate(-22deg);
    opacity: 0;
}

/* ── Card content (motto is the hero) ──────────────────────────── */
.ms-card-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 2.2px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.48);
}

.ms-card-label::before {
    content: '';
    width: 24px;
    height: 1px;
    background: linear-gradient(90deg, rgba(233, 30, 99, 0.8), rgba(124, 77, 255, 0.8));
}

.ms-card-mark {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 72px;
    line-height: 0.85;
    color: transparent;
    background: linear-gradient(135deg, #ff5a8c 0%, #a078ff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    margin: 22px 0 6px;
    user-select: none;
    letter-spacing: -4px;
}

.ms-card-motto {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    font-size: clamp(26px, 6.8vw, 36px);
    line-height: 1.28;
    font-weight: 700;
    text-align: left;
    color: #ffffff;
    letter-spacing: -0.5px;
    overflow-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
    margin: 0;
    /* Reserve space so short mottos still feel dramatic */
    min-height: 140px;
}

.ms-card-motto::after {
    content: '"';
    display: inline;
    font-family: Georgia, "Times New Roman", serif;
    margin-left: 2px;
    color: rgba(255, 255, 255, 0.3);
}

.ms-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 22px;
    margin-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.ms-card-who {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ms-card-name {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ms-card-meta {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.2px;
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ms-card-flag {
    font-size: 17px;
    line-height: 1;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: middle;
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol",
                 "Noto Color Emoji", "Twemoji Mozilla", "EmojiOne Color",
                 "Android Emoji", sans-serif;
    -webkit-text-fill-color: initial;
    color: initial;
}

/* ── Drag decision labels ───────────────────────────────────────── */
.ms-card-tag {
    position: absolute;
    top: 30px;
    padding: 10px 18px;
    border: 2.5px solid currentColor;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 900;
    letter-spacing: 3px;
    text-transform: uppercase;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 2;
}

.ms-card-tag-like {
    right: 26px;
    color: #4ade80;
    transform: rotate(14deg);
    background: rgba(74, 222, 128, 0.12);
    text-shadow: 0 0 18px rgba(74, 222, 128, 0.5);
}

.ms-card-tag-pass {
    left: 26px;
    color: #f87171;
    transform: rotate(-14deg);
    background: rgba(248, 113, 113, 0.12);
    text-shadow: 0 0 18px rgba(248, 113, 113, 0.5);
}

/* ── Action bar ─────────────────────────────────────────────────── */
.ms-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 34px;
    padding: 14px 0 22px;
    flex-shrink: 0;
}

.ms-btn {
    width: 66px;
    height: 66px;
    border-radius: 50%;
    background: linear-gradient(165deg, #241736 0%, #140b21 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow:
        0 14px 30px -10px rgba(0, 0, 0, 0.85),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: transform 0.15s ease, box-shadow 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.ms-btn:active { transform: scale(0.9); }
.ms-btn-pass { color: #f87171; }
.ms-btn-like { color: #4ade80; }

.ms-btn-pass:hover {
    box-shadow:
        0 14px 30px -10px rgba(248, 113, 113, 0.55),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.ms-btn-like:hover {
    box-shadow:
        0 14px 30px -10px rgba(74, 222, 128, 0.55),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.ms-btn svg {
    width: 28px;
    height: 28px;
    stroke-width: 2.6;
}

/* ── Empty / no-motto states ────────────────────────────────────── */
.ms-empty,
.ms-nomotto {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 30px;
    text-align: center;
}

.ms-empty.ms-visible,
.ms-nomotto.ms-visible {
    display: flex;
}

.ms-empty-icon,
.ms-nomotto-icon {
    font-size: 52px;
    margin-bottom: 18px;
    opacity: 0.85;
}

.ms-empty-title,
.ms-nomotto-title {
    font-size: 22px;
    font-weight: 800;
    color: #ffffff;
    margin: 0 0 10px;
    letter-spacing: -0.3px;
}

.ms-empty-text,
.ms-nomotto-text {
    font-size: 14px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.55);
    max-width: 310px;
    margin: 0 0 26px;
}

.ms-empty-btn,
.ms-nomotto-btn {
    padding: 14px 28px;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, #E91E63 0%, #7C4DFF 100%);
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 12px 28px -8px rgba(233, 30, 99, 0.55);
    transition: transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    letter-spacing: 0.2px;
}

.ms-empty-btn:active,
.ms-nomotto-btn:active { transform: scale(0.96); }

/* ══════════════════════════════════════════════════════════════════
   MATCH CELEBRATION  (confetti + profile card)
   ══════════════════════════════════════════════════════════════════ */

.ms-match-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    background: radial-gradient(120% 80% at 50% 40%, rgba(32, 14, 50, 0.95) 0%, rgba(4, 2, 10, 0.98) 100%);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 24px;
    animation: ms-fade-in 0.3s ease;
    overflow: hidden;
}

.ms-match-overlay.ms-active { display: flex; }

@keyframes ms-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Confetti canvas layer */
.ms-confetti {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.ms-confetti-piece {
    position: absolute;
    top: -20px;
    width: 10px;
    height: 16px;
    border-radius: 2px;
    opacity: 0;
    will-change: transform, opacity;
}

@keyframes ms-confetti-fall {
    0% {
        transform: translate(0, -40px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translate(var(--ms-cx, 0px), calc(var(--ms-cy, 100vh) + 60px)) rotate(var(--ms-cr, 720deg));
        opacity: 0;
    }
}

/* Match banner — headline */
.ms-match-banner {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 18px;
    animation: ms-banner-in 0.6s cubic-bezier(0.2, 1.4, 0.3, 1);
}

@keyframes ms-banner-in {
    0%   { transform: scale(0.4); opacity: 0; }
    60%  { transform: scale(1.08); opacity: 1; }
    100% { transform: scale(1);    opacity: 1; }
}

.ms-match-eyebrow {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 6px;
}

.ms-match-headline {
    font-size: 48px;
    line-height: 1;
    font-weight: 900;
    margin: 0;
    background: linear-gradient(135deg, #ff5a8c 0%, #ffb05e 50%, #a078ff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -1.5px;
    text-align: center;
    filter: drop-shadow(0 4px 24px rgba(233, 30, 99, 0.5));
}

/* Profile card inside the match */
.ms-match-profile {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 360px;
    padding: 26px 22px 22px;
    border-radius: 26px;
    background: linear-gradient(165deg, #261638 0%, #110820 100%);
    border: 1px solid rgba(233, 30, 99, 0.35);
    box-shadow:
        0 40px 80px -20px rgba(233, 30, 99, 0.55),
        0 12px 40px -10px rgba(0, 0, 0, 0.85);
    text-align: center;
    animation: ms-profile-in 0.5s cubic-bezier(0.2, 1.1, 0.3, 1) 0.15s both;
}

@keyframes ms-profile-in {
    from { transform: translateY(30px) scale(0.95); opacity: 0; }
    to   { transform: translateY(0)    scale(1);    opacity: 1; }
}

.ms-match-avatar {
    position: relative;
    width: 104px;
    height: 104px;
    margin: 0 auto 14px;
    border-radius: 50%;
    padding: 3px;
    background: conic-gradient(from 180deg,
        #ff5a8c 0%,
        #ffb05e 25%,
        #a078ff 55%,
        #7c4dff 80%,
        #ff5a8c 100%);
    animation: ms-ring-spin 6s linear infinite;
}

@keyframes ms-ring-spin {
    to { transform: rotate(360deg); }
}

.ms-match-avatar-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    background: #241736 center/cover no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 42px;
    font-weight: 800;
    animation: ms-ring-spin 6s linear infinite reverse;
    border: 3px solid #110820;
}

.ms-match-name {
    font-size: 22px;
    font-weight: 800;
    color: #ffffff;
    margin: 0 0 4px;
    letter-spacing: -0.3px;
}

.ms-match-sub {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.55);
    margin: 0 0 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.ms-match-sub .ms-dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
}

.ms-match-motto {
    font-size: 16px;
    line-height: 1.5;
    font-style: italic;
    color: rgba(255, 255, 255, 0.92);
    margin: 0 0 18px;
    padding: 16px 18px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
    position: relative;
}

.ms-match-motto::before {
    content: '"';
    position: absolute;
    top: -8px;
    left: 12px;
    font-family: Georgia, serif;
    font-size: 36px;
    color: rgba(233, 30, 99, 0.6);
    line-height: 1;
    background: #1a102a;
    padding: 0 4px;
}

.ms-match-actions {
    display: flex;
    gap: 10px;
}

.ms-match-btn {
    flex: 1;
    padding: 14px 14px;
    border-radius: 14px;
    border: none;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.ms-match-btn:active { transform: scale(0.97); }

.ms-match-btn-primary {
    background: linear-gradient(135deg, #E91E63 0%, #7C4DFF 100%);
    color: #ffffff;
    box-shadow: 0 10px 26px -8px rgba(233, 30, 99, 0.65);
}

.ms-match-btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ── Toast (mini feedback) ──────────────────────────────────────── */
.ms-toast {
    position: fixed;
    left: 50%;
    bottom: 150px;
    transform: translateX(-50%) translateY(14px);
    padding: 12px 20px;
    border-radius: 999px;
    background: rgba(20, 14, 28, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 16px 34px -10px rgba(0, 0, 0, 0.7);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.3s ease;
    z-index: 9999;
}

.ms-toast.ms-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── Mobile refinements ─────────────────────────────────────────── */
@media (max-height: 730px) {
    .ms-card { padding: 36px 28px 24px; }
    .ms-card-mark { font-size: 60px; margin: 16px 0 4px; }
    .ms-card-motto { min-height: 110px; }
    .ms-actions { padding: 10px 0 18px; }
    .ms-btn { width: 60px; height: 60px; }
    .ms-match-headline { font-size: 40px; }
}

@media (max-width: 360px) {
    .ms-card { padding: 32px 24px 22px; }
    .ms-card-motto { font-size: 24px; }
}
