/* Permutation (system entry) game page.
   (Controllers/GamesController.cs, Views/Games/Permutation.cshtml)

   Loads alongside predict.css purely for the shared top bar, which is keyed on
   body:has(.predict-shell). Nothing else on the site reads this file.

   The result list is a grid rather than a <table>: a 6-digit entry renders 360
   rows, and a grid of divs keeps the markup per row down to what is actually
   needed. Prize badges reuse .history-position-badge / .pos-* from site.css so
   they match the past-result search. */

.perm-shell {
    max-width: 520px;
    margin: 0 auto;
    padding: 16px 16px calc(126px + env(safe-area-inset-bottom));
    font-family: Arial, Helvetica, sans-serif;
    color: var(--text);
}

/* ── Header ─────────────────────────────────────────────────────────────── */

.perm-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.perm-back {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font-size: 18px;
    text-decoration: none;
}

.perm-topbar h1 {
    margin: 0;
    font-size: 19px;
    font-weight: 900;
}

.perm-tagline {
    margin: 2px 0 0;
    color: var(--text-soft);
    font-size: 12px;
}

/* ── Entry card ─────────────────────────────────────────────────────────── */

.perm-entry {
    padding: 16px;
    border: 1px solid rgba(216, 169, 63, .4);
    border-radius: 18px;
    background:
        radial-gradient(120% 80% at 50% 0%, rgba(216, 169, 63, .12), transparent 60%),
        var(--surface);
    box-shadow: var(--shadow);
}

.perm-label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 700;
}

.perm-input-row {
    position: relative;
}

.perm-input {
    width: 100%;
    box-sizing: border-box;
    padding: 14px 44px 14px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-soft);
    color: var(--text);
    font-size: 26px;
    font-weight: 900;
    letter-spacing: .34em;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.perm-input:focus {
    outline: none;
    border-color: rgba(216, 169, 63, .85);
    box-shadow: 0 0 0 3px rgba(216, 169, 63, .18);
}

.perm-clear {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 50%;
    background: var(--line);
    color: var(--text-soft);
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
}

/* Six pips showing how many digits are in so far. */
.perm-slots {
    display: flex;
    justify-content: center;
    gap: 7px;
    margin: 10px 0 4px;
}

.perm-slots i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--line);
    transition: background .15s;
}

.perm-slots i.is-filled {
    background: var(--gold);
}

/* The 5th and 6th pips are optional extras, so they read as outlines. */
.perm-slots i:nth-child(n+5) {
    box-shadow: inset 0 0 0 1px var(--text-soft);
    background: transparent;
}

.perm-slots i:nth-child(n+5).is-filled {
    background: var(--gold);
    box-shadow: none;
}

.perm-generate {
    width: 100%;
    margin-top: 14px;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: linear-gradient(180deg, #8b5c12, #6d4710);
    cursor: pointer;
}

.perm-generate span {
    display: block;
    padding: 14px 16px;
    border-radius: 12px;
    background: linear-gradient(180deg, #e8bd52, #c8952c);
    color: #40290a;
    font-size: 16px;
    font-weight: 900;
    letter-spacing: .04em;
    text-transform: uppercase;
    transform: translateY(-3px);
    transition: transform .09s ease;
}

.perm-generate:active span {
    transform: translateY(0);
}

.perm-generate[disabled] {
    cursor: default;
}

.perm-generate[disabled] span {
    transform: translateY(0);
    opacity: .75;
}

.perm-counts {
    margin: 12px 0 0;
    color: var(--text-soft);
    font-size: 11px;
    text-align: center;
}

.perm-status {
    margin: 8px 0 0;
    min-height: 18px;
    color: var(--text-soft);
    font-size: 12.5px;
    font-weight: 700;
    text-align: center;
}

.perm-status.is-error {
    color: #c0392b;
}

/* ── Section shells ─────────────────────────────────────────────────────── */

.perm-results,
.perm-history,
.perm-about {
    margin-top: 20px;
}

.perm-section-head {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 10px;
}

.perm-section-head h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 900;
}

.perm-section-head span {
    color: var(--text-soft);
    font-size: 11.5px;
}

.perm-empty {
    margin: 0;
    padding: 18px 0;
    color: var(--text-soft);
    font-size: 13px;
    text-align: center;
}

/* ── Result list ────────────────────────────────────────────────────────── */

.perm-list {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    overflow: hidden;
}

.perm-list-head,
.perm-row {
    display: grid;
    grid-template-columns: 30px 62px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
}

.perm-list-head {
    background: var(--surface-soft);
    border-bottom: 1px solid var(--line);
    color: var(--text-soft);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.perm-row {
    border-bottom: 1px solid var(--line);
}

.perm-row:last-child {
    border-bottom: 0;
}

/* Marks the arrangements that have actually come out before. */
.perm-row.has-hit {
    background: rgba(216, 169, 63, .07);
}

.perm-index {
    color: var(--text-soft);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.perm-number {
    color: var(--text);
    font-size: 17px;
    font-weight: 900;
    letter-spacing: .08em;
    font-variant-numeric: tabular-nums;
}

.perm-row.has-hit .perm-number {
    color: var(--gold);
}

/* The draw history sits to the right of each number, per row. */
.perm-hits {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    min-width: 0;
}

.perm-hit {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px 2px 3px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-soft);
    font-size: 10px;
    white-space: nowrap;
}

.perm-hit img {
    width: 14px;
    height: 14px;
    object-fit: contain;
    border-radius: 3px;
}

.perm-hit time {
    color: var(--text-soft);
    font-variant-numeric: tabular-nums;
}

/* Slimmer than the table version, since these sit inline in a dense list. */
.perm-hits .history-position-badge {
    padding: 1px 5px;
    font-size: 9px;
}

.perm-none {
    color: var(--text-soft);
    font-size: 11px;
}

/* ── Entry history ──────────────────────────────────────────────────────── */

.perm-history-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 8px;
}

.perm-history-list .perm-empty {
    grid-column: 1 / -1;
}

/* Tapping a past entry refills the box, so a set can be re-run in one tap. */
.perm-history-chip {
    display: grid;
    gap: 2px;
    padding: 10px 6px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    text-align: center;
    cursor: pointer;
    font-family: inherit;
}

.perm-history-chip strong {
    color: var(--gold);
    font-size: 17px;
    font-weight: 900;
    letter-spacing: .08em;
    font-variant-numeric: tabular-nums;
}

.perm-history-chip span {
    color: var(--text-soft);
    font-size: 10.5px;
}

.perm-history-chip.is-new {
    border-color: rgba(216, 169, 63, .7);
    animation: perm-chip-in .45s ease;
}

@keyframes perm-chip-in {
    from { opacity: 0; transform: translateY(-6px) scale(.94); }
    to   { opacity: 1; transform: none; }
}

/* ── Footer copy ────────────────────────────────────────────────────────── */

.perm-about h2 {
    margin: 0 0 6px;
    font-size: 15px;
    font-weight: 900;
}

.perm-about p {
    margin: 0;
    color: var(--text-soft);
    font-size: 13px;
    line-height: 1.6;
}

.perm-disclaimer {
    margin: 16px 0 0;
    color: var(--text-soft);
    font-size: 11px;
    line-height: 1.6;
}

@media (max-width: 360px) {
    .perm-list-head,
    .perm-row {
        grid-template-columns: 24px 56px minmax(0, 1fr);
        gap: 6px;
        padding: 8px 9px;
    }

    .perm-number {
        font-size: 15px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .perm-history-chip.is-new {
        animation: none;
    }
}
