/**
 * mod_hexpris , self-contained styling.
 *
 * Everything is scoped under .hexpris and uses its own custom properties, so
 * the site template cannot bleed in and the module cannot bleed out. Accent
 * colours are the official HEX logo gradient stops only; --hexpris-colour is
 * set per instance from the template (pink = PulseChain, yellow = Ethereum).
 */

.hexpris {
    --hexpris-bg: #0f0f0f;
    --hexpris-bg2: #151515;
    --hexpris-border: #1e1e1e;
    --hexpris-border2: #2a2a2a;
    --hexpris-text: #f0f0f0;
    --hexpris-muted: #888;
    --hexpris-up: #ffdb01;
    --hexpris-down: #ff3d3d;
    --hexpris-mono: ui-monospace, 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;

    box-sizing: border-box;
    padding: 14px 16px;
    border: 1px solid var(--hexpris-border);
    border-left: 2px solid var(--hexpris-colour, #f0f);
    border-radius: 2px;
    background: var(--hexpris-bg);
    color: var(--hexpris-text);
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

    /* The module is usually dropped straight above other content (e.g. via
       {loadmoduleid} in an article), where it would otherwise sit flush
       against whatever follows. */
    margin-block: 14px 18px;
}

.hexpris *,
.hexpris *::before,
.hexpris *::after {
    box-sizing: border-box;
}

.hexpris-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.hexpris-badge {
    padding: 1px 5px;
    border: 1px solid var(--hexpris-border2);
    border-radius: 2px;
    background: var(--hexpris-bg2);
    color: var(--hexpris-colour, #f0f);
    font-family: var(--hexpris-mono);
    font-size: 9px;
    letter-spacing: .5px;
    text-transform: uppercase;
}

.hexpris-pair {
    color: var(--hexpris-muted);
    font-family: var(--hexpris-mono);
    font-size: 9.5px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.hexpris-status {
    margin-left: auto;
    color: var(--hexpris-muted);
    font-family: var(--hexpris-mono);
    font-size: 9px;
    letter-spacing: .5px;
    text-transform: uppercase;
}

.hexpris-price {
    font-family: var(--hexpris-mono);
    font-size: 27px;
    font-weight: 500;
    line-height: 1.1;
    letter-spacing: -.5px;
    font-variant-numeric: tabular-nums;
}

.hexpris-sub {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 8px;
    color: var(--hexpris-muted);
    font-family: var(--hexpris-mono);
    font-size: 10px;
    letter-spacing: .4px;
}

.hexpris-change {
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.hexpris-change.is-up { color: var(--hexpris-up); }
.hexpris-change.is-down { color: var(--hexpris-down); }

.hexpris-ranges {
    display: flex;
    width: fit-content;
    margin-top: 12px;
    border: 1px solid var(--hexpris-border2);
    border-radius: 2px;
    overflow: hidden;
}

/* Reset aggressively: templates love to restyle buttons. */
.hexpris-ranges button {
    margin: 0;
    padding: 5px 10px;
    border: 0;
    border-right: 1px solid var(--hexpris-border2);
    border-radius: 0;
    background: var(--hexpris-bg);
    color: var(--hexpris-muted);
    font-family: var(--hexpris-mono);
    font-size: 10px;
    line-height: 1.2;
    letter-spacing: .5px;
    text-transform: none;
    cursor: pointer;
    box-shadow: none;
}

.hexpris-ranges button:last-child { border-right: 0; }

.hexpris-ranges button:hover:not(.is-active):not(:disabled) {
    background: #1a1a1a;
    color: var(--hexpris-text);
}

.hexpris-ranges button.is-active {
    background: var(--hexpris-colour, #f0f);
    color: #080808;
    font-weight: 600;
}

.hexpris-ranges button:disabled {
    opacity: .35;
    cursor: wait;
}

.hexpris-summary {
    margin-top: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--hexpris-border);
    color: var(--hexpris-muted);
    font-family: var(--hexpris-mono);
    font-size: 9.5px;
    letter-spacing: .4px;
}

.hexpris-chart {
    position: relative;
    margin-top: 8px;
}

.hexpris-footer {
    margin: 12px 0 0;
    color: #6d6169;
    font-family: var(--hexpris-mono);
    font-size: 9px;
    line-height: 1.7;
    letter-spacing: .2px;
}

@media (max-width: 520px) {
    .hexpris-price { font-size: 22px; }
    .hexpris-chart { height: 190px !important; }
}

/* ------------------------------------------------------------------
   Compact layout (tmpl/compact.php): a single line of plain text,
   price + chain + 24h change. No card, no chart, no borders - it is
   meant to sit inside article copy and inherit the page's look.
------------------------------------------------------------------- */
.hexpris-line {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px 8px;
    margin: 0;
    font-family: ui-monospace, 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
    font-size: 15px;
    line-height: 1.45;
}

/* "siste 24 timer" is the first thing worth losing when space runs out -
   the +% right before it already says what period it refers to. */
.hexpris-line-period { flex: 0 1 auto; min-width: 0; }

/* the two lines are dropped in one <p>; kill the <br> gap between them */
.hexpris-line + br { display: none; }

.hexpris-line-price {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: inherit;
}

.hexpris-line-sep { color: #b9c6d4; }

/* Chain name carries the chain's accent colour, so PulseChain and
   Ethereum stay tellable apart at a glance. Both values are ACTUAL stops
   from the official HEX logo gradient (see BRAND.md):
     #ff0f6f  pink stop   -> PulseChain
     #ff851f  orange stop -> Ethereum
   The logo's yellow (#ffdb01) is unreadable on a white article background,
   so the neighbouring orange stop is used at that end of the ramp. */
.hexpris-line-pulsechain .hexpris-line-name { color: #ff0f6f; }
/* #ff851f straight from the logo is only 2.43:1 on white - below the 3:1
   minimum for text. This is that same orange darkened (4.01:1). */
.hexpris-line-ethereum   .hexpris-line-name { color: #c96200; }

.hexpris-line-name {
    font-weight: 600;
    text-decoration: none;
}

.hexpris-line-name:hover { text-decoration: underline; }

.hexpris-line-change {
    font-variant-numeric: tabular-nums;
    font-size: 13px;
}

/* Down uses the official HEX red stop (#ff3d3d exists in the logo).
   The logo has no green, so "up" is a muted green chosen to sit calmly
   beside the HEX pink/orange rather than compete with them - it is
   darkened for contrast on the light article background (4.6:1). */
.hexpris-line-change.is-up   { color: #2f855a; }
.hexpris-line-change.is-down { color: #d92d20; }

.hexpris-line-period {
    font-size: 12px;
    color: #8a94a6;
}

/* The shared JS writes status/liquidity; this layout does not show them. */
.hexpris-hidden { display: none; }

/* Chart links in the card header, replacing the old "updated HH:MM" stamp. */
.hexpris-links {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-family: var(--hexpris-mono);
    font-size: 9.5px;
    letter-spacing: .5px;
    text-transform: uppercase;
    white-space: nowrap;
}

.hexpris-links a {
    color: var(--hexpris-colour, #f0f);
    text-decoration: none;
    border-bottom: 1px solid transparent;
}

.hexpris-links a:hover { border-bottom-color: currentColor; }
.hexpris-links-sep { color: var(--hexpris-muted); }

@media (max-width: 620px) {
    /* On phones the header ran wider than the viewport: badge + pair + two
       links do not fit on one line. Let the header wrap and drop the links
       onto their own full-width row instead of forcing a sideways scroll. */
    .hexpris-head { flex-wrap: wrap; }
    .hexpris-links {
        margin-left: 0;
        flex-basis: 100%;
        font-size: 9px;
        gap: 6px;
    }
    /* the compact line may wrap, but should not stretch */
    .hexpris-line { font-size: 14px; }
}

/* Chart links on the compact line, pushed to the right. */
.hexpris-line-links {
    margin-left: auto;
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    font-size: 11px;
    letter-spacing: .02em;
    white-space: nowrap;
}

.hexpris-line-links a {
    color: #1b75bb;
    text-decoration: none;
    border-bottom: 1px solid transparent;
}

.hexpris-line-links a:hover { border-bottom-color: currentColor; }
.hexpris-line-links-sep { color: #b9c6d4; }

/* Narrow / zoomed-in: drop "siste 24 timer" so price + chain + change +
   links still fit on ONE row. This covers browser zoom too, which simply
   shrinks the effective viewport (200% on a 1280px screen = 640px). */
@media (max-width: 900px) {
    .hexpris-line-period { display: none; }
    .hexpris-line-links { font-size: 10.5px; }
}

/* Genuinely narrow: let the links take their own row, and separate the two
   chain blocks so they do not read as one wall of text. */
@media (max-width: 460px) {
    .hexpris-line-links { margin-left: 0; flex-basis: 100%; }
    .hexpris-line { margin-bottom: 9px; }
    .hexpris-line:last-of-type { margin-bottom: 0; }
}
