/**
 * MCD Admin - base layer: reset, layout shell, typography, focus, motion.
 *
 * Loaded on every admin page (login and shell). Depends on tokens.css for
 * every color/space/radius/font/motion value; never a raw literal here.
 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.25;
  margin: 0 0 var(--space-3) 0;
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }

p { margin: 0 0 var(--space-3) 0; }

a {
  color: var(--color-accent);
  text-decoration: underline;
}

a:hover { color: var(--color-accent-strong); }

/* Skip link: first tab stop, hidden until focused */
.skip-link {
  position: absolute;
  left: var(--space-3);
  top: calc(-1 * var(--space-7));
  background: var(--color-surface);
  color: var(--color-ink);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-1);
  border: 1px solid var(--color-rule);
  transition: top var(--dur-fast) var(--ease-standard);
  z-index: 20;
}

.skip-link:focus-visible {
  top: var(--space-3);
}

/* Visible focus ring everywhere, on top of any browser default */
:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: var(--radius-1);
}

/* Layout shell */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-nav {
  width: var(--nav-width);
  flex: 0 0 var(--nav-width);
  background: var(--color-surface);
  border-right: 1px solid var(--color-rule);
  padding: var(--space-4) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.app-brand {
  font-size: var(--text-lg);
  font-weight: 700;
}

.app-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.app-nav-list a,
.app-nav-list .nav-disabled {
  display: block;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-1);
  color: var(--color-ink);
  text-decoration: none;
  font-size: var(--text-sm);
}

.app-nav-list a:hover {
  background: var(--color-surface-sunken);
}

.app-nav-list a[aria-current="page"] {
  background: var(--color-accent);
  color: var(--color-accent-ink);
}

.app-nav-list .nav-disabled {
  color: var(--color-muted);
  cursor: default;
}

.nav-section-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-muted);
  margin: var(--space-3) var(--space-3) 0;
}

.app-main {
  flex: 1 1 auto;
  padding: var(--space-5) var(--space-6);
  max-width: var(--page-max);
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.app-view {
  min-width: 0;
}

/* aria-live message region: visually present, not visually hidden, so a
   sighted person also sees what was just announced */
.app-announcer {
  min-height: 1.5em;
  margin-bottom: var(--space-3);
  font-size: var(--text-sm);
}

.app-announcer:empty {
  display: none;
}

.app-announcer[data-tone="error"] {
  color: var(--color-danger-ink);
}

.app-announcer[data-tone="success"] {
  color: var(--color-success-ink);
}

/* 360px floor: nav collapses to a top bar, no page ever scrolls sideways */
@media (max-width: 720px) {
  .app-shell {
    flex-direction: column;
  }

  .app-nav {
    width: 100%;
    flex: 0 0 auto;
    border-right: none;
    border-bottom: 1px solid var(--color-rule);
  }

  .app-nav-list {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .app-main {
    padding: var(--space-4);
  }
}

img, svg {
  max-width: 100%;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
