/* Loading astrolabe compass, sliding segmented plate, rolling digits and reduced-motion rules. */
.loading-cover {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background:
    radial-gradient(circle at 50% 48%, rgba(252, 251, 246, 0.92) 0, rgba(246, 244, 236, 0.98) 62%),
    repeating-radial-gradient(circle at 50% -28%, transparent 0 71px, rgba(47, 90, 65, 0.055) 71px 72px),
    var(--bg-paper);
  color: var(--accent);
}

.loading-cover > .brand-symbol {
  position: relative;
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  font-size: 36px;
  color: var(--accent);
}

.loading-cover > .brand-symbol .astrolabe-svg {
  width: 92px;
  height: 92px;
  animation: atlas-rose-sway 5.4s ease-in-out infinite;
}

.loading-cover > .brand-symbol::before,
.loading-cover > .brand-symbol::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.loading-cover > .brand-symbol::before {
  inset: 0;
  border: 1px solid rgba(158, 123, 56, 0.34);
  border-top: 2px solid var(--focus-ring);
  border-bottom: 2px solid var(--focus-ring);
  animation: atlas-compass-turn 4.8s linear infinite;
}

.loading-cover > .brand-symbol::after {
  inset: 8px;
  border: 1px dashed rgba(47, 90, 65, 0.38);
  animation: atlas-compass-turn 9.6s linear infinite reverse;
}

.loading-cover > p {
  margin: 20px 0 0;
  font-size: var(--text-caption);
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  animation: atlas-loading-breathe 2.2s ease-in-out infinite;
}

.loading-cover.loading-exit {
  position: fixed !important;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}

.error-state {
  color: var(--danger);
  text-align: center;
  padding: 32px;
}

.error-state button {
  margin: 8px;
}

@keyframes atlas-compass-turn {
  to { transform: rotate(360deg); }
}

@keyframes atlas-rose-sway {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(4deg); }
}

@keyframes atlas-loading-breathe {
  0%, 100% { opacity: 0.65; }
  50% { opacity: 1; }
}

/* Sliding segmented selection plate */
.atlas-segmented {
  position: relative;
  isolation: isolate;
  --segment-fill: var(--bg-surface);
}

.atlas-segmented::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: var(--segment-height, 0);
  width: var(--segment-width, 0);
  transform: translate(var(--segment-x, 0), var(--segment-y, 0));
  border-radius: var(--radius-sm);
  background: var(--segment-fill);
  box-shadow: 0 1px 3px rgba(28, 36, 30, 0.08);
  opacity: var(--segment-opacity, 0);
  pointer-events: none;
  z-index: 0;
}

.atlas-segmented[data-segment-ready]::before {
  transition: transform 240ms cubic-bezier(0.2, 0.7, 0.2, 1), width 240ms cubic-bezier(0.2, 0.7, 0.2, 1), height 240ms cubic-bezier(0.2, 0.7, 0.2, 1), opacity 140ms;
}

.atlas-segmented > button {
  position: relative;
  z-index: 1;
  background: transparent !important;
  box-shadow: none !important;
}

.atlas-segmented > button:hover:not(:disabled) {
  background: rgba(47, 90, 65, 0.06) !important;
}

/* Motion anchors & rolling digit ribbons */
#question-panel,
.question-messages,
#question-content,
#hint-text,
#feedback {
  position: relative;
}

.motion-answer-outline {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.map-mode-menu,
.layer-controls,
.map-legend-panel {
  transform-origin: top left;
}

.country-heading {
  transform-origin: center left;
}

#practice-settings[data-folding] {
  overflow: visible;
  clip-path: inset(-20px -4px 0);
  min-height: 0;
}

#practice-settings.fold-collapsing #practice-details {
  display: grid;
}

.stats b {
  position: relative;
}

.stats b .metric-readable {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stats b .metric-digits {
  display: inline-flex;
  align-items: baseline;
  white-space: nowrap;
  font: inherit;
  color: inherit;
}

.stats b .metric-digit {
  display: inline-block;
  height: 1.2em;
  overflow: hidden;
  vertical-align: bottom;
  line-height: 1.2em;
}

.stats b .metric-ribbon,
.stats b .metric-glyph {
  display: block;
  line-height: 1.2em;
}

.stats b .metric-glyph {
  height: 1.2em;
}

.stats b .metric-suffix {
  align-self: baseline;
  font-size: var(--text-caption);
  color: var(--ink-muted);
}

button {
  transition: background-color 140ms, color 140ms, border-color 140ms, transform 100ms;
}

.primary:active:not(:disabled),
.secondary:active:not(:disabled),
.reverse-choice:active:not(:disabled) {
  transform: scale(0.985);
}

.mobile-settings-dialog.motion-opening::backdrop {
  animation: atlas-backdrop-in 180ms ease-out both;
}

.mobile-settings-dialog.motion-closing::backdrop {
  animation: atlas-backdrop-out 120ms ease-in both;
}

@keyframes atlas-backdrop-in {
  from { background-color: rgba(28, 36, 30, 0); }
  to { background-color: rgba(28, 36, 30, 0.42); }
}

@keyframes atlas-backdrop-out {
  from { background-color: rgba(28, 36, 30, 0.42); }
  to { background-color: rgba(28, 36, 30, 0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .training-boundary-glow {
    opacity: 0.45;
  }
}
