/*
 * Design v3 — warstwa „front”: nagłówki zakładek, ekran logowania / wyboru świata, onboarding, dostępność.
 * Ładowany po arkuszach bazowych; reguły konkurujące z arkuszami funkcji doładowywanymi dynamicznie (account.css, economy.css…)
 * mają prefiks `html body`. ui/front.js przenosi <link> tego arkusza na koniec <head>, więc i tak wygrywa kolejnością.
 * Zdjęcia nagłówków (img/photo/*.jpg) są tłem WYŁĄCZNIE pseudoelementów widocznych paneli, zawsze pod gradientem (kontrast AA).
 */

/* ---------- dostępność ---------- */
.skip-link {
    position: absolute;
    left: 8px;
    top: -60px;
    z-index: 200;
    background: var(--accent);
    color: var(--accent-ink);
    padding: 10px 16px;
    border-radius: var(--radius-pill);
    font-weight: 700;
    text-decoration: none;
}

.skip-link:focus { top: 8px; }
.noscript { padding: 20px; text-align: center; color: var(--danger); }

html body :is(button, [role="button"], [role="link"], a, summary, input, select, textarea, [tabindex]):focus-visible {
    outline: 3px solid #ffd77a;
    outline-offset: 2px;
}

#panels:focus { outline: none; }

/* ---------- nagłówek zakładki: wąski pas ze zdjęciem ---------- */
.tab-panel[data-tab] { --banner-h: 76px; }

.tab-panel[data-tab]::before {
    content: var(--banner-title);
    order: -1;
    grid-column: 1 / -1;
    display: flex;
    align-items: flex-end;
    box-sizing: border-box;
    height: var(--banner-h);
    margin: 0 0 var(--gap);
    padding: 0 var(--s5) var(--s3);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background:
        linear-gradient(90deg, rgba(12, 10, 7, 0.82) 0%, rgba(12, 10, 7, 0.4) 55%, rgba(12, 10, 7, 0.05) 100%),
        var(--banner-img, none) var(--banner-pos, center) / cover no-repeat,
        var(--surface);
    background-blend-mode: normal;
    box-shadow: var(--shadow-1);
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 650;
    line-height: 1;
    letter-spacing: 0.01em;
    color: #fff6dc;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.85);
}

.tab-panel[data-tab="economy"] { --banner-title: "Budynki"; --banner-img: url("../img/photo/economy.jpg"); --banner-pos: center 55%; }
.tab-panel[data-tab="science"] { --banner-title: "Nauka"; --banner-img: url("../img/photo/science.jpg"); --banner-pos: center 40%; }
.tab-panel[data-tab="technologies"] { --banner-title: "Technologie"; --banner-img: url("../img/photo/science.jpg"); --banner-pos: center 60%; }
.tab-panel[data-tab="archive"] { --banner-title: "Archiwum"; --banner-img: url("../img/photo/science.jpg"); --banner-pos: center 25%; }
.tab-panel[data-tab="datacenter"] { --banner-title: "Centrum Danych"; --banner-img: url("../img/photo/science.jpg"); --banner-pos: center 75%; }
.tab-panel[data-tab="market"] { --banner-title: "Rynek"; --banner-img: url("../img/photo/market.jpg"); --banner-pos: center 50%; }
.tab-panel[data-tab="treasury"] { --banner-title: "Skarbiec regionu"; --banner-img: url("../img/photo/market.jpg"); --banner-pos: center 70%; }
.tab-panel[data-tab="politics"] { --banner-title: "Rada Regionalna"; --banner-img: url("../img/cards/scene/senate.jpg"); --banner-pos: center 45%; }
.tab-panel[data-tab="region"] { --banner-title: "Region"; --banner-img: url("../img/cards/scene/senate.jpg"); --banner-pos: center 65%; }
.tab-panel[data-tab="factions"] { --banner-title: "Frakcje"; --banner-img: url("../img/cards/scene/treaty.jpg"); --banner-pos: center 30%; }
.tab-panel[data-tab="global"] { --banner-title: "Sprawy globalne"; --banner-img: url("../img/cards/scene/treaty.jpg"); --banner-pos: center 40%; }
.tab-panel[data-tab="stalkers"] { --banner-title: "Stalkerzy"; --banner-img: url("../img/photo/stalker.jpg"); --banner-pos: center 28%; }
.tab-panel[data-tab="map"] { --banner-title: "Mapa pustkowi"; --banner-img: url("../img/photo/storm.jpg"); --banner-pos: center 55%; --banner-h: 56px; }
.tab-panel[data-tab="season"] { --banner-title: "Sezon"; --banner-img: url("../img/photo/hero.jpg"); --banner-pos: center 50%; }
.tab-panel[data-tab="trade"] { --banner-title: "Handel"; --banner-img: url("../img/photo/market.jpg"); --banner-pos: center 40%; }
.tab-panel[data-tab="help"] { --banner-title: "Pomoc"; --banner-img: url("../img/photo/science.jpg"); --banner-pos: center 50%; }
.tab-panel[data-tab="map"]::before { font-size: 18px; padding-bottom: var(--s2); }
.tab-panel[data-tab="dashboard"]::before { content: none; }

/* UX-P2B: nagłówek zakładki to tylko pas tytułowy (≤ 56 px) — wcześniej 104 px zjadało pierwszy ekran treści. */
@media (min-width: 640px) {
    .tab-panel[data-tab] { --banner-h: 56px; }
    .tab-panel[data-tab]::before { font-size: 24px; padding: 0 var(--s5); align-items: center; }
    .tab-panel[data-tab="map"] { --banner-h: 48px; }
    .tab-panel[data-tab="map"]::before { font-size: 20px; }
}

@media (max-width: 639px) {
    .tab-panel[data-tab] { --banner-h: 44px; }
    .tab-panel[data-tab]::before { font-size: 18px; padding: 0 var(--s4); align-items: center; }
}

/* ---------- ekran startowy / logowanie ---------- */
html body .acct-overlay {
    background:
        radial-gradient(ellipse at 50% 100%, rgba(120, 50, 20, 0.4), transparent 60%),
        linear-gradient(180deg, rgba(10, 8, 5, 0.35) 0%, rgba(10, 8, 5, 0.86) 100%),
        url("../img/photo/hero.jpg") center / cover no-repeat,
        #0c0a06;
    align-items: center;
}

html body .acct-panel:has(.auth-pitch) {
    width: min(100%, 960px);
    padding: 0;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    overflow: hidden;
    background: rgba(20, 17, 12, 0.88);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    backdrop-filter: blur(16px) saturate(1.2);
    border: 1px solid var(--border-strong);
    border-radius: 26px;
    box-shadow: var(--shadow-3);
    margin: auto 0;
}

html body .acct-panel:has(.auth-pitch)::before { display: none; }

.auth-pitch {
    padding: 38px 34px;
    display: flex;
    flex-direction: column;
    gap: var(--s4);
    justify-content: center;
    background: linear-gradient(160deg, rgba(240, 150, 50, 0.1), rgba(95, 208, 184, 0.06));
    border-right: 1px solid var(--border);
}

.auth-logo { width: min(100%, 280px); height: auto; filter: drop-shadow(0 0 14px rgba(240, 180, 64, 0.25)); }

.auth-slogan { margin: 0; font-family: var(--font-display); font-size: 30px; line-height: 1.15; font-weight: 650; color: #fff6dc; }
.auth-slogan span { display: block; margin-top: 8px; font-size: 13px; font-weight: 700; color: var(--accent); letter-spacing: 0.12em; text-transform: uppercase; }

.auth-steps, .ob-steps {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--s2);
    counter-reset: st;
}

.auth-steps li, .ob-steps li {
    counter-increment: st;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 2px;
    padding: 14px 8px 12px;
    background: rgba(255, 233, 180, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-soft);
}

.auth-steps li::before, .ob-steps li::before { content: counter(st); position: absolute; top: 6px; left: 9px; font-size: 11px; font-weight: 700; color: var(--text-faint); }
.auth-steps .ico, .ob-steps .ico { width: 30px; height: 30px; margin-bottom: 4px; color: var(--accent); }
.auth-steps .step-art, .ob-steps .step-art { width: 64px; height: 64px; margin-bottom: 6px; border-radius: 50%; object-fit: cover; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5); }
.auth-steps b, .ob-steps b { font-family: var(--font-display); font-size: 14px; color: #fff6dc; }
.auth-steps small, .ob-steps small { font-size: 11.5px; line-height: 1.3; color: var(--text-muted); }
.auth-worlds { margin: 0; font-size: 12.5px; color: var(--text-muted); }

.auth-form { padding: 38px 32px 30px; min-width: 0; }
html body .auth-form h2 { font-family: var(--font-display); font-size: 26px; padding-right: 0; }
html body .acct-panel:has(.auth-pitch) .acct-close { z-index: 2; }
html body .auth-form .acct-primary { min-height: 52px; font-size: 16px; }
html body .auth-form .acct-secondary { font-size: 13px; }

@media (max-width: 760px) {
    html body .acct-panel:has(.auth-pitch) { grid-template-columns: 1fr; border-radius: 22px; }
    .auth-pitch { padding: 20px 18px 16px; gap: 10px; border-right: 0; border-bottom: 1px solid var(--border); }
    .auth-logo { width: 160px; }
    .auth-slogan { font-size: 20px; }
    .auth-slogan span { font-size: 11.5px; }
    .auth-steps small, .auth-worlds { display: none; }
    .auth-steps li { padding: 10px 4px 8px; }
    .auth-steps b { font-size: 12.5px; }
    .auth-steps .ico { width: 24px; height: 24px; }
    .auth-steps .step-art { width: 44px; height: 44px; margin-bottom: 3px; }
    .auth-form { padding: 18px 18px 20px; }
    html body .auth-form h2 { font-size: 21px; }
}

/* wybór świata */
html body .acct-panel:has(.world-grid) {
    background: rgba(20, 17, 12, 0.9);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border-color: var(--border-strong);
    border-radius: 26px;
}

html body .acct-panel:has(.world-grid) > h2 { font-size: 28px; }
html body .world-grid { gap: var(--s4); }

@media (min-width: 720px) { html body .world-grid { grid-template-columns: 1fr 1fr; } }

html body .world-card { display: flex; flex-direction: column; padding: 0 0 var(--s4); overflow: hidden; border-radius: var(--radius); transition: transform var(--t-med) var(--ease-out), border-color var(--t-med), box-shadow var(--t-med); }
html body .world-card > * { margin-left: var(--s4); margin-right: var(--s4); }
html body .world-card:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: var(--shadow-2), 0 0 30px -10px var(--glow-accent); }

html body .world-card.eternal::before, html body .world-card.seasonal::before {
    content: "";
    display: block;
    height: 132px;
    margin: 0 0 var(--s3);
    background: center bottom / cover no-repeat;
    box-shadow: inset 0 -40px 30px -24px var(--surface-2);
}

html body .world-card.eternal::before { background-image: url("../img/art/hero-eternal.svg"); }
html body .world-card.seasonal::before { background-image: url("../img/art/hero-seasonal.svg"); }
html body .world-card h3 { font-size: 22px; }
.world-tagline { font-family: var(--font-display); font-size: 15px !important; color: var(--accent) !important; }

.world-perks { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 4px; font-size: 13px; color: var(--text-soft); }
.world-perks .ico { color: var(--teal); }
html body .world-card .world-stats { margin-top: auto; padding-bottom: 4px; }
html body .world-card .acct-primary { min-height: 50px; font-size: 15px; }

/* ---------- onboarding ---------- */
.ob-welcome {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(var(--safe-top) + 14px) 14px calc(var(--safe-bottom) + 14px);
    overflow-y: auto;
    background:
        linear-gradient(180deg, rgba(10, 8, 5, 0.3), rgba(10, 8, 5, 0.85)),
        url("../img/photo/hero.jpg") center / cover no-repeat,
        #0c0a06;
    animation: d-fade 0.4s ease-out;
}

.ob-welcome-card {
    width: min(100%, 540px);
    margin: auto 0;
    display: flex;
    flex-direction: column;
    gap: var(--s4);
    padding: 30px 26px 22px;
    text-align: center;
    background: rgba(20, 17, 12, 0.88);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-strong);
    border-radius: 26px;
    box-shadow: var(--shadow-3);
    animation: d-rise 0.5s var(--ease-out);
}

.ob-logo { width: min(100%, 250px); height: auto; align-self: center; filter: drop-shadow(0 0 14px rgba(240, 180, 64, 0.25)); }
.ob-welcome-card h2 { font-size: 28px; color: #fff6dc; }
.ob-lead { margin: 0; color: var(--text-soft); font-size: 15px; line-height: 1.55; }

.ob-cta, .ob-next {
    border: 0;
    border-radius: var(--radius-pill);
    background: linear-gradient(180deg, #f8c457, #e29a24);
    color: var(--accent-ink);
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset, 0 8px 22px -8px rgba(240, 160, 40, 0.7);
    transition: transform 110ms var(--ease-out), filter var(--t-fast);
}

.ob-cta { min-height: 56px; font-size: 17px; animation: d-pulse-ring 2.4s ease-in-out infinite; }
.ob-next { min-height: 44px; padding: 0 22px; }
.ob-cta:hover, .ob-next:hover { filter: brightness(1.08); transform: translateY(-1px); }
.ob-cta:active, .ob-next:active { transform: scale(0.96); }

.ob-skip { background: transparent; border: 0; color: var(--text-muted); min-height: 40px; padding: 0 10px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font-size: 13px; }
.ob-skip:hover { color: var(--text); }

.ob-tour { position: fixed; inset: 0; z-index: 85; pointer-events: none; }

.ob-spot {
    position: fixed;
    border-radius: 16px;
    border: 2px solid var(--accent);
    box-shadow: 0 0 0 100vmax rgba(6, 5, 3, 0.74), 0 0 24px 2px rgba(240, 180, 64, 0.55);
    transition: left 0.25s var(--ease-out), top 0.25s var(--ease-out), width 0.25s var(--ease-out), height 0.25s var(--ease-out);
}

.ob-card {
    position: fixed;
    pointer-events: auto;
    padding: 16px 18px 14px;
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-3);
    color: var(--text);
    transition: left 0.25s var(--ease-out), top 0.25s var(--ease-out);
}

.ob-kicker { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; font-weight: 700; }
.ob-card h3 { font-size: 18px; color: #fff6dc; margin-bottom: 6px; }
.ob-card p { margin: 0 0 12px; font-size: 13.5px; line-height: 1.5; color: var(--text-soft); }
.ob-actions { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }

/* ---------- ustawienia ---------- */
.tour-replay { width: 100%; margin-top: var(--s3); }

/* ---------- ekran „serwer nie odpowiada” ---------- */
.dash-offline {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--s2);
    padding: 40px var(--s4);
    text-align: center;
    color: var(--text-soft);
    background: var(--surface);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
}

.dash-offline b { font-family: var(--font-display); font-size: 20px; color: var(--accent); }
.dash-offline p { margin: 0; max-width: 32em; }
.dash-offline .ico { width: 40px; height: 40px; }

/* przewodnik (UX-P1): potwierdzenie zaliczonego kroku i ostatni krok bez „Pomiń” */
.ob-done { display: flex; align-items: center; gap: 6px; margin: -4px 0 10px; color: var(--good); font-weight: 700; font-size: 13.5px; }
.ob-done .ico { width: 16px; height: 16px; }
.ob-actions.last { justify-content: flex-end; }
.ob-next { white-space: nowrap; }
