/* Fotoquiz der Fotogilde Tailfingen e.V. */
:root {
    --bg: #f3f0ea;
    --card: #ffffff;
    --ink: #1f1e1c;
    --muted: #6a655c;
    --line: #e2dccf;
    --dark: #1b1a19;
    --dark-2: #2a2826;
    --brand: #e07a1f;
    --brand-d: #b85f10;
    --brand-l: #fdf0e2;
    --green: #2c7a4b;
    --green-l: #e6f3ea;
    --red: #b3372f;
    --red-l: #fbe9e7;
    --focus: #1a73e8;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 6px 20px rgba(0, 0, 0, .06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
p { margin: 0 0 .8em; }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { padding: 24px; text-align: center; }

.app { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- Kopfleiste (im Quiz mit Timer) ---------------------------------------- */
.topbar {
    position: sticky; top: 0; z-index: 20;
    background: var(--dark); color: #fff;
    border-bottom: 3px solid var(--brand);
}
.topbar-in {
    max-width: 920px; margin: 0 auto; padding: 8px 16px;
    display: flex; align-items: center; gap: 14px; min-height: 58px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .01em; min-width: 0; }
.brand .logo { flex: none; height: 50px; width: auto; display: block; margin: 2px 0; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand small { font-weight: 500; opacity: .75; margin-left: 4px; }
.topnav { margin-left: auto; display: flex; gap: 6px; }
.topnav button, .topbar .btn-ghost {
    background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, .28);
    padding: 6px 12px; border-radius: 999px; font-size: .9rem;
}
.topnav button:hover, .topbar .btn-ghost:hover { background: rgba(255, 255, 255, .12); }
.topnav button[aria-current="page"] { background: var(--brand); border-color: var(--brand); }

.qstatus { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.qcount { font-size: .95rem; opacity: .9; white-space: nowrap; }
.timer {
    display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.timer b { font-size: 1.6rem; letter-spacing: .02em; }
.timer small { font-size: .72rem; opacity: .7; white-space: nowrap; }
.timer.over b { color: #ffb45e; }
.progress { height: 5px; background: rgba(255, 255, 255, .15); }
.progress i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .25s ease; }

/* ---------- Layout ---------------------------------------------------------------- */
.view { flex: 1; width: 100%; max-width: 920px; margin: 0 auto; padding: 20px 16px 8px; outline: none; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 14px 16px 18px; }
.card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 20px;
}
.card + .card, .card + .grid, .grid + .card { margin-top: 16px; }
.grid > .card, .grid > .card + .card { margin-top: 0; }
.muted { color: var(--muted); }
.lead { font-size: 1.08rem; color: #3a3833; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    background: var(--brand); color: #fff; border: 0; border-radius: 10px;
    padding: 11px 20px; font-weight: 700; text-decoration: none;
    transition: background .15s, transform .05s;
}
.btn:hover { background: var(--brand-d); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: wait; }
.btn-secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-secondary:hover { background: #f7f4ee; }
.btn-block { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

/* ---------- Startseite ------------------------------------------------------------ */
.hero { text-align: center; padding: 8px 0 18px; }
.hero h1 { font-size: clamp(1.5rem, 4.5vw, 2.1rem); margin-bottom: .3em; }
.hero p { max-width: 640px; margin-left: auto; margin-right: auto; }

.grid { display: grid; gap: 16px; }
.levels { grid-template-columns: repeat(2, 1fr); }
.level { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.level-head { padding: 14px 18px; background: var(--dark); color: #fff; border-bottom: 3px solid var(--brand); }
.level-head h2 { margin: 0; font-size: 1.25rem; }
.level-head small { opacity: .75; }
.level-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.level-body p { margin: 0; color: #46433d; font-size: .95rem; }
.facts { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: .95rem; }
.facts li { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dashed var(--line); padding-bottom: 5px; }
.facts b { font-variant-numeric: tabular-nums; }
.facts .time b { color: var(--brand-d); }
.level .btn { margin-top: auto; }
.level .actions { margin-top: auto; }
.level .actions .btn { flex: 1 1 130px; margin-top: 0; }

.info-grid { grid-template-columns: repeat(2, 1fr); align-items: start; margin-top: 16px; }
.info-grid > .card { margin-top: 0; }
.info h3 { font-size: 1.05rem; }
.steps { margin: 0; padding-left: 1.2em; }
.steps li { margin-bottom: .45em; }
.tbl { width: 100%; border-collapse: collapse; font-size: .93rem; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 7px 8px; text-align: left; border-bottom: 1px solid var(--line); }
.tbl th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.tbl td.num, .tbl th.num { text-align: right; }
.note {
    background: var(--brand-l); border-left: 4px solid var(--brand); border-radius: 8px;
    padding: 10px 12px; font-size: .92rem; margin: 10px 0 0;
}
.banner {
    background: #fff8e6; border: 1px solid #f0d78c; border-radius: var(--radius);
    padding: 14px 16px; margin-bottom: 16px;
}
.banner b { display: block; margin-bottom: 2px; }

/* ---------- Frage ------------------------------------------------------------------ */
.q-cat {
    display: inline-block; background: var(--brand-l); color: var(--brand-d);
    border-radius: 999px; padding: 2px 12px; font-size: .8rem; font-weight: 700; margin-bottom: 10px;
}
.q-text { font-size: clamp(1.15rem, 3.4vw, 1.45rem); margin-bottom: 16px; outline: none; }
.opts { display: grid; gap: 10px; border: 0; padding: 0; margin: 0; }
.opt {
    display: flex; align-items: center; gap: 12px; padding: 12px 14px;
    background: #fff; border: 2px solid var(--line); border-radius: 12px; cursor: pointer;
    transition: border-color .12s, background .12s, transform .05s;
}
.opt:hover { border-color: var(--brand); background: #fffaf4; }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt .key {
    flex: none; width: 30px; height: 30px; border-radius: 50%;
    display: grid; place-items: center; font-weight: 700; font-size: .9rem;
    background: #f1ece2; color: #4b473f;
}
.opt .txt { flex: 1; }
.opt:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.opt:has(input:checked) { border-color: var(--brand); background: var(--brand-l); }
.opt:has(input:checked) .key { background: var(--brand); color: #fff; }
.opts.locked .opt { cursor: default; pointer-events: none; }
.hint { color: var(--muted); font-size: .85rem; margin-top: 12px; text-align: center; }

/* ---------- Ergebnis --------------------------------------------------------------- */
.result-top { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: center; }
.grade {
    width: 132px; height: 132px; border-radius: 50%; display: grid; place-content: center; text-align: center;
    background: var(--dark); color: #fff; border: 6px solid var(--brand);
}
.grade small { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; opacity: .75; }
.grade b { font-size: 2.6rem; line-height: 1; font-variant-numeric: tabular-nums; }
.grade span { font-size: .85rem; opacity: .85; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile { background: #faf7f1; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.tile small { display: block; color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; }
.tile b { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.tile em { display: block; font-style: normal; color: var(--muted); font-size: .8rem; }
.points-line { margin: 14px 0 0; font-size: 1.05rem; }
.points-line b { color: var(--brand-d); font-size: 1.25rem; }

.form { display: grid; gap: 12px; margin-top: 8px; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; }
.field input[type="text"], .field input[type="email"] {
    width: 100%; padding: 11px 12px; border: 2px solid var(--line); border-radius: 10px; font: inherit; background: #fff;
}
.field input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px rgba(224, 122, 31, .25); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .9rem; color: #46433d; }
.check input { margin-top: 4px; width: 18px; height: 18px; flex: none; accent-color: var(--brand); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.alert { background: var(--red-l); border: 1px solid #f0bdb8; color: #7d2019; border-radius: 10px; padding: 10px 12px; font-size: .92rem; }
.success { background: var(--green-l); border: 1px solid #b8dcc5; color: #1d5a37; border-radius: var(--radius); padding: 16px; }
.success b { font-size: 1.1rem; }

.review-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.review-head h3 { margin: 0; }
.switch { display: inline-flex; gap: 8px; align-items: center; font-size: .9rem; }
.rev { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.rev li { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; border-left-width: 5px; }
.rev li.ok { border-left-color: var(--green); }
.rev li.bad { border-left-color: var(--red); }
.rev .rq { font-weight: 600; margin-bottom: 4px; }
.rev .rc { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.rev .given { color: var(--red); }
.rev .right { color: var(--green); }
.rev .given s { opacity: .85; }

/* ---------- Rangliste --------------------------------------------------------------- */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tabs button {
    border: 1px solid var(--line); background: #fff; color: var(--ink);
    padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: .92rem;
}
.tabs button[aria-selected="true"] { background: var(--dark); color: #fff; border-color: var(--dark); }
.rank-wrap { overflow-x: auto; }
.rank { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.rank th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); text-align: left; padding: 8px 8px; border-bottom: 2px solid var(--line); white-space: nowrap; }
.rank td { padding: 9px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.rank .num { text-align: right; }
.rank td.name { white-space: normal; font-weight: 600; min-width: 110px; }
.rank td.pos { width: 44px; font-weight: 700; }
.rank tr.me td { background: var(--brand-l); }
.rank .pts { font-weight: 800; color: var(--brand-d); }
.rank .lvl { color: var(--muted); font-size: .85rem; }
.empty { text-align: center; padding: 28px 8px; color: var(--muted); }

.loading { text-align: center; padding: 40px 10px; color: var(--muted); }
.spin { display: inline-block; width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: middle; margin-right: 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

dialog { border: 0; border-radius: var(--radius); padding: 22px; max-width: 420px; width: calc(100% - 32px); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
dialog::backdrop { background: rgba(0, 0, 0, .55); }
dialog h3 { margin-top: 0; }

/* ---------- Responsiv --------------------------------------------------------------- */
@media (max-width: 820px) {
    .levels { grid-template-columns: 1fr; }
    .info-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
    .view { padding: 14px 12px 6px; }
    .card { padding: 16px 14px; }
    .topbar-in { gap: 8px; padding: 6px 10px; }
    .qstatus { gap: 10px; }
    .timer b { font-size: 1.35rem; }
    .brand small { display: none; }
    .brand-q span { display: none; }
    .qstatus { flex: 1; justify-content: space-between; }
    .result-top { grid-template-columns: 1fr; justify-items: center; text-align: center; }
    .tiles { grid-template-columns: 1fr; }
    .hide-s { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation-duration: .01ms !important; }
}
@media print {
    .topbar, .foot, .actions, .tabs { display: none; }
}

/* ---------- Druckkarte (Startseite) ------------------------------------------------ */
.printcard { margin-top: 16px; }
.printcard .actions { margin-top: 10px; }
.printbtn { flex-direction: column; gap: 0; padding: 9px 16px; min-width: 150px; line-height: 1.25; }
.printbtn small { font-weight: 500; opacity: .7; font-size: .78rem; }

/* ---------- Druckansicht / Fragebogen / Lösungsblatt --------------------------------- */
.print-tools { margin-bottom: 16px; }
.sheet {
    background: #fff; color: #000; border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 22px 26px; margin-bottom: 16px; font-size: 15px;
}
.sheet-head { background: #1b1a19; color: #fff; border-bottom: 3px solid #e07a1f; padding: 10px 14px; margin-bottom: 14px; }
.sh-title { font-weight: 800; font-size: 1.2em; }
.sh-row { display: flex; justify-content: space-between; gap: 12px; font-size: .85em; opacity: .9; flex-wrap: wrap; }
.sh-fields { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.sh-hint { color: #555; font-size: .85em; margin: 2px 0 12px; }
.pq { margin: 0 0 14px; break-inside: avoid; page-break-inside: avoid; }
.pq-q { font-weight: 700; margin-bottom: 4px; padding-left: 1.8em; text-indent: -1.8em; }
.pq-n { display: inline-block; min-width: 1.8em; }
.pq-o { list-style: none; margin: 0; padding: 0 0 0 1.8em; }
.pq-o li { display: flex; align-items: baseline; gap: 8px; margin: 2px 0; }
.pq-o .box { flex: none; width: 13px; height: 13px; border: 1.5px solid #333; border-radius: 2px; transform: translateY(2px); }
.solutions { display: none; }
.show-solutions .solutions { display: block; }
.solutions h3 { margin: 14px 0 6px; font-size: 1.05em; }
.keygrid { display: grid; grid-template-columns: repeat(10, 1fr); border: 1px solid #bbb; border-right: 0; border-bottom: 0; }
.kg { display: flex; justify-content: center; align-items: baseline; gap: 6px; padding: 4px 2px; border-right: 1px solid #bbb; border-bottom: 1px solid #bbb; font-variant-numeric: tabular-nums; }
.kg span { font-size: .78em; color: #444; }
.solwords { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 24px; font-size: .88em; }
.solwords li { break-inside: avoid; margin: 0 0 3px; }
.solwords li b { display: inline-block; min-width: 3.4em; }
@media (max-width: 560px) {
    .sheet { padding: 14px 12px; }
    .keygrid { grid-template-columns: repeat(5, 1fr); }
    .solwords { columns: 1; }
}

@page { size: A4; margin: 14mm 14mm 16mm; }
@media print {
    html, body { background: #fff !important; }
    .topbar, .foot, .noprint, #topalert { display: none !important; }
    .app { display: block; min-height: 0; }
    .view { max-width: none; padding: 0; }
    .sheet { border: 0; box-shadow: none; border-radius: 0; padding: 0; margin: 0; font-size: 10.5pt; }
    .sheet-head, .sh-title { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .solutions { display: block !important; break-before: page; page-break-before: always; }
    .solwords { columns: 2; }
    .keygrid { grid-template-columns: repeat(10, 1fr); }
    .pq-o .box { border-color: #000; }
}
