/*
 * National STR Map — engagement layer (str-engage.js).
 *   .se-watch …  "Watch this market" widget in #sm-market-tools / #sm-state-tools
 *   .se-trend …  trending boards appended to #sm-terminal
 * Everything is namespaced .se-* and inherits the --sm-* tokens from .sm (str-map.css).
 * The boards deliberately repeat the look of .st-board in str-terminal.css.
 */
.se {
    --se-mono: ui-monospace, 'SF Mono', 'Cascadia Mono', 'Segoe UI Mono', Consolas, monospace;
    --se-up: #34D399;
    --se-down: #F87171;
    --se-amber: #FBBF24;
    --se-info: #60A5FA;
    min-width: 0;
}
.se, .se * { box-sizing: border-box; }
.se button, .se input { font-family: inherit; }

/* ==========================================================
   Watch widget
   ========================================================== */
.se-watch {
    margin-top: 16px; border: 1px solid var(--sm-line); border-radius: 12px;
    background: linear-gradient(180deg, rgba(52, 211, 153, .05), rgba(52, 211, 153, 0) 70%), var(--sm-bg);
    overflow: hidden;
}
.se-watch.is-open { border-color: rgba(52, 211, 153, .4); }

.se-bar { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; padding: 10px 12px; }
.se-toggle {
    display: inline-flex; align-items: center; gap: 8px; max-width: 100%; cursor: pointer;
    background: rgba(52, 211, 153, .1); color: #D1FAE5; border: 1px solid rgba(52, 211, 153, .42);
    border-radius: 9px; padding: 8px 13px; font-size: .84rem; font-weight: 700; line-height: 1.2; text-align: left;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.se-toggle:hover { background: rgba(52, 211, 153, .18); border-color: var(--sm-accent); color: #fff; }
.se-toggle[aria-expanded="true"] { background: rgba(52, 211, 153, .2); border-color: var(--sm-accent); color: #fff; }
.se-bell { flex: 0 0 auto; font-size: .95rem; line-height: 1; }
.se-toggle-t { min-width: 0; overflow-wrap: anywhere; }
.se-bar-note { font-size: .74rem; line-height: 1.4; color: var(--sm-faint); min-width: 0; }

.se :focus-visible { outline: 2px solid var(--sm-accent); outline-offset: 2px; border-radius: 6px; }

.se-form { padding: 2px 12px 13px; }
.se-form[hidden] { display: none; }
.sm .se-hook {
    margin: 0 0 12px; padding: 9px 11px; font-size: .78rem; line-height: 1.5; color: #FDE9B0;
    background: rgba(251, 191, 36, .08); border: 1px solid rgba(251, 191, 36, .3); border-left: 3px solid var(--se-amber);
    border-radius: 8px; overflow-wrap: anywhere;
}
.se-hook strong { color: var(--se-amber); font-weight: 800; }

.se-field { display: flex; flex-direction: column; gap: 5px; }
.se-label { font-size: .66rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--sm-faint); }
.se-input {
    width: 100%; min-width: 0; padding: 10px 12px; font-size: 16px; /* 16px: no iOS zoom on focus */
    color: var(--sm-text); background: #0A111E; border: 1px solid var(--sm-line); border-radius: 9px;
    transition: border-color .15s ease, background .15s ease;
}
.se-input::placeholder { color: var(--sm-faint); opacity: .8; }
.se-input:hover { border-color: var(--sm-faint); }
.se-input:focus { outline: none; border-color: var(--sm-accent); background: #0C1524; box-shadow: 0 0 0 3px rgba(52, 211, 153, .16); }
.se-input[aria-invalid="true"] { border-color: rgba(248, 113, 113, .8); }

/* Honeypot: off-screen rather than display:none so naive bots still fill it. */
.se-hp { position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden; }

.se-consent { display: flex; align-items: flex-start; gap: 9px; margin-top: 11px; }
.se-check {
    flex: 0 0 auto; width: 18px; height: 18px; margin: 1px 0 0; accent-color: #10B981; cursor: pointer;
}
.se-check[aria-invalid="true"] { outline: 2px solid var(--se-down); outline-offset: 2px; border-radius: 3px; }
.se-consent-l { font-size: .76rem; line-height: 1.5; color: var(--sm-dim); cursor: pointer; min-width: 0; overflow-wrap: anywhere; }
.sm .se-link { color: var(--sm-accent); text-decoration: underline; text-underline-offset: 2px; }
.sm .se-link:hover { color: #fff; }

.se-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.se-submit {
    flex: 1 1 auto; min-width: 0; cursor: pointer; border-radius: 9px; padding: 10px 14px;
    font-size: .86rem; font-weight: 800; color: #05231A; background: var(--sm-accent-deep);
    border: 1px solid var(--sm-accent-deep); overflow-wrap: anywhere;
    transition: background .15s ease, border-color .15s ease;
}
.se-submit:hover { background: var(--sm-accent); border-color: var(--sm-accent); }
.se-submit:disabled { opacity: .65; cursor: progress; }
.se-cancel {
    flex: 0 0 auto; cursor: pointer; border-radius: 9px; padding: 10px 13px; font-size: .8rem; font-weight: 700;
    color: var(--sm-dim); background: transparent; border: 1px solid var(--sm-line);
    transition: border-color .15s ease, color .15s ease;
}
.se-cancel:hover { color: #fff; border-color: var(--sm-faint); }
.se-cancel:disabled { opacity: .5; cursor: default; }

.sm .se-msg { margin: 10px 0 0; font-size: .76rem; line-height: 1.45; color: var(--sm-dim); }
.sm .se-msg:empty { display: none; }
.sm .se-msg.is-error { color: #FCA5A5; }

/* Watching / success */
.se-on { padding: 11px 12px 12px; }
.se-on-top { display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap; }
.se-on-badge {
    flex: 0 0 auto; font-family: var(--se-mono); font-size: .66rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
    color: var(--se-up); background: rgba(52, 211, 153, .12); border: 1px solid rgba(52, 211, 153, .4);
    border-radius: 5px; padding: 4px 7px; line-height: 1; white-space: nowrap;
}
.se-on-title { font-size: .9rem; font-weight: 800; color: #fff; letter-spacing: -.01em; min-width: 0; overflow-wrap: anywhere; }
.sm .se-on-note { margin: 7px 0 0; font-size: .76rem; line-height: 1.55; color: var(--sm-dim); overflow-wrap: anywhere; }
.se-on-email { color: var(--sm-text); font-weight: 600; }
.se-unwatch {
    display: inline; padding: 0; margin: 0; background: none; border: 0; cursor: pointer;
    font-size: inherit; font-weight: 700; color: var(--sm-accent); text-decoration: underline; text-underline-offset: 2px;
}
.se-unwatch:hover { color: #fff; }
.se-unwatch:disabled { color: var(--sm-faint); cursor: progress; text-decoration: none; }
.se-watch[data-state="success"] { border-color: rgba(52, 211, 153, .5); animation: seIn .35s ease both; }
@keyframes seIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ==========================================================
   Trending section (inside #sm-terminal, after the terminal's own block)
   ========================================================== */
.se-trend { margin-top: 38px; }
.sm-terminal > .se-trend:first-child { margin-top: 0; }
.se-inner { max-width: 1880px; margin: 0 auto; padding: 0 24px; }

.se-head {
    display: flex; align-items: flex-end; justify-content: space-between; gap: 10px 28px; flex-wrap: wrap;
    margin-bottom: 14px;
}
.se-head-l { min-width: 0; }
.se-kicker {
    display: inline-flex; align-items: center; gap: 8px;
    font-family: var(--se-mono); font-size: .7rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
    color: var(--sm-accent);
}
.se-kicker::before { content: ''; width: 18px; height: 2px; background: var(--sm-accent); }
.sm .se-title {
    margin: 6px 0 0; font-size: clamp(1.25rem, 2vw, 1.6rem); font-weight: 800; letter-spacing: -.02em;
    line-height: 1.15; color: #fff; font-family: inherit;
}
.sm .se-head-sub { margin: 0; max-width: 62ch; font-size: .84rem; line-height: 1.5; color: var(--sm-dim); }

.se-boards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: stretch; }
.se-boards[data-se-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.se-boards[data-se-count="1"] { grid-template-columns: minmax(0, 560px); }

.se-board {
    background: var(--sm-panel); border: 1px solid var(--sm-line); border-radius: 16px; overflow: hidden;
    display: flex; flex-direction: column; min-width: 0;
}
.se-board-head { padding: 14px 16px 12px; border-bottom: 1px solid var(--sm-line); }
.se-board-top { display: flex; align-items: center; gap: 9px; min-width: 0; }
.se-board-code {
    flex: 0 0 auto; font-family: var(--se-mono); font-size: .62rem; font-weight: 800; letter-spacing: .1em;
    color: var(--sm-accent); background: rgba(52, 211, 153, .1); border: 1px solid rgba(52, 211, 153, .28);
    border-radius: 4px; padding: 3px 6px; line-height: 1;
}
.se-board--states .se-board-code { color: #93C5FD; background: rgba(96, 165, 250, .1); border-color: rgba(96, 165, 250, .3); }
.se-board--unmet .se-board-code { color: var(--se-amber); background: rgba(251, 191, 36, .1); border-color: rgba(251, 191, 36, .32); }
.sm .se-board-title {
    margin: 0; font-size: .95rem; font-weight: 800; letter-spacing: -.01em; line-height: 1.25; color: #fff;
    font-family: inherit; min-width: 0;
}
.sm .se-board-sub { margin: 7px 0 0; font-size: .75rem; line-height: 1.45; color: var(--sm-dim); min-height: 2.9em; }

.se-rows { list-style: none; margin: 0; padding: 0; flex: 1 1 auto; display: grid; grid-auto-rows: minmax(46px, auto); align-content: start; }
.se-li { margin: 0; padding: 0; display: flex; min-width: 0; }
.se-li + .se-li { border-top: 1px solid rgba(38, 51, 76, .55); }

.se-row {
    display: grid; align-items: center; column-gap: 12px; width: 100%;
    grid-template-columns: 22px minmax(0, 1fr) 64px;
    padding: 8px 16px 8px 13px; border: 0; border-left: 3px solid transparent;
    background: transparent; color: var(--sm-text); font-family: inherit; text-align: left;
    position: relative;
}
.se-has-delta .se-row { grid-template-columns: 22px minmax(0, 1fr) 58px 84px; }
.se-board--unmet .se-row { grid-template-columns: 22px minmax(0, 1fr) 76px; }

button.se-row { cursor: pointer; transition: background .14s ease, border-color .14s ease; }
button.se-row:hover { background: var(--sm-raise); border-left-color: var(--sm-accent); }
button.se-row:focus-visible { outline: 2px solid var(--sm-accent); outline-offset: -2px; border-radius: 0; background: var(--sm-raise); border-left-color: var(--sm-accent); }
.se-board--states button.se-row:hover, .se-board--states button.se-row:focus-visible { border-left-color: var(--se-info); }

.se-row--head {
    padding-top: 7px; padding-bottom: 7px; background: rgba(5, 9, 15, .35);
    border-bottom: 1px solid var(--sm-line);
    font-size: .6rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--sm-faint);
}
.se-c-rank {
    font-family: var(--se-mono); font-variant-numeric: tabular-nums; font-size: .72rem; font-weight: 700;
    color: var(--sm-faint); text-align: right;
}
.se-row.is-top .se-c-rank { color: var(--sm-accent); }
.se-board--states .se-row.is-top .se-c-rank { color: #93C5FD; }
.se-c-mkt { min-width: 0; display: block; }
.se-mkt-line { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
.se-mkt-city { font-size: .86rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.se-mkt-st { flex: 0 0 auto; font-family: var(--se-mono); font-size: .66rem; font-weight: 700; letter-spacing: .06em; color: var(--sm-faint); }
.se-mkt-sub {
    display: block; margin-top: 1px; font-size: .69rem; line-height: 1.4; color: var(--sm-faint);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.se-term { display: block; text-transform: capitalize; font-weight: 500; color: var(--sm-text); }
.se-term::before { content: '\201C'; color: var(--sm-faint); }
.se-term::after { content: '\201D'; color: var(--sm-faint); }

.se-c-fig {
    font-family: var(--se-mono); font-variant-numeric: tabular-nums; font-size: .78rem; font-weight: 600;
    color: var(--sm-dim); text-align: right; white-space: nowrap; min-width: 0;
}
.se-row--head .se-c-fig { font-family: inherit; font-size: inherit; font-weight: inherit; color: inherit; }
.se-c-fig--1 { font-size: .86rem; font-weight: 700; color: #fff; }
.se-c-delta.is-up { color: var(--se-up); }
.se-c-delta.is-down { color: var(--se-down); }
.se-c-delta.is-flat { color: var(--sm-dim); }
.se-c-delta.is-new {
    justify-self: end; font-size: .58rem; font-weight: 800; letter-spacing: .1em; color: var(--se-amber);
    border: 1px solid rgba(251, 191, 36, .35); border-radius: 3px; padding: 2px 5px; line-height: 1.2;
}

/* Hairline meter along the row's foot: value relative to the board leader. */
.se-meter {
    position: absolute; left: 0; bottom: -1px; height: 2px; max-width: 100%;
    background: linear-gradient(90deg, rgba(52, 211, 153, 0), rgba(52, 211, 153, .75));
    pointer-events: none; z-index: 1;
}
.se-meter.is-info { background: linear-gradient(90deg, rgba(96, 165, 250, 0), rgba(96, 165, 250, .7)); }
.se-meter.is-amber { background: linear-gradient(90deg, rgba(251, 191, 36, 0), rgba(251, 191, 36, .7)); }

.se-board-foot {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 10px 16px; border-top: 1px solid var(--sm-line); background: rgba(5, 9, 15, .35);
}
.se-board-n { font-family: var(--se-mono); font-size: .66rem; letter-spacing: .06em; text-transform: uppercase; color: var(--sm-faint); }

/* ==========================================================
   Responsive
   ========================================================== */
@media (max-width: 1180px) {
    .se-boards, .se-boards[data-se-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .se-boards[data-se-count="3"] .se-board--unmet { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
    .se-trend { margin-top: 30px; }
    .se-inner { padding: 0 16px; }
    .se-boards, .se-boards[data-se-count="2"], .se-boards[data-se-count="1"] { grid-template-columns: minmax(0, 1fr); }
    .se-boards[data-se-count="3"] .se-board--unmet { grid-column: auto; }
    .sm .se-board-sub { min-height: 0; }
    /* One board per row on a phone: top five each keeps the section a short scroll. */
    .se-li:nth-child(n+6) { display: none; }
}
@media (max-width: 480px) {
    .se-row, .se-board--unmet .se-row { column-gap: 9px; padding-left: 10px; padding-right: 12px; }
    .se-row { grid-template-columns: 20px minmax(0, 1fr) 56px; }
    .se-has-delta .se-row { grid-template-columns: 20px minmax(0, 1fr) 48px 70px; }
    .se-board--unmet .se-row { grid-template-columns: 20px minmax(0, 1fr) 70px; }
    .se-bar-note { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .se-toggle, .se-input, .se-submit, .se-cancel, button.se-row { transition: none; }
    .se-watch[data-state="success"] { animation: none; }
}
