/* ============================================================
   TRADE DESK — shared drawer + gear button
   Included by every page under live-season/trades/.
   Brown/brass palette matches the Trade Desk theme on the Live
   Season hub and the trades/index.html hub page. Drawer slides
   in from the right over a translucent backdrop.
   ============================================================ */

/* ── Theme tokens (re-declared so this file works as a standalone
   include — pages that already define them inherit; pages that
   don't pick these up). */
:root {
    --td-card:         #322217;
    --td-card-hover:   #3c2a1d;
    --td-line:         #4c3922;
    --td-line-soft:    #2a1d12;
    --td-mute:         #7d6a52;
    --td-text:         #f5e9c8;
    --td-text-em:      #c8a464;
    --td-desc:         #c4ad84;
    --td-live:         #c8a464;
    --td-bg-deep:      #15100a;
    --td-input-bg:     #1f160d;
    --td-input-border: #4c3922;
    --td-input-focus:  #c8a464;
    --td-overlay:      rgba(0, 0, 0, .74);
}

/* ── Inline settings trigger (no fixed gear) ──────────────────
   The Trade Desk hub renders a §02 Settings section with a wide
   card that calls openDrawer(). No floating UI — the trigger
   lives where users are scanning the page. */
.td-settings-trigger {
    display: flex; align-items: center; gap: 1rem;
    padding: 1.3rem 1.4rem;
    background: var(--td-card);
    border: 1px solid var(--td-line);
    border-radius: 4px;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
    width: 100%;
    text-align: left;
    font-family: inherit;
}
.td-settings-trigger:hover {
    background: var(--td-card-hover);
    border-color: var(--td-live);
}
.td-settings-trigger:focus-visible {
    outline: 2px solid var(--td-live);
    outline-offset: 2px;
}
.td-settings-trigger-icon {
    flex-shrink: 0;
    width: 38px; height: 38px;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(200, 164, 100, .08);
    border: 1px solid var(--td-line);
    border-radius: 4px;
    color: var(--td-live);
    font-size: 1.15rem;
}
.td-settings-trigger-body { flex: 1; min-width: 0; }
.td-settings-trigger-title {
    font-family: var(--serif); font-size: 1.15rem; line-height: 1.2;
    color: var(--td-text); margin: 0 0 .25rem;
}
.td-settings-trigger-title em { color: var(--td-text-em); font-style: italic; }
.td-settings-trigger-desc {
    color: var(--td-desc); font-size: .85rem; line-height: 1.5;
    margin: 0;
}
.td-settings-trigger-arrow {
    flex-shrink: 0;
    font-family: var(--mono); font-size: 1.1rem;
    color: var(--td-live);
}

/* ── Overlay + drawer ───────────────────────────────────────── */
.td-drawer-overlay {
    position: fixed; inset: 0;
    background: var(--td-overlay);
    /* No backdrop-filter — a viewport-sized live blur re-blurs the whole
       page (gradients and all) every frame while the drawer is open,
       which lags the drawer's own scrolling. A deeper plain scrim reads
       nearly the same and composites for free. */
    z-index: 60;
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease;
}
.td-drawer-overlay[data-open="true"] {
    opacity: 1;
    pointer-events: auto;
}

.td-drawer {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 100%;
    max-width: 460px;
    background: var(--td-bg-deep);
    border-left: 1px solid var(--td-line);
    box-shadow: -8px 0 28px rgba(0, 0, 0, .55);
    z-index: 70;
    display: flex; flex-direction: column;
    transform: translateX(100%);
    transition: transform .22s ease;
}
.td-drawer[data-open="true"] {
    transform: translateX(0);
}

/* ── Drawer header ──────────────────────────────────────────── */
.td-drawer-head {
    display: flex; align-items: baseline; gap: .8rem;
    padding: 1.3rem 1.4rem 1rem;
    border-bottom: 1px solid var(--td-line);
}
.td-drawer-sup {
    font-family: var(--mono); font-size: .58rem; letter-spacing: .28em;
    text-transform: uppercase; color: var(--td-live);
}
.td-drawer-title {
    font-family: var(--serif); font-size: 1.5rem; line-height: 1;
    color: var(--td-text); margin: 0;
}
.td-drawer-title em { color: var(--td-text-em); font-style: italic; }
.td-drawer-close {
    margin-left: auto;
    background: none; border: none; color: var(--td-mute);
    font-size: 1.5rem; line-height: 1; cursor: pointer;
    padding: .2rem .4rem;
}
.td-drawer-close:hover { color: var(--td-text); }

/* ── Drawer body — scrollable form area ─────────────────────── */
.td-drawer-body {
    padding: 1.1rem 1.4rem 1.4rem;
    overflow-y: auto;
    flex: 1;
}

/* Banner shown for non-commish viewers OR for unconfirmed non-Sleeper. */
.td-banner {
    padding: .8rem 1rem;
    margin-bottom: 1.2rem;
    background: rgba(200, 164, 100, .07);
    border: 1px solid rgba(200, 164, 100, .25);
    border-radius: 3px;
    color: var(--td-desc);
    font-size: .82rem; line-height: 1.5;
}
.td-banner[data-tone="warn"] {
    background: rgba(212, 169, 76, .1);
    border-color: rgba(212, 169, 76, .45);
    color: #e8c889;
}
.td-banner[data-tone="muted"] {
    background: rgba(125, 106, 82, .08);
    border-color: rgba(125, 106, 82, .35);
    color: var(--td-mute);
}

.td-section {
    margin-bottom: 1.6rem;
    padding-bottom: 1.2rem;
    border-bottom: 1px solid var(--td-line-soft);
}
.td-section:last-of-type { border-bottom: none; margin-bottom: 0; }

.td-section-label {
    font-family: var(--mono); font-size: .58rem; letter-spacing: .25em;
    text-transform: uppercase; color: var(--td-live);
    display: block; margin-bottom: .6rem;
}
.td-section-hint {
    font-size: .76rem; color: var(--td-mute); line-height: 1.5;
    margin: -.35rem 0 .65rem;
}

/* ── Inputs ──────────────────────────────────────────────────
   Native select + number-input with the theme baked in. Selects get
   appearance:none — without it Safari paints its own gradient pill and
   ignores the theme entirely. The OS picker still opens on tap; we
   redraw the chevron so the control still reads as a dropdown. */
.td-input, .td-select {
    width: 100%;
    padding: .55rem .7rem;
    background: var(--td-input-bg);
    border: 1px solid var(--td-input-border);
    border-radius: 3px;
    color: var(--td-text);
    font-family: inherit;
    font-size: .88rem;
    transition: border-color .12s ease;
}
select.td-select {
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%23a08a64' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right .7rem center;
    padding-right: 2rem;
    cursor: pointer;
}
.td-input:focus, .td-select:focus {
    outline: none;
    border-color: var(--td-input-focus);
}
.td-input:disabled, .td-select:disabled {
    opacity: .68;
    cursor: not-allowed;
}

/* ── Radio group — for value source preference ─────────────── */
.td-radio-group {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: .4rem;
}
.td-radio {
    position: relative;
    display: flex; align-items: center; justify-content: center;
    padding: .55rem .35rem;
    background: var(--td-input-bg);
    border: 1px solid var(--td-input-border);
    border-radius: 3px;
    cursor: pointer;
    font-family: var(--mono); font-size: .62rem;
    letter-spacing: .12em; text-transform: uppercase;
    color: var(--td-desc);
    transition: border-color .12s ease, background .12s ease;
    text-align: center;
}
.td-radio input { position: absolute; opacity: 0; pointer-events: none; }
.td-radio:hover { border-color: var(--td-line); }
.td-radio[data-checked="true"] {
    border-color: var(--td-live);
    color: var(--td-live);
    background: rgba(200, 164, 100, .07);
}
.td-radio[aria-disabled="true"] {
    cursor: not-allowed;
    opacity: .68;
}

/* ── Roster slot mini-grid ─────────────────────────────────── */
.td-slot-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .55rem;
}
.td-slot {
    display: flex; flex-direction: column;
}
.td-slot-name {
    font-family: var(--mono); font-size: .55rem; letter-spacing: .2em;
    text-transform: uppercase; color: var(--td-mute);
    margin-bottom: .3rem;
}
.td-slot input {
    width: 100%;
    padding: .35rem .45rem;
    background: var(--td-input-bg);
    border: 1px solid var(--td-input-border);
    border-radius: 3px;
    color: var(--td-text);
    font-family: inherit;
    font-size: .82rem;
    text-align: center;
}
.td-slot input:focus { outline: none; border-color: var(--td-input-focus); }
.td-slot input:disabled { opacity: .68; }

/* ── Drawer footer — save / cancel + provenance line ──────── */
.td-drawer-foot {
    padding: 1rem 1.4rem 1.2rem;
    border-top: 1px solid var(--td-line);
    display: flex; flex-direction: column; gap: .7rem;
}
.td-foot-row {
    display: flex; gap: .6rem; align-items: center;
}
.td-btn {
    padding: .6rem 1.1rem;
    border-radius: 3px;
    border: 1px solid var(--td-line);
    background: var(--td-card);
    color: var(--td-text);
    cursor: pointer;
    font-family: var(--mono); font-size: .65rem;
    letter-spacing: .2em; text-transform: uppercase;
    transition: background .15s ease, border-color .15s ease;
}
.td-btn:hover { background: var(--td-card-hover); border-color: var(--td-live); }
.td-btn[data-variant="primary"] {
    background: var(--td-live);
    color: var(--td-bg-deep);
    border-color: var(--td-live);
}
.td-btn[data-variant="primary"]:hover {
    background: #f3d775; border-color: #f3d775;
}
.td-btn[disabled] {
    opacity: .55; cursor: not-allowed;
}
.td-foot-status {
    margin-left: auto;
    font-family: var(--mono); font-size: .58rem; letter-spacing: .2em;
    text-transform: uppercase; color: var(--td-mute);
}
.td-foot-confirmed {
    font-size: .72rem; color: var(--td-mute);
}
.td-foot-confirmed strong { color: var(--td-desc); font-weight: 500; }

/* ── Wider drawer on desktop ───────────────────────────────── */
@media (min-width: 720px) {
    .td-drawer { max-width: 480px; }
}

/* ── Hide scrollbar visually but keep scrollable ───────────── */
.td-drawer-body { scrollbar-width: thin; scrollbar-color: var(--td-line) transparent; }
.td-drawer-body::-webkit-scrollbar { width: 8px; }
.td-drawer-body::-webkit-scrollbar-thumb { background: var(--td-line); border-radius: 4px; }
