/* ============================================
   Stat Explanation Modal (Stats widgets "?")
   ============================================ */

.stat-explain-subtitle {
    display: block;
    margin-top: var(--space-0-5);
    font-size: 0.8em;
    color: var(--text-muted);
}

.stat-explain-summary {
    margin: 0 0 var(--space-3);
    font-size: 0.92em;
    line-height: 1.5;
    color: var(--text-color);
    padding: var(--space-3) var(--space-3-5);
    background: var(--accent-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.stat-explain-sections {
    display: flex;
    flex-direction: column;
}

.stat-explain-section {
    padding: var(--space-3) var(--space-0-5);
    border-top: 1px solid var(--border-color);
}

.stat-explain-section:first-child {
    border-top: none;
}

.stat-explain-section.signal-absent {
    opacity: 0.72;
}

.stat-explain-section-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-1);
}

.stat-explain-section-icon {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    color: var(--accent-color);
}

.stat-explain-section-title {
    font-weight: 700;
    font-size: 0.9em;
    color: var(--text-color);
}

.stat-explain-floor {
    margin-left: auto;
    padding: var(--space-0-5) var(--space-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    background: var(--accent-bg);
    color: var(--accent-color);
    font-size: 0.7em;
    font-weight: 700;
    white-space: nowrap;
}

.stat-explain-detail {
    margin: 0;
    font-size: 0.85em;
    line-height: 1.45;
    color: var(--text-secondary);
}

.stat-explain-cards {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2-5);
    margin-top: var(--space-2-5);
}

.stat-explain-card {
    position: relative;
    width: 138px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    color: inherit;
    text-align: center;
}

.stat-explain-card.chip-clickable {
    cursor: pointer;
}

.stat-explain-card img {
    width: 100%;
    border-radius: var(--radius-lg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-explain-card.chip-clickable:hover img,
.stat-explain-card.chip-clickable:focus-visible img {
    transform: scale(1.06);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
    z-index: 2;
    position: relative;
}

.stat-explain-card.chip-clickable:hover .stat-explain-card-name {
    color: var(--accent-color);
}

.stat-explain-card-placeholder {
    width: 100%;
    aspect-ratio: 5 / 7;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    background: var(--accent-bg);
}

.stat-explain-card-count {
    position: absolute;
    top: 4px;
    right: 4px;
    padding: 1px 5px;
    border-radius: var(--radius-lg);
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    font-size: 0.65em;
    font-weight: 700;
}

.stat-explain-card-name {
    width: 100%;
    font-size: 0.68em;
    line-height: 1.2;
    text-align: center;
    color: var(--text-secondary);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.stat-explain-markers {
    margin: var(--space-1-5) 0 0;
    padding-left: var(--space-5);
    font-size: 0.85em;
    line-height: 1.5;
    color: var(--text-secondary);
}

.stat-explain-footnote {
    margin: var(--space-3-5) 0 0;
    padding-top: var(--space-2-5);
    border-top: 1px solid var(--border-color);
    font-size: 0.78em;
    color: var(--text-muted);
}

.stat-explain-footnote a {
    color: var(--accent-color);
}

/* Tier legend rows inside stat explanation modals */
.stat-explain-tiers {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    margin-top: var(--space-1-5);
}

.stat-explain-tier-row {
    display: grid;
    grid-template-columns: 110px 70px 1fr;
    gap: var(--space-2-5);
    align-items: baseline;
    padding: 5px 8px;
    border-radius: var(--radius-md);
    font-size: 0.82em;
}

.stat-explain-tier-row.has-alt {
    grid-template-columns: 110px 70px 70px 1fr;
}

.stat-explain-tier-head {
    padding-bottom: 0;
    font-size: 0.72em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-explain-tier-head .stat-explain-tier-range {
    color: var(--text-muted);
    font-weight: 700;
}

.stat-explain-reassurance {
    font-weight: 700;
}

.stat-explain-tiers + .stat-explain-detail {
    margin-top: var(--space-2);
    font-size: 0.78em;
    color: var(--text-muted);
}

.stat-explain-tier-row.tier-active {
    background: var(--accent-bg);
    border: 1px solid var(--accent-color);
}

.stat-explain-tier-label {
    font-weight: 700;
    color: var(--text-color);
}

.stat-explain-tier-row.tier-active .stat-explain-tier-label {
    color: var(--accent-color);
}

.stat-explain-tier-range {
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.stat-explain-tier-desc {
    color: var(--text-secondary);
}

.tag-customize-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    max-height: 46vh;
    overflow-y: auto;
    margin: var(--space-3) 0 0;
    padding-right: var(--space-1-5);
}

.tag-customize-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-1-5) var(--space-2-5);
    border-radius: var(--radius-xl);
    border: 1px solid transparent;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.tag-customize-row:hover {
    background: var(--widget-bg);
    border-color: var(--border-color);
}

/* A hidden group stays legible rather than disappearing: the reader is here to find it. */
.tag-customize-row.is-hidden .tag-customize-label {
    color: var(--text-muted);
}

/* The master switch leads the list; a rule sets it apart from the groups it governs. */
.tag-customize-row--all .tag-customize-label {
    font-weight: 600;
}

.tag-customize-divider {
    flex: 0 0 auto;
    height: 1px;
    margin: var(--space-1) var(--space-2-5);
    background: var(--border-color);
}

/* The shared pill toggle, narrowed: its 80px-per-side default is sized for a settings
   form and would leave no room for the label in a list this dense. */
.tag-customize-toggle {
    flex: 0 0 auto;
    height: 28px;
    /* Last on the row, pinned right. */
    margin-left: auto;
}

.tag-customize-toggle .toggle-btn {
    min-width: 42px;
    padding: var(--space-0-5) var(--space-2);
    font-size: 0.7rem;
}

.tag-customize-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Its own fixed column so the badges form a straight edge down the list rather than
   landing wherever each label happens to end. */
.tag-customize-flag {
    flex: 0 0 92px;
    display: flex;
    justify-content: flex-end;
}

/* A package missing one of its halves: a warmer badge than plain "small". */
.tag-customize-note--sides {
    color: var(--warning-color);
    border-color: color-mix(in srgb, var(--warning-color) 55%, transparent);
    white-space: nowrap;
}

.tag-customize-count {
    flex: 0 0 34px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Marks the groups the size rule hid, so an unfamiliar 'off' state has a stated reason. */
.tag-customize-note {
    font-size: 0.7em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1px 5px;
}

/* On a phone the four columns leave the tag name a few characters wide, which is the one
   thing in the row the reader is actually looking for. Two rows instead: the name gets the
   full width, and the controls that qualify it sit underneath. */
@media (max-width: 600px) {
    .tag-customize-row {
        display: grid;
        grid-template-columns: auto auto 1fr;
        grid-template-areas:
            "label label label"
            "flag count toggle";
        align-items: center;
        gap: var(--space-1-5) var(--space-2-5);
        padding: var(--space-2) var(--space-2-5);
    }

    .tag-customize-label {
        grid-area: label;
        white-space: normal;
        font-weight: 600;
    }

    .tag-customize-toggle {
        grid-area: toggle;
    }

    /* Sized to its badge rather than the fixed alignment column, which only earns its keep
       when the badges form a straight edge beside a name column. */
    .tag-customize-flag {
        grid-area: flag;
        flex: 0 0 auto;
        justify-content: flex-start;
    }

    .tag-customize-count {
        grid-area: count;
        flex: 1 1 auto;
        text-align: right;
    }
}

/* An active "Off" gets a filled grey rather than the accent fill, so a glance down the column
   separates on from off by color instead of by reading the word in each pill. "On" keeps the
   accent treatment it shares with every other toggle in the app. */
.tag-customize-toggle .toggle-btn.right.active {
    background: color-mix(in srgb, var(--text-muted) 42%, var(--widget-bg));
    color: var(--text-color);
    box-shadow: none;
}

.tag-customize-reset {
    display: inline-flex;
    align-items: center;
    /* The icon sat flush against the label before this. */
    gap: var(--space-2);
}

/* The count is why a group is off; it should not read as an afterthought. */
.tag-customize-count {
    color: var(--text-color);
    font-size: 1rem;
    font-weight: 700;
}

/* ============================================
   DECK SAVED MODAL
   ============================================ */
.deck-saved-modal {
    width: 560px;
    max-width: calc(100vw - 32px);
    position: relative;
}

.deck-saved-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
    margin: 0 0 var(--space-3-5);
    padding: 0 0 var(--space-3);
    border-bottom: 1px solid var(--border-color);
}

/* Theme text color, like every other titled modal — not the accent. */
.deck-saved-modal .modal-header h3 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
}

.deck-saved-modal .modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-1);
    line-height: 1;
    display: flex;
}

.deck-saved-modal .share-modal-sections {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

.deck-saved-section h4 {
    margin: 0 0 var(--space-1-5);
    color: var(--accent-light);
    font-size: 0.95rem;
}

.deck-saved-section h4 + .share-url-field,
.deck-saved-section h4 + select {
    margin-bottom: var(--space-3);
}

.deck-saved-section + .deck-saved-section,
.deck-saved-row {
    border-top: 1px solid var(--border-color);
    padding-top: var(--space-5);
}

.deck-saved-note {
    margin: 0 0 var(--space-3);
    color: var(--text-color);
    font-weight: 600;
}

.deck-saved-status {
    text-align: center;
    margin-bottom: var(--space-4);
}

.deck-saved-format-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
}

.deck-saved-format-field {
    flex: 1 1 14rem;
    min-width: 0;
}

.deck-saved-format-field > select {
    width: 100%;
}

.share-url-container {
    display: flex;
    gap: var(--space-2);
    width: 100%;
}

.share-social {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin-top: var(--space-2-5);
}

.share-social-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.share-social-link {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-muted);
    background: var(--input-bg);
    text-decoration: none;
    transition: color 0.15s, border-color 0.15s;
}

.share-social-link:hover {
    color: var(--accent-light);
    border-color: color-mix(in srgb, var(--accent-color) 50%, transparent);
}

.share-social-icon {
    width: 15px;
    height: 15px;
    background-color: currentColor;
}

.deck-saved-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-5);
}

.deck-saved-row .deck-saved-section {
    display: flex;
    flex-direction: column;
    border-top: none;
    padding-top: 0;
}

.deck-saved-row .deck-saved-section + .deck-saved-section {
    border-left: 1px solid var(--border-color);
    padding-left: var(--space-5);
}

.deck-saved-section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-1-5);
}

.deck-saved-section-title h4 {
    margin: 0;
}

.deck-saved-blurb {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0 0 var(--space-3);
    flex: 1;
}

.deck-saved-modal .deck-saved-action {
    width: 100%;
    height: 40px;
    /* A flex child in a column that may run long: without a real minimum and
       `flex-shrink: 0` the button was compressed to fit, so the two buttons
       came out different heights. */
    min-height: 40px;
    flex: 0 0 40px;
    padding: 0 var(--space-3-5);
    margin-top: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

/* The Share heading's row holds the link's copy button, as the studio's field heads do. */
.deck-saved-share-head {
    margin-bottom: var(--space-1-5);
}

.deck-saved-section .deck-saved-share-head h4 {
    margin: 0;
}

/* Room between the link and the studio button. */
.deck-saved-modal .deck-saved-action.deck-saved-studio {
    margin-top: var(--space-3);
}

.deck-saved-action.btn-unavailable {
    opacity: 0.45;
    cursor: not-allowed;
}

@media (max-width: 600px) {
    .deck-saved-row {
        grid-template-columns: 1fr;
    }

    .deck-saved-row .deck-saved-section + .deck-saved-section {
        border-left: none;
        padding-left: 0;
        border-top: 1px solid var(--border-color);
        padding-top: var(--space-5);
    }
}

