/* ==========================================================
   Pi Network — Unlock Locked Pi (Demo)
   Stylesheet
   Palette:  Purple #5B2D90  |  Gold #F4B400  |  White #FFFFFF
   Font:     Mulish
   ========================================================== */

/* ---------- Design tokens ---------- */
:root {
    /* Pi-inspired palette (royal purple + signature gold). Not affiliated
     * with Pi Network; values approximate the visual style only. */
    --purple: #6E3DAA;
    --purple-dark: #4F2A87;
    --purple-light: #9B6DEF;
    --gold: #F4B400;
    --gold-soft: #FFD24A;
    --white: #ffffff;
    --bg: #ffffff;
    --bg-soft: #faf8fd;
    --border: #ecebf2;
    --text: #1c1330;
    --text-muted: #6b6582;
    --shadow-sm: 0 2px 8px rgba(110, 61, 170, 0.06);
    --shadow-md: 0 10px 30px rgba(110, 61, 170, 0.12);
    --shadow-lg: 0 20px 60px rgba(110, 61, 170, 0.22);
    --radius: 14px;
    --radius-lg: 20px;
    --transition: 0.25s ease;

    /* Single source of truth for the application font.
     * Mulish is loaded from Google Fonts in index.html. */
    --font-family: 'Mulish', system-ui, -apple-system, BlinkMacSystemFont,
                   'Segoe UI', Roboto, sans-serif;
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-family);
}

html, body {
    font-family: var(--font-family);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    min-height: 100vh;
}

/* Form controls don't inherit font-family by default in some browsers —
 * force them to use Mulish explicitly. */
button,
input,
textarea,
select,
optgroup {
    font-family: var(--font-family);
}

button { cursor: pointer; }
a { text-decoration: none; color: inherit; }

.hidden { display: none !important; }

/* ==========================================================
   NAVBAR
   ========================================================== */
.navbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    backdrop-filter: saturate(180%) blur(10px);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    object-fit: contain;
    display: block;
    border-radius: 10px;
}

.logo-text {
    font-weight: 800;
    font-size: 18px;
    letter-spacing: -0.2px;
    color: var(--purple);
}

.nav-links {
    display: flex;
    gap: 28px;
}

.nav-link {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 14px;
    position: relative;
    padding: 8px 0;
    transition: color var(--transition);
}

.nav-link:hover { color: var(--purple); }

.nav-link.active {
    color: var(--purple);
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--gold);
    border-radius: 2px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #fff5d6;
    color: #8a6500;
    border: 1px solid #f5e1a3;
    padding: 6px 12px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.status-pill.unlocked {
    background: #e7f8ee;
    color: #1f7a3f;
    border-color: #b9e6c8;
}

.status-pill.unlocked .status-dot {
    background: #1f7a3f;
    box-shadow: 0 0 0 4px rgba(31, 122, 63, 0.18);
    animation: none;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gold);
    box-shadow: 0 0 0 4px rgba(244, 180, 0, 0.18);
    animation: pulseDot 1.6s infinite;
}

@keyframes pulseDot {
    0%, 100% { box-shadow: 0 0 0 4px rgba(244, 180, 0, 0.18); }
    50%      { box-shadow: 0 0 0 8px rgba(244, 180, 0, 0.05); }
}

/* ==========================================================
   ACCESS GATE
   ========================================================== */
.gate-screen {
    min-height: calc(100vh - 80px);
    display: grid;
    place-items: center;
    padding: 40px 20px;
    background:
        radial-gradient(1200px 600px at 80% -10%, rgba(244, 180, 0, 0.10), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(110, 61, 170, 0.10), transparent 60%),
        var(--bg);
}

.gate-card {
    width: 100%;
    max-width: 440px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 32px;
    box-shadow: var(--shadow-md);
    text-align: center;
    animation: fadeUp 0.5s ease both;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

.gate-logo {
    display: block;
    width: 88px;
    height: 88px;
    margin: 0 auto 18px;
    object-fit: contain;
    border-radius: 20px;
    filter: drop-shadow(0 10px 24px rgba(110, 61, 170, 0.28));
    animation: floaty 3.5s ease-in-out infinite;
}

@keyframes floaty {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-4px); }
}

.gate-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--purple);
    margin-bottom: 8px;
}

.gate-subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 28px;
}

.gate-form {
    text-align: left;
}

.gate-label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.input-wrap {
    position: relative;
    margin-bottom: 18px;
}

.gate-input {
    width: 100%;
    padding: 14px 44px 14px 16px;
    border-radius: 12px;
    border: 1.5px solid var(--border);
    background: var(--bg-soft);
    font-size: 15px;
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

/* Textarea variant for 24-word BIP39 phrase */
.gate-textarea {
    -webkit-text-security: disc;
}

.gate-textarea.revealed {
    -webkit-text-security: none;
}

.gate-input:focus {
    outline: none;
    border-color: var(--purple);
    background: var(--white);
    box-shadow: 0 0 0 4px rgba(110, 61, 170, 0.10);
}

.toggle-eye {
    position: absolute;
    right: 10px;
    top: 10px;
    background: transparent;
    border: 0;
    font-size: 16px;
    color: var(--text-muted);
    padding: 6px;
    border-radius: 8px;
    transition: background var(--transition), color var(--transition);
    z-index: 2;
}
.toggle-eye:hover { background: rgba(110, 61, 170, 0.08); color: var(--purple); }
.toggle-eye.active { color: var(--purple); }

.gate-btn {
    width: 100%;
}

.gate-error {
    margin-top: 12px;
    color: #c0392b;
    font-size: 13px;
    font-weight: 600;
    min-height: 18px;
    text-align: center;
}

.gate-footnote {
    margin-top: 22px;
    font-size: 12px;
    color: var(--text-muted);
}

/* ==========================================================
   BUTTONS
   ========================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-weight: 700;
    font-size: 14px;
    padding: 14px 22px;
    border-radius: 12px;
    border: 0;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}

.btn-primary {
    background: linear-gradient(135deg, var(--purple), var(--purple-light));
    color: var(--white);
    box-shadow: 0 8px 20px rgba(110, 61, 170, 0.30);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 26px rgba(110, 61, 170, 0.36);
}

.btn-primary:active { transform: translateY(0); }

/* ==========================================================
   DASHBOARD LAYOUT
   ========================================================== */
.dashboard {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px 64px;
    animation: fadeUp 0.5s ease both;
}

.welcome {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 16px;
    flex-wrap: wrap;
}

.welcome-title {
    font-size: 26px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.4px;
}

.welcome-sub {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 4px;
}

.welcome-date {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    padding: 10px 16px;
    border-radius: 12px;
    color: var(--purple);
    font-weight: 700;
    font-size: 13px;
}

/* ---------- Top Cards ---------- */
.cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 28px;
}

.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent, rgba(110, 61, 170, 0.04));
    opacity: 0;
    transition: opacity var(--transition);
    pointer-events: none;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}
.card:hover::before { opacity: 1; }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.card-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
}

.card-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(110, 61, 170, 0.08), rgba(244, 180, 0, 0.08));
    display: grid;
    place-items: center;
    font-size: 16px;
}

.card-value {
    font-size: 26px;
    font-weight: 800;
    color: var(--text);
    display: flex;
    align-items: baseline;
    gap: 6px;
    letter-spacing: -0.4px;
}

.card-unit {
    color: var(--gold);
    font-weight: 800;
    font-size: 18px;
}

.fee-percent {
    background: linear-gradient(135deg, var(--purple), var(--gold));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-size: 30px;
}

.card-footer {
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-muted);
}

.trend {
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
}
.trend-up   { background: #e7f8ee; color: #1f7a3f; }

/* ---------- Card: Success / Unlocked state ---------- */
.card.card-success {
    border-color: #b9e6c8;
    background:
        linear-gradient(135deg, rgba(31, 122, 63, 0.05), rgba(244, 180, 0, 0.05)),
        var(--white);
    animation: cardPop 0.55s ease both;
}

.card.card-success .card-icon {
    background: linear-gradient(135deg, #e7f8ee, #fff5d6);
    color: #1f7a3f;
    font-size: 18px;
}

@keyframes cardPop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.025); }
    100% { transform: scale(1); }
}

/* ---------- Progress Section ---------- */
.progress-section,
.fee-section,
.action-section {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 26px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.progress-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.section-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.2px;
}

.section-sub {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 4px;
}

.progress-percent {
    font-size: 28px;
    font-weight: 800;
    color: var(--purple);
    letter-spacing: -0.5px;
}

.progress-bar-wrap {
    height: 14px;
    border-radius: 999px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--purple), var(--gold));
    transition: width 0.3s ease;
    position: relative;
    overflow: hidden;
}

.progress-bar::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.45),
        transparent
    );
    transform: translateX(-100%);
    animation: shimmer 1.6s linear infinite;
}

@keyframes shimmer {
    100% { transform: translateX(100%); }
}

.progress-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

/* ---------- Fee Breakdown ---------- */
.fee-grid {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.fee-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--bg-soft);
    font-size: 14px;
    color: var(--text);
    font-weight: 600;
}

.fee-amount { color: #c0392b; }

.fee-row-total {
    background: linear-gradient(135deg, rgba(110, 61, 170, 0.07), rgba(244, 180, 0, 0.07));
    color: var(--purple);
    font-weight: 800;
    border: 1px solid rgba(110, 61, 170, 0.15);
    margin-top: 6px;
}

/* ---------- Action / Unlock Button ---------- */
.action-section { text-align: center; }

.btn-unlock {
    background: linear-gradient(135deg, var(--purple), var(--purple-light));
    color: var(--white);
    font-size: 16px;
    font-weight: 800;
    padding: 18px 36px;
    border-radius: 14px;
    border: 0;
    position: relative;
    overflow: hidden;
    box-shadow: 0 12px 28px rgba(110, 61, 170, 0.32);
    transition: transform var(--transition), box-shadow var(--transition);
    letter-spacing: 0.3px;
}

.btn-unlock::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--gold), var(--gold-soft));
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 0;
}

.btn-unlock > * { position: relative; z-index: 1; }

.btn-unlock:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 16px 36px rgba(110, 61, 170, 0.40);
}
.btn-unlock:hover::before { opacity: 1; }
.btn-unlock:active { transform: translateY(0); }

.btn-unlock[disabled] {
    cursor: not-allowed;
    opacity: 0.85;
    transform: none;
}

/* Permanent "Unlocked" state — replaces the purple gradient with a
 * confirmation green so it's visually clear the action is complete. */
.btn-unlock.btn-unlocked {
    background: linear-gradient(135deg, #1f7a3f, #2da866);
    box-shadow: 0 12px 28px rgba(31, 122, 63, 0.28);
    cursor: default;
    opacity: 1;
}
.btn-unlock.btn-unlocked::before { display: none; }
.btn-unlock.btn-unlocked:hover {
    transform: none;
    box-shadow: 0 12px 28px rgba(31, 122, 63, 0.28);
}
.btn-unlock.btn-unlocked .btn-spark {
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.25);
}

/* Progress bar in finished state — stop shimmer, lock in gradient */
.progress-bar.progress-done::after {
    animation: none;
    display: none;
}

.btn-arrow {
    transition: transform var(--transition);
}
.btn-unlock:hover .btn-arrow { transform: translateX(4px); }

.btn-spark {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--gold);
    box-shadow: 0 0 0 4px rgba(244, 180, 0, 0.30);
    animation: pulseDot 1.6s infinite;
}

/* Loading state inside button */
.btn-unlock.loading .btn-label::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: 10px;
    border: 2.5px solid rgba(255, 255, 255, 0.4);
    border-top-color: var(--white);
    border-radius: 50%;
    vertical-align: middle;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.action-note {
    margin-top: 14px;
    color: var(--text-muted);
    font-size: 13px;
}

/* ==========================================================
   MODAL — Success
   ========================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(28, 19, 48, 0.55);
    display: grid;
    place-items: center;
    padding: 20px;
    animation: fadeIn 0.3s ease;
    backdrop-filter: blur(4px);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
    width: 100%;
    max-width: 420px;
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 36px 28px 28px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: popIn 0.45s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes popIn {
    from { opacity: 0; transform: scale(0.85); }
    to   { opacity: 1; transform: scale(1); }
}

.success-ring {
    width: 84px;
    height: 84px;
    margin: 0 auto 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--purple), var(--gold));
    display: grid;
    place-items: center;
    box-shadow: 0 12px 32px rgba(110, 61, 170, 0.35);
    animation: ringPop 0.55s ease both;
}

@keyframes ringPop {
    0%   { transform: scale(0); }
    70%  { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.check {
    color: var(--white);
    font-size: 36px;
    font-weight: 900;
    line-height: 1;
}

.modal-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--purple);
    margin-bottom: 4px;
}

.modal-sub {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 22px;
}

.modal-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.modal-stat {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 4px;
}

.stat-value {
    display: block;
    font-size: 15px;
    color: var(--purple);
    font-weight: 800;
}

.modal-close { width: 100%; }

/* ==========================================================
   FOOTER
   ========================================================== */
.footer {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 13px;
    border-top: 1px solid var(--border);
    background: var(--bg-soft);
}

/* ==========================================================
   RESPONSIVE
   ========================================================== */
@media (max-width: 860px) {
    .cards { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
    .nav-links { display: none; }
    .cards { grid-template-columns: 1fr; }
    .welcome-title { font-size: 22px; }
    .gate-card { padding: 32px 22px; }
    .progress-section,
    .fee-section,
    .action-section { padding: 20px; }
    .btn-unlock { width: 100%; }
}