/**
 * Game item page: the pieces only games have on top of components/item-page.css. Price cards
 * (Steam, ITAD), platform rows, legacy achievements, the game's own extras tabs (my images, task
 * boards, plugin tabs) and the admin sync overlay. The tabs, the Media tab and the empty state are
 * shared (media-kit.css, item-page.css); the image viewer is the media kit lightbox.
 * Semantic tokens only.
 */

/* ================== PRICES ================== */
.price-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.price-cards:not(:has(.price-card:not([hidden]))) {
    display: none;
}

.price-card {
    padding: 18px 20px;
    border-radius: var(--radius);
    background: var(--surface-1);
    box-shadow: inset 0 0 0 1px var(--line);
}

.price-card-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px;
    font-size: 11px;
    font-weight: 600;
    line-height: 16px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-2);
}

.price-card-label .section-head-badge {
    margin-left: auto;
}

.price-card-body {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 10px 12px;
}

.price-card-amount {
    font-family: var(--font-display);
    font-weight: var(--font-display-weight);
    font-size: 36px;
    line-height: 36px;
    letter-spacing: 0.01em;
    font-variant-numeric: tabular-nums;
    color: var(--text-1);
}

.price-card-cut {
    align-self: center;
    height: 24px;
    padding: 1px 8px 0;
    border-radius: 4px;
    background: var(--text-1);
    font-family: var(--font-display);
    font-weight: var(--font-display-weight);
    font-size: 19px;
    line-height: 24px;
    color: var(--surface-0);
}

.price-card-regular {
    font-size: 13px;
    color: var(--text-2);
}

.price-card-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-1);
    text-decoration: none;
}

.price-card-link:hover {
    color: var(--accent);
}

.price-card-link i {
    font-size: 11px;
    color: var(--accent);
}

.price-card-note {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-2);
}

.price-card-note--free {
    font-weight: 600;
    color: var(--success);
}

.itad-deal-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
    color: var(--text-1);
    text-decoration: none;
}

.itad-deal-row:hover {
    color: var(--accent);
}

.itad-deal-row .price-card-cut {
    height: 20px;
    font-size: 15px;
    line-height: 20px;
}

.itad-deal-row > i {
    font-size: 11px;
    color: var(--text-2);
}

.itad-deal-shop {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    font-weight: 500;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.itad-deal-price {
    font-family: var(--font-display);
    font-weight: var(--font-display-weight);
    font-size: 20px;
    line-height: 20px;
    color: var(--success);
}

.itad-toggle-btn {
    margin-top: 10px;
}

.itad-lowest {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 0 0;
    padding-top: 10px;
    border-top: 1px dashed var(--line-strong);
    font-size: 12px;
    color: var(--text-2);
}

/* ================== ADMIN SYNC ================== */
.game-sync-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    margin-top: 20px;
    font-size: 13px;
    color: var(--text-2);
}

.game-sync-row > span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.game-sync-row .btn-hero {
    height: 38px;
    padding: 0 16px;
    font-size: 13px;
}

/* ================== PLATFORM ROWS ================== */
.platform-rows-head,
.platform-row {
    display: grid;
    grid-template-columns: minmax(0, 2.2fr) repeat(2, minmax(0, 1fr)) minmax(0, 1.2fr) 44px;
    align-items: center;
    gap: 12px;
}

.platform-rows-head {
    margin-bottom: 8px;
    font-size: 11px;
    font-weight: 600;
    line-height: 16px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-2);
}

.platform-row + .platform-row {
    margin-top: 10px;
}

.platform-row .entry-input {
    height: 46px;
}

.platform-row select.entry-input {
    padding-right: 36px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23b3aeb8' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 12px;
}

.platform-row .entry-input[readonly],
.platform-row .entry-input:disabled {
    color: var(--text-2);
    background-color: var(--surface-2);
}

.platform-row-field {
    min-width: 0;
    margin: 0;
}

/* The column heads name the fields; phones hide them and show this label on each field */
.platform-row-label {
    display: none;
}

.platform-row-remove-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: 0;
    padding: 0;
    border: 1px solid color-mix(in srgb, var(--danger) 50%, transparent);
    border-radius: 50%;
    background: transparent;
    color: var(--danger);
    cursor: pointer;
}

.platform-row-remove-btn:hover {
    background: color-mix(in srgb, var(--danger) 12%, transparent);
}

.platform-add {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    text-decoration: none;
    color: var(--text-1);
}

.platform-add i {
    color: var(--accent);
}

/* ================== LEGACY ACHIEVEMENTS ================== */
.achievements-entry {
    display: flex;
    align-items: center;
    gap: 12px;
}

.achievements-entry .entry-input {
    max-width: 130px;
}

.achievements-entry-sep {
    font-family: var(--font-display);
    font-size: 28px;
    color: var(--text-2);
}

.achievements-entry-percent {
    font-family: var(--font-display);
    font-weight: var(--font-display-weight);
    font-size: 28px;
    line-height: 28px;
    color: var(--accent);
}

.achievements-entry-percent.is-complete {
    color: var(--success);
}

/* ================== EXTRAS TABS ================== */
/* The tabs are the kit's (.kit-tabs, components/item-page/extras-tabs); a plugin tab keeps its star beside it */
.kit-tabs .game-extras-plugin {
    gap: 4px;
}

.game-tab-favorite-btn {
    margin: 0 0 8px;
    padding: 2px 4px;
    border: 0;
    background: none;
    font-size: 13px;
    color: var(--text-2);
    cursor: pointer;
}

.game-tab-favorite-btn .fas {
    color: var(--accent);
}

.game-extras-loading {
    justify-content: center;
    padding: 40px 0;
}

/* ================== GALLERY ================== */
/* The thumbnails are .extras-shot (components/item-page.css); the gallery's are portrait */
.extras-shot.is-portrait {
    aspect-ratio: 3 / 4;
}

/* ================== MY IMAGES ================== */
.extras-mine {
    display: grid;
    grid-template-columns: minmax(300px, 440px) minmax(0, 1fr);
    align-items: start;
    gap: 24px;
}

.extras-panel {
    padding: 22px 24px 24px;
    border-radius: var(--radius);
    background: var(--surface-1);
    box-shadow: inset 0 0 0 1px var(--line);
}

.extras-panel-head {
    margin-bottom: 18px;
}

.extras-panel-title {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    line-height: 24px;
    color: var(--text-1);
}

.extras-panel-text {
    margin: 4px 0 0;
    font-size: 13px;
    line-height: 18px;
    color: var(--text-2);
}

.extras-logo-body {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 16px;
}

.extras-logo-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    aspect-ratio: 2 / 3;
    overflow: hidden;
    padding: 12px;
    border-radius: 10px;
    background: var(--surface-2);
    box-shadow: inset 0 0 0 1px var(--line);
    font-size: 12px;
    line-height: 16px;
    text-align: center;
    color: var(--text-2);
}

.extras-logo-preview.has-image {
    padding: 0;
}

.extras-logo-preview > i {
    font-size: 26px;
}

.extras-logo-preview p {
    margin: 0;
}

.extras-logo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Drop zone: takes dropped files; a click anywhere opens the file picker (my-images.js) */
.extras-drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 20px 18px;
    border: 1px dashed var(--line-strong);
    border-radius: 10px;
    background: color-mix(in srgb, var(--surface-2) 45%, transparent);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.extras-drop:hover,
.extras-drop.is-dragging {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.extras-drop > i {
    font-size: 24px;
    color: var(--accent);
}

.extras-drop-title {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-1);
}

.extras-drop-text {
    margin: 0 0 8px;
    font-size: 12.5px;
    line-height: 18px;
    color: var(--text-2);
}

.extras-drop.is-row {
    flex-direction: row;
    justify-content: flex-start;
    gap: 16px;
    text-align: left;
}

.extras-drop.is-row .extras-drop-text {
    margin-bottom: 0;
}

.extras-drop.is-row .kit-button {
    margin-left: auto;
}

#galleryGrid {
    margin-top: 18px;
}

.extras-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.extras-gallery-item {
    position: relative;
}

.extras-gallery-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(11, 11, 14, 0.78);
    font-size: 13px;
    color: #f2efe9;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease, background-color 0.15s ease;
}

.extras-gallery-item:hover .extras-gallery-delete,
.extras-gallery-delete:focus-visible {
    opacity: 1;
}

.extras-gallery-delete:hover {
    background: var(--danger);
}

.extras-gallery-delete:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.extras-gallery-empty {
    justify-content: center;
    padding: 24px 0 6px;
}

/* ================== TASKS ================== */
.tasks-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px 24px;
    margin-bottom: 20px;
}

.tasks-head-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.tasks-head-actions .kit-button[hidden] {
    display: none;
}

.tasks-loading {
    justify-content: center;
    padding: 40px 0;
}

.tasks-loading[hidden],
.tasks-boards[hidden] {
    display: none;
}

/* Boards share a 12-column row: each takes its "minimum width" (1 to 12) on wide screens */
.tasks-boards {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 20px;
}

.task-board {
    grid-column: span var(--board-span, 12);
    min-width: 0;
    padding: 18px 20px 20px;
    border-radius: var(--radius);
    background: var(--surface-1);
    box-shadow: inset 0 0 0 1px var(--line);
}

.task-board-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    margin-bottom: 14px;
}

.task-board-title {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 22px;
    color: var(--text-1);
}

.task-board-title > i {
    font-size: 14px;
    color: var(--accent);
}

.task-board-title span {
    overflow-wrap: anywhere;
}

.task-board-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    margin-left: auto;
}

.task-icon-button {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 16px;
    background: none;
    font-size: 13px;
    color: var(--text-2);
    cursor: pointer;
}

.task-icon-button:hover {
    background: var(--surface-2);
    color: var(--text-1);
}

.task-icon-button.is-danger:hover {
    color: var(--danger);
}

.task-icon-button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.task-grid-scroll {
    overflow-x: auto;
    border-radius: 10px;
    box-shadow: inset 0 0 0 1px var(--line);
}

.task-grid {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
    line-height: 18px;
}

.task-grid th,
.task-grid td {
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.task-grid tr > :last-child {
    border-right: 0;
}

.task-grid tbody tr:last-child > * {
    border-bottom: 0;
}

.task-grid thead th {
    min-width: var(--column-width, 2.2rem);
    padding: 8px;
    background: var(--surface-2);
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    vertical-align: bottom;
    color: var(--text-1);
}

/* The row names stay in view while the columns scroll */
.task-grid tbody th,
.task-grid .task-grid-corner {
    position: sticky;
    left: 0;
    min-width: 160px;
}

.task-grid tbody th {
    z-index: 1;
    max-width: 260px;
    padding: 8px 10px 8px 14px;
    background: var(--surface-1);
    font-weight: 600;
    text-align: left;
    color: var(--text-1);
}

.task-grid .task-grid-corner {
    z-index: 2;
}

.task-grid-label {
    overflow-wrap: anywhere;
}

.task-grid-tools {
    display: inline-flex;
    gap: 2px;
    margin-left: 6px;
    vertical-align: middle;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.task-grid th:hover > .task-grid-tools,
.task-grid th:focus-within > .task-grid-tools {
    opacity: 1;
}

.task-grid-tools button {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 0;
    border-radius: 11px;
    background: none;
    font-size: 10.5px;
    color: var(--text-2);
    cursor: pointer;
}

.task-grid-tools button:hover {
    background: var(--surface-3);
    color: var(--text-1);
}

.task-grid-tools button.is-danger:hover {
    color: var(--danger);
}

.task-grid-tools button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.task-grid td {
    padding: 6px;
    text-align: center;
}

.task-grid tbody tr:hover td {
    background: color-mix(in srgb, var(--surface-2) 45%, transparent);
}

/* A check cell: a toggle button (aria-pressed) */
.task-cell {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1.5px solid var(--line-strong);
    border-radius: 7px;
    background: var(--field-bg);
    font-size: 13px;
    color: transparent;
    cursor: pointer;
    transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.task-cell:hover {
    border-color: var(--accent);
}

.task-cell[aria-pressed="true"] {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--on-accent);
}

.task-cell:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.task-grid-empty {
    padding: 26px 16px;
    border: 1px dashed var(--line-strong);
    border-radius: 10px;
    text-align: center;
    font-size: 14px;
    color: var(--text-2);
}

.task-grid-empty p {
    margin: 0;
}

/* "Manage" dialog (siteConfirm): the columns and rows of a board */
.task-manage-title {
    margin: 14px 0 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-2);
}

.task-manage-title:first-child {
    margin-top: 0;
}

.task-manage-list {
    max-height: 260px;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    list-style: none;
}

.task-manage-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid var(--line);
}

.task-manage-list li:last-child {
    border-bottom: 0;
}

.task-manage-list small {
    color: var(--text-2);
}

.task-manage-actions {
    display: flex;
    flex: none;
    gap: 2px;
}

.task-manage .is-danger-text {
    color: var(--danger);
}

.task-manage-empty {
    margin: 0;
    font-size: 13px;
    color: var(--text-2);
}

/* ================== OVERLAYS ================== */
.game-sync-modal {
    position: fixed;
    inset: 0;
    z-index: 9000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(11, 11, 14, 0.75);
}

.game-sync-modal .modal-dialog {
    width: 100%;
    max-width: 820px;
    margin: 0 auto;
}

/* ================== RESPONSIVE ================== */
@media (max-width: 767.98px) {
    .platform-rows-head {
        display: none;
    }

    .platform-row {
        grid-template-columns: repeat(3, minmax(0, 1fr)) 40px;
        align-items: end;
        padding: 12px;
        border: 1px solid var(--line);
        border-radius: 8px;
    }

    .platform-row .platform-select {
        grid-column: 1 / -1;
    }

    .platform-row-label {
        display: block;
        margin-bottom: 6px;
        font-size: 12px;
        font-weight: 600;
        line-height: 16px;
        color: var(--text-2);
    }

    .platform-row-remove {
        display: flex;
        align-items: center;
        height: 46px;
    }

    .extras-logo-body {
        grid-template-columns: minmax(0, 1fr);
    }

    .extras-logo-preview {
        width: 150px;
    }

    .extras-drop.is-row {
        flex-direction: column;
        text-align: center;
    }

    .extras-drop.is-row .kit-button {
        margin-left: 0;
    }

    .extras-gallery-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .task-board {
        padding: 14px;
    }

    .task-board-actions {
        width: 100%;
        margin-left: 0;
    }

    .task-grid tbody th,
    .task-grid .task-grid-corner {
        min-width: 120px;
    }
}

@media (max-width: 1199.98px) {
    .extras-mine {
        grid-template-columns: minmax(0, 1fr);
    }

    .task-board {
        grid-column: 1 / -1;
    }
}

/* No hover to reveal them on touch screens */
@media (hover: none) {
    .extras-gallery-delete,
    .task-grid-tools {
        opacity: 1;
    }
}
