/* Layout CSS - extracted from layout.pug for CSP compliance */

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

html {
  min-height: 100dvh;
}

/* =====================================================
   Accessibility Utilities (Phase 7.3)
   ===================================================== */

/* Screen reader only - visually hidden but accessible */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip to main content link */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  background: var(--color-primary-600);
  color: white;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  z-index: 9999;
  text-decoration: none;
  font-weight: var(--font-semibold);
}

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

/* Reduced motion preference */
@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;
  }
}

/* High contrast focus indicator for accessibility */
.focus-visible:focus,
[data-focus-visible-added] {
  outline: 2px solid var(--color-primary-500);
  outline-offset: 2px;
}

/* =====================================================
   End Accessibility Utilities
   ===================================================== */

body {
  font-family: var(--font-family);
  line-height: var(--line-height);
  margin: 0 auto;
  color: var(--text-color);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  --banner-height: 0px;
}

body.has-banner {
  --banner-height: 53px;
}

.error {
  color: var(--error-color);
  background-color: var(--error-bg);
  padding: 10px;
  border-left: 4px solid var(--error-color);
  margin: 10px 0;
}

.bold {
  font-weight: bold;
}

.italic {
  font-style: italic;
}

table {
  width: 100%;
  border-collapse: collapse;
  /*margin: 20px 0;*/
}

table th {
  background-color: var(--doc-primary-color, var(--primary-color));
  color: white;
  padding: 12px;
  text-align: left;
}

table td {
  padding: 10px;
  border: 1px solid var(--border-color);
}

table tr:nth-child(even) {
  background-color: #f9f9f9;
}

.table-notes {
  font-size: 0.9em;
  color: #666;
  margin-top: 5px;
}

/* Section h2 styling for non-document pages (form, home, etc.)
   Document pages use scoped brand colors via /css/document.css */
.section h2 {
  color: var(--doc-primary-color, var(--primary-color));
}

/* Only underline the first h2 (section heading), not nested sub-headings */
.section > h2:first-child {
  border-bottom: 2px solid var(--doc-primary-color, var(--primary-color));
  padding-bottom: 5px;
}

ul, ol {
  margin: 14px 0;
}

li {
  margin-bottom: 6px;
}
li:last-child {
  margin-bottom: 0;
}

.nested-list {
  margin: 14px 0;
}

.section p {
  margin-bottom: var(--paragraph-spacing);
}
.section p:last-child {
  margin-bottom: 0;
}

.section h2 + p {
  font-size: 1.05em;
  color: #4b5563;
  margin-top: 0;
}

.section h3 + p,
.section h4 + p {
  margin-top: 0;
}

.debug-info {
  background-color: #f0f8ff;
  border-left: 4px solid #4a90e2;
  padding: 8px 12px;
  margin: 15px 0;
  border-radius: 2px;
  position: relative;
}

/* Minimal padding when collapsed */
.debug-info.collapsed {
  padding: 6px 12px;
}

/* Clickable header */
.debug-header {
  font-weight: bold;
  color: #4a90e2;
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  user-select: none;
  margin-bottom: 10px;
}

/* Collapsed header has no bottom margin */
.debug-info.collapsed .debug-header {
  margin-bottom: 0;
}

/* Arrow indicator (expanded state) */
.debug-header::before {
  content: "\25BC ";
  margin-right: 5px;
}

/* Arrow indicator (collapsed state) */
.debug-info.collapsed .debug-header::before {
  content: "\25B6 ";
}

/* Header text */
.debug-header::after {
  content: "Debug Information";
}

/* Hide content when collapsed */
.debug-info.collapsed .debug-content {
  display: none;
}

/* Content spacing */
.debug-content p,
.debug-content table,
.debug-content ul,
.debug-content .nested-list {
  margin-top: 0;
}

/* ============================================
   Utility Classes (replacing beer.css)
   ============================================ */

/* Header styling */
header.site-header {
  background: var(--gradient-primary);
  color: var(--color-text-inverse);
  padding: var(--space-3) var(--space-6);
  box-shadow: 0 2px 8px rgba(33, 35, 73, 0.25);
  position: relative;
  z-index: 1;
}

/* Subtle bottom accent line */
header.site-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.2) 50%,
    rgba(255, 255, 255, 0) 100%
  );
}

header.site-header nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  margin: 0 auto;
}

header.site-header a {
  color: var(--color-text-inverse);
  text-decoration: none;
}

/* Logo container */
header.site-header a.header-logo {
  display: flex;
  align-items: center;
}

.header-logo-img {
  height: 32px;
  width: auto;
  transition: opacity var(--duration-moderate) var(--ease-out);
}

header.site-header a.header-logo:hover .header-logo-img {
  opacity: 0.85;
}

/* Centered navigation links */
.header-nav {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: var(--space-10);
}

.nav-link {
  color: var(--color-text-inverse);
  font-weight: var(--font-medium);
  font-size: var(--text-sm);
  text-decoration: none;
  opacity: 0.85;
  transition: opacity var(--duration-fast) var(--ease-out);
  letter-spacing: var(--tracking-wide);
}

.nav-link:hover,
.nav-link.active {
  opacity: 1;
}

/* #580: on phones the absolutely-centered nav overflowed the viewport and
   pushed Logout off-screen. Below 768px the logo + logout share the first
   row and the nav links wrap onto their own centered full-width row. */
@media (max-width: 768px) {
  header.site-header {
    padding: var(--space-2) var(--space-3);
  }

  header.site-header nav {
    flex-wrap: wrap;
    row-gap: var(--space-2);
  }

  .header-nav {
    position: static;
    transform: none;
    order: 3;
    flex-basis: 100%;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-4) var(--space-5);
  }

  /* #666: 44px tap targets (Apple HIG / WCAG 2.5.8) across the whole
     stacked-header range - the nav stacks below 768px, not 640px */
  .nav-link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 0 var(--space-2);
  }

  /* #678: the logout icon button must also meet the 44px minimum */
  header.site-header .logout-btn {
    width: 44px;
    height: 44px;
  }
}

/* Header login button (for unauthenticated users) */
header.site-header button {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-4);
  font-weight: var(--font-medium);
  backdrop-filter: blur(4px);
  transition: var(--transition-interactive), background-color var(--duration-fast) var(--ease-out);
}

header.site-header button:hover {
  background: rgba(255, 255, 255, 0.25);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

header.site-header button:active {
  box-shadow: none;
}

/* Logout form and button (must come after generic button to override) */
.logout-form {
  display: flex;
  margin: 0;
}

header.site-header .logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  color: var(--color-text-inverse);
  cursor: pointer;
  transition: var(--transition-interactive);
}

header.site-header .logout-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Header mobile responsive */
@media (max-width: 640px) {
  header.site-header {
    padding: var(--space-3) var(--space-4);
  }

  header.site-header nav {
    gap: var(--space-3);
  }

  header.site-header h5 {
    font-size: 1.15rem;
  }

  .logo-icon {
    width: 32px;
    height: 32px;
  }

  .logo-icon svg {
    width: 16px;
    height: 16px;
  }

  header.site-header a.header-logo {
    gap: var(--space-2);
  }

  .header-nav {
    position: static;
    transform: none;
    gap: var(--space-4);
  }

  .nav-link {
    font-size: var(--text-xs);
  }

  /* #678: keep 44px touch target (this block follows the 768px one in the
     cascade, so a smaller size here would win below 640px) */
  header.site-header .logout-btn {
    width: 44px;
    height: 44px;
  }

  header.site-header .logout-btn svg {
    width: 16px;
    height: 16px;
  }

  header.site-header button {
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-sm);
  }
}

/* Flex spacer - takes remaining space */
.flex-grow {
  flex-grow: 1;
}

/* Main content */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Main content container */
main.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
  width: 100%;
}

/* Text size utilities */
.text-small {
  font-size: 0.875rem;
}

.text-large {
  font-size: 1.25rem;
}

/* Display utilities */
.inline {
  display: inline;
}

/* Flex row */
.flex-row {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1rem;
}

/* Text alignment */
.text-center {
  text-align: center;
}

/* Padding utilities */
.padding-large {
  padding: 3rem 1rem;
}

/* Article container */
article.content-box {
  max-width: 600px;
  margin: 2rem auto;
  padding: 2rem;
}

/* Form field styling */
.form-field {
  /*margin-bottom: 1rem;*/
}

.form-field label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: var(--font-weight-medium);
  color: var(--text-color);
}

.form-field input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 1rem;
  box-sizing: border-box;
}

.form-field input:focus {
  outline: none;
  border-color: var(--primary-color);
}

/* Footer styling */
footer {
  flex-shrink: 0;
  margin-top: var(--space-8);
  padding: 0;
  background: var(--gradient-subtle);
  border-top: 3px solid var(--color-primary-500);
}

.footer-content {
  padding: var(--space-3) var(--space-4);
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  gap: var(--space-4);
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  justify-self: start;
}

.footer-logo {
  font-weight: var(--font-bold);
  font-size: var(--text-base);
  color: var(--color-primary-600);
  letter-spacing: var(--tracking-wide);
}

.footer-tagline {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  padding-left: var(--space-3);
  border-left: 1px solid var(--color-border-default);
}

.footer-copyright {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  justify-self: center;
}

.footer-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  justify-self: end;
}

.footer-link {
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  transition: color var(--duration-fast) var(--ease-out);
}

.footer-link:hover {
  color: var(--color-primary-600);
}

.footer-version {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: var(--font-medium);
  background: rgba(0, 0, 0, 0.04);
  padding: 0.125rem var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--color-text-tertiary);
}

/* Footer mobile responsive */
@media (max-width: 640px) {
  footer {
    margin-top: var(--space-4);
  }

  .footer-content {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-1);
    text-align: center;
    padding: var(--space-2) var(--space-3);
  }

  .footer-brand {
    grid-column: 1 / -1;
    grid-row: 1;
    justify-self: center;
    flex-direction: row;
  }

  .footer-tagline {
    display: none;
  }

  .footer-copyright {
    grid-row: 2;
    grid-column: 1;
    justify-self: start;
  }

  .footer-right {
    grid-row: 2;
    grid-column: 2;
    justify-self: end;
  }

  .footer-version {
    display: none;
  }
}

/* Field hint for forms */
.field-hint {
  font-size: 0.8rem;
  color: #666;
  margin-top: 0.25rem;
}

/* Login form article container */
article.auth-form {
  max-width: 400px;
  margin: 2rem auto;
  padding: 2rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

/* Action Card - sleek call-to-action */
.action-card {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-5) var(--space-6);
  margin-bottom: var(--space-6);
  background: var(--gradient-primary);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--color-text-inverse);
  box-shadow: var(--shadow-md), var(--shadow-primary-md);
  transition: var(--transition-interactive);
  max-width: 400px;
}

.action-card:hover {
  box-shadow: var(--shadow-lg), var(--shadow-primary-lg);
}

.action-card:active {
  box-shadow: var(--shadow-sm), var(--shadow-primary-sm);
}

.action-card-icon {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(4px);
}

.action-card-icon svg {
  width: 1.5rem;
  height: 1.5rem;
}

.action-card-content {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.action-card-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  letter-spacing: var(--tracking-wide);
}

.action-card-desc {
  font-size: var(--text-sm);
  opacity: 0.85;
}

/* ============================================
   Dashboard Layout
   ============================================ */

.dashboard {
  max-width: 1000px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-6);
}

.dashboard-hero {
  margin-bottom: var(--space-10);
}

.dashboard-hero .action-card {
  max-width: 480px;
}

.dashboard-section {
  /* Full width for projects */
}

/* Section header with count badge */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-bottom: var(--space-2);
  padding-bottom: var(--space-3);
}

.section-title {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: 0;
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--color-primary-600);
}

.section-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 var(--space-2);
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text-secondary);
}

.section-controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ============================================
   Section Tabs (Home page Current/Finalized toggle)
   ============================================ */

.section-tabs {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.section-tab:first-child::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--color-border-light);
}

.section-tab:first-child {
  position: relative;
  padding-right: var(--space-4);
}

.section-tab {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: none;
  border: none;
  padding: 0;
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--color-text-disabled);
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-out);
}

.section-tab:hover:not(.active) {
  color: var(--color-primary-600);
}

.section-tab.active {
  color: var(--color-primary-600);
  cursor: default;
}

.section-tab .section-count {
  font-size: var(--text-sm);
}

/* ============================================
   Premium Search Input
   ============================================ */

.search-container {
  position: relative;
  width: 100%;
  max-width: 300px;
}

.search-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-disabled);
  pointer-events: none;
  transition: color var(--duration-normal) var(--ease-out);
}

.search-input {
  width: 100%;
  padding: var(--space-2) var(--space-4) var(--space-2) 2.75rem;
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  background: var(--color-bg-secondary);
  color: var(--color-text-primary);
  transition: all var(--duration-moderate) var(--ease-out);
}

.search-input::placeholder {
  color: var(--color-text-disabled);
}

.search-input:hover:not(:focus) {
  border-color: var(--color-border-medium);
}

.search-input:focus {
  outline: none;
  border-color: var(--color-primary-500);
  background: var(--color-bg-primary);
  box-shadow: var(--shadow-focus);
}

.search-input:focus + .search-icon,
.search-input:not(:placeholder-shown) + .search-icon {
  color: var(--color-primary-500);
}

/* ============================================
   Project Cards Grid
   ============================================ */

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(410px, 1fr));
  gap: var(--space-4);
}

.project-card {
  position: relative;
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm), var(--shadow-primary-sm);
  transition: var(--transition-interactive), border-color var(--duration-moderate) var(--ease-out);
}

a.project-card {
  display: block;
  text-decoration: none;
  color: inherit;
}

.project-card:hover {
  box-shadow: var(--shadow-md), var(--shadow-primary-md);
  border-color: var(--color-primary-200);
}

.project-card-icon {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-primary);
  border-radius: var(--radius-md);
  color: var(--color-text-inverse);
}

.project-card-icon svg {
  width: 1.25rem;
  height: 1.25rem;
}

.project-card-description {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-3);
  line-height: var(--leading-relaxed);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.project-card-stats {
  display: flex;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.project-card-stat {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
}

.project-card-stat svg {
  width: 0.875rem;
  height: 0.875rem;
  opacity: 0.7;
}

.project-card-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  margin-bottom: var(--space-3);
}

.project-card-header-content {
  flex: 1;
  min-width: 0;
}

.project-card-name {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--color-text-primary);
  margin: 0;
  line-height: var(--leading-normal);
  word-wrap: break-word;
  overflow-wrap: break-word;
  letter-spacing: var(--tracking-wide);
  transition: color var(--duration-moderate) var(--ease-out);
}

.project-card:hover .project-card-name {
  color: var(--color-primary-600);
}

.project-card-date {
  display: block;
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  margin-top: var(--space-1);
}

.project-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border-light);
}

.project-card-actions .btn {
  display: inline-flex;
  width: auto;
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-xs);
}

/* ============================================
   Empty State
   ============================================ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-16) var(--space-8);
  max-width: 400px;
  margin: 0 auto;
}

.empty-state-illustration {
  width: 120px;
  height: 120px;
  margin-bottom: var(--space-6);
  color: var(--color-border-medium);
}

.empty-state-title {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--color-text-primary);
  margin: 0 0 var(--space-2) 0;
}

.empty-state-description {
  font-size: var(--text-base);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
  margin: 0 0 var(--space-6) 0;
}

.empty-state-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  background: var(--gradient-primary);
  color: var(--color-text-inverse);
  border-radius: var(--radius-lg);
  text-decoration: none;
  font-weight: var(--font-medium);
  box-shadow: var(--shadow-primary-md);
  transition: var(--transition-interactive);
}

.empty-state-cta:hover {
  box-shadow: var(--shadow-primary-lg);
}

/* Dashboard mobile responsive */
@media (max-width: 640px) {
  .dashboard {
    padding: var(--space-4);
  }

  .dashboard-hero .action-card {
    max-width: 100%;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .search-container {
    max-width: 100%;
  }

  .projects-grid {
    grid-template-columns: 1fr;
  }

  .empty-state {
    padding: var(--space-8) var(--space-4);
  }
}

/* ============================================
   Phase 6: Polish & Micro-interactions
   ============================================ */

/* Card fade-in animation */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.project-card {
  animation: fadeInUp var(--duration-slow) var(--ease-out) forwards;
  opacity: 0;
}

/* Staggered animation for cards */
.project-card:nth-child(1) { animation-delay: 0ms; }
.project-card:nth-child(2) { animation-delay: 50ms; }
.project-card:nth-child(3) { animation-delay: 100ms; }
.project-card:nth-child(4) { animation-delay: 150ms; }
.project-card:nth-child(5) { animation-delay: 200ms; }
.project-card:nth-child(6) { animation-delay: 250ms; }
.project-card:nth-child(n+7) { animation-delay: 300ms; }

/* Focus states for accessibility */
a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.project-card:focus-within {
  box-shadow: var(--shadow-md), var(--shadow-focus);
  border-color: var(--color-primary-500);
}

.action-card:focus-visible {
  box-shadow: var(--shadow-lg), var(--shadow-primary-lg), var(--shadow-focus);
}

.empty-state-cta:focus-visible {
  box-shadow: var(--shadow-primary-lg), var(--shadow-focus);
}

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

/* Print styles */
@media print {
  header.site-header,
  footer,
  .search-container,
  .action-card,
  .empty-state-cta {
    display: none;
  }

  .dashboard {
    padding: 0;
    max-width: 100%;
  }

  .project-card {
    box-shadow: none;
    border: 1px solid #ddd;
    break-inside: avoid;
    animation: none;
    opacity: 1;
  }

  .projects-grid {
    display: block;
  }

  .project-card + .project-card {
    margin-top: 1rem;
  }
}

/* ================================
   Organisation Styles
   ================================ */

/* Organisation section styling */
.org-section {
  border-left: 3px solid var(--color-primary-500);
  padding-left: var(--space-4);
  margin-bottom: var(--space-8);
}

.org-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.org-icon {
  color: var(--color-primary-500);
  flex-shrink: 0;
}


.project-card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-1);
}

.finalized-count {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-success-600, #16a34a);
}

.finalized-count svg {
  width: 12px;
  height: 12px;
}

.badge-protected {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  color: var(--color-warning-700, #b45309);
  font-size: var(--text-xs);
  border-radius: var(--radius-full);
}

.badge-protected svg {
  width: 12px;
  height: 12px;
}

/* Dashboard sidebar for organisations */
.dashboard-sidebar {
  position: fixed;
  z-index: 1;
  right: var(--space-4);
  top: calc(64px + var(--space-4));
  width: 200px;
  background: var(--color-bg-primary);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
}

.sidebar-title {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 var(--space-3) 0;
}

.org-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.org-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  text-decoration: none;
  font-size: var(--text-sm);
  transition: var(--transition-interactive);
}

.org-link:hover {
  background: var(--color-bg-secondary);
  color: var(--color-primary-600);
}

.org-link-icon {
  color: var(--color-text-tertiary);
  flex-shrink: 0;
}

/* #606: long unbroken names (raw emails, long company names) truncate with an
   ellipsis instead of forcing a horizontal scrollbar on the sidebar */
.org-link-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


.org-link.active {
  background: var(--color-primary-50);
  color: var(--color-primary-600);
}


.org-nav-count {
  margin-left: auto;
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  background: var(--color-bg-tertiary);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  font-weight: var(--font-medium);
}

/* Role-based icon tinting for workspace ownership */
.org-link-icon.role-owner {
  color: var(--color-warning-500, #f59e0b);
}

.org-link-icon.role-admin {
  color: var(--color-primary-500);
}


/* Responsive: hide sidebar on smaller screens */
@media (max-width: 1200px) {
  .dashboard-sidebar {
    display: none;
  }
}

/* ============================================
   Fullscreen Dashboard (Two-Panel Layout)
   ============================================ */

/* Dashboard becomes flex container when inside fullscreen */
.page-container--fullscreen .dashboard {
  display: flex;
  max-width: none;
  padding: 0;
  gap: 0;
}

/* Sidebar becomes left panel (was fixed right) */
.page-container--fullscreen .dashboard-sidebar {
  display: flex;
  flex-direction: column;
  position: static;
  width: 280px;
  min-width: 240px;
  flex-shrink: 0;
  border-right: 1px solid var(--color-border-default);
  border-radius: 0;
  padding: var(--space-6);
  overflow-y: auto;
  box-shadow: none;
  min-height: calc(100dvh - 196px - var(--banner-height, 0px));
}

/* Push sidebar footer link to bottom */
.page-container--fullscreen .sidebar-footer-link {
  margin-top: auto;
}

/* Main content area (right panel) */
.dashboard-main {
  flex: 1;
  min-width: 0;
  padding: var(--space-6);
  overflow-y: auto;
  max-height: calc(100vh - 60px - var(--banner-height, 0px));
}

/* FOUC prevention: hide containers during workspace restore */
.dashboard-main.workspace-loading .projects-container,
.dashboard-main.workspace-loading .reports-container {
  opacity: 0;
  transition: none;
}

/* Pause card animations so they play after workspace is resolved */
.dashboard-main.workspace-loading .project-card {
  animation-play-state: paused;
}

/* Mobile toggle button - hidden on desktop */
.sidebar-mobile-toggle {
  display: none;
}

/* Truncate long workspace names in toggle */
.sidebar-mobile-active {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* Responsive: stack on tablet/mobile */
@media (max-width: 768px) {
  .page-container--fullscreen .dashboard {
    flex-direction: column;
  }

  .page-container--fullscreen .dashboard-sidebar {
    width: 100%;
    min-width: 100%;
    height: auto;
    max-height: none;
    min-height: auto;
    border-right: none;
    border-bottom: 1px solid var(--color-border-default);
    padding: var(--space-4);
  }

  /* Show mobile toggle, hide desktop title */
  .page-container--fullscreen .sidebar-mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: var(--space-2) var(--space-3);
    min-height: 44px;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--color-text-primary);
  }

  .page-container--fullscreen .sidebar-title {
    display: none;
  }

  /* Collapsed state: hide org list only (NOT sidebar-footer-link) */
  .page-container--fullscreen .dashboard-sidebar.sidebar-collapsed .org-list {
    display: none;
  }

  /* Chevron rotation when collapsed */
  .page-container--fullscreen .dashboard-sidebar.sidebar-collapsed .sidebar-toggle-chevron {
    transform: rotate(-90deg);
  }

  .sidebar-toggle-chevron {
    transition: transform var(--duration-moderate) var(--ease-out);
    flex-shrink: 0;
  }

  /* Collapsed sidebar */
  .page-container--fullscreen .dashboard-sidebar.sidebar-collapsed {
    min-height: auto;
    gap: 8px;
  }

  .dashboard-main {
    height: auto;
    max-height: none;
    padding: var(--space-4);
  }
}

/* Report limit message - full-width alert banner below section header */
.limit-message {
  display: block;
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-warning-700);
  background: var(--color-warning-50);
  border: 1px solid var(--color-warning-100);
  border-radius: var(--radius-md);
  font-weight: var(--font-medium);
}

.limit-message.hidden {
  display: none;
}

/* Report usage indicator - shows remaining/total between header and limit banner */
.report-usage {
  font-size: var(--text-sm);
  color: color-mix(in srgb, var(--primary-color) 60%, transparent);
  padding: var(--space-1) 0;
  margin-bottom: 6px;
  text-align: center;
}

.report-usage strong {
  color: var(--primary-color);
  font-weight: var(--font-bold);
}

/* Responsive: adjust org sections on mobile */
@media (max-width: 640px) {
  .org-section {
    padding-left: var(--space-3);
    border-left-width: 2px;
  }

  .section-controls {
    flex-wrap: wrap;
  }

  .section-controls .btn-sm {
    flex: 1;
    text-align: center;
  }

  .section-controls #create-report-btn {
    flex: 1;
    text-align: center;
  }
}
