/* Geo-Explorer – Jaeger2go */

/* ---------- Grundgerüst & Schutz vor Theme-Stilen ---------- */
.j2g-geo {
	--ink: #16323d;
	--ink-soft: #4d6670;
	--bg1: #e6f2f1;
	--bg2: #f7f1e6;
	--card: #ffffff;
	--line: #dbe6e6;
	--brand: #0f4c5c;
	--accent: #2a9d8f;
	--ok: #23a455;
	--ok-bg: #e5f6eb;
	--bad: #d64545;
	--bad-bg: #fbe9e9;
	--warn: #e9a23b;
	--part: #2a9d8f;
	--radius: 22px;
	--shadow: 0 10px 30px rgba(15, 76, 92, .12), 0 2px 6px rgba(15, 76, 92, .08);
	--tap: 60px;
	position: relative;
	box-sizing: border-box;
	width: 100%;
	height: min(88vh, 860px);
	min-height: 540px;
	overflow: hidden;
	border-radius: 26px;
	background: linear-gradient(160deg, var(--bg1), var(--bg2));
	color: var(--ink);
	font-family: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 17px;
	line-height: 1.4;
	text-align: left;
	-webkit-font-smoothing: antialiased;
	-webkit-tap-highlight-color: transparent;
	-webkit-text-size-adjust: 100%;
	user-select: none;
	-webkit-user-select: none;
	container-type: size;
}
.j2g-geo *, .j2g-geo *::before, .j2g-geo *::after { box-sizing: border-box; }
.j2g-geo button, .j2g-geo input, .j2g-geo h1, .j2g-geo h2, .j2g-geo h3, .j2g-geo p, .j2g-geo img {
	all: unset;
	box-sizing: border-box;
}
.j2g-geo h1, .j2g-geo h2, .j2g-geo h3, .j2g-geo p { display: block; }
.j2g-geo img { display: block; max-width: 100%; }
.j2g-geo button { cursor: pointer; touch-action: manipulation; text-align: center; font: inherit; color: inherit; }
.j2g-geo button:focus-visible, .j2g-geo input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.j2g-geo svg { display: block; flex: none; }

/* App-Seite, Vollbild, Ersatz-Vollbild */
.j2g-geo-body { margin: 0; background: #0f4c5c; overscroll-behavior: none; }
.j2g-geo[data-mode="app"] {
	position: fixed; inset: 0; height: 100dvh; min-height: 0; border-radius: 0;
	padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.j2g-geo:fullscreen { height: 100%; min-height: 0; border-radius: 0; }
.j2g-geo:-webkit-full-screen { height: 100%; min-height: 0; border-radius: 0; }
.j2g-geo.is-pseudo-fs { position: fixed; inset: 0; z-index: 2147483000; height: 100dvh; min-height: 0; border-radius: 0; }

.j2g-geo__boot { display: grid; place-items: center; height: 100%; color: var(--ink-soft); }

/* Größere Schrift auf großen Flächen */
@container (min-width: 900px) and (min-height: 640px) { .j2g-geo__app { font-size: 19px; } }
@container (max-width: 520px) { .j2g-geo__app { font-size: 16px; --tap: 54px; } }

/* ---------- Gemeinsame Bausteine ---------- */
.j2g-geo__app { position: absolute; inset: 0; display: flex; flex-direction: column; }
.j2g-geo .view { position: absolute; inset: 0; display: flex; flex-direction: column; animation: geoIn .35s cubic-bezier(.2, .8, .2, 1); }
.j2g-geo .view.from-left { animation-name: geoInLeft; }
@keyframes geoIn { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
@keyframes geoInLeft { from { opacity: 0; transform: translateX(-28px); } to { opacity: 1; transform: none; } }

.j2g-geo .btn {
	display: inline-flex; align-items: center; justify-content: center; gap: .5em;
	min-height: var(--tap); padding: 0 1.4em; border-radius: 999px;
	font-weight: 700; font-size: 1.05em; letter-spacing: .01em;
	background: var(--card); color: var(--ink); box-shadow: 0 2px 0 rgba(15, 76, 92, .12), inset 0 0 0 2px var(--line);
	transition: transform .12s, box-shadow .12s, background .2s, opacity .2s;
}
.j2g-geo .btn:active { transform: translateY(2px) scale(.98); }
.j2g-geo .btn.primary { background: var(--part); color: #fff; box-shadow: 0 4px 0 color-mix(in srgb, var(--part) 70%, #000); }
.j2g-geo .btn.primary:active { box-shadow: 0 1px 0 color-mix(in srgb, var(--part) 70%, #000); }
.j2g-geo .btn.ghost { background: transparent; box-shadow: inset 0 0 0 2px var(--line); }
.j2g-geo .btn[disabled] { opacity: .45; pointer-events: none; }
.j2g-geo .icon-btn {
	width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center;
	background: rgba(255, 255, 255, .7); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line);
}
.j2g-geo .icon-btn:active { transform: scale(.94); }

.j2g-geo .stars { display: inline-flex; gap: 2px; }
.j2g-geo .stars svg { width: 1.15em; height: 1.15em; }

/* ---------- Startseite ---------- */
.j2g-geo .home { padding: clamp(16px, 3.2cqh, 34px) clamp(16px, 3.5cqw, 44px); gap: clamp(12px, 2.4cqh, 24px); overflow-y: auto; }
.j2g-geo .home-head { display: flex; align-items: center; gap: 16px; }
.j2g-geo .logo { width: 64px; height: 64px; border-radius: 18px; box-shadow: var(--shadow); flex: none; }
.j2g-geo .home-title h1 { font-size: 1.9em; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.j2g-geo .home-title p { color: var(--ink-soft); margin-top: 2px; }
.j2g-geo .home-head .spacer { flex: 1; }
.j2g-geo .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: clamp(12px, 2cqw, 20px); }
.j2g-geo .tile {
	position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 10px; text-align: left;
	padding: 18px 18px 16px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow);
	overflow: hidden; transition: transform .15s;
}
.j2g-geo .tile::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 6px; background: var(--part); }
.j2g-geo .tile:active { transform: scale(.98); }
.j2g-geo .tile-top { display: flex; align-items: center; gap: 12px; }
.j2g-geo .tile-icon {
	width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; font-size: 30px;
	background: color-mix(in srgb, var(--part) 16%, #fff);
}
.j2g-geo .tile-name { font-weight: 800; font-size: 1.15em; line-height: 1.15; hyphens: auto; -webkit-hyphens: auto; overflow-wrap: anywhere; }
.j2g-geo .tile-top > div:last-child { min-width: 0; }
.j2g-geo .tile-sub { color: var(--ink-soft); font-size: .9em; }
.j2g-geo .badge { display: inline-block; margin-left: 6px; padding: 2px 8px; border-radius: 999px; font-size: .72em; font-weight: 800; vertical-align: middle; background: var(--part); color: #fff; }
.j2g-geo .bar { height: 10px; border-radius: 999px; background: #edf2f2; overflow: hidden; }
.j2g-geo .bar > i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--part); transition: width .5s; }
.j2g-geo .tile-foot { display: flex; align-items: center; justify-content: space-between; font-size: .9em; color: var(--ink-soft); font-weight: 600; }
.j2g-geo .continue {
	display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: var(--radius);
	background: var(--brand); color: #fff; box-shadow: var(--shadow); text-align: left;
}
.j2g-geo .continue b { display: block; font-size: 1.05em; }
.j2g-geo .continue span { opacity: .8; font-size: .9em; }
.j2g-geo .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: clamp(12px, 2cqw, 20px); }
.j2g-geo .continue.drill { background: linear-gradient(135deg, #7A5BC9, #5B3FA8); }
.j2g-geo .continue.drill[disabled] { background: #fff; color: var(--ink-soft); box-shadow: inset 0 0 0 2px var(--line); cursor: default; }
.j2g-geo .drill-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-size: 24px; background: rgba(255, 255, 255, .18); flex: none; }
.j2g-geo .continue.drill[disabled] .drill-icon { background: #f1edf9; }
.j2g-geo .continue .go { margin-left: auto; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, .15); }
.j2g-geo .home-foot { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; justify-content: space-between; color: var(--ink-soft); font-size: .88em; margin-top: auto; }
.j2g-geo .linkish { background: none; text-decoration: underline; text-underline-offset: 3px; font-weight: 600; color: var(--ink-soft); padding: 8px 0; }

/* ---------- Kopfleiste in Teilen ---------- */
.j2g-geo .topbar { display: flex; align-items: center; gap: 12px; padding: 12px clamp(12px, 2cqw, 22px) 8px; }
.j2g-geo .topbar .title { flex: 1; min-width: 0; }
.j2g-geo .topbar .title b { display: block; font-size: 1.05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.j2g-geo .topbar .title span { color: var(--ink-soft); font-size: .85em; font-weight: 600; }
.j2g-geo .segments { display: flex; gap: 3px; padding: 0 clamp(12px, 2cqw, 22px); }
.j2g-geo .segments i { flex: 1; height: 7px; border-radius: 4px; background: rgba(15, 76, 92, .12); transition: background .3s; }
.j2g-geo .segments i.ok { background: var(--ok); }
.j2g-geo .segments i.bad { background: var(--bad); }
.j2g-geo .segments i.cur { box-shadow: 0 0 0 2px var(--ink); }

/* ---------- Einleitung ---------- */
.j2g-geo .intro { align-items: center; justify-content: center; text-align: center; padding: 24px; gap: 18px; }
.j2g-geo .intro .big-icon { font-size: 76px; width: 128px; height: 128px; border-radius: 36px; display: grid; place-items: center; background: #fff; box-shadow: var(--shadow); }
.j2g-geo .intro h2 { font-size: 2em; font-weight: 800; letter-spacing: -.02em; text-align: center; }
.j2g-geo .intro p { max-width: 34em; color: var(--ink-soft); text-align: center; }
.j2g-geo .intro .row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* ---------- Aufgabe ---------- */
.j2g-geo .stage {
	flex: 1; min-height: 0; display: grid; gap: clamp(10px, 1.6cqw, 18px);
	grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
	padding: 10px clamp(12px, 2cqw, 22px);
}
.j2g-geo .stage.no-media { grid-template-columns: minmax(0, 1fr); max-width: 760px; width: 100%; margin: 0 auto; }
.j2g-geo .media {
	position: relative; display: block; min-height: 0; border-radius: var(--radius); background: #fff; box-shadow: var(--shadow);
	overflow: hidden; cursor: zoom-in;
}
.j2g-geo .media img { position: absolute; inset: 10px; width: calc(100% - 20px); height: calc(100% - 20px); max-width: none; object-fit: contain; }
.j2g-geo .media .zoom-hint { position: absolute; right: 10px; bottom: 10px; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: rgba(15, 76, 92, .75); color: #fff; }
.j2g-geo .panel {
	min-height: 0; display: flex; flex-direction: column; border-radius: var(--radius);
	background: var(--card); box-shadow: var(--shadow); overflow: hidden;
}
.j2g-geo .panel-body { flex: 1; min-height: 0; overflow-y: auto; padding: clamp(14px, 2.2cqh, 22px) clamp(14px, 2cqw, 22px); -webkit-overflow-scrolling: touch; }
.j2g-geo .q { font-size: 1.18em; font-weight: 750; line-height: 1.3; margin-bottom: .8em; }
.j2g-geo .q small { display: block; margin-top: .3em; font-size: .72em; font-weight: 600; color: var(--ink-soft); }
.j2g-geo .panel-foot { padding: 12px clamp(14px, 2cqw, 22px) 14px; border-top: 1px solid var(--line); display: flex; gap: 10px; flex-wrap: wrap; }
.j2g-geo .panel-foot .btn { flex: 1 1 0; min-width: 0; padding: 0 .8em; white-space: nowrap; }

/* Auswahl */
.j2g-geo .opts { display: grid; gap: 10px; }
.j2g-geo .opt {
	display: flex; align-items: center; gap: 12px; min-height: var(--tap); padding: 10px 14px; border-radius: 16px;
	text-align: left; font-weight: 650; background: #f4f8f8; box-shadow: inset 0 0 0 2px transparent;
	transition: background .15s, box-shadow .15s, transform .1s;
}
.j2g-geo .opt:active { transform: scale(.99); }
.j2g-geo .opt .key {
	width: 32px; height: 32px; border-radius: 10px; flex: none; display: grid; place-items: center;
	font-weight: 800; font-size: .9em; background: #fff; color: var(--ink-soft); box-shadow: inset 0 0 0 2px var(--line);
}
.j2g-geo .opt.multi .key { border-radius: 8px; }
.j2g-geo .opt.sel { background: color-mix(in srgb, var(--part) 14%, #fff); box-shadow: inset 0 0 0 2.5px var(--part); }
.j2g-geo .opt.sel .key { background: var(--part); color: #fff; box-shadow: none; }
.j2g-geo .opt.ok { background: var(--ok-bg); box-shadow: inset 0 0 0 2.5px var(--ok); }
.j2g-geo .opt.ok .key { background: var(--ok); color: #fff; box-shadow: none; }
.j2g-geo .opt.bad { background: var(--bad-bg); box-shadow: inset 0 0 0 2.5px var(--bad); }
.j2g-geo .opt.bad .key { background: var(--bad); color: #fff; box-shadow: none; }
.j2g-geo .opt.miss { box-shadow: inset 0 0 0 2.5px var(--ok); border-style: dashed; }
.j2g-geo .locked .opt { pointer-events: none; }

/* Lückentext */
.j2g-geo .lines { display: grid; gap: 8px; }
.j2g-geo .lines.compact { grid-template-columns: repeat(auto-fill, minmax(min(100%, 215px), 1fr)); gap: 10px 14px; }
.j2g-geo .lines.compact .line { flex-wrap: nowrap; }
.j2g-geo .lines.compact .lbl { flex: none; min-width: 2.2em; }
.j2g-geo .lines.compact .gap { flex: 1; min-width: 0; }
.j2g-geo .lines.compact .gap input { width: 100% !important; }
.j2g-geo .line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-weight: 600; line-height: 1.6; }
.j2g-geo .gap {
	display: inline-flex; flex-direction: column; vertical-align: middle;
}
.j2g-geo .gap input {
	display: block; height: 44px; max-width: 100%; min-width: 4ch; padding: 0 12px; border-radius: 12px; background: #f4f8f8;
	box-shadow: inset 0 0 0 2px var(--line); font: inherit; font-size: 18px; font-weight: 700; color: var(--ink);
	user-select: text; -webkit-user-select: text; cursor: text; transition: box-shadow .15s, background .15s;
}
.j2g-geo .gap input:focus { background: #fff; box-shadow: inset 0 0 0 2.5px var(--part); outline: none; }
.j2g-geo .gap.ok input { background: var(--ok-bg); box-shadow: inset 0 0 0 2.5px var(--ok); }
.j2g-geo .gap.bad input { background: var(--bad-bg); box-shadow: inset 0 0 0 2.5px var(--bad); }
.j2g-geo .gap .sol { margin-top: 3px; font-size: .78em; font-weight: 800; color: var(--ok); line-height: 1.2; }
.j2g-geo .gap .typo { margin-top: 3px; font-size: .75em; font-weight: 700; color: var(--warn); line-height: 1.2; }

/* Rückmeldung */
.j2g-geo .feedback { display: none; align-items: center; gap: 12px; margin-top: 14px; padding: 12px 14px; border-radius: 16px; font-weight: 700; }
.j2g-geo .feedback.show { display: flex; animation: pop .35s cubic-bezier(.2, 1.4, .4, 1); }
.j2g-geo .feedback.ok { background: var(--ok-bg); color: #13703a; }
.j2g-geo .feedback.bad { background: var(--bad-bg); color: #a42d2d; }
.j2g-geo .feedback.part { background: #fdf3e2; color: #8a5a0f; }
.j2g-geo .feedback .fi { width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; }
.j2g-geo .feedback.ok .fi { background: var(--ok); }
.j2g-geo .feedback.bad .fi { background: var(--bad); }
.j2g-geo .feedback.part .fi { background: var(--warn); }
.j2g-geo .feedback small { display: block; font-weight: 600; opacity: .85; }
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
.j2g-geo .shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* Untere Navigation */
.j2g-geo .navbar { display: flex; align-items: center; gap: 12px; padding: 8px clamp(12px, 2cqw, 22px) 14px; }
.j2g-geo .nav {
	width: 76px; height: 64px; border-radius: 20px; display: grid; place-items: center;
	background: var(--card); box-shadow: var(--shadow); color: var(--ink);
}
.j2g-geo .nav:active { transform: scale(.95); }
.j2g-geo .nav[disabled] { opacity: .35; pointer-events: none; }
.j2g-geo .nav svg { width: 30px; height: 30px; }
.j2g-geo .navbar .counter { flex: 1; text-align: center; font-weight: 800; color: var(--ink-soft); }

/* Hochformat (wird per JS gesetzt) */
.j2g-geo.is-portrait .stage { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, .9fr) minmax(0, 1.1fr); }
.j2g-geo.is-portrait .stage.no-media { grid-template-rows: minmax(0, 1fr); }

/* ---------- Ergebnis ---------- */
.j2g-geo .result { align-items: center; padding: 18px; gap: 14px; overflow-y: auto; }
.j2g-geo .result-card { width: min(640px, 100%); background: var(--card); border-radius: 28px; box-shadow: var(--shadow); padding: 26px 22px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.j2g-geo .ring { position: relative; width: 150px; height: 150px; }
.j2g-geo .ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.j2g-geo .ring .val { position: absolute; inset: 0; display: grid; place-items: center; font-size: 2.1em; font-weight: 800; }
.j2g-geo .result-card h2 { font-size: 1.6em; font-weight: 800; text-align: center; }
.j2g-geo .result-card p { color: var(--ink-soft); text-align: center; }
.j2g-geo .result-card .stars svg { width: 2.2em; height: 2.2em; }
.j2g-geo .result .row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; width: min(640px, 100%); }
.j2g-geo .result .row .btn { flex: 1 1 auto; white-space: nowrap; }
.j2g-geo .mistakes { width: min(640px, 100%); display: grid; gap: 8px; }
.j2g-geo .mistakes h3 { font-weight: 800; margin: 6px 4px 2px; }
.j2g-geo .mistake { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 16px; background: var(--card); box-shadow: 0 2px 8px rgba(15, 76, 92, .08); text-align: left; font-weight: 600; }
.j2g-geo .mistake .n { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--bad-bg); color: var(--bad); font-weight: 800; flex: none; }

/* ---------- Lupe / Dialog ---------- */
.j2g-geo .overlay { position: absolute; inset: 0; z-index: 20; background: rgba(10, 30, 38, .86); display: grid; place-items: center; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.j2g-geo .overlay .zoom-wrap { width: 100%; height: 100%; overflow: hidden; touch-action: none; display: grid; place-items: center; }
.j2g-geo .overlay img { max-width: 96%; max-height: 92%; object-fit: contain; border-radius: 12px; background: #fff; transform-origin: 0 0; }
.j2g-geo .overlay .close { position: absolute; top: 14px; right: 14px; width: 56px; height: 56px; border-radius: 50%; background: #fff; display: grid; place-items: center; color: var(--ink); }
.j2g-geo .overlay .hint { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; color: rgba(255, 255, 255, .8); font-weight: 600; font-size: .9em; }
.j2g-geo .dialog { width: min(440px, 92%); background: #fff; border-radius: 24px; padding: 24px; display: grid; gap: 14px; box-shadow: var(--shadow); animation: pop .25s; }
.j2g-geo .dialog h3 { font-size: 1.25em; font-weight: 800; }
.j2g-geo .dialog p { color: var(--ink-soft); }
.j2g-geo .dialog .row { display: flex; gap: 10px; }
.j2g-geo .dialog .row .btn { flex: 1; }
.j2g-geo .btn.danger { background: var(--bad); color: #fff; box-shadow: 0 4px 0 #9b2c2c; }

/* Konfetti */
.j2g-geo canvas.confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 30; }

@media (prefers-reduced-motion: reduce) {
	.j2g-geo *, .j2g-geo *::before, .j2g-geo *::after { animation: none !important; transition: none !important; }
}
