/* Momentum Tools: one stylesheet for every page. */

@font-face {
    font-family: "Bricolage Grotesque";
    src: url("../fonts/BricolageGrotesque-Variable.woff2") format("woff2");
    font-weight: 200 800;
    font-display: swap;
}
@font-face {
    font-family: "Inter";
    src: url("../fonts/Inter-Variable.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
}

:root {
    --ink: #0E1420;
    --panel: #151D2B;
    --panel-raised: #1B2536;
    --line: #26324A;
    --line-strong: #34425E;
    --text: #E9EEF5;
    --muted: #94A0B4;
    --focus: #7CB7FF;

    --rewards: #5EE6A8;
    --balances: #7CB7FF;
    --sentinel: #C4A3FF;
    --bridge: #FFB86B;
    --ledger: #A9B4C6;
    --good: #5EE6A8;
    --bad: #FF7A93;

    --accent: var(--balances);
    --radius-s: 8px;
    --radius-m: 14px;
    --display: "Bricolage Grotesque", "Inter", system-ui, sans-serif;
    --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

    color-scheme: dark;
}

[data-category="rewards"]  { --accent: var(--rewards); }
[data-category="balances"] { --accent: var(--balances); }
[data-category="sentinel"] { --accent: var(--sentinel); }
[data-category="bridge"]   { --accent: var(--bridge); }
[data-category="ledger"]   { --accent: var(--ledger); }

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

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--ink);
    color: var(--text);
    font-family: var(--body);
    font-size: 1rem;
    line-height: 1.55;
    font-feature-settings: "tnum" 1, "cv11" 1;
    overflow-x: hidden;
}
body > main { flex: 1 0 auto; }

.container { max-width: 1120px; padding-inline: 20px; }

a { color: var(--accent); text-underline-offset: 3px; }
a:hover, a:focus { color: var(--text); }

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
    border-radius: 4px;
}

.skip-link {
    position: absolute;
    left: 12px;
    top: -60px;
    z-index: 100;
    padding: 0.5rem 0.9rem;
    background: var(--text);
    color: var(--ink);
    border-radius: var(--radius-s);
}
.skip-link:focus { top: 12px; color: var(--ink); }

/* ---------- Top bar ---------- */

.topbar {
    position: sticky;
    top: env(safe-area-inset-top, 0px);
    z-index: 50;
    background: rgba(14, 20, 32, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
}
.topbar-inner {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 64px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text);
    font-family: var(--display);
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.01em;
    text-decoration: none;
    white-space: nowrap;
}
.brand:hover, .brand:focus { color: var(--text); }
.brand img { display: block; border-radius: 7px; }
.brand-small { font-size: 1rem; }

.ticker {
    display: flex;
    gap: 1rem;
    margin: 0 0 0 auto;
    color: var(--muted);
    font-size: 0.875rem;
    white-space: nowrap;
}
.ticker b { color: var(--text); font-weight: 600; margin-left: 0.25rem; }

.menu-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 44px;
    padding: 0 0.95rem;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--panel);
    color: var(--text);
    font: 600 0.95rem/1 var(--body);
    cursor: pointer;
    transition: background-color 150ms ease, border-color 150ms ease;
}
.menu-toggle:hover { background: var(--panel-raised); border-color: var(--muted); }
.menu-toggle-icon,
.menu-toggle-icon::before,
.menu-toggle-icon::after {
    display: block;
    width: 16px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: transform 180ms ease, opacity 180ms ease;
}
.menu-toggle-icon { position: relative; }
.menu-toggle-icon::before, .menu-toggle-icon::after { content: ""; position: absolute; left: 0; }
.menu-toggle-icon::before { top: -5px; }
.menu-toggle-icon::after { top: 5px; }
.menu-toggle[aria-expanded="true"] .menu-toggle-icon { background: transparent; }
.menu-toggle[aria-expanded="true"] .menu-toggle-icon::before { transform: translateY(5px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] .menu-toggle-icon::after { transform: translateY(-5px) rotate(-45deg); }

.tool-menu {
    border-top: 1px solid var(--line);
    background: var(--ink);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
}
.tool-menu-inner {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem 2.5rem;
    padding-block: 1.25rem 1.75rem;
}
.tool-menu-heading {
    margin: 0 0 0.5rem;
    color: var(--muted);
    font-size: 0.85rem;
}
.tool-menu ul { list-style: none; margin: 0; padding: 0; }
.tool-menu a {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.7rem 0.75rem;
    margin-inline: -0.75rem;
    border-radius: var(--radius-s);
    color: var(--text);
    font-weight: 500;
    text-decoration: none;
}
.tool-menu a::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    flex: none;
}
.tool-menu a:hover, .tool-menu a:focus-visible { background: var(--panel); }
.tool-menu a[aria-current="page"] { background: var(--panel-raised); }

/* ---------- Home ---------- */

.hero {
    padding-block: clamp(2.75rem, 9vw, 6rem) clamp(2rem, 5vw, 3.5rem);
}
.hero h1 {
    margin: 0;
    font-family: var(--display);
    font-size: clamp(2.1rem, 6.2vw, 4.25rem);
    font-weight: 700;
    line-height: 1.02;
    letter-spacing: -0.025em;
    font-variation-settings: "opsz" 96;
}
.hero p {
    margin: 1.25rem 0 0;
    color: var(--muted);
    font-size: clamp(1.02rem, 2.2vw, 1.15rem);
}

.tool-group { margin-bottom: clamp(2.5rem, 6vw, 3.75rem); }
.tool-group h2 {
    margin: 0 0 1rem;
    font-family: var(--display);
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: -0.015em;
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.tool-grid > li { display: flex; }

.tool-card {
    position: relative;
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    width: 100%;
    padding: 1.25rem 1.25rem 1.1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-m);
    background: var(--panel);
    color: var(--text);
    text-decoration: none;
    overflow: hidden;
    transition: border-color 160ms ease, background-color 160ms ease;
}
.tool-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--accent);
}
.tool-card:hover, .tool-card:focus-visible {
    color: var(--text);
    border-color: var(--accent);
    background: var(--panel-raised);
}
.tool-card-category {
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 600;
}
.tool-card-title {
    margin-top: 0.3rem;
    font-family: var(--display);
    font-size: 1.3rem;
    font-weight: 650;
    line-height: 1.2;
    letter-spacing: -0.015em;
}
.tool-card-summary {
    margin-top: 0.45rem;
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.5;
}
.tool-card-input {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1.1rem;
    padding-top: 0.8rem;
    border-top: 1px dashed var(--line-strong);
    color: var(--muted);
    font-size: 0.85rem;
}
.tool-card-input::after {
    content: "";
    width: 9px;
    height: 9px;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 160ms ease, color 160ms ease;
}
.tool-card:hover .tool-card-input::after,
.tool-card:focus-visible .tool-card-input::after { color: var(--accent); transform: translateX(3px) rotate(45deg); }

/* ---------- Tool pages ---------- */

.page { padding-bottom: 3rem; }

.tool-intro { padding-block: clamp(1.75rem, 5vw, 3rem) 1.25rem; }
.tool-category {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 0.5rem;
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 600;
}
.tool-category::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}
.tool-intro h1 {
    margin: 0;
    font-family: var(--display);
    font-size: clamp(1.9rem, 5vw, 2.9rem);
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.03em;
}
.tool-lede {
    margin: 0.75rem 0 0;
    color: var(--muted);
}

.lookup {
    margin-bottom: 2rem;
    padding: 12px;
    border: 1px solid var(--line);
    border-top: 3px solid var(--accent);
    border-radius: var(--radius-m);
    background: var(--panel);
}
.lookup-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: start;
}
.lookup-form:has(.lookup-filters) { grid-template-columns: minmax(0, 1fr) auto auto; }
.lookup-filters { display: flex; gap: 10px; }

.lookup .form-control,
.lookup .form-select {
    min-height: 48px;
    background-color: var(--ink);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-s);
    color: var(--text);
    font-size: 1rem; /* 16px stops iOS from zooming into the field */
}
.lookup .form-control::placeholder { color: #6E7A8F; opacity: 1; }
.lookup .form-control:focus,
.lookup .form-select:focus {
    background-color: var(--ink);
    color: var(--text);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}
.lookup .form-select {
    min-width: 8.5rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394A0B4' viewBox='0 0 16 16'%3E%3Cpath d='M3.2 5h9.6c.86 0 1.32 1.06.75 1.66l-4.8 5.48a1 1 0 0 1-1.5 0L2.45 6.66C1.89 6.06 2.35 5 3.2 5z'/%3E%3C/svg%3E");
    background-size: 14px;
}
.lookup-textarea { resize: vertical; min-height: 7rem; line-height: 1.5; }
.lookup input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 40px var(--ink) inset !important;
    -webkit-text-fill-color: var(--text) !important;
}

.lookup-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    min-height: 48px;
    padding-inline: 1.3rem;
    border: 0;
    border-radius: var(--radius-s);
    background: var(--accent);
    color: var(--ink);
    font-weight: 650;
    white-space: nowrap;
}
.lookup-btn:hover, .lookup-btn:focus-visible { background: var(--text); color: var(--ink); }
.lookup-btn:active { background: var(--accent) !important; color: var(--ink) !important; }

/* Address shown above results */
.responsive-title {
    margin: 0 0 0.75rem;
    font-family: var(--body);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--muted);
    word-break: break-all;
}

/* ---------- Results ---------- */

.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text);
    --bs-table-border-color: var(--line);
    --bs-table-hover-bg: var(--panel-raised);
    width: 100%;
    margin-bottom: 1.75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-m);
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    background: var(--panel);
}
.table > :not(caption) > * > * {
    padding: 0.85rem 1rem;
    background: transparent;
    color: var(--text);
    border-bottom-color: var(--line);
}
.table thead th {
    background: var(--panel-raised);
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
    border-bottom: 1px solid var(--line-strong);
    white-space: nowrap;
}
.table tbody tr:last-child > * { border-bottom: 0; }
.table tbody tr:hover > * { background: rgba(255, 255, 255, 0.025); }
.table td { overflow-wrap: anywhere; }
.table .num { text-align: right; white-space: nowrap; }
.table td a { white-space: nowrap; }
.table-responsive { overflow: visible; }

.alert {
    border-radius: var(--radius-m);
    border: 1px solid color-mix(in srgb, var(--bridge) 45%, transparent);
    background: color-mix(in srgb, var(--bridge) 10%, var(--panel));
    color: var(--text);
}

.status-true { color: var(--good); font-weight: 600; }
.status-false { color: var(--bad); font-weight: 600; }
.status-unknown { color: var(--muted); }

.address-result { margin-block: 0 1.25rem; }
.sentinel-status-table { table-layout: fixed; }
.sentinel-status-table td { vertical-align: top; }
.sentinel-field-label { display: block; margin-bottom: 0.3rem; color: var(--muted); font-size: 0.85rem; font-weight: 600; }

.pagination { gap: 6px; flex-wrap: wrap; }
.pagination .page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-s) !important;
    background: var(--panel);
    color: var(--text);
}
.pagination .page-link:hover { background: var(--panel-raised); color: var(--text); }
.pagination .page-item.active .page-link { background: var(--accent); border-color: var(--accent); color: var(--ink); font-weight: 650; }
.pagination .page-item.disabled .page-link { background: transparent; color: #4C586E; border-color: var(--line); }

/* ---------- Footer ---------- */

.site-footer { border-top: 1px solid var(--line); margin-top: 2rem; }
.site-footer-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 2rem;
    padding-block: 1.5rem 2rem;
}
.site-footer p { margin: 0; color: var(--muted); font-size: 0.875rem; }
.site-footer a { color: var(--text); }
.site-footer a:hover, .site-footer a:focus { color: var(--balances); }

/* ---------- Narrower screens ---------- */

@media (max-width: 900px) {
    .tool-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
    .container { padding-inline: 16px; }
    .topbar-inner { min-height: 58px; gap: 0.75rem; }
    .ticker { flex-direction: column; gap: 0; font-size: 0.78rem; line-height: 1.35; text-align: right; }
    .menu-toggle-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .menu-toggle { width: 44px; padding: 0; justify-content: center; }

    .tool-menu { max-height: calc(100vh - 58px); overflow-y: auto; }
    .tool-menu-inner { grid-template-columns: 1fr; gap: 1.25rem; }
    .tool-menu a { padding-block: 0.85rem; }

    .tool-grid { grid-template-columns: 1fr; gap: 10px; }
    .tool-card { padding: 1rem 1rem 0.95rem 1.2rem; }
    .tool-card-title { font-size: 1.2rem; }
    .tool-card-input { margin-top: 0.85rem; padding-top: 0.65rem; }

    .lookup { padding: 10px; }
    .lookup-form, .lookup-form:has(.lookup-filters) { grid-template-columns: minmax(0, 1fr); }
    .lookup-filters > * { flex: 1 1 0; min-width: 0; }
    .lookup-btn { width: 100%; }

    /* Tables become stacked records: label on the left, value on the right. */
    .table.stackable, .table.stackable tbody, .table.stackable tr, .table.stackable td { display: block; width: 100%; }
    .table.stackable thead { display: none; }
    .table.stackable { border: 0; background: transparent; overflow: visible; }
    .table.stackable tbody tr {
        margin-bottom: 10px;
        border: 1px solid var(--line);
        border-radius: var(--radius-m);
        background: var(--panel);
        overflow: hidden;
    }
    .table.stackable tbody td {
        display: flex;
        justify-content: space-between;
        gap: 1rem;
        padding: 0.7rem 0.95rem;
        border-bottom: 1px solid var(--line);
        text-align: right;
    }
    .table.stackable tbody tr > td:last-child { border-bottom: 0; }
    .table.stackable td[data-label]::before {
        content: attr(data-label);
        flex: none;
        max-width: 45%;
        color: var(--muted);
        font-size: 0.85rem;
        font-weight: 600;
        text-align: left;
    }
    .table.stackable td > * { min-width: 0; }
    .table.stackable tr.row-summary td { justify-content: flex-start; font-weight: 600; text-align: left; }

    /* Narrow tables stay tables, just tighter. */
    .table:not(.stackable) > :not(caption) > * > * { padding: 0.7rem 0.6rem; font-size: 0.92rem; }
    .table:not(.stackable) thead th { white-space: normal; font-size: 0.8rem; }
    .table:not(.stackable) > :not(caption) > * > :first-child { padding-left: 0.85rem; }
    .table:not(.stackable) > :not(caption) > * > :last-child { padding-right: 0.85rem; }
    .sentinel-status-table, .sentinel-status-table tbody, .sentinel-status-table tr { display: block; width: 100%; }
    .sentinel-status-table td { display: flex; justify-content: space-between; gap: 1rem; width: 100%; text-align: right; }
    .sentinel-status-table .sentinel-field-label { margin: 0; text-align: left; }
    .sentinel-status-table tbody tr:first-child td { border-bottom-color: var(--line); }
    .sentinel-status-table tbody tr:first-child td:last-child { border-bottom: 1px solid var(--line-strong); }
}

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