/* Design Tokens */
:root {
  /* Spacing - 4 values only */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 32px;

  /* Colors - 5 total */
  --bg: #111;
  --surface: #1a1a1a;
  --text: #e5e5e5;
  --text-muted: #737373;
  --accent: #3b82f6;

  /* Typography */
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --text-base: 15px;
  --text-sm: 13px;
  --text-xs: 12px;
  --line-height: 1.5;

  /* Border radius - 1 value */
  --radius: 4px;
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--line-height);
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  word-break: break-word;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--text);
  text-decoration: none;
}

a:hover {
  color: var(--accent);
}

/* Header */
header {
  background: var(--bg);
  border-bottom: 1px solid var(--surface);
  min-height: 60px;
}

nav {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  max-width: 900px;
  margin: 0 auto;
  padding: var(--space-md);
}

.logo {
  font-weight: 600;
  color: var(--accent);
  font-size: var(--text-base);
}

.nav-links {
  display: flex;
  gap: var(--space-md);
}

.nav-links a {
  color: var(--text-muted);
}

.nav-links a:hover {
  color: var(--text);
}

.nav-auth {
  margin-left: auto;
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

.nav-auth a {
  color: var(--text-muted);
}

.nav-auth a:hover {
  color: var(--text);
}

.user-info {
  display: flex;
  gap: var(--space-xs);
  align-items: center;
}

.logout-form {
  display: flex;
  margin: 0;
}

.link-button {
  background: none;
  border: none;
  color: var(--text-muted);
  font: inherit;
  padding: 0;
  cursor: pointer;
  min-height: auto;
}

.link-button:hover {
  color: var(--text);
  background: none;
}

.karma {
  color: inherit;
}

/* Mobile header */
@media (max-width: 640px) {
  header {
    min-height: 48px;
  }

  nav {
    padding: var(--space-sm) var(--space-md);
    flex-wrap: wrap;
    gap: var(--space-sm);
  }

  .nav-links {
    order: 3;
    width: 100%;
    gap: var(--space-md);
    padding-top: var(--space-sm);
  }
}

/* Main content */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: var(--space-md);
}

@media (max-width: 640px) {
  footer {
    padding-left: var(--space-md);
    padding-right: var(--space-md);
  }
}

/* Post list */
.post-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.post-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
}

.post-rank {
  color: var(--text-muted);
  min-width: 24px;
  text-align: right;
  font-size: var(--text-sm);
  padding-top: 2px;
}

.post-vote {
  flex-shrink: 0;
}

.post-content {
  flex: 1;
  min-width: 0;
}

.post-title {
  margin-bottom: var(--space-xs);
  line-height: 1.4;
}

.post-english-title {
  color: var(--text-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-xs);
}

.post-link {
  color: var(--text);
  line-height: 1.4;
}

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

.post-domain {
  color: var(--text-muted);
  font-size: var(--text-sm);
  margin-left: var(--space-xs);
}

.post-meta {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.4;
}

.post-meta a {
  color: var(--text-muted);
}

.post-meta a:hover {
  color: var(--accent);
}

.post-text {
  margin-top: var(--space-md);
  padding: var(--space-md);
  background: var(--surface);
  max-width: 600px;
  border-radius: var(--radius);
}

/* Mobile post adjustments */
@media (max-width: 640px) {
  .post-rank {
    display: none;
  }

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

/* Vote button */
.vote-button {
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-xs);
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1;
  min-width: 32px;
  min-height: 44px;
  justify-content: center;
  border-radius: var(--radius);
}

.vote-button:hover {
  background: var(--surface);
}

.vote-button:hover .vote-arrow {
  color: var(--accent);
}

.vote-button.disabled {
  cursor: default;
  min-height: auto;
  padding: var(--space-xs) var(--space-xs) 0;
}

.vote-button.disabled:hover {
  background: none;
}

.vote-button.voted .vote-arrow {
  color: var(--accent);
}

.vote-arrow {
  font-size: 16px;
  line-height: 1;
  color: var(--text-muted);
  display: block;
  margin-bottom: var(--space-xs);
}

.vote-count {
  font-size: var(--text-xs);
}

/* Comments */
.comments {
  margin-top: var(--space-lg);
}

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

.comment-meta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.comment-author {
  color: var(--accent);
}

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

.comment-text {
  margin: var(--space-sm) 0;
  max-width: 600px;
  color: var(--text);
}

.comment-actions {
  font-size: var(--text-sm);
}

.comment-actions a {
  color: var(--text-muted);
}

.comment-actions a:hover {
  color: var(--accent);
}

.comment-deleted {
  color: var(--text-muted);
  font-style: italic;
}

.no-comments {
  color: var(--text-muted);
  font-style: italic;
}

/* Mobile comment adjustments */
@media (max-width: 640px) {
  .comment {
    margin-left: 0 !important;
    padding-left: var(--space-sm);
    border-left-width: 2px;
  }

  /* Indent nested comments less aggressively on mobile */
  .comment .comment {
    margin-left: var(--space-sm) !important;
  }
}

/* Reply form */
.reply-form {
  margin: var(--space-md) 0;
  display: block;
}

.reply-form textarea {
  display: block;
  width: 100%;
  max-width: 500px;
  font-family: inherit;
  font-size: var(--text-base);
  padding: var(--space-sm);
  margin-bottom: var(--space-sm);
  background: var(--surface);
  border: 1px solid var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  min-height: 80px;
}

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

.reply-form button {
  font-size: var(--text-sm);
  padding: var(--space-sm) var(--space-md);
  margin-right: var(--space-sm);
}

.add-comment {
  margin: var(--space-lg) 0;
  padding-top: var(--space-lg);
  border-top: 1px solid var(--surface);
}

.add-comment h3 {
  margin: 0 0 var(--space-md) 0;
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
}

/* Auth pages */
.auth-page {
  max-width: 400px;
}

.auth-page h1 {
  margin-bottom: var(--space-md);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
}

.auth-page p {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

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

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.form-group label {
  font-weight: 600;
  color: var(--text);
  font-size: var(--text-sm);
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.input-group .form-group {
  margin: 0;
}

.form-divider {
  margin: var(--space-xs) 0 var(--space-sm);
  color: var(--text-muted);
  font-weight: 600;
  font-size: var(--text-sm);
}

.form-group input,
.form-group textarea {
  padding: var(--space-sm);
  font-size: var(--text-base);
  font-family: inherit;
  border: 1px solid var(--surface);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  min-height: 44px;
}

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

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Mobile form adjustments */
@media (max-width: 640px) {
  .auth-page,
  .submit-page,
  .user-page,
  .item-page {
    max-width: none;
  }

  .form-group input,
  .form-group textarea,
  .reply-form textarea {
    font-size: 16px; /* Prevents iOS zoom on focus */
  }
}

/* Submit page */
.submit-page {
  max-width: 600px;
}

.submit-page h1 {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-md);
}

.submit-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* User page */
.user-page h1 {
  margin-bottom: var(--space-sm);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
}

.user-stats {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-xs) var(--space-md);
  margin: var(--space-md) 0;
}

.user-stats dt {
  font-weight: 600;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.user-stats dd {
  color: var(--text);
  font-size: var(--text-sm);
}

.user-about {
  margin: var(--space-lg) 0;
  padding: var(--space-md);
  background: var(--surface);
  max-width: 600px;
  border-radius: var(--radius);
}

.user-about h2 {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-sm);
}

.user-about p {
  color: var(--text);
}

.user-submissions {
  margin-top: var(--space-lg);
}

.user-submissions h2 {
  margin-bottom: var(--space-md);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
}

/* Mobile content width adjustments */
@media (max-width: 640px) {
  .user-about,
  .post-text,
  .comment-text {
    max-width: none;
  }
}

/* Item page */
.item-page {
  max-width: 900px;
}

/* Utility classes */
.error {
  color: var(--text);
  padding: var(--space-md);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid #ef4444;
  border-radius: var(--radius);
  margin-bottom: var(--space-md);
  font-size: var(--text-sm);
}

.empty-state {
  color: var(--text-muted);
  font-style: italic;
  padding: var(--space-md);
}

/* Footer */
footer {
  max-width: 900px;
  margin: var(--space-lg) auto var(--space-md);
  padding: var(--space-md) 0;
  border-top: 1px solid var(--surface);
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-align: center;
}

footer a {
  color: var(--text-muted);
}

footer a:hover {
  color: var(--accent);
}

/* Cloudflare Turnstile */
.cf-turnstile {
  margin: var(--space-sm) 0;
}

/* Buttons */
button {
  background: var(--accent);
  color: white;
  border: none;
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  font-size: var(--text-sm);
  font-family: inherit;
  font-weight: 600;
  border-radius: var(--radius);
  min-height: 44px;
}

button:hover {
  background: #2563eb;
}

/* Mobile button adjustments */
@media (max-width: 640px) {
  .auth-form button,
  .submit-form button {
    width: 100%;
  }
}
