/*
 * css/reflections.css · The Long Game — Reflect tab scoped styles
 * Purpose: visual system for the Weekly Reflection ritual — week activity
 *          summary, gentle prompt form, past-reflections list, arrived-letter
 *          surface. All tokens come from styles.css; no overrides to global rules.
 * Key classes: .rf-section, .rf-section-title, .rf-section-sub, .rf-week-activity,
 *   .rf-week-stat, .rf-prompt-card, .rf-view-card, .rf-detail-letter,
 *   .rf-letter-detail, .rf-past-list, .rf-past-row, .rf-letter-row, .rf-loading
 * Related: js/reflections.js (renders these classes), css/styles.css (tokens source)
 */

/* ===== SKELETON LOADING PLACEHOLDER ===================================== */
/* Shown for ~1 async tick while data loads — prevents layout jump. */
.rf-loading {
  height: 320px;
  background: var(--surface-2);
  border-radius: var(--radius);
  animation: rf-pulse 1.4s ease-in-out infinite;
}
@keyframes rf-pulse {
  0%, 100% { opacity: 0.4; }
  50%       { opacity: 0.75; }
}
@media (prefers-reduced-motion: reduce) {
  .rf-loading { animation: none; opacity: 0.5; }
}

/* ===== SECTION WRAPPER =================================================== */
.rf-section {
  margin-bottom: var(--space-5);
}

.rf-section-title {
  font-family: var(--serif);
  font-size: 1.08rem;
  font-weight: 400;
  color: var(--ink);
  margin: 0 0 var(--space-2);
  line-height: 1.4;
}

.rf-section-sub {
  font-size: 0.88rem;
  color: var(--ink-soft);
  line-height: 1.55;
  margin: 0 0 var(--space-3);
}

/* ===== ARRIVED LETTERS LIST ============================================== */
.rf-letter-list {
  /* inherits surface-card--rows */
}

.rf-letter-row {
  /* row contract base: flex, gap 10, top-border */
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s;
  border-top: 1px solid var(--line);
  color: var(--ink);
}
.rf-letter-row:first-child,
.rf-letter-row.row-first-in-group { border-top: none; }
.rf-letter-row:hover  { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.rf-letter-row:active { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.rf-letter-row:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -2px;
  border-radius: calc(var(--radius) - 2px);
}

.rf-letter-icon {
  font-size: 1.35rem;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  flex-shrink: 0;
  color: var(--accent);
}

.rf-letter-title {
  font-weight: 600;
  font-size: 0.97rem;
  line-height: 1.35;
  margin-bottom: 3px;
}
.rf-letter-meta {
  font-size: 0.78rem;
  color: var(--ink-soft);
}

/* Row meta chevron */
.rf-letter-row .row__meta svg {
  display: block;
  width: 18px; height: 18px;
  opacity: 0.45;
  transform: rotate(180deg); /* back icon → forward arrow */
}

/* ===== WEEK ACTIVITY SUMMARY ============================================= */
/* Displayed as a small stat strip; numbers are NOT scores — just gentle context. */
.rf-week-activity {
  display: flex;
  gap: var(--space-5);
  padding: var(--space-4) 0 var(--space-2);
}

.rf-week-stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* De-emphasized: was 2rem accent — felt like a scoreboard tally.
   Now body-weight ink-soft so numbers are data, not goals. */
.rf-week-count {
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1;
  color: var(--ink-soft);
}

.rf-week-label {
  font-size: 0.8rem;
  color: var(--ink-soft);
  font-weight: 500;
}

.rf-week-quiet {
  font-style: italic;
  font-family: var(--serif);
  font-size: 0.95rem;
  color: var(--ink-soft);
  line-height: 1.6;
  margin: var(--space-3) 0 0;
  padding-left: var(--space-2);
  border-left: 2px solid var(--line);
}

/* ===== REFLECTION PROMPT FORM (new this week) ============================ */
.rf-prompt-card {
  /* inherits surface-card */
}

.rf-prompt-item {
  margin-bottom: var(--space-4);
}
.rf-prompt-item:last-of-type { margin-bottom: 0; }

.rf-prompt-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: var(--space-2);
  line-height: 1.4;
}

.rf-textarea {
  /* extends .journal-area — just ensures consistent spacing in the form */
  margin-bottom: 0;
}

.rf-prompt-actions {
  margin-top: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.rf-prompt-note {
  font-size: 0.8rem;
  color: var(--ink-soft);
  text-align: center;
  margin: 0;
}

/* ===== REFLECTION VIEW (this week, already saved) ======================== */
.rf-view-card {
  /* inherits surface-card */
}

.rf-view-item {
  padding: var(--space-4) 0;
  border-top: 1px solid var(--line);
}
.rf-view-item:first-child { border-top: none; padding-top: 0; }

.rf-view-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin-bottom: var(--space-2);
}

.rf-view-text {
  font-size: 0.97rem;
  line-height: 1.65;
  color: var(--ink);
}

.rf-view-empty {
  font-size: 0.9rem;
  font-style: italic;
  color: var(--ink-soft);
  margin: 0 0 var(--space-4);
}

.rf-edit-btn {
  /* extends .btn.ghost — just a width reset */
  display: inline-flex;
  width: auto;
  font-size: 0.88rem;
  padding: 9px 16px;
  gap: 6px;
}
.rf-edit-btn svg { width: 16px; height: 16px; display: block; }

/* ===== PAST REFLECTIONS LIST ============================================= */
.rf-past-empty {
  font-size: 0.88rem;
  color: var(--ink-soft);
  line-height: 1.55;
  font-style: italic;
  margin: 0;
  padding: var(--space-4) 0;
}

.rf-past-list {
  /* inherits surface-card--rows */
}

.rf-past-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 14px 16px;
  width: 100%;
  background: none;
  border: none;
  border-top: 1px solid var(--line);
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s;
  min-height: var(--tap);
  color: var(--ink);
}
.rf-past-row:first-child,
.rf-past-row.row-first-in-group { border-top: none; }
.rf-past-row:hover  { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.rf-past-row:active { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.rf-past-row:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -2px;
  border-radius: calc(var(--radius) - 2px);
}

.rf-past-week {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

.rf-past-range {
  font-weight: 600;
  font-size: 0.97rem;
}

.rf-past-year {
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.rf-past-preview {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rf-past-snippet {
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-style: italic;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
  line-clamp: 1;
  overflow: hidden;
}

/* ===== REFLECTION DETAIL OVERLAY ======================================== */
.rf-detail-letter {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: var(--space-5);
}

.rf-detail-header {
  margin-bottom: var(--space-4);
}

.rf-detail-block {
  padding: var(--space-4) 0;
  border-top: 1px solid var(--line);
}
.rf-detail-block:first-of-type { border-top: none; }

.rf-detail-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin-bottom: var(--space-2);
}

.rf-detail-text {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--ink);
}

.rf-detail-foot {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--line);
  font-size: 0.78rem;
  color: var(--ink-soft);
}

/* ===== LETTER DETAIL OVERLAY ============================================= */
.rf-letter-detail {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: var(--space-5);
  position: relative;
}

/* Subtle envelope top-fold visual */
.rf-letter-detail::before {
  content: '';
  display: block;
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
  border-radius: var(--radius) var(--radius) 0 0;
  opacity: 0.45;
}

.rf-letter-stamp {
  display: flex;
  gap: var(--space-2);
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.rf-letter-body {
  font-size: 1.08rem;
  line-height: 1.75;
  color: var(--ink);
  white-space: pre-wrap; /* preserve intentional line breaks in the letter body */
}

.rf-letter-foot {
  margin-top: var(--space-4);
  font-size: 0.78rem;
  color: var(--ink-soft);
  font-style: italic;
}

/* ===== FOOTER BREATHING ROOM ============================================= */
/* Space below the last section so the FAB never occludes the last row. */
.rf-footer-space {
  height: 32px;
}

/* ===== REDUCED MOTION: kill pulse, keep layout ========================== */
@media (prefers-reduced-motion: reduce) {
  .rf-loading { animation: none; }
  .rf-past-row,
  .rf-letter-row { transition: none; }
}
