/* style.css – hráčská část.
   Mobile-first: navrženo pro telefon v ruce venku na slunci.
   Velké dotykové cíle (min. 48 px), vysoký kontrast, spodní lišta v dosahu palce.

   Barvy jsou výhradně v proměnných, aby šel režim přepnout jedním atributem:
     výchozí (bez data-theme) = podle nastavení systému
     data-theme="light"       = vynucený světlý
     data-theme="dark"        = vynucený tmavý
   Přepínač je v assets/theme.js. */

/* --- Světlá sada (základ) --------------------------------------------------- */
:root {
    --bg:         #f2f4f7;
    --surface:    #ffffff;
    --surface-2:  #eaedf2;
    --line:       #d5dae2;
    --text:       #171a20;
    --muted:      #5d6673;
    --footer:     #8b94a3;

    /* Žlutá zůstává výplní tlačítek v obou režimech; na text je na světlém
       podkladu nečitelná, proto má text vlastní tmavší odstín. */
    --accent:      #ffd63a;
    --accent-ink:  #12141a;
    --accent-text: #8a5a00;

    --nav-bg:     rgba(255, 255, 255, 0.97);
    --me-bg:      #fff6d8;
    --me-text:    #6b4600;

    --err-bg: #fdecea;  --err-text: #a01d1d;  --err-line: #f0b3ac;
    --ok-bg:  #e7f6ea;  --ok-text:  #1b6b2a;  --ok-line:  #a8d9b2;
    --info-bg:#e6f0fb;  --info-text:#12508f;  --info-line:#a8c9ea;

    --hint-bg: #f3edfa;  --hint-line: #cbb8e4;  --hint-text: #4a2f6b;

    /* Pole pro kód stanoviště – schválně vyčnívá z okolí. */
    --code-bg: #fff4f4;  --code-line: #d64545;  --code-text: #7a1a1a;

    --radius: 16px;
}

/* --- Tmavá sada ------------------------------------------------------------- */
/* Systémové nastavení – uplatní se, dokud si uživatel nevynutí světlý režim. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg:         #0f1115;
        --surface:    #171a21;
        --surface-2:  #212530;
        --line:       #2a2f3b;
        --text:       #f2f4f8;
        --muted:      #99a0ae;
        --footer:     #5f6674;

        --accent-text: #ffd63a;

        --nav-bg:     rgba(15, 17, 21, 0.97);
        --me-bg:      #24211a;
        --me-text:    #ffd63a;

        --err-bg: #3d1520;  --err-text: #ffb3b3;  --err-line: #8c3040;
        --ok-bg:  #12331b;  --ok-text:  #b8f0b8;  --ok-line:  #2f7a3f;
        --info-bg:#132b42;  --info-text:#b3d9ff;  --info-line:#35618c;

        --hint-bg: #241f2c;  --hint-line: #4d3f60;  --hint-text: #efe6ff;

        --code-bg: #2b1a1c;  --code-line: #e0625f;  --code-text: #ffd7d4;
    }
}

/* Ruční volba tmavého režimu – musí přebít i světlý systém. */
:root[data-theme="dark"] {
    --bg:         #0f1115;
    --surface:    #171a21;
    --surface-2:  #212530;
    --line:       #2a2f3b;
    --text:       #f2f4f8;
    --muted:      #99a0ae;
    --footer:     #5f6674;

    --accent-text: #ffd63a;

    --nav-bg:     rgba(15, 17, 21, 0.97);
    --me-bg:      #24211a;
    --me-text:    #ffd63a;

    --err-bg: #3d1520;  --err-text: #ffb3b3;  --err-line: #8c3040;
    --ok-bg:  #12331b;  --ok-text:  #b8f0b8;  --ok-line:  #2f7a3f;
    --info-bg:#132b42;  --info-text:#b3d9ff;  --info-line:#35618c;

    --hint-bg: #241f2c;  --hint-line: #4d3f60;  --hint-text: #efe6ff;

    --code-bg: #2b1a1c;  --code-line: #e0625f;  --code-text: #ffd7d4;
}

* { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg); color: var(--text);
    font-size: 17px; line-height: 1.55;
    -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 640px; margin: 0 auto; padding: 14px 16px 24px; }

/* Na stránkách se spodní lištou nesmí obsah podtéct pod ni
   (+ bezpečná zóna na iPhonech s gesture barem). */
body.with-nav .wrap { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }

h1 { font-size: 1.45rem; line-height: 1.25; margin: 6px 0 2px; letter-spacing: -0.01em; }

/* Hlavička úvodní stránky – buď název, nebo nahrané logo. */
.site-head { margin: 10px 0 4px; }
.site-logo { display: block; max-height: 88px; max-width: 100%; height: auto; }
h2 { font-size: 1.05rem; margin: 0 0 12px; color: var(--accent-text); letter-spacing: 0.01em; }
h3 { font-size: 0.95rem; margin: 18px 0 8px; color: var(--muted);
     text-transform: uppercase; letter-spacing: 0.06em; }
a { color: var(--accent-text); }
img, audio { max-width: 100%; }
.muted { color: var(--muted); }

/* --- Přepínač světlý / tmavý režim ----------------------------------------- */
.page-top { display: flex; justify-content: flex-end; margin-bottom: -6px; }
.theme-toggle {
    display: flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; padding: 0;
    border: 1px solid var(--line); border-radius: 50%;
    background: var(--surface); color: var(--text);
    font-size: 1.15rem; line-height: 1; cursor: pointer;
}
.theme-toggle:active { transform: scale(0.94); }

/* --- Formulářová pole ------------------------------------------------------ */
input[type=text], input[type=password], input[type=tel], input[type=email] {
    width: 100%; padding: 15px 14px; font-size: 1.15rem;
    border: 2px solid var(--line); border-radius: 12px;
    background: var(--surface-2); color: var(--text);
    text-align: center; letter-spacing: 1px;
}
input:focus { outline: none; border-color: var(--accent-text); }

/* Pole pro kód stanoviště – nejdůležitější prvek celé hry, ať je na první
   pohled jasné, kam se píše. Kód je vždy velkými písmeny, proto větší
   rozpal a neproporcionální písmo. */
/* Selektor musí obsahovat i [type=text], jinak ho základní pravidlo pro
   formulářová pole přebije – to má vyšší specificitu než samotná třída. */
/* Uvnitř červené karty musí být pole světlé, jinak by s ní splynulo. */
input[type=text].code-input {
    background: var(--surface);
    border: 3px solid var(--code-line);
    color: var(--code-text);
    font-family: ui-monospace, "SF Mono", Consolas, monospace;
    font-size: 1.3rem; font-weight: 700; letter-spacing: 3px;
}
input[type=text].code-input::placeholder {
    color: var(--code-line); opacity: 0.55; letter-spacing: 3px;
}
input[type=text].code-input:focus {
    border-color: var(--code-line);
    box-shadow: 0 0 0 4px rgba(214, 69, 69, 0.18);
}

/* Kontaktní údaje se čtou líp zarovnané doleva než na střed. */
.member input { text-align: left; letter-spacing: 0; font-size: 1.05rem; }

/* Profilový obrázek v kruhu. */
.profile-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.avatar {
    flex: 0 0 auto; width: 84px; height: 84px;
    border-radius: 50%; object-fit: cover;
    border: 2px solid var(--accent); background: var(--surface-2);
    display: flex; align-items: center; justify-content: center;
    font-size: 2.2rem; line-height: 1;
}
.avatar-empty { border-style: dashed; border-color: var(--line); }
.avatar-sm { width: 52px; height: 52px; font-size: 1.4rem; }
.avatar-xs { width: 32px; height: 32px; font-size: 0.95rem; border-width: 1px; }

/* Název týmu s obrázkem – v nadpisu i v tabulce pořadí. */
.team-head { display: flex; align-items: center; gap: 12px; }
.team-head span { min-width: 0; overflow-wrap: anywhere; }
td.team-cell { display: flex; align-items: center; gap: 10px; }

/* Výběr souboru by se jinak ztrácel v okolí. */
input[type=file] {
    width: 100%; padding: 12px; margin-top: 4px;
    border: 2px dashed var(--line); border-radius: 12px;
    background: var(--surface-2); color: var(--text); font-size: 0.95rem;
}

/* Rozbalovací karta jednoho člena týmu. */
.member {
    border: 1px solid var(--line); border-radius: 12px;
    background: var(--surface-2); margin: 10px 0; overflow: hidden;
}
.member > summary {
    cursor: pointer; padding: 14px 16px; font-weight: 600;
    list-style: none; display: flex; align-items: center; gap: 8px;
}
.member > summary::-webkit-details-marker { display: none; }
.member > summary::before { content: '▸'; color: var(--accent-text); }
.member[open] > summary::before { content: '▾'; }
.member > form { padding: 0 16px 16px; }
label { display: block; margin: 14px 0 6px; font-weight: 600; font-size: 0.95rem; }

/* --- Tlačítka -------------------------------------------------------------- */
.btn {
    display: block; width: 100%; min-height: 54px; padding: 15px 18px; margin: 12px 0 0;
    font-size: 1.05rem; font-weight: 700; text-align: center; line-height: 1.3;
    border: none; border-radius: 14px; cursor: pointer; text-decoration: none;
    background: var(--accent); color: var(--accent-ink);
}
.btn:active { transform: scale(0.985); }
.btn-secondary {
    background: transparent; color: var(--accent-text);
    border: 2px solid var(--accent-text);
}
.btn-hint { background: var(--surface-2); color: var(--accent-text); border: 1px solid var(--line); }

/* --- Hlášky ---------------------------------------------------------------- */
.msg {
    padding: 13px 15px; border-radius: 12px; margin: 12px 0;
    font-weight: 600; font-size: 0.95rem;
}
.msg-error { background: var(--err-bg);  color: var(--err-text);  border: 1px solid var(--err-line); }
.msg-ok    { background: var(--ok-bg);   color: var(--ok-text);   border: 1px solid var(--ok-line); }
.msg-info  { background: var(--info-bg); color: var(--info-text); border: 1px solid var(--info-line); }

/* --- Karty ----------------------------------------------------------------- */
.card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 16px; margin: 14px 0;
}
/* Karta se zadáním kódu – celý blok červeně, ať je v terénu na první pohled
   jasné, kde se hra posouvá dál. */
.card-code {
    background: var(--code-bg);
    border: 2px solid var(--code-line);
}
.card-code h2,
.card-code label { color: var(--code-text); }

/* Karta s varováním – potvrzení nápovědy, která prozradí řešení. */
.card-warn {
    background: var(--err-bg);
    border: 2px solid var(--err-line);
}
.card-warn h2 { color: var(--err-text); }

.station-meta { color: var(--muted); font-size: 0.9rem; margin: 2px 0 10px; }
.content-html { margin: 14px 0; }
.content-html img { border-radius: 12px; margin: 8px 0; display: block; }
.content-html p:first-child { margin-top: 0; }

/* --- Tabulka pořadí -------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 8px; text-align: left; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: none; }
th { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; }
td.rank { font-weight: 700; width: 40px; color: var(--muted); }
td.st { text-align: right; font-weight: 700; white-space: nowrap; }
tr.me td { background: var(--me-bg); color: var(--me-text); font-weight: 700; }
tr.me td.rank { color: var(--me-text); }
tr.me td:first-child { border-radius: 10px 0 0 10px; }
tr.me td:last-child  { border-radius: 0 10px 10px 0; }

/* --- Spodní navigace týmu (tab bar) ---------------------------------------- */
.teamnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
    background: var(--nav-bg);
    border-top: 1px solid var(--line);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.teamnav a {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; min-height: 52px; padding: 6px 2px;
    border-radius: 12px; text-decoration: none;
    color: var(--muted); font-size: 0.7rem; font-weight: 600; line-height: 1.1;
    text-align: center;
}
.teamnav a .ico { font-size: 1.3rem; line-height: 1; }
.teamnav a.active { color: var(--accent-text); background: var(--surface-2); }
.teamnav a:active { background: var(--surface-2); }

/* --- Postup (stats.php) ---------------------------------------------------- */
.progress-head {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 10px; margin-bottom: 10px;
}
.progress-head .big { font-size: 2rem; font-weight: 800; color: var(--accent-text); line-height: 1; }
.progress-head .lbl { color: var(--muted); font-size: 0.9rem; text-align: right; }
.progress { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; }

/* Dlaždice s čísly – 2 sloupce na telefonu, víc na širších displejích. */
.stat-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(138px, 1fr));
    gap: 10px; margin-top: 16px;
}
.stat {
    background: var(--surface-2); border: 1px solid var(--line);
    border-radius: 12px; padding: 12px 10px; text-align: center;
}
.stat b { display: block; font-size: 1.45rem; font-weight: 800; color: var(--accent-text); line-height: 1.15; }
.stat span { display: block; color: var(--muted); font-size: 0.78rem; line-height: 1.35; margin-top: 2px; }

/* --- Přehled stanovišť ----------------------------------------------------- */
.stat-row { border-top: 1px solid var(--line); padding: 14px 0; }
.stat-row:first-of-type { border-top: none; padding-top: 2px; }
.stat-row-head { display: flex; align-items: flex-start; gap: 8px; }
.stat-row-head .num {
    flex: 0 0 auto; font-weight: 800; color: var(--accent-text);
    min-width: 24px; font-variant-numeric: tabular-nums;
}
.stat-row-head .title { flex: 1 1 auto; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.badge {
    flex: 0 0 auto; font-size: 0.68rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    padding: 4px 9px; border-radius: 999px;
    background: var(--ok-bg); color: var(--ok-text);
}
.stat-row.open .badge { background: var(--info-bg); color: var(--info-text); }

/* Údaje jako samostatné „štítky", aby se čistě zalamovaly. */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0 32px; }
.chip {
    background: var(--surface-2); border: 1px solid var(--line);
    color: var(--muted); font-size: 0.8rem; line-height: 1.3;
    padding: 4px 10px; border-radius: 999px; white-space: nowrap;
}

/* --- QR skener a drobnosti ------------------------------------------------- */
#qr-reader { margin: 12px 0; border-radius: 12px; overflow: hidden; }
.hidden { display: none; }
.gps-box {
    font-size: 1.25rem; font-weight: 800; text-align: center; letter-spacing: 0.5px;
    background: var(--surface-2); border: 1px solid var(--line);
    border-radius: 12px; padding: 14px; margin: 4px 0 0;
    font-variant-numeric: tabular-nums;
}
.hint-content {
    background: var(--hint-bg); border: 1px solid var(--hint-line); color: var(--hint-text);
    padding: 13px 15px; border-radius: 12px; margin: 10px 0 0;
}
footer { text-align: center; color: var(--footer); font-size: 0.8rem; padding: 22px 0 6px; }

/* Na širším displeji (tablet/desktop) se lišta chová jako pruh pod hlavičkou. */
@media (min-width: 720px) {
    body.with-nav .wrap { padding-bottom: 24px; }
    .teamnav {
        position: static; max-width: 640px; margin: 10px auto 0;
        border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
        padding: 6px;
    }
}
