/*
 * Shared tactical UI primitives.
 *
 * These classes are opt-in building blocks for the visual refresh. Existing
 * page-specific classes remain the owner of current behavior until a page is
 * deliberately migrated.
 */

:root {
    --tactical-button-clip-path: polygon(
        10px 0,
        100% 0,
        100% calc(100% - 10px),
        calc(100% - 10px) 100%,
        0 100%,
        0 10px
    );
    --tactical-button-inner-border-color: rgba(92, 64, 24, 0.88);
}

button,
input[type='button'],
input[type='submit'],
input[type='reset'],
.discord-btn {
    clip-path: var(--tactical-button-clip-path);
}

button:not(.tactical-popup-close-button):not(.error-popup-close-button):not(.chat-popup-close-button):not(.arena-setup-popup-close-button):not(.research-tech-popup-close-button):not(.military-modal-close):not(.modal-close):not(.twofa-close):not(.ranking-popup-close-button):not(.icon-btn):not(#chatButton),
.discord-btn {
    position: relative;
    isolation: isolate;
}

button:not(.tactical-popup-close-button):not(.error-popup-close-button):not(.chat-popup-close-button):not(.arena-setup-popup-close-button):not(.research-tech-popup-close-button):not(.military-modal-close):not(.modal-close):not(.twofa-close):not(.ranking-popup-close-button):not(.icon-btn):not(#chatButton)::before,
.discord-btn::before {
    content: '';
    position: absolute;
    inset: 2px;
    border: 1px solid var(--neveron-button-inner-border-color, var(--tactical-button-inner-border-color));
    clip-path: inherit;
    pointer-events: none;
    z-index: 1;
}

.tactical-page {
    box-sizing: border-box;
    min-height: 100%;
    color: #f1efe8;
    font-family: var(--font-body);
}

.tactical-panel,
.tactical-frame,
.tactical-popup {
    position: relative;
    box-sizing: border-box;
    color: #f1efe8;
    background:
        linear-gradient(180deg, rgba(20, 25, 24, 0.98), rgba(5, 12, 14, 0.99));
    border: 1px solid rgba(255, 177, 48, 0.62);
    border-radius: 6px;
    box-shadow:
        0 20px 48px rgba(0, 0, 0, 0.52),
        0 0 0 2px rgba(5, 8, 9, 0.96),
        0 0 0 3px rgba(148, 86, 20, 0.38),
        inset 0 0 0 1px rgba(240, 165, 26, 0.2),
        inset 0 0 0 6px rgba(0, 0, 0, 0.28);
}

.tactical-frame::before,
.tactical-popup::before {
    content: '';
    position: absolute;
    inset: 8px;
    z-index: 1;
    pointer-events: none;
    border: 1px solid rgba(244, 169, 51, 0.25);
    box-shadow:
        inset 0 0 0 1px rgba(255, 222, 148, 0.08),
        inset 0 0 24px rgba(240, 165, 26, 0.08);
}

.tactical-frame::after,
.tactical-popup::after {
    content: '';
    position: absolute;
    inset: 8px;
    z-index: 1;
    pointer-events: none;
    background:
        linear-gradient(90deg, rgba(255, 185, 54, 0.86), transparent 70%) left top / 96px 1px no-repeat,
        linear-gradient(180deg, rgba(255, 185, 54, 0.86), transparent 70%) left top / 1px 44px no-repeat,
        linear-gradient(270deg, rgba(255, 185, 54, 0.86), transparent 70%) right top / 96px 1px no-repeat,
        linear-gradient(180deg, rgba(255, 185, 54, 0.86), transparent 70%) right top / 1px 44px no-repeat,
        linear-gradient(90deg, rgba(255, 185, 54, 0.58), transparent 70%) left bottom / 96px 1px no-repeat,
        linear-gradient(0deg, rgba(255, 185, 54, 0.58), transparent 70%) left bottom / 1px 44px no-repeat,
        linear-gradient(270deg, rgba(255, 185, 54, 0.58), transparent 70%) right bottom / 96px 1px no-repeat,
        linear-gradient(0deg, rgba(255, 185, 54, 0.58), transparent 70%) right bottom / 1px 44px no-repeat;
}

.tactical-panel-title,
.tactical-popup-title-bar {
    box-sizing: border-box;
    color: #ffd790;
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.tactical-popup {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    max-height: 88vh;
    overflow: hidden;
}

.tactical-popup-modal {
    position: fixed;
    display: none;
    flex-direction: column;
}

.tactical-popup-title-bar {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 8px 8px 0;
    padding: 16px 20px;
    border: 1px solid rgba(240, 165, 26, 0.22);
    border-bottom-color: rgba(240, 165, 26, 0.42);
    background:
        linear-gradient(90deg, rgba(75, 47, 14, 0.68), rgba(10, 26, 32, 0.96) 48%, rgba(5, 12, 14, 0.98)),
        linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent);
}

.tactical-popup-title-bar .tactical-popup-close-button {
    position: static;
    flex: 0 0 auto;
    margin: 0;
    padding: 0;
    max-width: none;
}

.tactical-popup-body,
.tactical-section {
    box-sizing: border-box;
    position: relative;
    z-index: 2;
}

.tactical-popup-body {
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 18px 20px 20px;
}

.tactical-section {
    padding: 14px;
    border: 1px solid rgba(143, 188, 201, 0.18);
    border-radius: 6px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.015));
}

input[type='number'] {
    box-sizing: border-box;
    min-height: 44px;
    padding: 10px 12px;
    color: #f8f3e6;
    background: rgba(2, 9, 12, 0.94);
    border: 1px solid rgba(240, 165, 26, 0.42);
    border-radius: 5px;
    color-scheme: dark;
    box-shadow:
        inset 0 0 0 1px rgba(255, 220, 144, 0.05),
        0 0 0 1px rgba(8, 15, 20, 0.8);
}

input[type='number']:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow:
        inset 0 0 0 1px rgba(255, 220, 144, 0.08),
        0 0 0 1px rgba(240, 165, 26, 0.35);
}

input[type='number']:disabled {
    color: rgba(241, 239, 232, 0.45);
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(143, 188, 201, 0.22);
    box-shadow: none;
    cursor: not-allowed;
}

.tactical-button,
.tactical-button-primary,
.tactical-button-danger,
.tactical-popup-close-button {
    box-sizing: border-box;
    min-height: 44px;
    padding: 10px 16px;
    color: #fff;
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border: 1px solid transparent;
    background:
        var(--tactical-button-fill-layer, linear-gradient(180deg, rgba(240, 165, 26, 0.38), rgba(120, 70, 10, 0.55))) padding-box,
        var(--tactical-button-border-layer, linear-gradient(180deg, rgba(255, 205, 111, 0.72), rgba(138, 86, 18, 0.92))) border-box;
    cursor: pointer;
}

.tactical-button,
.tactical-button-primary {
    --tactical-button-border-layer: linear-gradient(180deg, rgba(255, 205, 111, 0.72), rgba(138, 86, 18, 0.92));
    --tactical-button-fill-layer: linear-gradient(180deg, rgba(240, 165, 26, 0.38), rgba(120, 70, 10, 0.55));
    --neveron-button-inner-border-color: rgba(92, 64, 24, 0.88);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.22);
}

.tactical-button:hover,
.tactical-button-primary:hover {
    --tactical-button-border-layer: linear-gradient(180deg, rgba(255, 231, 177, 0.94), rgba(176, 108, 20, 0.96));
    --tactical-button-fill-layer: linear-gradient(180deg, rgba(255, 186, 58, 0.5), rgba(140, 81, 12, 0.7));
    box-shadow: 0 16px 28px rgba(0, 0, 0, 0.3);
}

.tactical-button-danger {
    color: #fff;
    --tactical-button-border-layer: linear-gradient(180deg, rgba(247, 167, 149, 0.84), rgba(111, 32, 17, 0.94));
    --tactical-button-fill-layer: linear-gradient(180deg, rgba(228, 65, 37, 0.42), rgba(94, 19, 12, 0.7));
    --neveron-button-inner-border-color: rgba(86, 22, 14, 0.88);
}

.tactical-popup-close-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    min-width: 44px;
    height: 44px;
    padding: 0;
    color: #fff5d9;
    --tactical-button-border-layer: linear-gradient(180deg, rgba(255, 217, 136, 0.9), rgba(151, 95, 24, 0.98));
    --tactical-button-fill-layer: linear-gradient(180deg, rgba(92, 64, 24, 0.92), rgba(56, 34, 10, 0.98));
    box-shadow:
        inset 0 0 0 1px rgba(255, 220, 144, 0.12),
        0 10px 20px rgba(0, 0, 0, 0.3);
}

.tactical-popup-close-button:hover {
    color: #fff;
    --tactical-button-border-layer: linear-gradient(180deg, rgba(255, 239, 194, 0.98), rgba(185, 116, 24, 0.99));
    --tactical-button-fill-layer: linear-gradient(180deg, rgba(145, 93, 22, 0.95), rgba(86, 48, 10, 0.98));
}

.tactical-button:disabled,
.tactical-button-primary:disabled,
.tactical-button-danger:disabled {
    color: rgba(241, 239, 232, 0.45);
    --tactical-button-border-layer: linear-gradient(180deg, rgba(143, 188, 201, 0.22), rgba(95, 118, 130, 0.24));
    --tactical-button-fill-layer: rgba(255, 255, 255, 0.05);
    cursor: not-allowed;
    box-shadow: none;
}

.tactical-table {
    width: 100%;
    border-collapse: collapse;
    color: #f1efe8;
    font-family: var(--font-body);
    background: rgba(4, 11, 16, 0.74);
    border: 1px solid rgba(240, 165, 26, 0.22);
}

.tactical-table th,
.tactical-table td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(143, 188, 201, 0.14);
    text-align: left;
}

.tactical-table th {
    color: #ffd996;
    font-family: var(--font-display);
    font-size: 14px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: rgba(75, 47, 14, 0.35);
}

.tactical-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.025);
}

.tactical-table tbody tr:hover {
    background: rgba(240, 165, 26, 0.08);
}

.tactical-image-slot,
.tactical-hero-image {
    position: relative;
    box-sizing: border-box;
    overflow: hidden;
    border: 1px dashed rgba(240, 165, 26, 0.45);
    border-radius: 6px;
    background:
        linear-gradient(180deg, rgba(18, 30, 38, 0.84), rgba(8, 16, 20, 0.98)),
        repeating-linear-gradient(135deg, rgba(240, 165, 26, 0.06) 0, rgba(240, 165, 26, 0.06) 12px, rgba(255, 255, 255, 0.02) 12px, rgba(255, 255, 255, 0.02) 24px);
}

.tactical-image-slot {
    aspect-ratio: 16 / 9;
}

.tactical-hero-image {
    aspect-ratio: 21 / 9;
}

.tactical-image-slot img,
.tactical-hero-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.tactical-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    margin: 0;
    border: 1px solid rgba(240, 165, 26, 0.55);
    border-radius: 4px;
    background:
        linear-gradient(180deg, rgba(14, 24, 30, 0.98), rgba(6, 12, 16, 0.98));
    box-shadow:
        inset 0 0 0 1px rgba(255, 220, 144, 0.06),
        0 4px 10px rgba(0, 0, 0, 0.22);
    cursor: pointer;
    position: relative;
}

.tactical-checkbox:hover {
    border-color: rgba(255, 202, 92, 0.78);
}

.tactical-checkbox:checked {
    border-color: var(--purple);
    background:
        linear-gradient(180deg, rgba(14, 24, 30, 0.98), rgba(6, 12, 16, 0.98)),
        linear-gradient(180deg, rgba(164, 91, 232, 0.2), rgba(92, 46, 138, 0.24));
}

.tactical-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 1px;
    width: 5px;
    height: 10px;
    border-right: 2px solid var(--purple);
    border-bottom: 2px solid var(--purple);
    transform: rotate(40deg);
}

.tactical-checkbox:focus-visible {
    outline: 2px solid rgba(164, 91, 232, 0.72);
    outline-offset: 2px;
}

.tactical-empty-state {
    box-sizing: border-box;
    padding: 18px;
    color: #f1efe8;
    border: 1px dashed rgba(240, 165, 26, 0.34);
    border-radius: 6px;
    background: rgba(4, 11, 16, 0.72);
    font-family: var(--font-body);
}

.tactical-status-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 26px;
    padding: 3px 10px;
    color: #f1efe8;
    border: 1px solid rgba(143, 188, 201, 0.22);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    font-family: var(--font-display);
    font-size: 13px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.tactical-scroll {
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: var(--gold-soft) rgba(7, 16, 20, 0.92);
}

.tactical-scroll::-webkit-scrollbar,
.tactical-popup-body::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

.tactical-scroll::-webkit-scrollbar-track,
.tactical-popup-body::-webkit-scrollbar-track {
    background: rgba(7, 16, 20, 0.92);
    border-left: 1px solid rgba(143, 188, 201, 0.12);
}

.tactical-scroll::-webkit-scrollbar-thumb,
.tactical-popup-body::-webkit-scrollbar-thumb {
    background:
        linear-gradient(180deg, rgba(240, 165, 26, 0.92), rgba(123, 82, 23, 0.95));
    border: 2px solid rgba(7, 16, 20, 0.92);
    border-radius: 999px;
}

.tactical-scroll::-webkit-scrollbar-thumb:hover,
.tactical-popup-body::-webkit-scrollbar-thumb:hover {
    background:
        linear-gradient(180deg, rgba(255, 196, 86, 0.98), rgba(160, 102, 24, 0.98));
}

@media (max-width: 900px) {
    .tactical-popup-title-bar {
        padding: 14px 16px;
        font-size: 18px;
    }

    .tactical-popup-body {
        padding: 16px;
    }

    .tactical-button,
    .tactical-button-primary,
    .tactical-button-danger {
        width: 100%;
    }
}

/*
 * Page styles load after this file. These higher-specificity opt-in rules keep
 * migrated elements on the tactical treatment without forcing hidden popups to
 * become visible before their existing page scripts open them.
 */

.tactical-popup.tactical-popup[style*="display: block"] {
    display: grid !important;
}

.tactical-popup.tactical-popup[style*="display: flex"] {
    display: grid !important;
}

dialog.tactical-popup:not([open]) {
    display: none;
}

dialog.tactical-popup[open] {
    display: grid;
}

.tactical-popup.tactical-popup,
.tactical-frame.tactical-frame,
.tactical-panel.tactical-panel {
    color: #f1efe8;
    background:
        linear-gradient(180deg, rgba(20, 25, 24, 0.98), rgba(5, 12, 14, 0.99));
    border-color: rgba(255, 177, 48, 0.62);
    border-radius: 6px;
    box-shadow:
        0 20px 48px rgba(0, 0, 0, 0.52),
        0 0 0 2px rgba(5, 8, 9, 0.96),
        0 0 0 3px rgba(148, 86, 20, 0.38),
        inset 0 0 0 1px rgba(240, 165, 26, 0.2),
        inset 0 0 0 6px rgba(0, 0, 0, 0.28);
}

.tactical-popup-title-bar.tactical-popup-title-bar,
.tactical-panel-title.tactical-panel-title {
    color: #ffd790;
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border-color: rgba(240, 165, 26, 0.22);
    border-bottom-color: rgba(240, 165, 26, 0.42);
    background:
        linear-gradient(90deg, rgba(75, 47, 14, 0.68), rgba(10, 26, 32, 0.96) 48%, rgba(5, 12, 14, 0.98)),
        linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent);
}

.tactical-section.tactical-section {
    color: #f1efe8;
    border-color: rgba(143, 188, 201, 0.18);
    border-radius: 6px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.015));
}

.tactical-button.tactical-button,
.tactical-button-primary.tactical-button-primary {
    color: #fff;
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border: 1px solid transparent;
    background:
        var(--tactical-button-fill-layer, linear-gradient(180deg, rgba(240, 165, 26, 0.38), rgba(120, 70, 10, 0.55))) padding-box,
        var(--tactical-button-border-layer, linear-gradient(180deg, rgba(255, 205, 111, 0.72), rgba(138, 86, 18, 0.92))) border-box;
}

.tactical-popup-close-button.tactical-popup-close-button {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    color: #fff5d9;
    font-family: var(--font-display);
    border: 1px solid transparent;
    background:
        var(--tactical-button-fill-layer, linear-gradient(180deg, rgba(92, 64, 24, 0.92), rgba(56, 34, 10, 0.98))) padding-box,
        var(--tactical-button-border-layer, linear-gradient(180deg, rgba(255, 217, 136, 0.9), rgba(151, 95, 24, 0.98))) border-box;
}

.tactical-button-danger.tactical-button-danger {
    color: #fff;
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border: 1px solid transparent;
    background:
        var(--tactical-button-fill-layer, linear-gradient(180deg, rgba(228, 65, 37, 0.42), rgba(94, 19, 12, 0.7))) padding-box,
        var(--tactical-button-border-layer, linear-gradient(180deg, rgba(247, 167, 149, 0.84), rgba(111, 32, 17, 0.94))) border-box;
}

.tactical-table.tactical-table {
    color: #f1efe8;
    border-color: rgba(240, 165, 26, 0.22);
    background: rgba(4, 11, 16, 0.74);
}

.tactical-table.tactical-table th {
    color: #ffd996;
    font-family: var(--font-display);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: rgba(75, 47, 14, 0.35);
}
