/* ============================================
   CODACOIN — Bitcoin Halving Countdown
   Dark theme · Matching main site
   ============================================ */

/* ---- Design Tokens (same as main) ---- */
:root {
    --bg: #08080d;
    --bg-card: #111118;
    --bg-hover: #1a1a26;
    --border: #22222e;
    --text: #d4d4e0;
    --text-dim: #7a7a99;
    --text-muted: #4a4a66;
    --green: #22c55e;
    --green-bg: rgba(34, 197, 94, .12);
    --red: #ef4444;
    --red-bg: rgba(239, 68, 68, .12);
    --accent: #3b82f6;
    --accent-dim: #2563eb;
    --orange: #f59e0b;
    --orange-bg: rgba(245, 158, 11, .10);
    --btc: #f7931a;
    --btc-bg: rgba(247, 147, 26, .10);
    --btc-glow: rgba(247, 147, 26, .25);
    --radius: 8px;
    --radius-lg: 12px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --mono: 'SF Mono', 'Fira Code', 'Courier New', monospace;
    --max-w: 860px;
    --gap: 16px;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    padding: 0 var(--gap) 48px;
    max-width: var(--max-w);
    margin: 0 auto;
    min-height: 100vh;
}

.hidden { display: none !important; }

/* ---- Top Nav ---- */
.top-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 0 10px;
}

.top-nav__link {
    color: var(--text-dim);
    font-size: .85rem;
    font-weight: 600;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 4px 10px;
    border-radius: var(--radius);
    transition: color .15s, background .15s;
}

.top-nav__link:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.top-nav__link--active {
    color: var(--btc);
    background: var(--btc-bg);
}

.top-nav__sep {
    color: var(--text-muted);
    font-size: .7rem;
}

/* ---- Halving Hero ---- */
.halving-hero {
    text-align: center;
    padding: 24px 0 20px;
}

.halving-hero__icon {
    font-size: 2.8rem;
    color: var(--btc);
    margin-bottom: 6px;
    text-shadow: 0 0 24px var(--btc-glow);
}

.halving-hero__title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.01em;
    margin-bottom: 4px;
}

.halving-hero__subtitle {
    font-size: .85rem;
    color: var(--text-dim);
    margin-bottom: 18px;
}

.halving-hero__subtitle span {
    color: var(--btc);
    font-weight: 600;
    font-family: var(--mono);
}

/* ---- Progress Bar ---- */
.progress-wrap {
    width: 100%;
    max-width: 520px;
    height: 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 99px;
    margin: 0 auto 6px;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--btc), #fbbf24);
    border-radius: 99px;
    transition: width .8s ease;
    width: 0%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
    min-width: 40px;
}

.progress-bar__text {
    font-size: .65rem;
    font-weight: 700;
    color: #000;
    font-family: var(--mono);
    white-space: nowrap;
}

.progress-label {
    font-size: .72rem;
    color: var(--text-muted);
    font-family: var(--mono);
    margin-bottom: 20px;
}

/* ---- Countdown ---- */
.countdown {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-bottom: 8px;
}

.countdown__unit {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 68px;
}

.countdown__num {
    font-size: 2.6rem;
    font-weight: 800;
    font-family: var(--mono);
    color: var(--text);
    line-height: 1;
    letter-spacing: -.02em;
}

.countdown__label {
    font-size: .65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-top: 4px;
}

.countdown__sep {
    font-size: 2rem;
    font-weight: 300;
    color: var(--text-muted);
    padding-bottom: 16px;
}

.halving-hero__date {
    font-size: .82rem;
    color: var(--btc);
    font-weight: 500;
}

/* ---- Stats Grid ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: var(--gap);
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: border-color .15s;
}

.stat-card:hover {
    border-color: var(--text-muted);
}

.stat-card--clickable {
    cursor: pointer;
    user-select: none;
}

.stat-card--clickable:hover {
    border-color: var(--btc);
}

.stat-card__hint {
    font-size: .6rem;
    color: var(--text-muted);
}

/* ---- Epoch History Dropdown ---- */
.epoch-history {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-top: -8px;
    margin-bottom: var(--gap);
    overflow: hidden;
    animation: slideDown .2s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.epoch-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .8rem;
}

.epoch-table th {
    text-align: left;
    font-size: .65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}

.epoch-table td {
    padding: 9px 14px;
    color: var(--text-dim);
    font-family: var(--mono);
    font-size: .78rem;
    border-bottom: 1px solid var(--border);
}

.epoch-table tr:last-child td {
    border-bottom: none;
}

.epoch-table__current td {
    color: var(--btc) !important;
    font-weight: 600;
}

.stat-card__label {
    font-size: .68rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    line-height: 1.2;
}

.stat-card__value {
    font-size: 1.1rem;
    font-weight: 700;
    font-family: var(--mono);
    color: var(--text);
    line-height: 1.2;
}

.stat-card__value--live {
    color: var(--green);
}

/* ---- Block Time Chart ---- */
.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    margin-bottom: var(--gap);
}

.chart-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.chart-card__title {
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-dim);
}

.chart-card__hover-info {
    font-size: .75rem;
    font-weight: 600;
    font-family: var(--mono);
    color: var(--btc);
    min-height: 1em;
}

.chart-card__wrap {
    position: relative;
    height: 200px;
}

.chart-card__wrap canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ---- Recent Blocks ---- */
.section-title {
    font-size: .9rem;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 10px;
}

.recent-blocks {
    margin-bottom: var(--gap);
}

.blocks-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.blocks-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .82rem;
}

.blocks-table th {
    text-align: left;
    font-size: .68rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 10px 12px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
}

.blocks-table td {
    padding: 9px 12px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    font-family: var(--mono);
    font-size: .78rem;
    white-space: nowrap;
}

.blocks-table tr:last-child td {
    border-bottom: none;
}

.blocks-table a {
    color: var(--text);
    text-decoration: none;
    transition: color .15s;
}

.blocks-table a:hover {
    color: var(--btc);
}

.blocks-table tr:hover td {
    background: var(--bg-hover);
}

.blocks-table .fast { color: var(--green); }
.blocks-table .slow { color: var(--red); }
.blocks-table .normal { color: var(--text-dim); }

/* ---- New Block Flash ---- */
.blocks-table tr.new-block td {
    animation: flashBlock .8s ease;
}

@keyframes flashBlock {
    0%   { background: var(--btc-bg); }
    100% { background: transparent; }
}

/* ---- Live Badge ---- */
.live-badge {
    position: fixed;
    bottom: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 99px;
    padding: 6px 14px 6px 10px;
    font-size: .72rem;
    color: var(--text-dim);
    z-index: 1000;
}

.live-badge__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background .3s;
}

.live-badge--connected .live-badge__dot {
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
    animation: pulse 2s infinite;
}

.live-badge--connected .live-badge__text {
    color: var(--green);
}

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

/* ---- Block Flash ---- */
.block-flash {
    animation: bgFlash 1.2s ease;
}

@keyframes bgFlash {
    0%   { background-color: rgba(247, 147, 26, .12); }
    100% { background-color: var(--bg); }
}

/* ---- Beep Toggle ---- */
.beep-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 99px;
    padding: 5px 12px 5px 8px;
    font-size: .7rem;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: border-color .15s, color .15s;
    margin-left: 8px;
}

.beep-toggle:hover {
    border-color: var(--text-dim);
    color: var(--text-dim);
}

.beep-toggle--on {
    border-color: var(--btc);
    color: var(--btc);
}

.beep-toggle__icon {
    font-size: .85rem;
    line-height: 1;
}

/* ---- Data Tabs ---- */
.data-tabs {
    margin-bottom: var(--gap);
}

.data-tabs__nav {
    display: flex;
    border-bottom: 1px solid var(--border);
    gap: 0;
}

.data-tabs__btn {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    padding: 10px 18px;
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 7px;
    transition: color .15s, border-color .15s;
    letter-spacing: .01em;
    font-family: var(--font);
}

.data-tabs__btn:hover { color: var(--text); }

.data-tabs__btn--active {
    color: var(--text);
    border-bottom-color: var(--btc);
}

.data-tabs__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background .3s, box-shadow .3s;
    flex-shrink: 0;
}

.data-tabs__btn--active .data-tabs__dot {
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
    animation: pulse 2s infinite;
}

.data-tabs__panel {
    padding-top: var(--gap);
}

/* ---- Txn Stats Bar ---- */
.txn-stats-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--gap);
    margin-bottom: var(--gap);
}

.txn-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.txn-stat-card__label {
    font-size: .65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    white-space: nowrap;
}

.txn-stat-card__value {
    font-size: .9rem;
    font-weight: 700;
    color: var(--text);
    font-family: var(--mono);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.txn-stat-card__value--highlight { color: var(--btc); }

/* ---- Live Transactions Feed ---- */
.live-txns {
    margin-top: 0;
}

.txn-feed {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 380px;
    overflow: hidden;
    position: relative;
}

.txn-feed__empty {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: .82rem;
}

.txn-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 14px;
    border-bottom: 1px solid var(--border);
    font-size: .78rem;
    font-family: var(--mono);
    animation: txnSlideIn .35s ease;
}

.txn-row:last-child {
    border-bottom: none;
}

.txn-row__amount {
    font-weight: 600;
    min-width: 100px;
    text-align: right;
}

.txn-row__amount--large {
    color: var(--btc);
}

.txn-row__amount--medium {
    color: var(--orange);
}

.txn-row__amount--small {
    color: var(--text-dim);
}

.txn-row__hash {
    color: var(--text-muted);
    text-decoration: none;
    transition: color .15s;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
}

.txn-row__hash:hover {
    color: var(--btc);
}

.txn-row__time {
    color: var(--text-muted);
    font-size: .7rem;
    min-width: 50px;
    text-align: right;
}

@keyframes txnSlideIn {
    0% {
        opacity: 0;
        transform: translateY(-18px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---- Footer ---- */
.footer-bar {
    display: flex;
    align-items: center;
    font-size: .7rem;
    color: var(--text-muted);
    padding: 16px 0 8px;
    border-top: 1px solid var(--border);
    margin-top: 16px;
}

.footer-bar__left,
.footer-bar__right {
    flex: 1;
}

.footer-bar__left {
    color: var(--text-muted);
}

.footer-bar__right {
    text-align: right;
    color: var(--text-muted);
}

/* ── mytools.studio credit footer ── */
.mytools-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.mytools-footer__link {
    display: flex;
    align-items: center;
    gap: 7px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: lowercase;
    transition: color 0.15s;
}

.mytools-footer__link:hover { color: var(--text-dim); }

.mytools-footer__logo {
    width: 20px;
    height: 20px;
    border-radius: 5px;
    opacity: 0.75;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.mytools-footer__link:hover .mytools-footer__logo { opacity: 1; }

.mytools-footer__label {
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 1px;
    transition: border-color 0.15s, color 0.15s;
}

.mytools-footer__link:hover .mytools-footer__label {
    border-bottom-color: var(--accent);
    color: var(--accent);
}

.mytools-footer__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    flex-shrink: 0;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
    animation: mts-pulse 2.4s ease-in-out infinite;
}

@keyframes mts-pulse {
    0%   { opacity: 1;    box-shadow: 0 0 0 0   rgba(34, 197, 94, 0.55); }
    50%  { opacity: 0.6;  box-shadow: 0 0 0 5px rgba(34, 197, 94, 0);    }
    100% { opacity: 1;    box-shadow: 0 0 0 0   rgba(34, 197, 94, 0.55); }
}

/* ---- Responsive ---- */
@media (max-width: 700px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .txn-stats-bar {
        grid-template-columns: repeat(2, 1fr);
    }

    .countdown__num {
        font-size: 1.8rem;
    }

    .countdown__unit {
        min-width: 50px;
    }

    .countdown__sep {
        font-size: 1.4rem;
    }

    .chart-card__wrap {
        height: 160px;
    }

    .blocks-table th:nth-child(5),
    .blocks-table td:nth-child(5) {
        display: none;
    }

    .txn-row__hash {
        max-width: 120px;
    }
}

@media (max-width: 420px) {
    .countdown__num {
        font-size: 1.5rem;
    }

    .countdown__unit {
        min-width: 42px;
    }

    .stat-card__value {
        font-size: .9rem;
    }

    .halving-hero__title {
        font-size: 1.1rem;
    }

    .blocks-table th:nth-child(4),
    .blocks-table td:nth-child(4) {
        display: none;
    }
}
