/* Import Inter font from Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

/**
 * Linear Projects Viewer - Stylesheet
 *
 * Design: CLI/terminal aesthetic with monospace fonts and box-drawing characters.
 * Theme: Light mode with clean, minimal colors.
 * Layout: Single-column, max 120ch wide for readability.
 */

/* =============================================================================
   CSS Custom Properties (Theme Colors)
   =============================================================================
   Using CSS variables for consistent theming and easy customization.
   - bg/fg: Background and foreground (text) colors
   - fg-dim: Muted text for secondary information
   - green/yellow/blue: Status and accent colors matching Linear's palette
*/
:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --fg-dim: #666666;
  --fg-vdim: #eeeeee;  /* Very dim - box-drawing characters, structural elements */
  --green: #16a085;    /* Completed status */
  --yellow: #d4a600;   /* In-progress status */
  --blue: #2563eb;     /* Links and project headers */
  --red: #cc0000;      /* Danger actions (remove) */
  --red-hover: #990000;

  /* Font families: Separate structural (monospace) from content (readable) */
  --font-structural: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  --font-content: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* =============================================================================
   Base Reset & Typography
   ============================================================================= */
* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  overflow-x: hidden;
}

/* Terminal-style typography: structural base is monospace for alignment */
body {
  font-family: var(--font-structural);
  font-size: 16px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--fg);
  padding: 2rem;
  max-width: 120ch;  /* Optimal reading width */
  overflow-x: hidden;
  width: 100%;
}

/* =============================================================================
   Header Layout
   ============================================================================= */
header {
  text-align: center;
  margin-bottom: 2rem;
}

h1 {
  color: var(--fg);
  font-weight: normal;
  font-family: var(--font-content);
}

/* =============================================================================
   Navigation Bar
   =============================================================================
   Text-based navigation with label: value pattern.
   Filters (workspace, team) on left, actions (reset, logout) on right.
*/
.nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem 2ch;
}

.nav-filters {
  display: flex;
  align-items: baseline;
  gap: 2ch;
  flex-wrap: wrap;
}

.nav-item {
  display: flex;
  align-items: baseline;
  gap: 0.5ch;
}

.nav-label {
  color: var(--fg-dim);
  font-family: var(--font-content);
  font-size: 0.9em;
}

.nav-value {
  background: none;
  border: none;
  padding: 0;
  font-family: var(--font-content);
  font-size: 0.9em;
  color: var(--fg);
  cursor: pointer;
}

.nav-value:hover {
  color: var(--blue);
}

.nav-value[aria-expanded="true"] {
  color: var(--blue);
}

.nav-actions {
  display: flex;
  align-items: baseline;
  gap: 1.5ch;
}

.nav-action {
  color: var(--fg-dim);
  text-decoration: none;
  font-size: 0.9em;
  font-family: var(--font-content);
}

.nav-action:hover {
  color: var(--fg);
}

/* =============================================================================
   Options Panel (appears below nav bar when selector is expanded)
   ============================================================================= */
.nav-options-panel {
  padding: 0.5rem 0;
  margin-left: 3ch;  /* Indent for visual containment */
  margin-bottom: 0.5rem;
  max-width: 30ch;  /* Keep compact on desktop */
}

.nav-options-panel.hidden {
  display: none;
}

.nav-options-row {
  display: flex;
  align-items: baseline;
  gap: 0.5ch;
}

.option-prefix {
  color: var(--fg-vdim);
  white-space: pre;
  flex-shrink: 0;
}

.nav-option-form {
  display: contents;
}

.nav-option {
  background: none;
  border: none;
  padding: 0;
  font-family: var(--font-content);
  font-size: 0.9em;
  color: var(--fg);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: baseline;
  gap: 0.25ch;
}

.nav-option:hover {
  color: var(--blue);
}

.nav-option.selected {
  font-weight: 500;
}

.option-marker {
  color: var(--blue);
  font-size: 0.85em;
}

.option-marker-placeholder {
  display: inline-block;
  width: 1.1ch;  /* Same width as marker */
}

.nav-option-add {
  color: var(--fg-dim);
}

.nav-option-danger {
  margin-left: auto;  /* Right-align remove button */
  color: var(--red);
}

.nav-option-danger:hover {
  color: var(--red-hover);
}

/* =============================================================================
   "In Progress" Section
   =============================================================================
   Displays all in-progress issues across projects in a single collapsible list.
   Yellow accent color matches Linear's "started" state.
*/
.in-progress-section {
  margin-bottom: 2.5rem;
}

.in-progress-header {
  color: var(--yellow);
  font-weight: 600;
  cursor: pointer;
  padding: 0.5rem 0;
  font-family: var(--font-content);
}

/* Project name badge shown after issue title in In Progress section */
.in-progress-project {
  color: var(--fg-dim);
  margin-left: 1ch;
  font-size: 0.9em;
  font-family: var(--font-content);
}

/* =============================================================================
   Project Sections
   =============================================================================
   Each project is a collapsible section with header, description, and issue tree.
*/
.project {
  margin-bottom: 2.5rem;
  overflow: hidden;
}

.project-header {
  color: var(--blue);
  font-weight: 600;
  cursor: pointer;
  padding: 0.5rem 0;
  font-family: var(--font-content);
}

.project-description {
  color: var(--fg-dim);
  margin-left: 3ch;  /* Indent under project header */
  margin-bottom: 0.5rem;
  word-wrap: break-word;
  overflow-wrap: break-word;
  cursor: pointer;
  font-family: var(--font-content);
}

.project-description:hover {
  color: var(--fg);
}

.desc-toggle {
  background: none;
  border: none;
  color: var(--blue);
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  padding: 0;
}

.desc-toggle:hover {
  text-decoration: underline;
}

/* =============================================================================
   Issue Tree Lines
   =============================================================================
   Each issue is rendered as a "line" with:
   - prefix: Box-drawing characters (├─ └─ │) showing tree structure
   - state: Status indicator (✓ ◐ ○)
   - title: Issue title (clickable to expand details)
   - toggle: Collapse/expand arrow for parent issues
*/
.line {
  display: flex;
  align-items: baseline;
  min-height: 1.6em;
  padding: 4px 0;
}

/* Parent items (with children) get bolder weight for visual hierarchy */
.line.has-children .title {
  font-weight: 500;
}

/* Box-drawing prefix (├─ └─ │) - preserves whitespace for alignment */
.prefix {
  color: var(--fg-vdim);
  white-space: pre;
  flex-shrink: 0;
}

/* Status indicators: ✓ (done), ◐ (in-progress), ○ (todo) */
.state {
  flex-shrink: 0;
  margin-right: 0.5ch;
}
.state.done { color: var(--green); }
.state.in-progress { color: var(--yellow); }
.state.todo { color: var(--fg-dim); }

/* Issue title - fills remaining space, wraps on overflow */
.title {
  flex: 1;
  min-width: 0;  /* Allow flex item to shrink below content size */
  word-wrap: break-word;
  overflow-wrap: break-word;
  font-family: var(--font-content);
}
.title.done { color: var(--fg-dim); }

/* Collapse/expand toggle arrow (▼/▶) */
.toggle {
  color: var(--fg);
  cursor: pointer;
  margin-left: 1ch;
  flex-shrink: 0;
  padding: 0.25rem 0.5rem;
  margin-right: -0.5rem;
  font-size: 0.85em;
}

.toggle:hover {
  color: var(--blue);
}

.detail-link {
  color: var(--blue);
  text-decoration: none;
  font-size: 0.9em;
  font-family: var(--font-content);
}

.detail-link:hover {
  text-decoration: underline;
}

.project-meta {
  color: var(--fg-dim);
  margin-left: 3ch;
  margin-bottom: 0.75rem;
  font-family: var(--font-content);
}

/* "Show N completed" toggle link */
.completed-toggle {
  color: var(--fg-dim);
  cursor: pointer;
  margin-left: 4ch;
  padding: 0.5rem 0;
  font-family: var(--font-content);
}

/* Utility class for hiding elements (used by JS for expand/collapse) */
.hidden { display: none !important; }

/* =============================================================================
   Node Container Structure
   =============================================================================
   Each issue is wrapped in a .node container that holds:
   - .line (the clickable row)
   - .details (expandable details panel)
   - .children (nested child nodes)
*/
.node {
  /* Structural container only */
}

/* Hover highlighting for issue groups */
.node:hover > .line {
  background-color: rgba(0, 0, 0, 0.02);
}

/* Children container for nested nodes */
.children {
  /* Structural container */
}

.child-count {
  color: var(--fg-dim);
  font-size: 12px;
  font-family: var(--font-content);
}

/* =============================================================================
   Expandable Items & Details Panel
   =============================================================================
   Clicking an issue line expands a details panel showing description,
   assignee, dates, labels, and Linear link.
*/
.line.expandable {
  cursor: pointer;
}

.line.expandable:hover .title {
  text-decoration: underline;
  text-decoration-color: var(--fg-dim);
  text-underline-offset: 2px;
}

/* Details panel shown when issue is expanded */
.details {
  line-height: 1.5;
  padding: 0.2rem 0;
  overflow: hidden;
}

.detail-line {
  display: flex;
  align-items: baseline;
}

.detail-text {
  color: var(--fg-dim);
  flex: 1;
  min-width: 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
  font-family: var(--font-content);
}

.detail-meta {
  color: var(--fg-dim);
  font-size: 0.9em;
  flex: 1;
  min-width: 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
  font-family: var(--font-content);
}

/* =============================================================================
   Responsive Breakpoints
   =============================================================================
   640px: Tablets and large phones - reduce padding, increase tap targets
   400px: Small phones - further reduce padding and font sizes
*/

/* Tablets and large phones */
@media (max-width: 640px) {
  body {
    padding: 1rem;
    font-size: 14px;
  }

  /* Nav bar stacks on mobile */
  .nav-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .nav-filters {
    flex-direction: column;
    gap: 0.5rem;
  }

  .nav-option {
    padding: 0.5rem 0;  /* Larger tap targets */
  }

  header {
    margin-bottom: 1.5rem;
  }

  h1 {
    font-size: 1.3rem;
  }

  /* Reduce vertical spacing on issue lines */
  .line {
    padding: 2px 0;
  }

  .project {
    margin-bottom: 2rem;
  }

  .in-progress-section {
    margin-bottom: 2rem;
  }

  .project-header {
    padding: 0.4rem 0;
  }

  .project-description {
    margin-bottom: 0.5rem;
  }

  /* Larger tap targets for touch devices (44px minimum recommended) */
  .toggle {
    padding: 0.5rem 0.75rem;
    margin: -0.5rem -0.75rem -0.5rem 0.5rem;
    font-size: 1rem;
  }

  .completed-toggle {
    margin-left: 3ch;
    padding: 0.5rem 0;
    display: block;
  }

  .details {
    padding-left: 1rem;
  }

  /* Disable hover underline on touch devices (no hover state) */
  .line.expandable:hover .title {
    text-decoration: none;
  }
}

/* Small phones */
@media (max-width: 400px) {
  body {
    padding: 0.75rem;
    font-size: 13px;
  }

  header {
    margin-bottom: 1rem;
  }

  h1 {
    font-size: 1.2rem;
  }

  .project {
    margin-bottom: 1.5rem;
  }

  .in-progress-section {
    margin-bottom: 1.5rem;
  }
}

/* =============================================================================
   Login Page (Landing Page CTA)
   =============================================================================
   Shown at the bottom of the landing page for unauthenticated users.
   Button uses Linear's brand purple color.
*/
.login-container {
  text-align: center;
  margin-top: 4rem;
}

.login-container p {
  color: var(--fg-dim);
  margin-bottom: 1.5rem;
  font-family: var(--font-content);
}

.login-button {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  background: #5e6ad2;  /* Linear's brand purple */
  color: white;
  text-decoration: none;
  border-radius: 4px;
  font-family: var(--font-content);
}

.login-button:hover {
  background: #4e5bc2;
}

/* =============================================================================
   Error Page
   =============================================================================
   Friendly error display for OAuth and other errors.
*/
.error-container {
  text-align: center;
  margin-top: 4rem;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.error-title {
  font-family: var(--font-content);
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--fg);
  margin-bottom: 1rem;
}

.error-message {
  color: var(--fg-dim);
  margin-bottom: 2rem;
  font-family: var(--font-content);
  line-height: 1.5;
}

.error-home-link {
  display: block;
  margin-top: 1rem;
  color: var(--fg-dim);
  font-family: var(--font-content);
  font-size: 0.9em;
}

.error-home-link:hover {
  color: var(--fg);
}
