/* Pet Summon Calculator (tools/pet-summon.html). Compact: the inputs and the ticket count fit one phone screen;
   explanations live in (i) tooltips and the "How it's calculated" dialog. Quality colours match the Pets wiki. */
.ps {
    --ps-radius: 10px;
    --ps-on: #c97a12;
    --ps-control: 34px;
    font-size: 15px;
}

.ps .ps-q3 {
    --q-color: #427bc3;
    --q-soft: #eaf2fb;
}

.ps .ps-q4 {
    --q-color: #ad5cd9;
    --q-soft: #f5ecfb;
}

.ps .ps-q5 {
    --q-color: #d6852c;
    --q-soft: #fdf3e6;
}

.ps-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 2px 16px;
    margin-bottom: 10px;
}

.ps-head h1 {
    margin: 0;
    font-size: 26px;
    line-height: 1.2;
}

.ps-link {
    padding: 0;
    font: inherit;
    font-size: 14px;
    color: var(--link);
    background: none;
    border: 0;
    text-decoration: underline;
    cursor: pointer;
}

/* Luck disclaimer under the title: brief but prominent (user decision 2026-11-01). */
.ps-luck {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 0 0 10px;
    padding: 8px 12px;
    font-size: 15px;
    line-height: 1.35;
    color: #7a4a06;
    background: #fff4dc;
    border: 1px solid #f0c66b;
    border-left: 5px solid #d6852c;
    border-radius: var(--ps-radius);
}

.ps-luck strong {
    color: #5c3500;
}

.ps-luck-icon {
    flex: none;
}

/* Panels: "I want" and "I have" side by side when there's room, stacked on narrow screens; "I need" and "I also get"
   always take a full line of their own. */
.ps-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.ps-panel {
    flex: 1 1 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 8px 12px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--ps-radius);
}

.ps-panel--want,
.ps-panel--have {
    flex: 1 1 320px;
}

.ps-panel[hidden] {
    display: none;
}

.ps-panel-title {
    margin: 0 0 6px;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.ps-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.ps-field {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.ps-field--pet {
    flex: 3 1 0;
}

/* "I want": the pet picker and the star picker are the same height; the star picker wraps under the pet when the pet's
   name needs the room. */
.ps-panel--want .ps-row {
    flex-wrap: wrap;
    align-items: stretch;
}

/* The pet field is as wide as the longest pet name needs (--ps-pet-min, measured by pet-summon.js) and grows to fill the
   line, so its width - and whether "at Stars" fits beside it - never depends on the selected pet. */
.ps-panel--want .ps-field--pet {
    flex: 1 1 var(--ps-pet-min, 240px);
    min-width: min(100%, var(--ps-pet-min, 240px));
}

.ps-field--target {
    flex: 0 0 116px;
}

.ps-panel--want .ps-picker {
    display: flex;
    flex: 1 1 auto;
}

.ps-panel--want .ps-picker-btn {
    height: auto;
    min-height: 56px;
}

.ps-panel--want .ps-picker-btn .ps-picon {
    width: 46px;
    height: 46px;
}

/* Star picker: number on the first line, the in-game star row under it. (Doubled classes beat the generic picker rules
   further down.) */
.ps-picker-btn.ps-stars-btn {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 2px;
    height: auto;
    min-height: 56px;
    padding: 4px 24px 4px 10px;
    border-left-width: 1px;
}

.ps-stars-num {
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.ps-stars {
    display: flex;
    gap: 1px;
}

.ps-stars.is-off {
    opacity: 0.3;
    filter: grayscale(1);
}

.ps-stars img {
    width: 16px;
    height: auto;
}

.ps-pop.ps-pop--stars {
    left: auto;
    right: 0;
    width: max-content;
    padding: 4px;
}

.ps-pop.ps-pop--stars.is-left {
    left: 0;
    right: auto;
}

.ps-pop--stars .ps-list {
    margin: 0;
    max-height: none;
}

.ps-option.ps-star-option {
    gap: 10px;
    padding: 5px 10px;
}

.ps-star-option .ps-stars img {
    width: 20px;
}

.ps-star-option .ps-stars-num {
    min-width: 1.4em;
    text-align: right;
}

.ps-option.ps-star-option:hover,
.ps-option.ps-star-option.is-active {
    background: #f0f2f6;
}

.ps-list:focus {
    outline: none;
}

.ps-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
}

.ps select,
.ps .ps-row input[type="number"],
.ps-pop input {
    width: 100%;
    height: var(--ps-control);
    padding: 4px 6px;
    font: inherit;
    font-size: 15px;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    box-sizing: border-box;
    min-width: 0;
}

.ps .ps-row input[type="number"]:disabled {
    color: var(--muted);
    background: #f3f4f7;
}

/* "I have": two fixed lines, Stars | Shards, then Wished? | Pet Tokens (same columns), with a wide gap between the two fields.
   Fields are top-aligned so the titles on a line share one line. Every box is 56 px tall (the Stars dropdown) with its
   game icon before it. */
.ps-row--have {
    align-items: flex-start;
    column-gap: clamp(12px, 4vw, 24px);
}

.ps-row--have + .ps-row--have {
    margin-top: 10px;
}

.ps-field.ps-field--shards,
.ps-field.ps-field--tokens {
    flex: 1 1 118px;
    min-width: 118px;
    max-width: 220px;
}

/* Never narrower than its title, so "Pet Tokens" is never clipped. */
.ps-field.ps-field--tokens {
    min-width: max-content;
}

.ps-input-icon {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 56px;
}

.ps .ps-row .ps-input-icon input[type="number"] {
    flex: 1 1 auto;
    width: 0;
    height: 56px;
    min-width: 56px;
}

/* Both icons sit in the same fixed-size slot, so the Shards and Pet Tokens boxes start at the same x. */
.ps-shard-icon,
.ps-token-icon {
    flex: none;
    width: 52px;
    height: 46px;
    object-fit: contain;
}

/* The Wish crystal ball (with the selected pet inside) before the switch; dimmed while the switch is off. */
.ps-wish-icon {
    flex: none;
    width: auto;
    height: 56px;
    transition: opacity 0.15s, filter 0.15s;
}

.ps-wish-icon.is-off {
    opacity: 0.45;
    filter: grayscale(0.8);
}

.ps-field--stars,
.ps-row--have .ps-field--switch {
    flex: 0 0 116px;
}

.ps-field--switch {
    flex: 0 0 auto;
}

.ps-label label {
    cursor: pointer;
}

.ps input[role="switch"] {
    appearance: none;
    position: relative;
    flex: none;
    width: 34px;
    height: 20px;
    margin: 0;
    background: #c8ced9;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s;
}

.ps input[role="switch"]::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    transition: transform 0.15s;
}

.ps input[role="switch"]:checked {
    background: var(--ps-on);
}

.ps input[role="switch"]:checked::before {
    transform: translateX(14px);
}

.ps input[role="switch"]:focus-visible {
    outline: 2px solid var(--link);
    outline-offset: 2px;
}

.ps input[role="switch"]:disabled {
    opacity: 0.45;
    cursor: default;
}

.ps-field--switch:has(input[role="switch"]:disabled) label {
    cursor: default;
}

/* (i) buttons: inline in their text, same font size and baseline, never taller than the line. */
.ps-i {
    display: inline-block;
    box-sizing: border-box;
    width: 1.15em;
    height: 1.15em;
    margin: 0 0 0 0.1em;
    padding: 0;
    font: inherit;
    font-weight: 700;
    line-height: calc(1.15em - 2px);
    text-align: center;
    vertical-align: baseline;
    color: var(--link);
    background: none;
    border: 1px solid currentColor;
    border-radius: 50%;
    cursor: pointer;
}

.ps-i:hover,
.ps-i[aria-describedby] {
    color: #fff;
    background: var(--link);
    border-color: var(--link);
}

.ps-tip {
    position: fixed;
    z-index: 60;
    max-width: min(320px, calc(100vw - 16px));
    padding: 8px 10px;
    font-size: 13px;
    line-height: 1.45;
    color: #fff;
    background: #1d2330;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(20, 30, 50, 0.25);
    box-sizing: border-box;
}

/* Pet picker */
.ps-picker {
    position: relative;
}

.ps-picker-btn {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    height: var(--ps-control);
    padding: 2px 26px 2px 4px;
    font: inherit;
    font-size: 15px;
    text-align: left;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--border);
    border-left: 4px solid var(--q-color, var(--border));
    border-radius: 6px;
    cursor: pointer;
}

.ps-picker-btn::after {
    content: "";
    position: absolute;
    right: 10px;
    top: 50%;
    width: 6px;
    height: 6px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: translateY(-70%) rotate(45deg);
}

.ps-picker-btn .ps-picon {
    width: 26px;
    height: 26px;
}

.ps-picker-text {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
    line-height: 1.2;
}

/* The pet name never wraps; when the pet and the star picker don't fit side by side, "at Stars" moves to the next line. */
.ps-picker-name {
    font-weight: 600;
    white-space: nowrap;
}

.ps-picker-quality {
    font-size: 12px;
    font-weight: 600;
    color: var(--q-color);
    white-space: nowrap;
}

.ps-pop {
    position: absolute;
    z-index: 20;
    top: calc(100% + 4px);
    left: 0;
    width: max(100%, 280px);
    max-width: calc(100vw - 24px);
    padding: 8px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(20, 30, 50, 0.16);
    box-sizing: border-box;
}

.ps-list {
    list-style: none;
    margin: 6px 0 0;
    padding: 0;
    max-height: min(340px, 60vh);
    overflow-y: auto;
}

.ps-group {
    padding: 8px 6px 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--q-color);
}

/* "Hot" section heading: the wiki's Hot badge colour. */
.ps-group.ps-hot {
    color: #f76b15;
}

.ps-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    font-size: 15px;
    color: var(--text);
    border-radius: 6px;
    cursor: pointer;
}

.ps-option .ps-picon {
    width: 30px;
    height: 30px;
}

.ps-option:hover,
.ps-option.is-active {
    background: var(--q-soft);
}

.ps-option[aria-selected="true"] .ps-option-name {
    font-weight: 700;
}

.ps-option-name {
    white-space: nowrap;
}

.ps-picon {
    display: block;
    flex: none;
    border-radius: 50%;
    background: var(--q-soft, #f0f2f6);
    box-shadow: inset 0 0 0 2px var(--q-color, var(--border));
    object-fit: contain;
}

/* Result */
.ps-answer {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding-left: 10px;
    border-left: 4px solid var(--q-color);
}

.ps-answer-icon {
    flex: none;
    width: 46px;
    height: 46px;
    object-fit: contain;
}

.ps-answer-num {
    font-size: 30px;
    font-weight: 700;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.ps-answer-unit {
    font-size: 14px;
    color: var(--muted);
}

.ps-table {
    border-collapse: collapse;
    font-size: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
}

.ps-table th,
.ps-table td {
    padding: 4px 12px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--border);
}

.ps-table thead th {
    font-size: 12px;
    color: var(--muted);
    background: #f0f2f6;
}

.ps-table td.n {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.ps-qname {
    font-weight: 700;
    color: var(--q-color);
}

.ps-left {
    margin: 6px 0;
    font-size: 14px;
}

/* Inline icons span exactly one line, so they never change the line height. */
.ps-inline-icon {
    height: 1lh;
    width: auto;
    margin-right: 4px;
    vertical-align: top;
}

.ps-pet {
    white-space: nowrap;
}

.ps-pet .ps-picon {
    display: inline-block;
    height: 1lh;
    width: auto;
    aspect-ratio: 1;
    margin-right: 6px;
    vertical-align: top;
}

.ps-details {
    margin: 8px 0;
    font-size: 14px;
    max-width: 100%;
    overflow-x: auto;
}

.ps-details summary {
    margin-bottom: 6px;
    font-weight: 600;
    cursor: pointer;
}

/* How it's calculated */
.ps-dialog {
    width: min(560px, calc(100vw - 24px));
    max-height: calc(100vh - 48px);
    padding: 14px 18px;
    color: var(--text);
    border: 0;
    border-radius: var(--ps-radius);
    box-shadow: 0 16px 48px rgba(20, 30, 50, 0.3);
    box-sizing: border-box;
}

.ps-dialog::backdrop {
    background: rgba(15, 20, 30, 0.45);
}

.ps-dialog-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.ps-dialog h2 {
    margin: 0 0 6px;
    font-size: 19px;
}

.ps-close {
    flex: none;
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 22px;
    line-height: 1;
    color: var(--muted);
    background: none;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
}

.ps-close:hover {
    background: #f0f2f6;
}

.ps-notes {
    margin: 0;
    padding-left: 20px;
    font-size: 14px;
}

.ps-notes li {
    margin: 4px 0;
}

@media (max-width: 560px) {
    .ps-head h1 {
        font-size: 22px;
    }

    .ps-grid {
        gap: 8px;
    }
}

@media (max-width: 380px) {
    .ps-table {
        font-size: 13px;
    }

    .ps-table th,
    .ps-table td {
        padding: 4px 6px;
    }

    .ps-pet .ps-picon {
        margin-right: 4px;
    }
}
