/* Pupil pages and login: shell with tab bar (rail from 1000 px and on landscape tablets), tiles, category page
   (prototype konzept-1/app.html). The "wide" layout below always uses the same media query:
   (min-width: 1000px), (orientation: landscape) and (min-width: 720px) */

/* ---------- Shell: scrolling content + tab bar (rail on wide screens) ---------- */
.shell { height: 100%; display: flex; flex-direction: column; }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.page { max-width: 720px; margin: 0 auto; padding: 20px max(20px, env(safe-area-inset-right)) 32px max(20px, env(safe-area-inset-left)); display: flex; flex-direction: column; gap: 24px; }
.tabbar { flex: none; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); background: var(--surface); border-top: 1px solid var(--line); padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); }
.tab { display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 56px; justify-content: center; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.tab .pill { display: grid; place-items: center; width: 60px; height: 32px; border-radius: 16px; transition: background-color 0.15s; }
.tab.is-active { color: var(--ink); }
.tab.is-active .pill { background: var(--surface-3); }
@media (min-width: 1000px), (orientation: landscape) and (min-width: 720px) {
  .shell { flex-direction: row-reverse; }
  .tabbar { grid-auto-flow: row; grid-auto-columns: auto; grid-auto-rows: min-content; align-content: start; gap: 12px; width: 96px; border-top: 0; border-right: 1px solid var(--line); padding: 24px 8px; }
  .page { max-width: 1080px; padding-top: 40px; }
  .page.narrow { max-width: 720px; }
}

/* ---------- Top line: brand, back button, avatar ---------- */
.topline { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.topline-end { display: flex; align-items: center; gap: 8px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; color: var(--ink-2); }
.avatar { flex: none; width: 48px; height: 48px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px; }
.iconbtn { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); color: var(--ink); }
.to-admin { display: inline-flex; align-items: center; min-height: 48px; padding: 0 16px; border-radius: 24px; background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line); font-weight: 650; font-size: 14px; }

/* ---------- Start: four tiles ---------- */
/* The page fills the screen and the tiles share the free height: full size when there is room, smaller down to a
   minimum when Chrome's address bar and tab strip take space. Only below that minimum does the page scroll. */
.page.home { min-height: 100%; }
.tiles { --tile-min: 132px; --tile-max: 184px; --tile-rows: 2; --tile-gap: 12px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(var(--tile-min), var(--tile-max)); align-content: start; gap: var(--tile-gap); }
/* Without an explicit minimum, the flex item would never be smaller than the tiles at full size. */
.home .tiles { flex: 1 1 0; min-height: calc(var(--tile-rows) * var(--tile-min) + (var(--tile-rows) - 1) * var(--tile-gap)); }
.tile { position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 10px; min-width: 0; padding: 18px 18px 16px; border-radius: var(--r-lg); background: var(--c-c); color: var(--c-on); text-align: left; transition: transform 0.12s ease; }
.tile:active { transform: scale(0.98); }
.tile .glyph { font-size: 38px; }
.tile-name { display: block; font-size: 18px; font-weight: 700; color: var(--ink); letter-spacing: -0.015em; }
.tile-state { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 14px; font-weight: 550; color: var(--ink-2); }
.tile-state .dot { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--ok); color: #fff; }
.tile-state .dot .icon { width: 12px; height: 12px; stroke-width: 3.2; }
.tile-state .dot.open { background: transparent; box-shadow: inset 0 0 0 2px currentColor; color: var(--muted); }
@media (max-width: 339px) { .tiles { grid-template-columns: 1fr; --tile-min: 112px; --tile-max: 120px; --tile-rows: 4; } }
@media (min-width: 600px) { .tiles { --tile-min: 168px; --tile-max: 232px; } .tile { padding: 24px 24px 22px; } .tile .glyph { font-size: 52px; } .tile-name { font-size: 21px; } }
@media (min-width: 1000px), (orientation: landscape) and (min-width: 720px) {
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); --tile-gap: 16px; --tile-min: 156px; --tile-max: 300px; --tile-rows: 1; }
  .tile { padding: 22px 18px 20px; }
  .tile .glyph { font-size: clamp(38px, 4.2vw, 52px); }
  .tile-name { font-size: clamp(17px, 1.8vw, 21px); }
}

/* ---------- Category page: back button and title in one row; with last tests two columns when wide ---------- */
.cat-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px 32px; }
.cat-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cat-head .iconbtn { flex: none; }
.cat-main { display: grid; gap: 16px; align-content: start; }
.about { display: grid; gap: 14px; }
.about-head { display: flex; align-items: center; gap: 14px; }
.about-scope { font-size: 17px; font-weight: 650; color: var(--ink); }
.about-count { font-size: 15px; color: var(--muted); }
.about-purpose { color: var(--ink-2); }
@media (min-width: 1000px), (orientation: landscape) and (min-width: 720px) {
  .page.split { max-width: 1080px; }
  .split .cat-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split .cat-head { grid-column: 1 / -1; }
}
/* Target and last time side by side, the goal chip below (prototype screen 4) */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stat-label { font-size: 14px; color: var(--muted); font-weight: 550; }
.stat-value { font-size: 30px; font-weight: 750; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.15; margin-top: 2px; }
.stat-empty { font-size: 17px; font-weight: 650; color: var(--muted); margin-top: 8px; }
.stats .chip { grid-column: 1 / -1; justify-self: start; }
.more-link { display: flex; align-items: center; justify-content: flex-end; gap: 4px; min-height: 48px; padding: 0 4px; font-weight: 650; font-size: 15px; color: var(--ink-2); }
.more-link .icon { width: 18px; height: 18px; }
.hero-glyph { width: 76px; height: 76px; border-radius: 22px; background: var(--c-c); color: var(--c-on); display: grid; place-items: center; flex: none; }
.hero-glyph .glyph { font-size: 24px; }

/* ---------- Login ---------- */
.login { min-height: 100%; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 32px 24px; }
.login-card { width: 100%; max-width: 400px; display: grid; gap: 28px; }
.login-mark { display: grid; grid-template-columns: repeat(2, 30px); gap: 5px; }
.login-mark i { width: 30px; height: 30px; border-radius: 9px; }
.login-mark i:nth-child(1) { background: var(--E); }
.login-mark i:nth-child(2) { background: var(--Q); }
.login-mark i:nth-child(3) { background: var(--S); }
.login-mark i:nth-child(4) { background: var(--K); }
.fields { display: grid; gap: 14px; }
.input { display: grid; gap: 6px; }
.input span { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.input input { width: 100%; min-width: 0; height: 56px; border-radius: 14px; border: 0; background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line); padding: 0 16px; font-size: 17px; outline: none; }
.input input:focus { box-shadow: inset 0 0 0 2px var(--ink); }
.input.is-error input { box-shadow: inset 0 0 0 2px var(--error-line); }

/* ---------- Actions and lists (category page, result) ---------- */
.actions { display: grid; gap: 10px; }
.section-title { margin-bottom: 10px; }
.list { display: block; background: var(--surface); border-radius: var(--r-lg); overflow: hidden; }
.row { display: flex; align-items: center; gap: 14px; min-height: 60px; padding: 10px 18px; }
.row + .row { box-shadow: inset 0 1px 0 var(--line); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 650; }
.row-value { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 17px; }
.row-main > .row-title, .row-main > .row-sub { display: block; }
.row-sub { font-size: 14px; color: var(--muted); }
a.row > .icon { width: 20px; height: 20px; color: var(--muted); }
/* The list cuts off what sticks out, so the focus frame lies inside the row */
a.row:focus-visible { outline-offset: -3px; }

/* ---------- Start: card of the open test ---------- */
.resume { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 4px 14px; padding: 16px; border-radius: var(--r-lg); background: var(--surface); text-align: left; box-shadow: inset 0 0 0 2px var(--c); }
.resume-text { display: grid; gap: 2px; font-size: 14px; color: var(--muted); }
.resume-text b { font-size: 16px; color: var(--ink); }
.resume-go { grid-column: 1 / -1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; margin-top: 10px; border-radius: 14px; background: var(--c); color: #fff; font-weight: 650; }
.resume-go .icon { width: 20px; height: 20px; }
.hero-glyph.small { width: 52px; height: 52px; border-radius: 16px; }
.hero-glyph.small .glyph { font-size: 15px; }
/* From 600 px the card is one row: glyph, text, "Weiter". */
@media (min-width: 600px) {
  .resume { grid-template-columns: auto minmax(0, 1fr) auto; }
  .resume-go { grid-column: auto; margin-top: 0; padding: 0 22px; }
}

/* ---------- Sheet before the test: from below on the phone, a dialog from 600 px ---------- */
/* Both buttons always stay in view; on a short screen only the rules above them scroll. */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; background: rgba(18, 20, 26, 0.42); animation: fade 0.2s ease both; }
.sheet { width: 100%; max-width: 560px; max-height: 100%; display: flex; flex-direction: column; overflow: hidden; background: var(--surface); border-radius: 28px 28px 0 0; box-shadow: 0 12px 40px rgba(18, 20, 26, 0.25); animation: rise 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.sheet::before { content: ""; flex: none; width: 40px; height: 5px; margin-top: 12px; border-radius: 3px; background: var(--surface-3); align-self: center; }
.sheet-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 20px; padding: 20px 24px 0; }
.sheet-actions { flex: none; display: grid; gap: 10px; padding: 20px 24px calc(24px + env(safe-area-inset-bottom)); }
.sheet .title { font-size: 24px; }
.rules { display: grid; gap: 16px; }
.rule { display: flex; gap: 14px; align-items: flex-start; font-size: 16px; color: var(--ink-2); }
.rule .icon-c { width: 40px; height: 40px; border-radius: 12px; background: var(--c-c); color: var(--c-on); display: grid; place-items: center; flex: none; }
.rule .icon-c .icon { width: 20px; height: 20px; }
.rule p { padding-top: 9px; }
@media (min-width: 600px) {
  .sheet-wrap { align-items: center; padding: 24px; }
  .sheet { border-radius: 28px; }
  .sheet::before { display: none; }
  .sheet-body { padding: 28px 28px 0; }
  /* Side by side: "Noch nicht" left, "Los geht's" right */
  .sheet-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 24px 28px 28px; }
  .sheet-actions .btn-soft { order: -1; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }

/* ---------- Result ---------- */
/* Total time in one compact row, so the list below starts higher up. */
.result-hero { background: var(--c-c); border-radius: var(--r-lg); padding: 14px 20px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 16px; }
.result-label { font-weight: 650; color: var(--c-on); font-size: 16px; }
.result-time { font-size: 40px; font-weight: 800; letter-spacing: -0.035em; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--ink); }
/* Goal of the result: white chip on the category colour, the target that applied small beside it */
.result-goal { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 4px; }
.result-goal .chip { background: var(--surface); }
.result-goal .chip-no_target { color: var(--muted); }
.result-target { font-size: 14px; font-weight: 600; color: var(--c-on); }
.mini-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.mini-stats div { background: var(--surface); border-radius: 18px; padding: 14px; min-width: 0; }
.mini-stats b { display: block; font-size: 24px; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.mini-stats span { font-size: 13px; color: var(--muted); line-height: 1.3; display: block; }
.res-eq { font-size: 20px; font-weight: 700; }
.res-eq .eq .gap { min-width: 0; padding: 0 0.25em; height: 1.35em; }
.tries { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
/* Equation and answers side by side only if both fit, otherwise the answers stand below on the right */
.row:has(> .tries) { flex-wrap: wrap; gap: 8px 14px; }
.row > .res-eq { flex: 1 0 auto; }
.row > .tries { margin-left: auto; }
.try { display: inline-flex; align-items: center; gap: 3px; height: 28px; padding: 0 10px; border-radius: 14px; font-weight: 650; font-size: 15px; font-variant-numeric: tabular-nums; }
.try .icon { width: 14px; height: 14px; stroke-width: 3; }
.try-no { background: var(--surface-2); color: var(--muted); text-decoration: line-through; }
.try-ok { background: var(--ok-c); color: var(--ok); }

/* ---------- Practice: end of a round with the tasks that were not right at the first try ---------- */
.page > [data-view] { display: flex; flex-direction: column; gap: 24px; }
.practice-score { grid-template-columns: minmax(0, 1fr); }
.solved { display: flex; flex-wrap: wrap; gap: 8px; }
.solved span { background: var(--surface); border-radius: 12px; padding: 8px 12px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- History: category select and pages ---------- */
/* A select instead of five filter buttons (acceptance M4); Android opens its own list to choose from. */
.picker { position: relative; align-self: flex-start; max-width: 100%; }
.picker select { appearance: none; -webkit-appearance: none; display: block; max-width: 100%; min-height: 48px; padding: 0 48px 0 18px; border: 0; border-radius: 24px; background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line); color: var(--ink); font: inherit; font-size: 16px; font-weight: 650; cursor: pointer; }
.picker select:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.picker .icon { position: absolute; top: 50%; right: 18px; width: 18px; height: 18px; transform: translateY(-50%) rotate(90deg); color: var(--muted); pointer-events: none; }
.pager { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 10px; }

/* ---------- Short screens (landscape tablet with address bar and tab strip): less air ---------- */
@media (max-height: 560px) {
  .page { padding-top: 16px; padding-bottom: 16px; gap: 16px; }
  .sheet-body { gap: 14px; padding-top: 20px; }
  .rules { gap: 10px; }
  .sheet-actions { padding-top: 16px; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
}
@media (min-width: 600px) and (max-height: 560px) {
  .sheet-wrap { padding: 12px 24px; }
}

/* ---------- Very small areas: a phone with a large system font, which Chrome applies as page zoom ---------- */
@media (max-width: 359px) {
  .row-glyph { display: none; }
  .row-title { overflow-wrap: anywhere; hyphens: auto; }
  .result-goal .chip { height: auto; min-height: 30px; padding: 4px 12px; white-space: normal; }
  .mini-stats { grid-template-columns: minmax(0, 1fr); }
}
