/* ============================================================================
   PromptFail — Image-First Stacked Design
   ============================================================================ */

/* Variables */
:root {
  /* Colors */
  --bg-primary: #0f0f0f;
  --bg-secondary: #1a1a1a;
  --fg-primary: #f5f5f0;
  --fg-muted: #999;
  --border: #2a2a2a;
  --accent-red: #ff3b30;
  --accent-cyan: #00d4ff;
  --accent-purple: #9b59b6;
  --accent-gold: #f1c40f;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Monaco", "Courier New", monospace;

  /* Spacing */
  --gap-xs: 8px;
  --gap-sm: 12px;
  --gap-md: 16px;
  --gap-lg: 24px;
  --gap-xl: 32px;
  --gap-2xl: 40px;

  /* Type scale */
  --text-xs: 11px;
  --text-sm: 13px;
  --text-base: 16px;
  --text-lg: 20px;
  --text-xl: 24px;
  --text-2xl: 32px;

  /* Line height */
  --lh-tight: 1.2;
  --lh-normal: 1.5;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg-primary: #fafaf8;
    --bg-secondary: #f5f5f0;
    --fg-primary: #1a1a1a;
    --fg-muted: #666;
    --border: #e8e6e1;
  }
}

/* Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--fg-primary);
  font-size: var(--text-base);
  line-height: var(--lh-normal);
  overflow-x: hidden;
}

/* Links */
a {
  color: var(--accent-red);
  text-decoration: none;
  transition: opacity 0.2s;
}

a:hover {
  opacity: 0.8;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: var(--lh-tight);
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }

/* ============================================================================
   Layout: Feed Container
   ============================================================================ */

.feed {
  max-width: 100%;
  margin: 0 auto;
}

/* ============================================================================
   Header (Sticky)
   ============================================================================ */

header {
  position: sticky;
  top: 0;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  padding: var(--gap-md) var(--gap-md);
  z-index: 100;
  backdrop-filter: blur(8px);
  background: rgba(15, 15, 15, 0.95);
}

@media (prefers-color-scheme: light) {
  header {
    background: rgba(250, 250, 248, 0.95);
  }
}

header h1 {
  font-size: var(--text-xl);
  margin-bottom: var(--gap-xs);
  letter-spacing: -0.5px;
}

header .tagline {
  font-size: var(--text-sm);
  color: var(--fg-muted);
}

.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap-md);
  max-width: 1100px;
  margin: 0 auto;
}

.submit-btn {
  background: var(--accent-red);
  color: #fff;
  padding: var(--gap-sm) var(--gap-md);
  border-radius: 4px;
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
}

.submit-btn:hover {
  opacity: 0.9;
}

/* ============================================================================
   Feed Controls (Sort / Tags)
   ============================================================================ */

.feed-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-lg);
  padding: var(--gap-md);
  border-bottom: 1px solid var(--border);
  max-width: 1100px;
  margin: 0 auto;
  font-size: var(--text-sm);
}

.control-group {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  flex-wrap: wrap;
}

.control-label {
  color: var(--fg-muted);
  text-transform: uppercase;
  font-size: var(--text-xs);
  letter-spacing: 0.5px;
  font-weight: 600;
}

.feed-controls a {
  color: var(--fg-muted);
}

.feed-controls a:hover {
  color: var(--accent-red);
  opacity: 1;
}

.control-active {
  color: var(--fg-primary);
  font-weight: 700;
}

/* ============================================================================
   Pagination
   ============================================================================ */

.pagination {
  display: flex;
  gap: var(--gap-sm);
  justify-content: center;
  padding: var(--gap-xl) var(--gap-md);
  font-variant-numeric: tabular-nums;
}

.pagination a {
  color: var(--fg-muted);
  padding: var(--gap-xs) var(--gap-sm);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.pagination a:hover {
  color: var(--accent-red);
  border-color: var(--accent-red);
  opacity: 1;
}

.pagination .page-current {
  color: #fff;
  background: var(--accent-red);
  padding: var(--gap-xs) var(--gap-sm);
  border: 1px solid var(--accent-red);
  border-radius: 4px;
  font-weight: 700;
}

/* ============================================================================
   Back navigation (post / comment detail)
   ============================================================================ */

.back-nav {
  padding: var(--gap-md) var(--gap-md) 0;
  max-width: 1100px;
  margin: 0 auto;
}

.back-nav a {
  color: var(--fg-muted);
  font-size: var(--text-sm);
  font-weight: 500;
}

.back-nav a:hover {
  color: var(--accent-red);
  opacity: 1;
}

/* ============================================================================
   Post Card: Container
   ============================================================================ */

.post-card {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

/* Desktop: side-by-side */
@media (min-width: 769px) {
  .post-card {
    flex-direction: row;
    align-items: stretch;
    margin-bottom: 2px;
  }
}

/* ============================================================================
   Post Image
   ============================================================================ */

.post-image {
  background: linear-gradient(135deg, var(--accent-red) 0%, var(--accent-gold) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 80px;
  position: relative;
  overflow: hidden;
  /* Consistent, bounded image panel regardless of the photo's aspect ratio.
     Kept short so several posts are visible on screen at once. */
  aspect-ratio: 16 / 7;
  max-height: 45vh;
}

/* Blurred copy of the image fills the panel so any aspect ratio reads as
   intentional instead of leaving bars around a letterboxed image. */
.post-image-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(28px) brightness(0.5) saturate(1.2);
  transform: scale(1.15);
  z-index: 0;
}

/* Sharp image sits on top, fully visible (never cropped). */
.post-image-fg {
  position: relative;
  z-index: 1;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.post-image .placeholder {
  font-weight: 700;
  color: rgba(255, 255, 255, 0.3);
}

/* Model tag color variations */
.post-card[data-model="GPT-4"] .post-image {
  background: linear-gradient(135deg, #ff3b30 0%, #ff9500 100%);
}

.post-card[data-model="Claude"] .post-image {
  background: linear-gradient(135deg, #00d4ff 0%, #0099ff 100%);
}

.post-card[data-model="Gemini"] .post-image {
  background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
}

.post-card[data-model="ChatGPT"] .post-image {
  background: linear-gradient(135deg, #f1c40f 0%, #e67e22 100%);
}

.post-card[data-model="Midjourney"] .post-image {
  background: linear-gradient(135deg, #e94b3c 0%, #c7254e 100%);
}

.post-card[data-model="DALL-E"] .post-image {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.post-card[data-model="Other"] .post-image {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

@media (min-width: 769px) {
  .post-image {
    flex: 0 0 58%;
    aspect-ratio: 16 / 7;
    max-height: 49vh;
    align-self: center;
  }
}

/* ============================================================================
   Post Info Section
   ============================================================================ */

.post-info {
  flex: 0 0 30%;
  display: flex;
  flex-direction: column;
  padding: var(--gap-lg) var(--gap-md);
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
}

@media (min-width: 769px) {
  .post-info {
    flex: 1;
    justify-content: center;
    padding: var(--gap-2xl) var(--gap-2xl);
    border-top: none;
    border-left: 1px solid var(--border);
  }
}

/* ============================================================================
   Post Metadata
   ============================================================================ */

.post-tag {
  font-size: var(--text-xs);
  color: var(--accent-red);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--gap-sm);
  display: inline-block;
}

.post-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: var(--lh-tight);
  margin-bottom: var(--gap-md);
}

@media (min-width: 769px) {
  .post-title {
    font-size: clamp(var(--text-2xl), 4vw, 40px);
  }
}

.post-meta {
  font-size: var(--text-sm);
  color: var(--fg-muted);
  margin-bottom: var(--gap-lg);
  display: flex;
  gap: var(--gap-md);
  align-items: center;
  flex-wrap: wrap;
}

.post-meta .vote-count {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-red);
}

.post-meta .author {
  font-weight: 600;
}

/* ============================================================================
   Post Actions
   ============================================================================ */

.post-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--gap-sm);
  margin-top: auto;
  padding-top: var(--gap-md);
  border-top: 1px solid var(--border);
}

/* Shared inline action look — chips used across posts, votes, reports,
   comments and the copy-prompt button. Applies to elements carrying the
   .action-btn class and to the bare htmx buttons inside the partials. */
.action-btn,
[id^="vote-"] button,
[id^="report-"] button,
.comment button,
#copy-prompt {
  background: none;
  border: 1px solid var(--border);
  color: var(--fg-muted);
  font-size: var(--text-sm);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 4px;
  font-weight: 500;
  transition: color 0.2s, border-color 0.2s;
  font-family: var(--font-sans);
  line-height: 1.4;
}

.action-btn:hover:not(.disabled),
[id^="vote-"] button:hover,
[id^="report-"] button:not(.disabled):hover,
.comment button:hover,
#copy-prompt:hover {
  color: var(--accent-red);
  border-color: var(--accent-red);
  opacity: 1;
}

.action-btn.voted {
  color: var(--accent-red);
  border-color: var(--accent-red);
}

.action-btn.disabled {
  color: var(--fg-muted);
  cursor: not-allowed;
  opacity: 0.5;
}

.action-btn.disabled:hover {
  color: var(--fg-muted);
  border-color: var(--border);
}

/* Vote & report partials render as inline chip groups */
[id^="vote-"],
[id^="report-"] {
  display: inline-flex;
  align-items: center;
  gap: var(--gap-xs);
}

[id^="vote-"] strong {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--accent-red);
  font-weight: 700;
}

/* ============================================================================
   Comment preview (feed cards)
   ============================================================================ */

.comment-preview {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
  margin: var(--gap-md) 0 var(--gap-lg);
  padding-left: var(--gap-md);
  border-left: 2px solid var(--border);
}

.comment-preview li {
  font-size: var(--text-sm);
  line-height: var(--lh-normal);
}

.cp-author {
  font-weight: 600;
  color: var(--fg-primary);
  margin-right: var(--gap-xs);
}

.cp-body {
  color: var(--fg-muted);
}

.cp-more a {
  font-size: var(--text-sm);
  color: var(--fg-muted);
}

.cp-more a:hover {
  color: var(--accent-red);
  opacity: 1;
}

/* ============================================================================
   Post Description (optional, in detail view)
   ============================================================================ */

.post-description {
  font-size: var(--text-base);
  line-height: var(--lh-normal);
  color: var(--fg-primary);
  margin-bottom: var(--gap-lg);
  max-width: 70ch;
}

.post-prompt {
  background: var(--bg-secondary);
  border-left: 3px solid var(--accent-red);
  padding: var(--gap-md) var(--gap-lg);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  margin-bottom: var(--gap-lg);
  border-radius: 4px;
}

/* ============================================================================
   Comments Section
   ============================================================================ */

.comments-section {
  padding: var(--gap-2xl) var(--gap-md);
  border-top: 1px solid var(--border);
  max-width: 70ch;
}

@media (min-width: 769px) {
  .comments-section {
    padding: var(--gap-2xl) var(--gap-2xl);
  }
}

.comments-heading {
  font-size: var(--text-lg);
  margin-bottom: var(--gap-lg);
}

.comment {
  padding: var(--gap-md) 0 var(--gap-md) var(--gap-md);
  border-left: 2px solid var(--border);
}

/* Author name */
.comment > [id^="comment-body-"] > strong {
  font-weight: 600;
}

/* Edited marker next to author */
.comment [id^="comment-body-"] > span[title] {
  font-size: var(--text-xs);
  color: var(--fg-muted);
  margin-left: var(--gap-xs);
}

/* Comment body text */
.comment [id^="comment-body-"] > p {
  margin: var(--gap-xs) 0 var(--gap-sm);
  line-height: var(--lh-normal);
}

/* Reply/edit slot spacing */
.comment [id^="reply-slot-"]:not(:empty) {
  margin-top: var(--gap-sm);
}

/* "Continue thread" link */
.comment > p > a {
  font-size: var(--text-sm);
}

/* ============================================================================
   Page container (form / simple pages)
   ============================================================================ */

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: var(--gap-2xl) var(--gap-md);
}

.page h1 {
  margin-bottom: var(--gap-lg);
}

.page a {
  color: var(--accent-red);
}

/* ============================================================================
   Form Styles (Post Submit, Comment Form)
   ============================================================================ */

form {
  margin-bottom: var(--gap-lg);
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--gap-xs);
  font-size: var(--text-sm);
}

input[type="text"],
input[type="file"],
textarea,
select {
  width: 100%;
  padding: var(--gap-sm) var(--gap-md);
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--fg-primary);
  font-family: var(--font-sans);
  border-radius: 4px;
  font-size: var(--text-base);
  margin-bottom: var(--gap-md);
  transition: border-color 0.2s;
}

input[type="text"]:focus,
input[type="file"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent-red);
}

textarea {
  resize: vertical;
  min-height: 100px;
}

button[type="submit"] {
  background: var(--accent-red);
  color: white;
  padding: var(--gap-sm) var(--gap-lg);
  border: none;
  border-radius: 4px;
  font-weight: 600;
  font-size: var(--text-base);
  cursor: pointer;
  transition: opacity 0.2s;
}

button[type="submit"]:hover {
  opacity: 0.9;
}

button[type="submit"]:active {
  opacity: 0.8;
}

/* ============================================================================
   Mobile
   ============================================================================ */

@media (max-width: 768px) {
  .post-info {
    padding: var(--gap-md) var(--gap-md);
  }

  .post-title {
    font-size: var(--text-lg);
  }

  .post-actions {
    gap: var(--gap-sm);
  }
}

/* ============================================================================
   Utilities
   ============================================================================ */

.text-muted {
  color: var(--fg-muted);
}

.text-accent {
  color: var(--accent-red);
}

.mt-md { margin-top: var(--gap-md); }
.mb-md { margin-bottom: var(--gap-md); }
.mt-lg { margin-top: var(--gap-lg); }
.mb-lg { margin-bottom: var(--gap-lg); }

.hidden {
  display: none !important;
}

/* ============================================================================
   Accessibility
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* Focus visible for keyboard navigation */
*:focus-visible {
  outline: 2px solid var(--accent-red);
  outline-offset: 2px;
}
