/* Base element styles and reset. Layered on top of tokens.css. */

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
}

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

h1 {
  font-size: var(--text-3xl);
}

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

h3 {
  font-size: var(--text-xl);
}

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

a {
  color: var(--color-primary);
  text-decoration: none;
}

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

ul,
ol {
  padding-left: var(--space-5);
}

small,
.text-muted {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-5) 0;
}

code,
pre {
  font-family: var(--font-mono);
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* App shell */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  height: var(--header-height);
  padding: 0 var(--space-5);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  min-width: 0;
}

.app-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text);
  flex-shrink: 0;
}

.app-logo:hover {
  color: var(--color-text);
  text-decoration: none;
}

.app-logo-mark {
  width: 1.5rem;
  height: 1.5rem;
  color: var(--color-primary);
}

.app-logo-text {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.app-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  overflow-x: auto;
}

.app-nav-link {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.app-nav-link:hover {
  background: var(--color-surface-alt);
  color: var(--color-text);
  text-decoration: none;
}

.app-nav-link.active {
  background: var(--color-primary-light);
  color: var(--color-primary-hover);
  font-weight: 600;
}

/* User menu (native <details>/<summary> dropdown — no JS required) */
.user-menu {
  position: relative;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
  cursor: pointer;
  list-style: none;
  font-size: var(--text-sm);
  color: var(--color-text);
}

.user-menu-trigger::-webkit-details-marker {
  display: none;
}

.user-menu-trigger:hover {
  background: var(--color-surface-alt);
}

.user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  font-size: var(--text-xs);
  font-weight: 700;
}

.user-menu-label {
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-menu[open] .user-menu-trigger {
  background: var(--color-surface-alt);
}

.user-menu-panel {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  min-width: 12rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--space-3);
}

.user-menu-role {
  margin: 0 0 var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.user-menu-logout {
  width: 100%;
  justify-content: flex-start;
}

/* Mobile (KAN-57): the nav's horizontal scroll works at any width, but
   the logo wordmark and username label eat space that the nav needs
   more on a phone-width header. */
@media (max-width: 480px) {
  .app-header {
    padding: 0 var(--space-3);
    gap: var(--space-2);
  }

  .app-header-left {
    gap: var(--space-3);
  }

  .app-logo-text {
    display: none;
  }

  .user-menu-label {
    display: none;
  }
}

.app-main {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: var(--space-6) var(--space-5);
}
