/* =============================================
   CONFESSIONAL — Stylesheet
   Dark · Minimal · Anonymous
   ============================================= */

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

:root {
  --bg:           #0a0e1a;
  --surface:      #0f1626;
  --surface-2:    #131d30;
  --border:       #1a2744;
  --border-focus: #2563eb;
  --blue:         #2563eb;
  --blue-hover:   #3b82f6;
  --blue-glow:    #1d4ed8;
  --blue-dim:     rgba(37, 99, 235, 0.12);
  --text:         #f1f5f9;
  --text-dim:     #94a3b8;
  --text-muted:   #475569;
  --green:        #22c55e;
  --green-dim:    rgba(34, 197, 94, 0.12);
  --red:          #ef4444;
  --red-dim:      rgba(239, 68, 68, 0.12);
  --yellow:       #f59e0b;
  --radius:       6px;
  --radius-lg:    8px;
  --font-ui:      'Syne', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'Courier New', monospace;
  --transition:   150ms cubic-bezier(0.4, 0, 0.2, 1);
  --max-width:    720px;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

/* ── Atmosphere ────────────────────────────────────────────────────── */
.noise {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
  background-size: 128px 128px;
}

.scanlines {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
}

/* ── Header ────────────────────────────────────────────────────────── */
.site-header {
  position: relative;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.04) 0%, transparent 100%);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.25rem 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.1em;
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--blue-hover);
}

.logo-bracket {
  color: var(--text-muted);
  font-weight: 400;
}

.logo-text {
  background: linear-gradient(90deg, var(--blue-hover), #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--blue-hover);
  margin-left: 3px;
  animation: blink 1.1s step-end infinite;
  vertical-align: text-bottom;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.tagline {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* ── Main Layout ───────────────────────────────────────────────────── */
.main-content {
  position: relative;
  z-index: 10;
  flex: 1;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* ── Confess Toggle ────────────────────────────────────────────────── */
.confess-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.confess-section:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 1px var(--blue-dim), 0 4px 24px rgba(37, 99, 235, 0.08);
}

.confess-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background var(--transition);
  font-family: var(--font-ui);
}

.confess-toggle:hover {
  background: var(--blue-dim);
}

.toggle-icon {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  color: var(--blue-hover);
  width: 1.2rem;
  text-align: center;
  transition: transform var(--transition);
  flex-shrink: 0;
  font-weight: 600;
  line-height: 1;
}

.confess-toggle[aria-expanded="true"] .toggle-icon {
  transform: rotate(45deg);
}

.toggle-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text);
}

.toggle-hint {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-left: auto;
  letter-spacing: 0.04em;
}

/* ── Form ──────────────────────────────────────────────────────────── */
.confess-form-wrapper {
  border-top: 1px solid var(--border);
  padding: 1.5rem 1.25rem;
  animation: slideDown 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.confess-form-wrapper[hidden] {
  display: none;
}

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

.field-group {
  margin-bottom: 1.25rem;
}

.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.char-counter {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.02em;
  transition: color var(--transition);
}

.char-counter.warning { color: var(--yellow); }
.char-counter.danger  { color: var(--red); }

.field-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  padding: 0.7rem 0.9rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  resize: none;
  line-height: 1.6;
}

.field-input::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

.field-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-dim);
}

.field-textarea {
  min-height: 120px;
  resize: vertical;
}

/* ── Form Footer ───────────────────────────────────────────────────── */
.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.anon-notice {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

.notice-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
  animation: pulse-green 2.5s ease-in-out infinite;
}

@keyframes pulse-green {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 var(--green-dim); }
  50%       { opacity: 0.7; box-shadow: 0 0 0 4px transparent; }
}

.submit-btn {
  position: relative;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0.65rem 1.25rem;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
  overflow: hidden;
  white-space: nowrap;
}

.submit-btn:hover:not(:disabled) {
  background: var(--blue-hover);
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4);
}

.submit-btn:active:not(:disabled) {
  transform: scale(0.97);
}

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

.btn-loading {
  display: none;
}

.submit-btn.loading .btn-text    { display: none; }
.submit-btn.loading .btn-loading { display: block; }

/* ── Form Messages ─────────────────────────────────────────────────── */
.form-message {
  margin-top: 1rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius);
  border-left: 3px solid transparent;
  display: none;
  line-height: 1.5;
}

.form-message.error {
  display: block;
  background: var(--red-dim);
  border-left-color: var(--red);
  color: #fca5a5;
}

.form-message.success {
  display: block;
  background: var(--green-dim);
  border-left-color: var(--green);
  color: #86efac;
}

/* ── Feed Controls ─────────────────────────────────────────────────── */
.feed-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.sort-tabs {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.sort-tab {
  padding: 0.5rem 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
  position: relative;
}

.sort-tab::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--blue);
  transform: scaleX(0);
  transition: transform var(--transition);
}

.sort-tab:hover {
  color: var(--text);
  background: var(--blue-dim);
}

.sort-tab.active {
  color: var(--blue-hover);
}

.sort-tab.active::after {
  transform: scaleX(1);
}

.feed-count {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* ── Feed ──────────────────────────────────────────────────────────── */
.feed {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Loading Dots */
.feed-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
  padding: 4rem 0;
}

.loading-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--blue);
  animation: loadBounce 1.2s ease-in-out infinite;
}

.loading-dot:nth-child(2) { animation-delay: 0.15s; }
.loading-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes loadBounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40%            { transform: scale(1);   opacity: 1; }
}

.feed-loading[hidden],
.feed-empty[hidden] { display: none; }

.feed-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 5rem 0;
}

.empty-text {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text-muted);
}

.empty-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0.6;
}

/* ── Confession Card ───────────────────────────────────────────────── */
.confession-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 0.75rem;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  animation: cardIn 250ms cubic-bezier(0.4, 0, 0.2, 1) both;
}

.confession-card:hover {
  border-color: rgba(37, 99, 235, 0.3);
  box-shadow: 0 4px 24px rgba(37, 99, 235, 0.06);
}

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

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
  letter-spacing: 0.01em;
}

.card-time {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  padding-top: 2px;
}

.card-body {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.75;
  word-break: break-word;
  white-space: pre-wrap;
  margin-bottom: 1rem;
}

/* ── Card Footer / Votes ───────────────────────────────────────────── */
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.vote-group {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.vote-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.55rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  cursor: pointer;
  transition:
    color var(--transition),
    background var(--transition),
    border-color var(--transition),
    transform var(--transition),
    box-shadow var(--transition);
  user-select: none;
}

.vote-btn:hover:not(:disabled) {
  border-color: var(--border-focus);
  background: var(--blue-dim);
  color: var(--text);
}

.vote-btn.voted-up {
  color: var(--green);
  border-color: rgba(34, 197, 94, 0.3);
  background: var(--green-dim);
}

.vote-btn.voted-down {
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.3);
  background: var(--red-dim);
}

.vote-btn.pulse {
  animation: votePulse 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes votePulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.vote-btn:disabled {
  cursor: default;
  opacity: 0.7;
}

.vote-icon {
  font-size: 0.65rem;
  line-height: 1;
}

.vote-count {
  font-weight: 600;
  min-width: 1ch;
  text-align: center;
}

.vote-score {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 0 0.3rem;
  min-width: 2.5ch;
  text-align: center;
}

.vote-score.positive { color: var(--green); }
.vote-score.negative { color: var(--red); }

.card-id {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text-muted);
  opacity: 0.4;
  letter-spacing: 0.04em;
}

/* ── Footer ────────────────────────────────────────────────────────── */
.site-footer {
  position: relative;
  z-index: 10;
  border-top: 1px solid var(--border);
  padding: 1.25rem;
  text-align: center;
  background: linear-gradient(0deg, rgba(37, 99, 235, 0.03) 0%, transparent 100%);
}

.footer-text {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  opacity: 0.5;
}

/* ── Scrollbar ─────────────────────────────────────────────────────── */
::-webkit-scrollbar              { width: 6px; }
::-webkit-scrollbar-track        { background: var(--bg); }
::-webkit-scrollbar-thumb        { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover  { background: var(--blue-glow); }

/* ── Selection ─────────────────────────────────────────────────────── */
::selection {
  background: rgba(37, 99, 235, 0.3);
  color: var(--text);
}

/* ── Focus Ring ────────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .main-content {
    padding: 1.25rem 1rem 3rem;
    gap: 1.5rem;
  }

  .header-inner {
    flex-direction: column;
    gap: 0.2rem;
  }

  .tagline {
    font-size: 0.6rem;
  }

  .toggle-hint {
    display: none;
  }

  .form-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .submit-btn {
    width: 100%;
    text-align: center;
  }

  .feed-count {
    display: none;
  }

  .card-header {
    flex-direction: column;
    gap: 0.25rem;
  }

  .card-time {
    order: -1;
  }
}
