/* ==========================================================================
   DevDeck — Design Tokens & Layout (aligned with assets/code.html prototype)
   ========================================================================== */

/* --- Custom Properties (Design Tokens) --- */
:root {
  --primary: #FF9020;
  --on-primary-container: #653300;
  --primary-container: #FF9020;
  --secondary: #00696D;
  --on-secondary: #FFFFFF;
  --on-secondary-container: #006e72;
  --tertiary: #4A6800;
  --on-tertiary: #FFFFFF;
  --surface: #FAF8FF;
  --surface-container: #ebedff;
  --surface-container-low: #f3f2ff;
  --surface-container-high: #E4E7FD;
  --surface-container-highest: #dee1f7;
  --surface-variant: #dee1f7;
  --background: #FAF8FF;
  --inverse-surface: #2c3040;
  --inverse-on-surface: #eff0ff;
  --neutral-dark: #242838;
  --on-surface: #171B2A;
  --on-surface-variant: #564335;
  --text-main: #171B2A;
  --text-muted: #564335;
  --border-subtle: rgba(36, 40, 56, 0.12);
  --error: #DD3C57;
  --on-error: #FFFFFF;
  --status-production-bg: #00696D;
  --status-production-text: #FFFFFF;
  --status-beta-bg: #FF9020;
  --status-beta-text: #653300;
  --status-mvp-bg: #4A6800;
  --status-mvp-text: #FFFFFF;
  --status-internal-bg: #E4E7FD;
  --status-internal-text: #171B2A;
  --status-archived-bg: #DCC1AF;
  --status-archived-text: #564335;
  --outline-variant: #DCC1AF;
  --gutter: 24px;
  --container-max: 1440px;
  --margin-desktop: 40px;
  --margin-mobile: 16px;
  --baseline: 4px;
  --radius-card: 4px;
  --radius-button: 0px;
  --radius-input: 0px;
  --focus-outline: 2px solid #FF9020;
  --focus-offset: 2px;
  --sidebar-width: 256px;
  --topbar-height: 64px;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-weight: 400;
  font-size: 14px;
  line-height: 20px;
  color: var(--text-main);
  background: var(--background);
  min-height: 100vh;
}

/* --- Material Symbols --- */
.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  vertical-align: middle;
  font-size: 20px;
}

/* --- Typography Classes --- */
.headline-sm {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-weight: 600; font-size: 20px; line-height: 28px; letter-spacing: 0em;
}
.headline-md {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-weight: 600; font-size: 24px; line-height: 32px; letter-spacing: -0.01em;
}
.headline-lg {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-weight: 700; font-size: 32px; line-height: 40px; letter-spacing: -0.01em;
}
.body-sm {
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 400; font-size: 14px; line-height: 20px;
}
.body-md {
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 400; font-size: 16px; line-height: 24px;
}
.label-sm {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 500; font-size: 12px; line-height: 14px;
}
.label-md {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 500; font-size: 14px; line-height: 16px;
}

/* --- Top Bar --- */
.top-bar {
  background: var(--inverse-surface);
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
}
.top-bar-inner {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--margin-desktop);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.top-bar-left {
  display: flex;
  align-items: center;
  gap: 32px;
}
.top-bar-brand {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-weight: 700;
  font-size: 24px;
  line-height: 32px;
  letter-spacing: -0.01em;
  color: #FFFFFF;
}
.top-bar-nav {
  display: none;
  gap: 24px;
}
@media (min-width: 768px) {
  .top-bar-nav { display: flex; }
}
.top-bar-link {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 500;
  font-size: 14px;
  line-height: 16px;
  color: var(--surface-variant);
  text-decoration: none;
  transition: color 0.2s;
  padding-bottom: 4px;
}
.top-bar-link:hover { color: var(--primary); }
.top-bar-link--active {
  color: var(--primary);
  border-bottom: 2px solid var(--primary);
}
.top-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  justify-content: flex-end;
  max-width: 560px;
}

/* --- Top Bar Search --- */
.top-bar-search {
  position: relative;
  width: 100%;
  max-width: 320px;
}
.top-bar-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--surface-variant);
  font-size: 20px;
}
.top-bar-search-input {
  width: 100%;
  background: rgba(0, 79, 82, 0.6);
  border: none;
  color: #FFFFFF;
  padding: 8px 16px 8px 40px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 20px;
  border-radius: 0;
}
.top-bar-search-input::placeholder { color: var(--surface-variant); }
.top-bar-search-input:focus {
  outline: none;
  box-shadow: inset 0 0 0 1px var(--primary);
}
.top-bar-filter-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 79, 82, 0.6);
  border: none;
  color: #FFFFFF;
  padding: 8px 16px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}
.top-bar-filter-btn:hover { background: var(--surface-variant); color: var(--on-surface); }
.top-bar-filter-btn .material-symbols-outlined { font-size: 18px; }
.top-bar-avatar {
  width: 32px;
  height: 32px;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.top-bar-avatar .material-symbols-outlined { color: var(--on-primary-container); font-size: 20px; }

/* --- App Layout --- */
.app-layout {
  display: flex;
  min-height: calc(100vh - var(--topbar-height));
}

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  left: 0;
  top: var(--topbar-height);
  height: calc(100vh - var(--topbar-height));
  width: var(--sidebar-width);
  background: var(--inverse-surface);
  display: none;
  flex-direction: column;
  z-index: 40;
}
@media (min-width: 1280px) {
  .sidebar { display: flex; }
}
.sidebar-cta { padding: 24px; }
.sidebar-new-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.sidebar-nav { flex: 1; }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  font-size: 14px;
  line-height: 16px;
  color: var(--surface-variant);
  text-decoration: none;
  transition: all 0.2s;
  border-left: 4px solid transparent;
}
.sidebar-link:hover {
  background: rgba(0, 79, 82, 0.4);
  color: var(--inverse-on-surface);
}
.sidebar-link--active {
  color: var(--primary);
  border-left-color: var(--primary);
  background: rgba(0, 79, 82, 0.4);
}
.sidebar-link--active .material-symbols-outlined {
  font-variation-settings: 'FILL' 1;
}
.sidebar-footer {
  padding: 24px;
  border-top: 1px solid rgba(222, 225, 247, 0.1);
}
.sidebar-version {
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-version-icon {
  width: 40px;
  height: 40px;
  background: rgba(0, 79, 82, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-version-icon .material-symbols-outlined { color: var(--primary); }
.sidebar-version-label {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  font-size: 14px;
  color: #FFFFFF;
}
.sidebar-version-status {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--surface-variant);
}

/* --- Main Content --- */
.main-content {
  flex: 1;
  padding: var(--margin-mobile);
}
@media (min-width: 768px) {
  .main-content { padding: var(--margin-desktop); }
}
@media (min-width: 1280px) {
  .main-content { margin-left: var(--sidebar-width); }
}
.main-inner {
  max-width: var(--container-max);
  margin: 0 auto;
}

/* --- Page Header --- */
.page-header {
  margin-bottom: 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
@media (min-width: 768px) {
  .page-header {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
  }
}
.page-title {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-weight: 700;
  font-size: 32px;
  line-height: 40px;
  letter-spacing: -0.01em;
  color: var(--on-surface);
  margin-bottom: 8px;
}
.page-subtitle {
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  line-height: 24px;
  color: var(--text-muted);
}
.page-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.page-sort-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-muted);
}
.page-sort-select {
  background: transparent;
  border: none;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  font-size: 14px;
  color: var(--on-surface);
  cursor: pointer;
  padding-right: 24px;
}

/* --- Filter Panel --- */
.filter-panel {
  margin-bottom: 24px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.filter-panel[hidden] { display: none; }
.filter-panel-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}
.filter-group { display: flex; align-items: center; gap: 8px; }
.filter-group--count { margin-left: auto; }
.filter-label {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  font-size: 12px;
  color: var(--text-muted);
}
.filter-select {
  border: 1px solid var(--border-subtle);
  border-radius: 0;
  padding: 6px 12px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text-main);
  background: #FFFFFF;
  min-width: 120px;
}
.filter-select--tags { min-height: 80px; min-width: 160px; }
.filter-select:focus { border-color: var(--primary); outline: none; }
.project-count {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  font-size: 12px;
  color: var(--text-muted);
}

/* --- Responsive Card Grid --- */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gutter);
}
@media (min-width: 640px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .card-grid { grid-template-columns: repeat(3, 1fr); }
}

/* --- Card --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 24px;
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
}
.card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}
.card-type-badge {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  font-size: 12px;
  line-height: 14px;
  padding: 4px 8px;
  background: rgba(0, 110, 114, 0.1);
  color: var(--on-secondary-container);
}
.card-status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  font-size: 12px;
  line-height: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.status-dot {
  width: 8px;
  height: 8px;
  display: inline-block;
}
.status-dot--production { background: var(--secondary); }
.status-dot--beta { background: var(--primary); }
.status-dot--mvp { background: var(--tertiary); }
.status-dot--internal { background: var(--surface-container-high); }
.status-dot--archived { background: var(--text-muted); }
.status-text--production { color: var(--secondary); }
.status-text--beta { color: var(--primary); }
.status-text--mvp { color: var(--tertiary); }
.status-text--internal { color: var(--text-muted); }
.status-text--archived { color: var(--text-muted); }
.card-name {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-weight: 600;
  font-size: 20px;
  line-height: 28px;
  color: var(--text-main);
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card:hover .card-name { color: var(--primary); }
.card-description {
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  font-size: 14px;
  line-height: 20px;
  color: var(--text-muted);
  margin-bottom: 24px;
  flex: 1;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* --- Tags --- */
.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}
.card-tags:empty { display: none; }
.tag-chip {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  font-size: 12px;
  line-height: 14px;
  padding: 4px 8px;
  background: var(--surface-container-low);
  border: 1px solid var(--border-subtle);
  color: var(--on-surface);
}
.card-actions { margin-top: auto; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-button);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  font-size: 14px;
  line-height: 16px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}
.btn-primary {
  background: var(--primary);
  color: var(--on-primary-container);
  width: 100%;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-secondary {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
  width: 100%;
}
.btn-secondary:hover {
  background: var(--primary);
  color: var(--on-primary-container);
}
.btn:disabled, .btn--disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
.btn .material-symbols-outlined { font-size: 18px; }

/* --- Error Card --- */
.card--error {
  border: 2px solid var(--error);
  position: relative;
  overflow: hidden;
}
.card--error::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(221, 60, 87, 0.05);
  pointer-events: none;
}
.card--error .card-header { position: relative; z-index: 1; }
.card--error .card-body-content { opacity: 0.5; position: relative; z-index: 1; }
.card--error .card-actions { position: relative; z-index: 1; }
.card--error .error-status {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 12px;
  color: var(--error);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.card--error .error-status .material-symbols-outlined { font-size: 16px; }
.card--error .btn {
  background: var(--surface-variant);
  color: var(--text-muted);
  cursor: not-allowed;
  pointer-events: none;
}

/* --- Inputs --- */
input, select {
  border-radius: var(--radius-input);
  border: 1px solid var(--border-subtle);
  padding: 8px 12px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 20px;
  color: var(--text-main);
  background: #FFFFFF;
}
input::placeholder { color: var(--text-muted); }
input:focus, select:focus { border-color: var(--primary); outline: none; }

/* --- Focus Indicators --- */
:focus-visible { outline: var(--focus-outline); outline-offset: var(--focus-offset); }

/* --- Stats Section --- */
.stats-section {
  margin-top: 64px;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gutter);
  border-top: 1px solid var(--border-subtle);
  padding-top: 32px;
}
@media (min-width: 640px) {
  .stats-section { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 768px) {
  .stats-section { grid-template-columns: repeat(4, 1fr); }
}
.stat-item {}
.stat-label {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.stat-value {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-weight: 600;
  font-size: 24px;
  line-height: 32px;
}
.stat-value--success { color: var(--tertiary); }
.stat-value--error { color: var(--error); }

/* --- Footer --- */
.site-footer {
  background: #FFFFFF;
  border-top: 1px solid var(--border-subtle);
  padding: 32px 0;
}
@media (min-width: 1280px) {
  .site-footer { margin-left: var(--sidebar-width); }
}
.footer-inner {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--margin-desktop);
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}
@media (min-width: 768px) {
  .footer-inner { flex-direction: row; justify-content: space-between; }
}
.footer-left { display: flex; align-items: center; gap: 24px; }
.footer-brand {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-weight: 700;
  font-size: 20px;
  color: var(--on-surface);
}
.footer-copy {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text-muted);
}
.footer-links { display: flex; gap: 32px; }
.footer-link {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text-muted);
  text-decoration: underline;
  transition: color 0.2s;
}
.footer-link:hover { color: var(--primary); }

/* --- Loading Spinner --- */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px var(--gutter);
  gap: 16px;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text-muted);
}

/* --- Empty State & Global Error --- */
.empty-state, .registry-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px var(--gutter);
  gap: 12px;
  text-align: center;
}
.empty-state-message, .registry-error-message {
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  font-size: 16px;
  line-height: 24px;
  color: var(--text-muted);
}

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