/*
 * Noosphere application styles.
 * Direction 04 — editorial-humanist (parchment + vermilion).
 * All values reference --noo-* tokens; see app/assets/stylesheets/tokens.css.
 */

/* ========================================
   Baseline — body uses serif for prose,
   page background is parchment / ink.
   ======================================== */

body {
  font-family: var(--noo-font-serif);
  font-size: var(--noo-font-size-base);
  line-height: var(--noo-line-height);
  background: var(--noo-surface);
  color: var(--noo-text);
  margin: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* UI chrome (nav, buttons, forms, headings on app surfaces) uses sans. */
button, input, select, textarea,
.noo-btn, .noo-input, .menu-item, .menu-title, .menu-wordmark,
.hamburger-toggle, h1, h2, h3, h4, h5, h6 {
  font-family: var(--noo-font-sans);
}

/* Headings inherit -tight tracking; large headings use the display tracking
   in the dashboards/landing where applied via .noo-display. */
h1, h2, h3 {
  letter-spacing: var(--noo-tracking-tight);
  line-height: var(--noo-line-height-tight);
}

a {
  color: var(--noo-accent);
  text-decoration: none;
  text-underline-offset: 2px;
}
a:hover {
  text-decoration: underline;
  color: var(--noo-accent-hover);
}

code, pre, kbd, samp {
  font-family: var(--noo-font-mono);
  font-size: 0.92em;
}

/* "Editorial eyebrow" — used above hero text on the landing/dashboard. */
.noo-eyebrow {
  font-family: var(--noo-font-sans);
  font-size: var(--noo-font-size-xs);
  font-weight: var(--noo-font-weight-medium);
  letter-spacing: var(--noo-tracking-label);
  text-transform: uppercase;
  color: var(--noo-accent);
}

/* ========================================
   Editorial page chrome
   Reusable frame for index/detail pages.
   ======================================== */

.noo-page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 80px var(--noo-space-xl) 96px;
}
.noo-page--narrow { max-width: 760px; }
.noo-page--wide   { max-width: 1400px; }

.noo-page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--noo-space-lg);
  padding-bottom: var(--noo-space-lg);
  border-bottom: 1px solid var(--noo-border);
  margin-bottom: var(--noo-space-2xl);
}
.noo-page-header-text { min-width: 0; }
.noo-page-header-actions {
  display: flex;
  gap: var(--noo-space-sm);
  align-items: center;
  flex-wrap: wrap;
}
.noo-page-eyebrow {
  font-family: var(--noo-font-mono);
  font-size: var(--noo-font-size-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--noo-accent);
  margin: 0 0 6px 0;
}
.noo-page-title {
  font-family: var(--noo-font-serif);
  font-size: var(--noo-font-size-2xl);
  font-weight: 500;
  letter-spacing: var(--noo-tracking-tight);
  margin: 0;
  color: var(--noo-text);
}
.noo-page-subtitle {
  font-family: var(--noo-font-serif);
  font-style: italic;
  font-size: var(--noo-font-size-sm);
  color: var(--noo-text-muted);
  margin-top: 4px;
}

/* Action buttons in the page-header. Smaller than .noo-btn primary,
   designed for "New X" + ghost secondaries. */
.noo-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--noo-accent);
  color: var(--noo-accent-text);
  border: 1px solid var(--noo-accent);
  border-radius: var(--noo-radius);
  font-family: var(--noo-font-sans);
  font-size: var(--noo-font-size-sm);
  font-weight: var(--noo-font-weight-medium);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--noo-duration) var(--noo-ease),
              border-color var(--noo-duration) var(--noo-ease),
              color var(--noo-duration) var(--noo-ease);
}
.noo-action:hover {
  background: var(--noo-accent-hover);
  border-color: var(--noo-accent-hover);
  color: var(--noo-accent-text);
  text-decoration: none;
}
.noo-action--ghost {
  background: transparent;
  color: var(--noo-text);
  border-color: var(--noo-border);
}
.noo-action--ghost:hover {
  background: var(--noo-surface-sunken);
  color: var(--noo-text);
  border-color: var(--noo-text-muted);
}
.noo-action--quiet {
  background: transparent;
  color: var(--noo-text-muted);
  border-color: transparent;
}
.noo-action--quiet:hover {
  background: var(--noo-surface-sunken);
  color: var(--noo-text);
  border-color: transparent;
}

/* Card grids for indexes */
.noo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--noo-space-lg);
}
.noo-grid--wide {
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
}

/* Editorial-styled card — for index lists.
   Uses borders + slight shadow, not the gradient pop of the old design. */
.noo-tile {
  display: block;
  background: var(--noo-surface-raised);
  border: 1px solid var(--noo-border);
  border-radius: var(--noo-radius-lg);
  padding: var(--noo-space-lg);
  color: inherit;
  text-decoration: none;
  transition: border-color var(--noo-duration) var(--noo-ease),
              box-shadow var(--noo-duration) var(--noo-ease),
              transform var(--noo-duration) var(--noo-ease);
}
.noo-tile:hover {
  border-color: var(--noo-text-muted);
  box-shadow: var(--noo-shadow);
  text-decoration: none;
  color: inherit;
  transform: translateY(-1px);
}
.noo-tile-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--noo-space-sm);
  margin-bottom: 6px;
}
.noo-tile-title {
  font-family: var(--noo-font-serif);
  font-size: var(--noo-font-size-lg);
  font-weight: 500;
  letter-spacing: var(--noo-tracking-tight);
  color: var(--noo-text);
  margin: 0;
}
.noo-tile-body {
  font-family: var(--noo-font-serif);
  font-size: var(--noo-font-size-sm);
  color: var(--noo-text-muted);
  line-height: 1.55;
  margin: 8px 0 0 0;
}
.noo-tile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--noo-space-md);
  margin-top: var(--noo-space-md);
  padding-top: var(--noo-space-md);
  border-top: 1px solid var(--noo-border-muted);
  font-family: var(--noo-font-mono);
  font-size: var(--noo-font-size-xs);
  color: var(--noo-text-muted);
  letter-spacing: 0.04em;
}

/* Pill — small, semantic, used to mark ownership/role/state.
   Different from .noo-badge in that it's outlined, not solid. */
.noo-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border: 1px solid var(--noo-border);
  border-radius: var(--noo-radius-round);
  font-family: var(--noo-font-mono);
  font-size: var(--noo-font-size-xs);
  letter-spacing: 0.04em;
  color: var(--noo-text-muted);
  background: transparent;
}
.noo-pill--owner { color: var(--noo-success); border-color: var(--noo-success); }
.noo-pill--shared { color: var(--noo-accent); border-color: var(--noo-accent); }
.noo-pill--accent { color: var(--noo-accent); border-color: var(--noo-accent); }

/* Empty state — restrained, italic-serif voice, single primary CTA */
.noo-empty {
  text-align: center;
  padding: var(--noo-space-2xl) var(--noo-space-lg);
  border: 1px solid var(--noo-border);
  border-radius: var(--noo-radius-lg);
  background: var(--noo-surface-raised);
}
.noo-empty-title {
  font-family: var(--noo-font-serif);
  font-size: var(--noo-font-size-xl);
  font-weight: 500;
  letter-spacing: var(--noo-tracking-tight);
  color: var(--noo-text);
  margin: 0 0 8px 0;
}
.noo-empty-lede {
  font-family: var(--noo-font-serif);
  font-size: var(--noo-font-size-base);
  color: var(--noo-text-muted);
  margin: 0 auto var(--noo-space-lg) auto;
  max-width: 50ch;
}

@media (max-width: 768px) {
  .noo-page { padding: 80px var(--noo-space-md) var(--noo-space-2xl); }
  .noo-page-header { flex-direction: column; align-items: flex-start; }
  .noo-page-header-actions { width: 100%; }
}


/* ========================================
   Upload Badge Styles
   Backward-compatible wrapper over .noo-badge base.
   .upload-badge inherits base badge styling from .noo-badge
   and adds upload-specific sizing (height, smaller font).
   ======================================== */

.upload-badges,
.upload-metadata-badges,
.upload-all-badges {
  display: inline-flex;
  gap: 0.375rem;
  align-items: center;
  flex-wrap: wrap;
}

.upload-badge {
  /* Base badge properties (delegated from .noo-badge) */
  display: inline-flex;
  align-items: center;
  padding: var(--noo-space-xs) var(--noo-space-sm);
  border-radius: var(--noo-radius-round);
  font-size: var(--noo-font-size-xs);
  font-weight: var(--noo-font-weight-semibold);
  /* Upload-specific overrides */
  height: 20px;
  font-size: 0.7rem;
  padding: 0.2rem var(--noo-space-sm);
  border-radius: var(--noo-radius);
  white-space: nowrap;
  transition: all var(--noo-duration) var(--noo-ease);
  border: 1px solid transparent;
}

/* Origin badge colors */
.origin-badge.badge-plugin {
  background: var(--noo-accent-subtle);
  color: var(--noo-accent);
  border-color: var(--noo-accent-subtle);
}

.origin-badge.badge-file {
  background: var(--noo-success-subtle);
  color: var(--noo-success-text);
  border-color: var(--noo-success-subtle);
}

.origin-badge.badge-url {
  background: var(--noo-info-subtle);
  color: var(--noo-info-text);
  border-color: var(--noo-info-subtle);
}

.origin-badge.badge-default {
  background: var(--noo-surface-sunken);
  color: var(--noo-text-muted);
  border-color: var(--noo-border-muted);
}

/* Category badge */
.category-badge {
  background: var(--noo-warning-subtle);
  color: var(--noo-warning-text);
  border-color: var(--noo-warning-subtle);
}

/* Quality badge colors */
.quality-badge.badge-quality-high {
  background: var(--noo-success-subtle);
  color: var(--noo-success-text);
  border-color: var(--noo-success-subtle);
}

.quality-badge.badge-quality-medium {
  background: var(--noo-warning-subtle);
  color: var(--noo-warning-text);
  border-color: var(--noo-warning-subtle);
}

.quality-badge.badge-quality-low {
  background: var(--noo-danger-subtle);
  color: var(--noo-danger-text);
  border-color: var(--noo-danger-subtle);
}

/* Stats badge */
.stats-badge {
  background: var(--noo-surface-sunken);
  color: var(--noo-text-muted);
  border-color: var(--noo-border-muted);
}

/* Hover effects */
.upload-badge:hover {
  transform: translateY(-1px);
  box-shadow: var(--noo-shadow);
}

/* No metadata placeholder */
.no-metadata {
  color: var(--noo-text-muted);
  font-size: var(--noo-font-size-xs);
}

/* Admin table badge styling - consistent with my_uploads */
.admin-table .upload-badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  height: 18px;
  border-radius: 3px;
  border: 1px solid;
}

.admin-table .upload-badges,
.admin-table .upload-metadata-badges,
.admin-table .upload-all-badges {
  gap: 0.375rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .upload-badges,
  .upload-metadata-badges {
    gap: var(--noo-space-xs);
  }

  .upload-badge {
    font-size: 0.7rem;
    padding: 0.2rem var(--noo-space-sm);
    height: 22px;
  }
}

/* ========================================
   Hamburger Menu Styles
   ======================================== */

/* Hamburger Menu Wrapper */
.hamburger-menu-wrapper {
  position: relative;
  z-index: 1000;
}

/* Hamburger Toggle Button */
.hamburger-toggle {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 1001;
  width: 44px;
  height: 44px;
  border: 1px solid var(--noo-border);
  background: var(--noo-surface-raised);
  border-radius: var(--noo-radius-lg);
  box-shadow: var(--noo-shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s var(--noo-ease);
}

.hamburger-toggle:hover {
  background: var(--noo-surface-sunken);
  box-shadow: var(--noo-shadow-lg);
  transform: translateY(-2px);
}

.hamburger-toggle:active {
  transform: translateY(0);
}

.hamburger-toggle:focus {
  outline: 2px solid var(--noo-accent);
  outline-offset: 2px;
}

.hamburger-icon {
  width: 24px;
  height: 24px;
  color: var(--noo-text);
}

/* Menu Container */
.menu-container {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 300px;
  background: var(--noo-surface-raised);
  border-right: 1px solid var(--noo-border);
  box-shadow: var(--noo-shadow-lg);
  z-index: 1002;
  transition: transform 0.3s var(--noo-ease);
  overflow-y: auto;
}

.menu-container.menu-hidden {
  transform: translateX(-100%);
}

.menu-container.menu-visible {
  transform: translateX(0);
}

/* Menu Navigation */
.menu-nav {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 20px;
}

/* Close Button Inside Menu */
.menu-close-button {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--noo-radius);
  transition: all var(--noo-duration) var(--noo-ease);
}

.menu-close-button:hover {
  background: var(--noo-surface-sunken);
}

.menu-close-button:active {
  background: var(--noo-border-muted);
}

.menu-close-button:focus {
  outline: 2px solid var(--noo-accent);
  outline-offset: 2px;
}

.close-icon {
  width: 20px;
  height: 20px;
  color: var(--noo-text-muted);
}

/* Menu Header — thought mark + serif wordmark + italic tagline */
.menu-header {
  margin-top: 40px;
  margin-bottom: var(--noo-space-lg);
  padding-bottom: var(--noo-space-md);
  border-bottom: 1px solid var(--noo-border);
}

.menu-brand {
  display: flex;
  align-items: center;
  gap: var(--noo-space-md);
}

.menu-brand svg {
  flex-shrink: 0;
}

.menu-brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1;
}

.menu-wordmark {
  font-family: var(--noo-font-sans);
  font-size: var(--noo-font-size-xl);
  font-weight: var(--noo-font-weight-medium);
  letter-spacing: var(--noo-tracking-tight);
  color: var(--noo-text);
}

.menu-tagline {
  font-family: var(--noo-font-serif);
  font-style: italic;
  font-size: var(--noo-font-size-xs);
  color: var(--noo-text-muted);
  margin-top: 2px;
}

/* Menu Items */
.menu-items {
  display: flex;
  flex-direction: column;
  gap: var(--noo-space-sm);
}

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--noo-radius);
  text-decoration: none;
  color: var(--noo-text);
  font-family: var(--noo-font-sans);
  font-size: var(--noo-font-size-base);
  font-weight: var(--noo-font-weight-medium);
  letter-spacing: -0.005em;
  transition: all var(--noo-duration) var(--noo-ease);
  border-left: 2px solid transparent;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.menu-item:hover {
  background: var(--noo-surface-sunken);
  color: var(--noo-text);
  border-left-color: var(--noo-accent);
  text-decoration: none;
}

.menu-item:active {
  background: var(--noo-surface-sunken);
}

.menu-item:focus {
  outline: 2px solid var(--noo-accent);
  outline-offset: -2px;
}

.menu-item-label {
  display: flex;
  align-items: center;
  gap: 12px;
}

.menu-item-icon {
  width: 20px;
  height: 20px;
  color: var(--noo-text-muted);
}

.menu-item-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 var(--noo-space-sm);
  background: transparent;
  border: 1px solid var(--noo-border);
  border-radius: var(--noo-radius);
  font-family: var(--noo-font-mono);
  font-size: var(--noo-font-size-xs);
  font-weight: var(--noo-font-weight-medium);
  color: var(--noo-text-muted);
}

.menu-item-danger {
  color: var(--noo-danger);
}

.menu-item-danger:hover {
  background: var(--noo-danger-subtle);
  color: var(--noo-danger-text);
}

.menu-item-danger .menu-item-icon {
  color: var(--noo-danger);
}

/* Backdrop */
.menu-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1001;
  transition: opacity 0.3s var(--noo-ease);
}

.menu-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

.menu-backdrop.backdrop-visible {
  opacity: 1;
  pointer-events: auto;
}

/* Responsive Styles */
@media (max-width: 768px) {
  .menu-container {
    width: 80%;
    max-width: 320px;
  }

  .hamburger-toggle {
    top: 16px;
    left: 16px;
    width: 44px;
    height: 44px;
  }

  .hamburger-icon {
    width: 22px;
    height: 22px;
  }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
  .menu-container,
  .menu-backdrop,
  .hamburger-toggle,
  .menu-item,
  .menu-close-button {
    transition: none;
  }
}

/* Focus Visible for Keyboard Navigation */
.hamburger-toggle:focus-visible,
.menu-close-button:focus-visible,
.menu-item:focus-visible {
  outline: 2px solid var(--noo-accent);
  outline-offset: 2px;
}

/* ========================================
   Shared Reusable Component Classes
   ======================================== */

/* Cards */
.noo-card {
  background: var(--noo-surface-raised);
  border: 1px solid var(--noo-border);
  border-radius: var(--noo-radius-lg);
  padding: var(--noo-space-lg);
  box-shadow: var(--noo-shadow);
}

/* Card: Stat variant -- centered stat display (number + label) */
.noo-card--stat {
  flex: 1;
  text-align: center;
}

/* Badges */
.noo-badge {
  display: inline-block;
  padding: var(--noo-space-xs) var(--noo-space-sm);
  border-radius: var(--noo-radius-round);
  font-size: var(--noo-font-size-xs);
  font-weight: var(--noo-font-weight-semibold);
}

.noo-badge--success {
  background: var(--noo-success-subtle);
  color: var(--noo-success-text);
}

.noo-badge--warning {
  background: var(--noo-warning-subtle);
  color: var(--noo-warning-text);
}

.noo-badge--danger {
  background: var(--noo-danger-subtle);
  color: var(--noo-danger-text);
}

.noo-badge--info {
  background: var(--noo-info-subtle);
  color: var(--noo-info-text);
}

/* Badge: Accent variant -- for "Shared" badges and brand-colored badges */
.noo-badge--accent {
  background: var(--noo-accent);
  color: var(--noo-accent-text);
}

/* Badge: Muted variant -- for secondary/neutral role indicators */
.noo-badge--muted {
  background: var(--noo-text-muted);
  color: var(--noo-text-inverse);
}

/* Buttons */
.noo-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--noo-space-xs);
  padding: var(--noo-space-sm) var(--noo-space-md);
  border: 1px solid var(--noo-border);
  border-radius: var(--noo-radius);
  background: var(--noo-surface-raised);
  color: var(--noo-text);
  font-family: var(--noo-font-sans);
  font-size: var(--noo-font-size-sm);
  font-weight: var(--noo-font-weight-medium);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--noo-duration) var(--noo-ease);
}

.noo-btn:hover {
  background: var(--noo-surface-sunken);
}

.noo-btn--primary {
  background: var(--noo-accent);
  color: var(--noo-accent-text);
  border-color: var(--noo-accent);
}

.noo-btn--primary:hover {
  background: var(--noo-accent-hover);
}

.noo-btn--danger {
  background: var(--noo-danger);
  color: #fff;
  border-color: var(--noo-danger);
}

.noo-btn--danger:hover {
  opacity: 0.85;
}

/* Button: Secondary variant */
.noo-btn--secondary {
  background: var(--noo-text-muted);
  color: var(--noo-text-inverse);
  border-color: var(--noo-text-muted);
}

.noo-btn--secondary:hover {
  opacity: 0.85;
}

/* Button: Warning variant */
.noo-btn--warning {
  background: var(--noo-warning);
  color: var(--noo-text-inverse);
  border-color: var(--noo-warning);
}

.noo-btn--warning:hover {
  opacity: 0.85;
}

/* Button: Small size modifier */
.noo-btn--sm {
  padding: var(--noo-space-xs) var(--noo-space-sm);
  font-size: var(--noo-font-size-sm);
}

/* Form Inputs */
.noo-input {
  width: 100%;
  padding: var(--noo-space-sm) var(--noo-space-md);
  border: 1px solid var(--noo-border);
  border-radius: var(--noo-radius);
  background: var(--noo-surface-raised);
  color: var(--noo-text);
  font-family: var(--noo-font-sans);
  font-size: var(--noo-font-size-base);
  transition: border-color var(--noo-duration) var(--noo-ease);
}

.noo-input:focus {
  outline: none;
  border-color: var(--noo-accent);
  box-shadow: 0 0 0 3px var(--noo-accent-subtle);
}

/* Tables */
.noo-table {
  width: 100%;
  border-collapse: collapse;
}

.noo-table th,
.noo-table td {
  padding: var(--noo-space-md);
  text-align: left;
  border-bottom: 1px solid var(--noo-border-muted);
}

.noo-table th {
  background: var(--noo-surface-sunken);
  font-weight: var(--noo-font-weight-semibold);
  color: var(--noo-text-muted);
  font-size: var(--noo-font-size-sm);
}

.noo-table tbody tr:hover {
  background: var(--noo-surface-sunken);
}
