/* ==========================================================================
   GM Markets chrome — pixel-accurate navbar + footer cloned from gm.markets
   Design tokens and component rules lifted from the live site so the blog's
   header/footer match the product 1:1 across breakpoints.
   ========================================================================== */

:root {
    /* Surfaces & text */
    --bg: #FBF8F2;
    --surface: #FFFFFF;
    --surface-1: var(--surface);
    --surface-2: #F5F0E8;
    --surface-3: #EFEAE0;
    --surface-4: #E8E1D2;
    --overlay: rgba(28, 27, 26, 0.42);
    --text-1: #1C1B1A;
    --text-2: #5E5B57;
    --text-3: #8A857F;
    --text-inverse: #FFFFFF;

    /* Brand accent */
    --accent: #B8923D;
    --accent-strong: #8C6E29;
    --accent-soft: #F4E8CB;
    --accent-tint: #FBF3DE;
    --accent-hover: #A07F33;

    /* Status */
    --pos: #1C7C43;
    --pos-soft: #E6F0E8;
    --neg: #B6362E;
    --neg-soft: #F3E0DE;
    --neutral: #6E6A65;

    /* Lines & shadows */
    --hairline: rgba(28, 27, 26, 0.08);
    --hairline-strong: rgba(28, 27, 26, 0.14);
    --hairline-focus: rgba(184, 146, 61, 0.45);
    --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
    --shadow-pill: 0 1px 2px rgba(0, 0, 0, 0.06), 0 0 0 0.5px rgba(184, 146, 61, 0.18);
    --shadow-sheet: 0 12px 48px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);

    /* Radii */
    --r-1: 4px;
    --r-2: 6px;
    --r-3: 8px;
    --r-md: var(--r-3);
    --r-4: 10px;
    --r-card: 12px;
    --r-card-lg: 16px;
    --r-pill: 999px;

    /* Spacing scale */
    --s-1: 4px;
    --s-2: 8px;
    --s-3: 12px;
    --s-4: 16px;
    --s-5: 20px;
    --s-6: 24px;
    --s-7: 32px;
    --s-8: 40px;
    --s-9: 56px;
    --s-10: 80px;

    /* Type — map onto the fonts the Source theme already bundles */
    --font-inter: var(--font-sans), "Inter", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    --ff: var(--font-inter);
    --ff-mono: var(--font-mono), "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
    --fs-10: 10.5px;
    --fs-11: 11.5px;
    --fs-12: 12px;
    --fs-13: 13px;
    --fs-14: 14px;
    --fs-15: 15px;
    --fs-16: 16px;
    --fs-18: 18px;
    --fs-20: 20px;
    --fs-24: 24px;
    --fs-32: 32px;
    --lh-tight: 1.25;
    --lh-snug: 1.4;
    --lh-base: 1.5;

    /* Motion */
    --d-fast: 120ms;
    --d-base: 200ms;
    --d-slow: 300ms;
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-inout: cubic-bezier(0.4, 0, 0.2, 1);

    /* Layout */
    --max-w: 1440px;
    --header-h: 64px;
    --bottom-tabs-h: 56px;
}

/* Make the cloned chrome render in Inter regardless of the active theme font. */
.header,
.footer,
.bottom-tabs {
    font-family: var(--ff);
}

/* The chrome uses its own link colours; reset Ghost's underline/hover styles.
   Exclude .btn so the gold CTA gradient (set via the background shorthand) survives. */
.header a:not(.btn),
.footer a:not(.btn),
.bottom-tabs a:not(.btn) {
    text-decoration: none;
    box-shadow: none;
    background-image: none;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */

.header {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 50;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    -webkit-backdrop-filter: saturate(140%) blur(12px);
    backdrop-filter: saturate(140%) blur(12px);
    border-bottom: 1px solid var(--hairline);
}

.header-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    height: var(--header-h);
    padding: 0 var(--s-7);
    display: flex;
    align-items: center;
    gap: var(--s-6);
    min-width: 0;
}

.header-inner > * {
    min-width: 0;
}

/* Wordmark */
.wordmark {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 17px;
    letter-spacing: -0.015em;
    color: var(--text-1);
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    flex-shrink: 0;
}

.wordmark .gm {
    color: var(--accent-strong);
}

.wordmark-mark {
    height: 1.7em;
    width: auto;
    display: block;
    margin-right: 2px;
    flex-shrink: 0;
}

.wordmark .markets {
    position: relative;
    padding-right: 0.45em;
}

.wordmark .markets:after {
    content: "";
    position: absolute;
    width: 0.26em;
    height: 0.26em;
    border-radius: 50%;
    background: var(--accent);
    right: 0;
    top: 0.04em;
}

/* Primary nav */
.nav-primary {
    display: none;
    gap: var(--s-4);
}

.nav-primary a {
    font-size: var(--fs-13);
    font-weight: 500;
    color: var(--text-2);
    padding: 6px 8px;
    border-radius: var(--r-3);
    transition: color var(--d-fast) var(--ease-out), background var(--d-fast) var(--ease-out);
}

.nav-primary a:hover {
    color: var(--text-1);
    background: var(--surface-2);
}

.nav-primary a[aria-current="page"] {
    color: var(--text-1);
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    flex-shrink: 0;
    margin-left: auto;
}

/* Icon buttons */
.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-2);
    border: 1px solid var(--hairline);
    background: var(--surface);
    cursor: pointer;
    transition: background var(--d-fast) var(--ease-out), color var(--d-fast) var(--ease-out);
}

.icon-btn:hover {
    background: var(--surface-2);
    color: var(--text-1);
}

.header-back-btn,
.header-menu-btn {
    display: none;
}

/* Buttons — lifted from gm.markets (.btn / .btn-sm / .btn-primary) */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 40px;
    padding: 0 var(--s-4);
    border: 0;
    border-radius: var(--r-pill);
    font-family: var(--ff);
    font-size: var(--fs-13);
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    transition: filter var(--d-fast) var(--ease-out), transform var(--d-fast) var(--ease-out), background var(--d-fast) var(--ease-out), border-color var(--d-fast) var(--ease-out);
}

.btn-sm {
    height: 32px;
    padding: 0 var(--s-3);
    font-size: var(--fs-12);
}

.btn-lg {
    height: 48px;
    padding: 0 var(--s-5);
    font-size: var(--fs-14);
}

.btn-primary {
    background: linear-gradient(180deg, #C8A04A, #B8923D);
    color: #FFFFFF;
    box-shadow: 0 1px 2px rgba(159, 124, 47, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.btn-primary:hover:not(:disabled) {
    filter: brightness(1.04);
    transform: translateY(-0.5px);
    color: #FFFFFF;
}

.btn-primary:disabled {
    background: #ECECEC;
    color: #9A9A9A;
    border: 1px solid #dedede;
    box-shadow: none;
    opacity: 1;
}

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

.footer {
    border-top: 1px solid var(--hairline);
    background: var(--bg);
}

.footer-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: var(--s-6) var(--s-7);
    font-size: var(--fs-11);
    color: var(--text-2);
    line-height: var(--lh-base);
}

.footer-inner a {
    color: var(--accent-strong);
    font-weight: 500;
}

.footer-inner a:hover {
    color: var(--accent);
}

.footer-top {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(0, 2fr);
    grid-gap: var(--s-7);
    gap: var(--s-7);
    align-items: start;
    padding-bottom: var(--s-5);
    border-bottom: 1px solid var(--hairline);
}

.footer-brand {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.footer-brand .wordmark {
    font-size: 17px;
}

.footer-brand p {
    font-size: var(--fs-11);
    color: var(--text-2);
    line-height: 1.55;
}

.footer-brand .wordmark .gm,
.footer-brand .wordmark .markets {
    display: inline;
}

.footer-brand .wordmark-mark {
    margin-right: 2px;
}

.footer-cols {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-gap: var(--s-6);
    gap: var(--s-6);
}

.footer-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.footer-col-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-1);
    margin-bottom: 2px;
}

.footer-col a {
    color: var(--text-2);
    font-weight: 400;
}

.footer-col a.footer-col-title {
    color: var(--text-1);
    font-weight: 700;
}

.footer-col a:hover {
    color: var(--accent-strong);
}

.footer-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-3);
    margin-top: var(--s-4);
    font-size: var(--fs-11);
    align-items: center;
}

.footer-meta,
.footer-sep {
    color: var(--text-3);
}

.footer-meta a {
    color: var(--text-2);
}

.footer-meta a:hover {
    color: var(--accent-strong);
}

.beta-tag {
    display: inline-flex;
    align-items: center;
    margin-left: 6px;
    padding: 1px 5px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--accent-strong);
    border: 1px solid rgba(184, 146, 61, 0.35);
    border-radius: var(--r-1);
    line-height: 1.4;
    text-transform: uppercase;
    vertical-align: middle;
    background: var(--accent-tint);
}

/* --------------------------------------------------------------------------
   Mobile bottom tab bar
   -------------------------------------------------------------------------- */

.bottom-tabs {
    display: none;
}

.bottom-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 8px 4px 10px;
    min-height: var(--bottom-tabs-h);
    color: var(--text-3);
    text-decoration: none;
    font-family: inherit;
    transition: color var(--d-fast) var(--ease-out);
}

.bottom-tab:hover {
    color: var(--text-2);
}

.bottom-tab--active,
.bottom-tab[aria-current="page"] {
    color: var(--accent-strong);
}

.bottom-tab-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.bottom-tab-label {
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.01em;
}

/* --------------------------------------------------------------------------
   Responsive — breakpoints mirror gm.markets exactly
   -------------------------------------------------------------------------- */

@media (min-width: 1024px) {
    .nav-primary {
        display: inline-flex;
    }
}

@media (max-width: 1023px) {
    .header-inner {
        padding: 0 var(--s-4);
        gap: var(--s-3);
    }

    .nav-primary {
        display: none;
    }

    .header-back-btn,
    .header-menu-btn {
        display: inline-flex;
    }

    .footer-inner {
        padding: var(--s-5) var(--s-4);
    }

    .footer-top {
        grid-template-columns: 1fr;
        gap: var(--s-5);
    }

    /* Fixed bottom tab bar appears below the lg breakpoint */
    .bottom-tabs {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 50;
        background: color-mix(in srgb, var(--bg) 92%, transparent);
        -webkit-backdrop-filter: saturate(140%) blur(12px);
        backdrop-filter: saturate(140%) blur(12px);
        border-top: 1px solid var(--hairline);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    /* Keep page content clear of the fixed tab bar */
    .gh-viewport {
        padding-bottom: calc(var(--bottom-tabs-h) + env(safe-area-inset-bottom));
    }
}

@media (max-width: 767px) {
    .header-inner {
        gap: var(--s-3);
    }

    .wordmark .gm,
    .wordmark .markets {
        display: none;
    }

    .wordmark-mark {
        margin-right: 0;
        height: 2em;
    }
}

@media (max-width: 720px) {
    .footer {
        background: var(--surface-2);
    }

    .footer-cols {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: var(--s-5);
    }
}

@media (max-width: 640px) {
    .header-right {
        gap: var(--s-2);
    }
}

@media print {
    .footer,
    .header,
    .bottom-tabs,
    .sheet-root {
        display: none !important;
    }
}

/* --------------------------------------------------------------------------
   Mobile menu drawer (opened by the header hamburger) — cloned from gm.markets
   -------------------------------------------------------------------------- */

.sheet-root {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    font-family: var(--ff);
}

.sheet-backdrop {
    position: absolute;
    inset: 0;
    background: var(--overlay);
    opacity: 0;
    transition: opacity var(--d-base) var(--ease-out);
    pointer-events: none;
}

.sheet-root[data-open="true"] .sheet-backdrop {
    opacity: 1;
    pointer-events: auto;
}

.sheet {
    position: relative;
    background: var(--surface);
    border-radius: var(--r-card-lg);
    box-shadow: var(--shadow-sheet);
    width: 520px;
    max-width: calc(100vw - var(--s-7));
    max-height: 88vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(8px) scale(0.98);
    transition: opacity var(--d-base) var(--ease-out), transform var(--d-base) var(--ease-out);
    pointer-events: none;
}

.sheet-root[data-open="true"] .sheet {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.sheet-grab {
    display: none;
    width: 36px;
    height: 4px;
    background: var(--hairline-strong);
    border-radius: 2px;
    margin: 8px auto 0;
}

.sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--s-4) var(--s-5);
    border-bottom: 1px solid var(--hairline);
    gap: var(--s-3);
}

.sheet-close {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: var(--r-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-2);
    background: transparent;
    cursor: pointer;
    transition: background var(--d-fast) var(--ease-out), color var(--d-fast) var(--ease-out);
    flex-shrink: 0;
}

.sheet-close:hover {
    background: var(--surface-2);
    color: var(--text-1);
}

.menu-sheet-header .wordmark .gm,
.menu-sheet-header .wordmark .markets {
    display: inline;
}

.menu-sheet-header .wordmark-mark {
    margin-right: 2px;
    height: 1.7em;
}

.menu-sheet-body {
    flex: 1 1;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    padding: var(--s-4) var(--s-5) var(--s-6);
    display: flex;
    flex-direction: column;
    gap: var(--s-5);
}

/* Grouped rows (Explore / Trust / Learn / Earn / Preferences) */
.menu-sheet-group {
    display: flex;
    flex-direction: column;
}

.menu-sheet-group-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
    margin-bottom: 6px;
}

.menu-sheet-group-title-sub {
    text-transform: none;
    letter-spacing: 0;
    font-weight: 500;
    color: var(--text-3);
}

.menu-sheet-rows {
    display: flex;
    flex-direction: column;
    margin: 0 calc(-1 * var(--s-5));
    border-bottom: 1px solid var(--hairline);
}

.menu-sheet-rows .menu-row {
    width: 100%;
    text-align: left;
    background: transparent;
    border-left: 0;
    border-right: 0;
}

.menu-sheet-rows .menu-row:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.menu-row {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: 14px 22px;
    border-top: 1px solid var(--hairline);
    cursor: pointer;
    transition: background var(--d-fast) var(--ease-out);
    color: var(--text-1);
    font-size: var(--fs-14);
    text-decoration: none;
}

.menu-row:first-child {
    border-top: none;
}

.menu-row:hover {
    background: var(--surface-2);
}

.menu-row-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--r-3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-2);
    background: var(--surface-2);
    flex-shrink: 0;
}

.menu-row-body {
    flex: 1 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.menu-row-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: var(--text-1);
}

.menu-row-sub {
    font-size: var(--fs-12);
    color: var(--text-2);
}

.menu-row-chevron {
    color: var(--text-3);
    flex-shrink: 0;
}

.menu-row-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--accent-strong);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
}

/* Currency preference row with an invisible native <select> overlay */
.menu-row--currency {
    position: relative;
    cursor: pointer;
}

.menu-row-currency-glyph {
    justify-content: center;
    width: 16px;
    height: 16px;
    font-weight: 600;
    color: currentColor;
}

.menu-row-currency-glyph,
.menu-row-trailing {
    display: inline-flex;
    align-items: center;
    font-size: 13px;
}

.menu-row-trailing {
    gap: 6px;
    margin-left: auto;
    color: var(--text-3);
    pointer-events: none;
}

.menu-row-trailing-value {
    font-weight: 500;
    color: var(--text-2);
}

.menu-row-currency-select {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    -moz-appearance: none;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: 0;
    color: transparent;
    opacity: 0;
    cursor: pointer;
    font-size: 16px;
    text-indent: -9999px;
}

.menu-row-currency-select option {
    color: var(--text-1);
}

.menu-sheet-footer-strip {
    display: flex;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--text-3);
    padding: 4px 0;
}

.menu-sheet-footer-strip-item {
    display: inline-flex;
    align-items: center;
}

.menu-sheet-footer-strip-item a {
    color: var(--text-3);
    text-decoration: none;
    padding: 4px 0;
}

.menu-sheet-footer-strip-item a:hover {
    color: var(--text-1);
}

.menu-sheet-footer-strip-sep {
    color: var(--text-3);
    opacity: 0.5;
    padding: 0 6px;
}

.menu-sheet-brand-line {
    font-size: 11px;
    color: var(--text-3);
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
}

.menu-sheet-brand-line .beta-tag {
    margin-left: 2px;
}

.menu-sheet-floor {
    flex: 0 0 auto;
    padding: 12px 22px calc(16px + env(safe-area-inset-bottom));
    background: var(--bg);
    border-top: 1px solid var(--hairline);
}

.menu-sheet-floor-cta {
    width: 100%;
    justify-content: center;
}

/* Drawer behaviour: slide in from the left on tablet/mobile. The hamburger that
   opens it is only visible below 1024px, so the centred-modal fallback above is
   never actually triggered on desktop. */
@media (max-width: 1023px) {
    .sheet-root {
        align-items: flex-end;
    }

    .sheet {
        width: 100%;
        max-width: 100%;
        max-height: 92vh;
        border-radius: var(--r-card-lg) var(--r-card-lg) 0 0;
        transform: translateY(100%);
    }

    .sheet-root[data-open="true"] .sheet {
        transform: translateY(0);
    }

    .sheet.sheet--drawer-left {
        align-self: stretch;
        margin-right: auto;
        width: min(86vw, 340px);
        max-width: 86vw;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0 var(--r-card-lg) var(--r-card-lg) 0;
        transform: translateX(-100%);
        overscroll-behavior: contain;
        touch-action: pan-y;
    }

    .sheet-root[data-open="true"] .sheet.sheet--drawer-left {
        transform: translateX(0);
    }

    .sheet.sheet--drawer-left .sheet-grab {
        display: none;
    }
}

/* Lock background scroll while the drawer is open */
body.gm-menu-open {
    overflow: hidden;
}

/* --------------------------------------------------------------------------
   Blog content & post listing — on-brand polish layered over the Source theme.
   gm-chrome.css loads after screen.css, so equal-specificity rules win.
   -------------------------------------------------------------------------- */

/* Gap between the page content and the footer (the original .gh-footer carried
   margin-top:120px; our gm.markets .footer replaced it, so restore the breathing
   room here — applies to the post page and every listing). */
.footer {
    margin-top: clamp(64px, 8vw, 112px);
}

/* Section heading above the feed ("Latest", tag/author names) — match the
   uppercase, tracked, muted treatment used across gm.markets. */
.gh-container-title {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    color: var(--text-3);
    border-bottom-color: var(--hairline);
}

/* Post cards: rounded, hairline-framed imagery + a subtle hover lift. */
.gh-card-link {
    transition: transform var(--d-base) var(--ease-out);
}

.gh-card-link:hover {
    transform: translateY(-2px);
}

.gh-card-image {
    border-radius: var(--r-card);
    overflow: hidden;
    border: 1px solid var(--hairline);
    background: var(--surface-2);
}

.gh-card-title {
    transition: color var(--d-fast) var(--ease-out);
}

.gh-card-link:hover .gh-card-title {
    color: var(--accent-strong);
}

.gh-card-tag {
    color: var(--accent-strong);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

/* "See all →" link under the feed picks up the brand gold. */
.gh-more a {
    color: var(--accent-strong);
}

.gh-more a:hover {
    color: var(--accent);
}

/* Article (single post) reads on the cream page; round the feature image and
   keep a comfortable gap before related posts / comments / footer. */
.gh-article-image,
.gh-article-image img {
    border-radius: var(--r-card-lg);
}

.gh-article-image {
    overflow: hidden;
}

.gh-article {
    padding-bottom: var(--s-6);
}

/* Tag links and inline accents in article chrome use the brand gold. */
.gh-article-tag {
    color: var(--accent-strong);
}
