/* ==========================================================================
   Project Stopwatch — minimal flat UI
   Primary: Vermilion #E34234
   ========================================================================== */

:root {
  --vermilion: #e34234;
  --vermilion-hover: #c9362a;
  --vermilion-soft: rgba(227, 66, 52, 0.12);
  --vermilion-ring: rgba(227, 66, 52, 0.35);

  --bg: #f5f4f2;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --border: #e8e6e3;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-running: 0 2px 12px rgba(227, 66, 52, 0.15);

  --radius: 12px;
  --font: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  /* Keep the system arrow cursor so it stays visible on light backgrounds */
  cursor: default;
}

button,
input {
  font-family: inherit;
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

.app {
  width: min(640px, 100% - 2rem);
  margin: 0 auto;
  padding: 2.5rem 0 4rem;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.app-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.project-list {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.empty-state {
  margin: 3rem 0 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.empty-state[hidden],
.modal-overlay[hidden] {
  display: none !important;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.2;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
  color: var(--text);
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  white-space: nowrap;
  user-select: none;
}

.btn:focus-visible {
  outline: 2px solid var(--vermilion);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--vermilion);
  color: #fff;
  border-color: var(--vermilion);
}

.btn-primary:hover:not(:disabled) {
  background: var(--vermilion-hover);
  border-color: var(--vermilion-hover);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  border-color: #d0cdc8;
  background: #fafafa;
}

.btn-ghost {
  color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--border);
  color: var(--text);
}

.btn-danger {
  color: var(--vermilion);
  border-color: transparent;
  background: transparent;
}

.btn-danger:hover:not(:disabled) {
  background: var(--vermilion-soft);
}

.btn-icon {
  padding: 0.4rem 0.55rem;
  min-width: 2rem;
}

/* --------------------------------------------------------------------------
   Project card
   -------------------------------------------------------------------------- */

.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.125rem 1.25rem;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  gap: 0.75rem 0.75rem;
  align-items: center;
  transition: border-color 0.15s ease, box-shadow 0.15s ease,
    background 0.15s ease;
  cursor: default;
  touch-action: pan-y;
}

.project-card.running {
  border-color: rgba(227, 66, 52, 0.45);
  background: #fffaf9;
  box-shadow: var(--shadow-running);
}

.project-card.dragging {
  opacity: 0.55;
  box-shadow: none;
}

.project-card.drag-over {
  border-color: var(--vermilion);
  box-shadow: 0 0 0 2px var(--vermilion-ring);
}

.drag-handle {
  grid-row: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  width: 1.75rem;
  margin: -0.25rem 0 -0.25rem -0.25rem;
  padding: 0.35rem 0.2rem;
  border-radius: 8px;
  /* Darker grip so it stays visible on white / off-white cards */
  color: #4a4a4a;
  background: #eceae6;
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: -0.12em;
  user-select: none;
  line-height: 1;
  cursor: grab;
}

.drag-handle:hover {
  color: #1a1a1a;
  background: #e0ddd8;
}

.drag-handle:active,
.project-card.dragging .drag-handle {
  cursor: grabbing;
  color: var(--vermilion);
  background: var(--vermilion-soft);
}

.project-main {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.project-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-width: 0;
}

.project-name-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.project-name {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Pulsing vermilion indicator when running */
.status-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--vermilion);
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.project-card.running .status-dot {
  opacity: 1;
  transform: scale(1);
  animation: pulse-dot 1.4s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(227, 66, 52, 0.45);
    opacity: 1;
  }
  50% {
    box-shadow: 0 0 0 6px rgba(227, 66, 52, 0);
    opacity: 0.75;
  }
}

.elapsed {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  font-size: 1.375rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--text);
  line-height: 1;
}

.project-card.running .elapsed {
  font-weight: 700;
  color: var(--text);
}

.project-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
}

/* --------------------------------------------------------------------------
   Modal
   -------------------------------------------------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 26, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.modal {
  width: min(380px, 100%);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
  padding: 1.5rem;
}

.modal-title {
  margin: 0 0 1.25rem;
  font-size: 1.125rem;
  font-weight: 600;
}

.modal-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
}

.modal-input {
  width: 100%;
  padding: 0.625rem 0.75rem;
  font-size: 0.9375rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  margin-bottom: 1.25rem;
}

.modal-input:focus {
  outline: none;
  border-color: var(--vermilion);
  box-shadow: 0 0 0 3px var(--vermilion-ring);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 480px) {
  .app {
    width: min(100% - 1.5rem, 640px);
    padding-top: 1.5rem;
  }

  .app-title {
    font-size: 1.25rem;
  }

  .project-card {
    padding: 1rem;
  }

  .elapsed {
    font-size: 1.25rem;
  }

  .project-top {
    flex-direction: column;
    align-items: flex-start;
  }
}
