/* ===== Claimed — Styles ===== */

:root {
  --bg: #0e0e10;
  --bg-raised: #18181b;
  --bg-card: #1c1c1f;
  --bg-card-hover: #222225;
  --text: #ececec;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --accent: #00d2d3;
  --accent-hover: #00b8b9;
  --accent-dim: rgba(0, 210, 211, 0.08);
  --gold: #f9ca24;
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.1);
  --error: #ef4444;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  --radius: 10px;
  --radius-sm: 6px;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* ===== Reset ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ===== Base ===== */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== Day Navigation ===== */
.day-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  gap: 0.375rem;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  justify-content: center;
  -webkit-overflow-scrolling: touch;
}

.day-nav::-webkit-scrollbar {
  height: 0;
}

.day-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.8125rem;
  min-width: 52px;
  min-height: 52px;
  transition: all 0.15s var(--ease);
  user-select: none;
}

.day-pill:hover {
  border-color: var(--border-strong);
  color: var(--text-secondary);
  background: var(--bg-raised);
}

/* Yesterday — slightly larger */
.day-pill--yesterday {
  min-width: 62px;
  min-height: 58px;
  padding: 0.5rem 0.875rem;
}

.day-pill--yesterday .day-pill__date {
  font-size: 1.25rem;
}

/* Today — solid accent */
.day-pill--today {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 600;
}

.day-pill--today:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--bg);
}

/* Active / selected day */
.day-pill--active:not(.day-pill--today) {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-dim);
}

.day-pill__name {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.625rem;
  line-height: 1;
}

.day-pill__date {
  font-size: 1.0625rem;
  font-weight: 500;
  line-height: 1.2;
}

/* ===== Layout ===== */
main {
  max-width: 768px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
}

/* ===== Grid ===== */
.masonry {
  column-count: 1;
  column-gap: 0.75rem;
}

@media (min-width: 540px) {
  .masonry { column-count: 2; }
}

.grid__empty {
  text-align: center;
  color: var(--text-muted);
  padding: 4rem 1rem;
  font-style: italic;
  column-span: all;
}

/* ===== Add button (inline, top of grid) ===== */
.fab {
  column-span: all;
  width: 100%;
  height: 52px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
  font-size: 1.5rem;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.15s var(--ease);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.fab:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.fab:active {
  transform: scale(0.98);
}

/* ===== Latest card (newest post, hero) ===== */
.card--latest {
  column-span: all;
  padding: 1.5rem;
  margin-bottom: 0.75rem;
  border-color: var(--accent);
}

.card--latest .card__topic {
  font-size: 1.125rem;
}

.card--latest .card__body {
  font-size: 1rem;
}

/* ===== Empty cards ===== */
.card--empty {
  min-height: 88px;
  animation: none;
  opacity: 0.4;
}

/* ===== Card ===== */
.card {
  break-inside: avoid;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.125rem;
  margin-bottom: 0.75rem;
  animation: fadeIn 0.2s var(--ease);
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}

.card:hover {
  border-color: var(--border-strong);
  background: var(--bg-card-hover);
}

.card--claimed {
  border-color: rgba(249, 202, 36, 0.25);
}

.card--claimed:hover {
  border-color: rgba(249, 202, 36, 0.4);
}

.card--editing {
  border-color: var(--accent);
}

.card--updated {
  animation: pulse 0.5s var(--ease);
}

.card__topic {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 0.375rem;
  line-height: 1.3;
  color: var(--text);
}

.card__body {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 0.625rem;
  word-break: break-word;
  white-space: pre-wrap;
}

.card__meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.card__time {
  font-size: 0.6875rem;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.card__edit-icon {
  font-size: 0.8125rem;
  cursor: pointer;
  transition: opacity 0.15s var(--ease);
  padding: 0.125rem 0.25rem;
  user-select: none;
  line-height: 1;
}

.card__edit-icon:hover {
  opacity: 0.6;
}

.card__edits {
  font-size: 0.6875rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  cursor: pointer;
  transition: color 0.15s var(--ease);
  user-select: none;
  padding: 0.125rem 0.25rem;
}

.card__edits:hover {
  color: var(--accent);
}

.card--latest .card__edits {
  background: linear-gradient(135deg, var(--gold), #e17055, #d63031);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
  font-size: 0.75rem;
}

.card__lock {
  font-size: 0.75rem;
}

.card__claim-btn {
  font-size: 0.6875rem;
  padding: 0.25rem 0.625rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s var(--ease);
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.01em;
}

.card__claim-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}

/* ===== Origin Reveal ===== */
.card__origin:empty {
  display: none;
}

.card__origin {
  margin-top: 0.625rem;
}

.origin__content {
  padding: 0.625rem 0.75rem;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--border-strong);
}

.origin__label {
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.origin__topic {
  font-size: 0.8125rem;
  text-decoration: line-through;
  color: var(--text-muted);
  margin-bottom: 0.125rem;
}

.origin__body {
  font-size: 0.75rem;
  text-decoration: line-through;
  color: var(--text-muted);
  font-style: italic;
  white-space: pre-wrap;
}

.origin__text {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 0.375rem 0;
}

/* ===== Modal ===== */
.modal__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
  animation: fadeIn 0.12s var(--ease);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

@media (min-width: 540px) {
  .modal__backdrop {
    align-items: center;
  }
}

.modal__content {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 1.5rem;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
}

@media (min-width: 540px) {
  .modal__content {
    border-radius: var(--radius);
  }
}

.modal__content h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.modal__content > p {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* ===== Forms ===== */
label {
  display: block;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.875rem;
  font-weight: 500;
}

input[type="text"],
input[type="password"],
textarea {
  display: block;
  width: 100%;
  margin-top: 0.375rem;
  padding: 0.625rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  transition: border-color 0.15s var(--ease);
  min-height: 40px;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

textarea {
  resize: vertical;
  min-height: 72px;
  line-height: 1.5;
}

.char-count {
  float: right;
  font-size: 0.6875rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.form__actions {
  display: flex;
  gap: 0.625rem;
  margin-top: 1rem;
}

button[type="submit"] {
  padding: 0.625rem 1.25rem;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s var(--ease);
  min-height: 40px;
}

button[type="submit"]:hover {
  background: var(--accent-hover);
}

button[type="submit"]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.form__actions button[type="button"] {
  padding: 0.625rem 1.25rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all 0.15s var(--ease);
  min-height: 40px;
}

.form__actions button[type="button"]:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.form-errors:empty {
  display: none;
}

.form-errors {
  margin-bottom: 0.625rem;
}

.error {
  color: var(--error);
  font-size: 0.8125rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(239, 68, 68, 0.08);
}

.pow-status {
  font-size: 0.75rem;
  color: var(--accent);
  min-height: 1.25rem;
}

/* ===== Post Budget ===== */
.post-budget {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  min-height: 1.5rem;
}

.budget-count {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-sm);
}

.budget-count--empty {
  color: var(--gold);
  background: rgba(249, 202, 36, 0.1);
}

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

.post-budget--exhausted .budget-text {
  color: var(--gold);
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 210, 211, 0); }
  50%      { box-shadow: 0 0 0 3px rgba(0, 210, 211, 0.12); }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ===== Claim Confetti ===== */
.confetti-piece {
  position: fixed;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 9999;
  animation: confetti-fall var(--fall-duration, 1.2s) var(--ease) forwards;
}

.confetti-emoji {
  position: fixed;
  font-size: 1.25rem;
  pointer-events: none;
  z-index: 9999;
  animation: confetti-fall var(--fall-duration, 1.2s) var(--ease) forwards;
}

@keyframes confetti-fall {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  100% {
    opacity: 0;
    transform:
      translate(var(--drift-x, 0px), var(--drift-y, 120px))
      rotate(var(--spin, 360deg))
      scale(0.4);
  }
}
