/* =============================================
   INSV Refresh — shared app chrome
   One owner for the brand wordmark, topbar and footer
   across options / support / privacy. Tokens only.
   ============================================= */

/* ── Brand wordmark (header logo) ───────────────── */
.app-wordmark {
  font-family: var(--font-display);
  color: var(--brand-500);
  font-size: 21px;
  letter-spacing: var(--tracking-wordmark);
  line-height: 1;
}

/* ── Topbar (full-page surfaces: support, privacy) ─ */
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 40px;
  /* Floating chrome rather than an opaque strip: the page scrolls underneath
     and stays faintly visible through the blur, so the two read as one surface
     with a layer over it. 80% (not the thinner glass this would allow) keeps
     the muted link colours above AA whatever scrolls under them. */
  background: color-mix(in srgb, var(--surface-sunken, #fff) 80%, transparent);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  flex-shrink: 0;
}

/* A scroll edge in place of a 1px rule. The separation should come from
   content fading under the material, which only reads where the bar actually
   overlaps something, not from a line drawn whether it does or not. */
.app-topbar::after {
  content: "";
  position: absolute;
  inset: 100% 0 auto 0;
  height: 12px;
  pointer-events: none;
  background: linear-gradient(to bottom, rgb(0 0 0 / 0.06), transparent);
}

[data-theme="dark"] .app-topbar::after {
  background: linear-gradient(to bottom, rgb(0 0 0 / 0.28), transparent);
}

/* The blur is decoration; the separation it carries is not. Asked for less
   transparency or more contrast, the bar goes solid and takes its line back. */
@media (prefers-reduced-transparency: reduce) {
  .app-topbar {
    background: var(--surface-sunken, #fff);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom: 1px solid var(--border, #E5E7EF);
  }
  .app-topbar::after { display: none; }
}

@media (prefers-contrast: more) {
  .app-topbar {
    background: var(--surface-sunken, #fff);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom: 2px solid var(--text, #1B2340);
  }
  .app-topbar::after { display: none; }
}

.app-topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.app-topbar-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border, #E5E7EF);
  background: var(--surface, #fff);
  color: var(--text-muted, #6B7390);
  font-size: 0.83rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out), transform var(--dur-press) var(--ease-out);
}

.app-topbar-back:hover {
  color: var(--brand-500);
  border-color: var(--brand-500);
}

.app-topbar-back:active {
  transform: scale(0.97);
}

/* ── Footer (options, support, privacy) ─────────── */
.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 20px 40px;
  background: var(--surface-sunken, #fff);
  border-top: 1px solid var(--border, #E5E7EF);
  flex-shrink: 0;
}

.app-footer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-xs);
  letter-spacing: var(--tracking-micro);
  color: var(--text-muted, #6B7390);
}

.app-footer-links {
  display: flex;
  gap: 20px;
}

.app-footer-links a {
  font-size: 0.75rem;
  color: var(--text-muted, #6B7390);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}

.app-footer-links a:hover { color: var(--brand-500); }
.app-footer-links a.accent { color: var(--brand-500); }
.app-footer-links a.accent:hover { color: var(--brand-600); }

/* ── Shared keyboard focus (WCAG 2.4.7) ─────────── */
.app-topbar-brand:focus-visible,
.app-topbar-back:focus-visible,
.app-footer-links a:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

[data-theme="dark"] .app-topbar-brand:focus-visible,
[data-theme="dark"] .app-topbar-back:focus-visible,
[data-theme="dark"] .app-footer-links a:focus-visible {
  outline-color: var(--brand-400);
}

/* ── Dark-mode parity (tokens already flip in variaveis) */
[data-theme="dark"] .app-topbar-back {
  background: rgb(255 255 255 / 0.04);
  border-color: rgb(255 255 255 / 0.1);
  color: var(--ink-300);
}

[data-theme="dark"] .app-topbar-back:hover {
  background: rgb(255 255 255 / 0.07);
  border-color: rgb(255 255 255 / 0.2);
  color: var(--ink-100);
}

[data-theme="dark"] .app-footer-links a:hover { color: var(--ink-100); }
[data-theme="dark"] .app-footer-links a.accent { color: var(--brand-300); }
[data-theme="dark"] .app-footer-links a.accent:hover { color: var(--brand-200); }

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 768px) {
  .app-topbar { padding: 12px 20px; }
  .app-footer {
    padding: 16px 20px;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}

/* Narrow windows: the back link keeps its chevron and its accessible name,
   but the label stops pushing the topbar past the viewport edge. */
@media (max-width: 480px) {
  .app-topbar { padding: 12px 16px; }
  .app-topbar-back span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}
