/* Home View */
#view-home {
  gap: var(--space-3);
}

/* Header */
.home-header {
  margin-bottom: var(--space-3);
}

/* Header Top - Horizontal Layout */
.header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-2);
  width: 100%;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow: hidden;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Header Actions */
.header-actions {
  display: flex;
  gap: 8px;
}

.header-btn,
.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast) var(--ease-out);
  font-size: 0.875rem;
}

.header-btn:hover,
.theme-toggle:hover {
  background-color: var(--bg-tertiary);
  transform: scale(1.05);
}

.theme-icon {
  font-size: 0.875rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: var(--font-light);
  margin-bottom: var(--space-1);
}

.date-display {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Streak Display - Pill Format */
.streak-display {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-lg);
  opacity: 0;
  transform: scale(0.9);
  transition: all var(--duration-normal) var(--ease-out);
}

.streak-display.active {
  opacity: 1;
  transform: scale(1);
}

.streak-flame {
  font-size: 0.875rem;
}

.streak-count {
  font-size: 0.875rem;
  font-weight: var(--font-medium);
  color: var(--text-primary);
}

.streak-label {
  display: none;
}

/* Home Widgets - Single line summary */
.home-widgets {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background-color: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin-top: var(--space-3);
  max-width: 100%;
  overflow: hidden;
}

.widget {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.widget-value {
  font-size: 1rem;
  font-weight: var(--font-medium);
  color: var(--text-primary);
}

.widget-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.widget-tip {
  flex: 1;
  text-align: right;
}

.widget-text {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.anchors-help {
  text-align: center;
  margin-top: var(--space-3);
  padding: 0 var(--space-2);
}

.anchors-prompt {
  font-style: italic;
  color: var(--text-subtle);
  font-size: 0.75rem;
  margin-bottom: var(--space-1);
}

.anchors-hint {
  font-size: 0.6875rem;
  color: var(--text-subtle);
  line-height: 1.5;
}

/* Anchors Container */
.anchors-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
  max-width: 100%;
  overflow: hidden;
}

/* Anchor Cards */
.anchor-card {
  background-color: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  grid-template-rows: auto auto;
  gap: var(--space-1) var(--space-2);
  align-items: center;
  transition: all var(--duration-normal) var(--ease-out);
  position: relative;
  overflow: hidden;
  max-width: 100%;
}

.anchor-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
}

.anchor-card[data-label="health"]::before { background-color: var(--accent-health); }
.anchor-card[data-label="wealth"]::before { background-color: var(--accent-wealth); }
.anchor-card[data-label="creativity"]::before { background-color: var(--accent-creative); }
.anchor-card[data-label="clarity"]::before { background-color: var(--accent-clarity); }
.anchor-card[data-label="exploration"]::before { background-color: var(--accent-exploration); }
.anchor-card[data-label="relationships"]::before { background-color: var(--accent-relationships); }

.anchor-card.completed {
  opacity: 0.7;
  background-color: var(--bg-tertiary);
}

.anchor-card.completed .anchor-text {
  color: var(--text-subtle);
}

/* Anchor Header - Grid positioning */
.anchor-header {
  display: contents;
}

.anchor-label {
  grid-column: 1;
  grid-row: 1;
}

.anchor-header .anchor-checkbox {
  grid-column: 2;
  grid-row: 1 / 3;
  align-self: center;
}

.anchor-header .anchor-delete {
  grid-column: 3;
  grid-row: 1 / 3;
  align-self: center;
}

.anchor-checkbox {
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--duration-fast) var(--ease-out);
}

.anchor-checkbox:hover {
  border-color: var(--text-primary);
}

.anchor-checkbox.checked {
  background-color: var(--text-primary);
  border-color: var(--text-primary);
}

.anchor-checkbox.checked::after {
  content: '✓';
  color: var(--bg-primary);
  font-size: 12px;
  font-weight: bold;
}

.anchor-label {
  font-size: 0.75rem;
  font-weight: var(--font-medium);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.anchor-card[data-label="health"] .anchor-label { color: var(--accent-health); }
.anchor-card[data-label="wealth"] .anchor-label { color: var(--accent-wealth); }
.anchor-card[data-label="creativity"] .anchor-label { color: var(--accent-creative); }
.anchor-card[data-label="clarity"] .anchor-label { color: var(--accent-clarity); }
.anchor-card[data-label="exploration"] .anchor-label { color: var(--accent-exploration); }
.anchor-card[data-label="relationships"] .anchor-label { color: var(--accent-relationships); }

.anchor-delete {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  color: var(--text-subtle);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all var(--duration-fast) var(--ease-out);
}

.anchor-card:hover .anchor-delete {
  opacity: 1;
}

.anchor-delete:hover {
  color: var(--text-primary);
  background-color: var(--bg-tertiary);
}

.anchor-text {
  grid-column: 1;
  grid-row: 2;
  width: 100%;
  min-width: 0;
  min-height: 24px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.5;
  resize: none;
  padding: 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.anchor-text::placeholder {
  color: var(--text-subtle);
}

.anchor-text:focus {
  outline: none;
}

/* Add Anchor Button */
.add-anchor-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  background-color: transparent;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.9375rem;
  min-height: 56px;
  margin-top: var(--space-2);
  transition: all var(--duration-normal) var(--ease-out);
  border: 2px dashed var(--text-subtle);
}

.add-anchor-btn:hover,
.add-anchor-btn:focus {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--text-primary);
}

.add-icon {
  font-size: 1.5rem;
  font-weight: var(--font-light);
}

/* Label Options Modal */
.label-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-3);
}

.label-option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9375rem;
  transition: all var(--duration-fast) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}

.label-option:hover {
  background-color: var(--bg-primary);
  transform: translateX(4px);
}

/* Focus styles - only show visible focus ring for keyboard users */
.label-option:focus {
  outline: none;
}

.label-option:focus-visible {
  box-shadow: 0 0 0 2px var(--text-muted);
  background-color: var(--bg-primary);
}

.label-icon {
  font-size: 1.25rem;
}

/* History Toggle & View */
.history-toggle {
  display: block;
  margin: var(--space-2) auto 0;
  padding: var(--space-1) var(--space-2);
  background: transparent;
  color: var(--text-subtle);
  font-size: 0.75rem;
  border: none;
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-out);
}

.history-toggle:hover {
  color: var(--text-muted);
}

.anchor-history {
  margin-top: var(--space-3);
  background-color: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  animation: slideDown var(--duration-normal) var(--ease-out);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
}

.history-header h3 {
  font-size: 0.875rem;
  font-weight: var(--font-medium);
  color: var(--text-muted);
}

.close-history {
  font-size: 1.25rem;
  color: var(--text-subtle);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
}

.close-history:hover {
  color: var(--text-primary);
}

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

.history-day {
  border-left: 2px solid var(--border-subtle);
  padding-left: var(--space-2);
}

.history-date {
  font-size: 0.75rem;
  color: var(--text-subtle);
  margin-bottom: var(--space-1);
}

.history-anchors {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-anchor {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 0.8125rem;
  color: var(--text-muted);
  padding: 4px 0;
}

.history-anchor.completed {
  opacity: 0.6;
}

.history-anchor.completed .history-anchor-text {
  text-decoration: line-through;
}

.history-anchor-label {
  font-size: 0.625rem;
  font-weight: var(--font-medium);
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
  background-color: var(--bg-tertiary);
}

.history-anchor[data-label="health"] .history-anchor-label { color: var(--accent-health); }
.history-anchor[data-label="wealth"] .history-anchor-label { color: var(--accent-wealth); }
.history-anchor[data-label="creativity"] .history-anchor-label { color: var(--accent-creative); }
.history-anchor[data-label="clarity"] .history-anchor-label { color: var(--accent-clarity); }
.history-anchor[data-label="exploration"] .history-anchor-label { color: var(--accent-exploration); }
.history-anchor[data-label="relationships"] .history-anchor-label { color: var(--accent-relationships); }

/* History Anchor Toggle Button */
.history-anchor-toggle {
  width: 16px;
  height: 16px;
  min-width: 16px;
  min-height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--text-subtle);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--duration-fast) var(--ease-out);
  padding: 0;
}

.history-anchor-toggle:hover {
  border-color: var(--text-muted);
  transform: scale(1.1);
}

.history-anchor-toggle:focus {
  outline: none;
}

.history-anchor-toggle:focus-visible {
  box-shadow: 0 0 0 2px var(--accent-primary);
}

.history-anchor-toggle.checked {
  background-color: var(--text-muted);
  border-color: var(--text-muted);
}

.history-anchor-toggle.checked::after {
  content: '';
  width: 6px;
  height: 6px;
  background-color: var(--bg-primary);
  border-radius: 50%;
}

.history-empty {
  text-align: center;
  color: var(--text-subtle);
  font-size: 0.8125rem;
  font-style: italic;
  padding: var(--space-2);
}

.label-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.label-desc {
  font-size: 0.75rem;
  color: var(--text-subtle);
  font-weight: var(--font-light);
}

/* Quick Thought Modal Content */
.quick-thought-content {
  max-width: 420px;
  text-align: center;
}

.quick-thought-content h3 {
  margin-bottom: var(--space-3);
  font-size: 1.125rem;
}

#quick-thought-input {
  width: 100%;
  padding: var(--space-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.9375rem;
  font-family: inherit;
  resize: none;
  margin-bottom: var(--space-3);
  text-align: left;
}

#quick-thought-input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

#quick-thought-input::placeholder {
  color: var(--text-subtle);
}

.quick-thought-tags {
  display: flex;
  justify-content: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}

.qt-tag-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 2px solid transparent;
  font-size: 1.25rem;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  display: flex;
  align-items: center;
  justify-content: center;
}

.qt-tag-btn:hover {
  background: var(--bg-secondary);
  transform: scale(1.05);
}

.qt-tag-btn.active {
  border-color: var(--accent-primary);
  background: var(--bg-secondary);
  transform: scale(1.1);
}

/* Quick Letter Modal Content */
.quick-letter-content {
  max-width: 420px;
}

.quick-letter-content h3 {
  margin-bottom: var(--space-3);
  font-size: 1.125rem;
  text-align: center;
}

#quick-letter-text {
  width: 100%;
  padding: var(--space-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.9375rem;
  font-family: inherit;
  resize: vertical;
  min-height: 120px;
  margin-bottom: var(--space-2);
}

#quick-letter-text:focus {
  outline: none;
  border-color: var(--accent-primary);
}

#quick-letter-text::placeholder {
  color: var(--text-subtle);
}

.quick-letter-content label {
  display: block;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: var(--space-1);
  margin-top: var(--space-1);
}

#quick-letter-date {
  width: 100%;
  padding: var(--space-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.9375rem;
  font-family: inherit;
}

#quick-letter-date:focus {
  outline: none;
  border-color: var(--accent-primary);
}

/* =============================================
   RESPONSIVE / MOBILE STYLES - HOME VIEW
   ============================================= */

/* Touch device detection - always show delete on touch */
@media (hover: none) and (pointer: coarse) {
  .anchor-delete {
    opacity: 0.4;
  }

  /* Active state feedback for touch */
  .anchor-card:active {
    transform: scale(0.99);
  }

  .anchor-checkbox:active {
    transform: scale(0.95);
  }

  .add-anchor-btn:active {
    transform: scale(0.98);
    background-color: var(--bg-tertiary);
  }

  /* Prevent stuck hover/focus states on label options */
  .label-option {
    -webkit-tap-highlight-color: transparent;
  }

  .label-option:hover,
  .label-option:focus {
    background-color: var(--bg-tertiary);
    transform: none;
    box-shadow: none;
  }

  .label-option:active {
    background-color: var(--bg-secondary);
  }

  .label-option:active {
    transform: scale(0.98);
    background-color: var(--bg-secondary);
  }

  .header-btn:active,
  .theme-toggle:active {
    transform: scale(0.92);
  }

  .qt-tag-btn:active {
    transform: scale(0.95);
  }

  .history-toggle:active {
    background-color: var(--bg-secondary);
  }
}

/* Tablet breakpoint */
@media (max-width: 768px) {
  .home-header {
    margin-bottom: var(--space-2);
  }

  .page-title {
    font-size: 1.375rem;
  }

  .anchors-help {
    padding: 0 var(--space-1);
  }

  .quick-thought-content,
  .quick-letter-content {
    max-width: calc(100vw - 32px);
  }
}

/* Phone breakpoint */
@media (max-width: 480px) {
  #view-home {
    gap: var(--space-1);
  }

  .home-widgets {
    gap: var(--space-2);
    padding: var(--space-2);
    flex-wrap: wrap;
  }

  .widget-value {
    font-size: 0.9375rem;
  }

  .widget-label {
    font-size: 0.6875rem;
  }

  .widget-tip {
    flex-basis: 100%;
    text-align: center;
  }

  .widget-text {
    font-size: 0.75rem;
  }

  .home-header {
    margin-bottom: var(--space-2);
  }

  /* Keep header horizontal on mobile but optimize spacing */
  .header-top {
    flex-direction: row;
    align-items: center;
    gap: var(--space-2);
  }

  .header-left {
    flex: 1;
    min-width: 0;
  }

  .header-right {
    flex-shrink: 0;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: nowrap;
  }

  /* Hide letter button on mobile - less essential */
  #quick-letter-btn {
    display: none;
  }

  .header-actions {
    gap: 4px;
  }

  /* Smaller header buttons on mobile */
  .header-btn,
  .theme-toggle {
    width: 32px;
    height: 32px;
    font-size: 0.8125rem;
  }

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

  .date-display {
    font-size: 0.75rem;
  }

  /* Compact streak pill on mobile */
  .streak-display {
    padding: 4px 8px;
  }

  .streak-flame {
    font-size: 0.75rem;
  }

  .streak-count {
    font-size: 0.8125rem;
  }

  /* Hide streak label on mobile to save space */
  .streak-label {
    display: none;
  }

  /* Anchors - Compact cards for mobile */
  .anchors-container {
    gap: 8px;
  }

  .anchor-card {
    padding: 12px 12px 12px 16px;
    gap: 4px var(--space-2);
    /* Single row layout: label+text | checkbox | delete */
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-rows: auto;
  }

  /* Compact: label and text on same row area */
  .anchor-label {
    grid-column: 1;
    grid-row: 1;
    font-size: 0.625rem;
    margin-bottom: 2px;
  }

  .anchor-text {
    grid-column: 1;
    grid-row: 2;
    font-size: 0.9375rem;
    min-height: 20px;
    line-height: 1.3;
  }

  /* Smaller checkbox - 20px with 44px touch target */
  .anchor-checkbox {
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    aspect-ratio: 1;
    border-radius: 50%;
    border-width: 2px;
    /* Invisible padding for touch target */
    padding: 12px;
    margin: -12px;
    box-sizing: content-box;
  }

  .anchor-checkbox.checked::after {
    font-size: 11px;
  }

  /* Delete button - smaller, top-right corner */
  .anchor-delete {
    opacity: 0.4;
    width: 20px;
    height: 20px;
    font-size: 0.75rem;
    /* Touch target padding */
    padding: 12px;
    margin: -12px;
    margin-right: -8px;
    box-sizing: content-box;
  }

  /* Add anchor button */
  .add-anchor-btn {
    padding: var(--space-2);
    min-height: 48px;
    font-size: 0.875rem;
  }

  .add-icon {
    font-size: 1.25rem;
  }

  /* Hide help text on mobile to save space */
  .anchors-help {
    display: none;
  }

  /* History toggle */
  .history-toggle {
    min-height: 44px;
    padding: var(--space-2);
  }

  /* History view */
  .anchor-history {
    padding: var(--space-2);
  }

  .close-history {
    min-width: 44px;
    min-height: 44px;
    font-size: 1.5rem;
  }

  /* Label options modal */
  .label-option {
    padding: var(--space-2);
    min-height: 56px;
  }

  .label-icon {
    font-size: 1.5rem;
  }

  .label-desc {
    font-size: 0.6875rem;
  }

  /* Quick thought modal */
  .quick-thought-content,
  .quick-letter-content {
    max-width: calc(100vw - 24px);
  }

  .quick-thought-content h3,
  .quick-letter-content h3 {
    font-size: 1rem;
    margin-bottom: var(--space-2);
  }

  #quick-thought-input {
    font-size: 16px; /* Prevents iOS zoom */
    padding: var(--space-2);
    margin-bottom: var(--space-2);
  }

  #quick-letter-text,
  #quick-letter-date {
    font-size: 16px; /* Prevents iOS zoom */
  }

  .quick-thought-tags {
    gap: var(--space-1);
    margin-bottom: var(--space-2);
  }

  .qt-tag-btn {
    width: 44px;
    height: 44px;
    font-size: 1.125rem;
  }
}

/* Small phone breakpoint */
@media (max-width: 320px) {
  .page-title {
    font-size: 1rem;
  }

  .date-display {
    font-size: 0.6875rem;
  }

  /* Even smaller header buttons */
  .header-btn,
  .theme-toggle {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
  }

  /* Hide quick thought button on very small screens */
  #quick-thought-btn {
    display: none;
  }

  /* Minimal streak display */
  .streak-display {
    padding: 3px 6px;
  }

  .streak-flame {
    font-size: 0.6875rem;
  }

  .streak-count {
    font-size: 0.75rem;
  }

  .anchor-checkbox {
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
  }

  .anchor-checkbox.checked::after {
    font-size: 12px;
  }

  .anchor-delete {
    width: 18px;
    height: 18px;
    font-size: 0.625rem;
  }

  .qt-tag-btn {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }

  .label-option {
    padding: var(--space-1) var(--space-2);
    min-height: 48px;
  }
}
