/* ═══════════════════════════════════════════
   From Stranger – Dark theme, responsive
   ═══════════════════════════════════════════ */

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --border: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #818cf8;
  --accent-hover: #6366f1;
  --success: #34d399;
  --error: #f87171;
  --heart: #f472b6;
  --hate: #a78bfa;
  --ignore: #64748b;
  --radius: 16px;
  --transition: 0.3s ease;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─── Header ─── */
.app-header {
  text-align: center;
  padding: 1.25rem 1rem 0.25rem;
}

.app-header h1 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ─── Layout ─── */
.app-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  min-height: calc(100vh - 80px);
  align-items: start;
}

.panel {
  display: flex;
  flex-direction: column;
}

.panel-left {
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 120px);
}

/* ─── Card ─── */
.card-flip-container {
  width: 100%;
  max-width: 360px;
}

.card-scene {
  aspect-ratio: 3 / 4;
  width: 100%;
}

.sentence-card {
  width: 100%;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}

/* Flip animations */
.sentence-card.flip-out {
  animation: flipOut 0.3s ease-in forwards;
}

.sentence-card.flip-in {
  animation: flipIn 0.3s ease-out forwards;
}

@keyframes flipOut {
  0%   { transform: perspective(800px) rotateY(0deg);  opacity: 1; }
  100% { transform: perspective(800px) rotateY(90deg);  opacity: 0; }
}

@keyframes flipIn {
  0%   { transform: perspective(800px) rotateY(-90deg); opacity: 0; }
  100% { transform: perspective(800px) rotateY(0deg);   opacity: 1; }
}

.card-content {
  width: 100%;
}

.sentence-text {
  font-size: 1.2rem;
  line-height: 1.7;
  color: var(--text);
  word-break: break-word;
}

/* Loading dots */
.loading-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  min-height: 40px;
}

.loading-dots span {
  width: 10px;
  height: 10px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: dotPulse 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes dotPulse {
  0%, 80%, 100% { transform: scale(0.5); opacity: 0.3; }
  40%           { transform: scale(1);   opacity: 1; }
}

/* Reaction display */
.reaction-display {
  font-size: 4rem;
  animation: reactionPop 0.4s ease-out;
}

@keyframes reactionPop {
  0%   { transform: scale(0); opacity: 0; }
  60%  { transform: scale(1.3); }
  100% { transform: scale(1); opacity: 1; }
}

/* Swipe hints */
.swipe-hints {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 0.25rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  opacity: 0.7;
}

/* ─── Right Panel ─── */
.panel-right {
  gap: 1rem;
}

.publish-section,
.published-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.publish-section h2,
.published-section h2 {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem;
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
  min-height: 80px;
  transition: border-color var(--transition);
}

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

.btn-publish {
  margin-top: 0.75rem;
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 0.7rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}

.btn-publish:hover:not(:disabled) {
  background: var(--accent-hover);
}

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

/* Status messages */
.status {
  margin-top: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  font-size: 0.85rem;
}

.status.ok {
  background: rgba(52, 211, 153, 0.12);
  color: var(--success);
}

.status.error {
  background: rgba(248, 113, 113, 0.12);
  color: var(--error);
}

/* Published items */
.published-section {
  max-height: 50vh;
  overflow-y: auto;
}

.published-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.published-item:last-child {
  border-bottom: none;
}

.published-text {
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 0.4rem;
  color: var(--text);
}

.reaction-counts {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
}

.count-heart  { color: var(--heart); }
.count-hate   { color: var(--hate); }
.count-ignore { color: var(--ignore); }

.empty-state {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 1.5rem 0;
}

/* ─── Sub-tabs (mobile publish section) ─── */
.sub-tabs {
  display: none;
  gap: 0;
  background: var(--surface);
  border-radius: 12px;
  padding: 4px;
  border: 1px solid var(--border);
}

.sub-tab {
  flex: 1;
  padding: 0.55rem 0.5rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  transition: all var(--transition);
}

.sub-tab.active {
  background: var(--accent);
  color: #fff;
}

/* ─── Mobile Bottom Nav ─── */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0.4rem 0 0.6rem;
  z-index: 100;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem;
  transition: color var(--transition);
}

.nav-btn.active {
  color: var(--accent);
}

.nav-icon  { font-size: 1.2rem; }
.nav-label { font-size: 0.65rem; font-weight: 500; }

/* ─── Results page ─── */
.results-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 500px;
  margin: 2rem auto;
}

.results-card h2 {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.results-text {
  font-size: 1.1rem;
  line-height: 1.6;
  margin-bottom: 1rem;
}

.result-counts {
  display: flex;
  gap: 1.5rem;
}

.result-count {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .app-header { padding: 1rem 1rem 0.25rem; }

  .app-container {
    display: block;
    padding: 0.75rem;
    padding-bottom: 80px;
    min-height: auto;
  }

  .panel { display: none; }
  .panel.active { display: flex; }

  .panel-left.active {
    min-height: calc(100vh - 160px);
    align-items: center;
    justify-content: center;
  }

  .card-flip-container { max-width: 300px; }

  .mobile-nav { display: flex; }
  .sub-tabs   { display: flex; }

  .sub-content         { display: none; }
  .sub-content.active  { display: block; }
}

@media (min-width: 769px) {
  .panel       { display: flex !important; }
  .sub-content { display: block !important; }
}
