/* Installed web app: "add to home screen" button, install steps sheet, safe areas in full-screen mode. */

/* The page may run edge to edge (viewport-fit=cover); keep content clear of the notch in landscape. */
body { padding-right: env(safe-area-inset-right); padding-left: env(safe-area-inset-left); }

.setup-topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.install-slot:empty { display: none; }
.install-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--primary-line);
  border-radius: 12px;
  color: var(--primary);
  background: rgba(var(--glass), .92);
  box-shadow: 0 6px 16px rgba(69, 89, 230, .1);
  cursor: pointer;
  font: inherit;
  font-size: .8rem;
  font-weight: 700;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .15s;
}
.install-button:hover { border-color: var(--primary-line-strong); background: var(--primary-bg-soft); transform: translateY(-1px); }
.install-button svg { flex: none; }

/* Install steps: centred dialog, bottom sheet on phones. */
.install-sheet {
  width: min(100% - 32px, 440px);
  max-width: none;
  max-height: min(88vh, 640px);
  padding: 0;
  border: 0;
  border-radius: 22px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(22, 32, 61, .25);
}
.install-sheet::backdrop { background: rgba(15, 22, 42, .45); }
.install-sheet-body { display: grid; gap: 14px; padding: 22px 22px 20px; }
.install-sheet h2 { margin: 0; font-size: 1.05rem; }
.install-sheet p { margin: 0; color: var(--muted); font-size: .84rem; line-height: 1.8; }
.install-steps { display: grid; gap: 12px; margin: 4px 0 6px; padding: 0; list-style: none; }
.install-steps li { display: flex; align-items: flex-start; gap: 11px; font-size: .88rem; line-height: 1.9; }
.install-step-number {
  display: grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  margin-top: 2px;
  border-radius: 9px;
  color: var(--primary);
  background: var(--primary-bg);
  font-size: .8rem;
  font-weight: 800;
}
.install-key {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 26px;
  margin: 0 2px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ios-blue);
  background: var(--canvas);
  font-weight: 800;
  line-height: 1;
  vertical-align: -7px;
}
.install-sheet .button { width: 100%; }

@media (max-width: 530px) {
  .install-button { min-height: 36px; padding: 0 11px; font-size: .74rem; }
  .install-sheet {
    width: 100%;
    margin: auto 0 0;
    border-radius: 22px 22px 0 0;
  }
  .install-sheet-body { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
}

@media (max-width: 820px) {
  .exam-nav { padding-right: max(18px, env(safe-area-inset-right)); padding-left: max(18px, env(safe-area-inset-left)); }
}

@media (max-width: 340px) {
  .setup-topbar .brand > span:last-child { display: none; }
}

/* Full-screen (installed) mode: no browser bar above the page, so leave room for the status bar area. */
@media (display-mode: standalone) {
  .intro-page, .results-page { padding-top: max(20px, env(safe-area-inset-top)); }
  .exam-header { padding-top: max(16px, env(safe-area-inset-top)); }
}

@media (prefers-reduced-motion: reduce) {
  .install-button { transition: none; }
}

/* App logo in the page headers (replaces the old «آ» text mark). */
.brand-logo { display: block; flex: none; width: 32px; height: 32px; filter: drop-shadow(0 6px 12px rgba(69, 89, 230, .25)); }
.install-sheet .install-note { color: var(--muted); font-size: .76rem; }

/* Start-page content in index.html, shown until the app starts (and to search engines). */
.static-features { display: grid; gap: 8px; max-width: 460px; margin: 0 auto 18px; padding: 0; list-style: none; text-align: right; }
.static-features li { padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-size: .88rem; }
.static-loading { margin: 0; color: var(--muted); font-size: .84rem; }

/* Site footer with the link to the source repository. */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 16px;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: var(--canvas);
  font-size: .78rem;
}
.site-footer a { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); font-weight: 700; text-decoration: none; }
.site-footer a:hover { color: var(--primary); }

/* Figures taken from the textbook are sharp enough to show larger than the old exam crops (smaller pictures keep their size). */
.question-image img { max-height: 300px; }
@media (max-width: 530px) { .question-image img { max-height: 260px; } }
