/* Forg — app.css
 * App shell and content engine UI styles.
 * Inherits all tokens from theme.css (loaded first).
 * Does NOT re-declare :root tokens.
 */

/* ============================================
   APP SHELL
   ============================================ */
.app-body {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================================
   NAV
   ============================================ */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 48px;
  height: 60px;
  background: rgba(8, 13, 8, 0.92);
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.app-nav-logo {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.app-nav-logo:hover {
  color: var(--accent);
}

.app-nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
}

.app-nav-link {
  font-size: 0.875rem;
  color: var(--fg-muted);
  text-decoration: none;
  transition: color 0.15s;
}

.app-nav-link:hover {
  color: var(--fg);
}

/* ============================================
   MAIN CONTENT AREA
   ============================================ */
.app-main {
  flex: 1;
  padding: 48px 48px 80px;
}

.app-page {
  max-width: 720px;
  margin: 0 auto;
}

.app-page-wide {
  max-width: 1060px;
}

.app-page-center {
  text-align: center;
  padding-top: 80px;
}

.app-page-header {
  margin-bottom: 40px;
}

/* ============================================
   TYPOGRAPHY UTILITIES
   ============================================ */
.app-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid rgba(61, 220, 132, 0.18);
  padding: 4px 12px;
  border-radius: 3px;
  margin-bottom: 20px;
}

.app-heading {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--fg);
  line-height: 1.1;
  margin-bottom: 12px;
}

.app-subheading {
  font-size: 1rem;
  color: var(--fg-muted);
  line-height: 1.7;
  max-width: 540px;
}

/* ============================================
   FORMS
   ============================================ */
.app-form {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-row-2 > .form-field {
  flex: 1;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-field label {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--fg-muted);
  letter-spacing: 0.01em;
}

.req {
  color: var(--danger);
  opacity: 0.7;
}

.optional {
  font-weight: 400;
  opacity: 0.55;
}

.form-field input,
.form-field select,
.form-field textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

.form-field input::placeholder,
.form-field textarea::placeholder {
  color: var(--fg-dim);
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: rgba(61, 220, 132, 0.4);
  box-shadow: 0 0 0 3px rgba(61, 220, 132, 0.08);
}

.form-field select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237a8f7a' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.form-field select option {
  background: var(--surface);
  color: var(--fg);
}

.form-field textarea {
  resize: vertical;
  min-height: 88px;
  line-height: 1.6;
}

.field-hint {
  font-size: 0.8rem;
  color: var(--fg-dim);
  line-height: 1.5;
}

.topic-input {
  font-size: 1.05rem !important;
  padding: 14px 16px !important;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
  color: #000;
  background: var(--accent);
  padding: 13px 24px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, transform 0.12s;
}

.btn-primary:hover {
  background: #4aeea0;
  box-shadow: 0 0 20px rgba(61, 220, 132, 0.2), 0 4px 12px rgba(61, 220, 132, 0.15);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  cursor: not-allowed;
}

.btn-full {
  width: 100%;
  justify-content: center;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--fg-muted);
  padding: 12px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.btn-ghost:hover {
  border-color: var(--border);
  color: var(--fg);
}

.btn-arrow {
  display: inline-block;
  transition: transform 0.15s;
}

.btn-primary:hover .btn-arrow,
.btn-ghost:hover .btn-arrow {
  transform: translateX(3px);
}

/* ============================================
   ERROR STATE
   ============================================ */
.app-error {
  padding: 14px 18px;
  background: rgba(232, 93, 74, 0.08);
  border: 1px solid rgba(232, 93, 74, 0.2);
  border-radius: var(--radius);
  color: #f0907d;
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 8px;
}

/* ============================================
   PROFILE SUMMARY (in generate page)
   ============================================ */
.profile-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
}

.profile-summary-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.profile-summary-pill {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--fg-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 4px 10px;
  text-transform: capitalize;
}

.tone-pill {
  color: var(--accent);
  border-color: rgba(61, 220, 132, 0.2);
  background: var(--accent-glow);
}

.profile-summary-change {
  font-size: 0.8rem;
  color: var(--fg-dim);
  text-decoration: none;
  margin-left: 4px;
  transition: color 0.15s;
}

.profile-summary-change:hover {
  color: var(--fg-muted);
}

/* ============================================
   TOPIC SUGGESTIONS
   ============================================ */
.topic-suggestions {
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
}

.suggestions-label {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin-bottom: 12px;
}

.suggestions-chips {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.suggestion-chip {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg-muted);
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 9px 14px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.suggestion-chip:hover {
  border-color: rgba(61, 220, 132, 0.25);
  color: var(--fg);
  background: rgba(61, 220, 132, 0.04);
}

/* ============================================
   POSTS CTA
   ============================================ */
.posts-cta {
  margin-top: 32px;
  text-align: center;
}

.posts-cta-link {
  font-size: 0.875rem;
  color: var(--fg-dim);
  text-decoration: none;
  transition: color 0.15s;
}

.posts-cta-link:hover {
  color: var(--fg-muted);
}

/* ============================================
   POST VIEW
   ============================================ */
.post-header {
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 40px;
}

.post-meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.post-business {
  font-size: 0.85rem;
  color: var(--fg-muted);
}

.post-dot {
  color: var(--fg-dim);
}

.post-date {
  font-size: 0.82rem;
  color: var(--fg-dim);
}

.post-title {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--fg);
  line-height: 1.15;
  margin-bottom: 12px;
}

.post-meta-description {
  font-size: 1rem;
  color: var(--fg-muted);
  line-height: 1.7;
  margin-bottom: 16px;
  font-style: italic;
}

.post-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.keyword-tag {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-dim);
  background: rgba(61, 220, 132, 0.06);
  border: 1px solid rgba(61, 220, 132, 0.14);
  border-radius: 2px;
  padding: 3px 9px;
  letter-spacing: 0.04em;
}

/* Post layout: article + sidebar */
.post-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 48px;
  align-items: start;
}

/* ============================================
   POST BODY MARKDOWN RENDERING
   ============================================ */
.post-body {
  color: var(--fg);
  line-height: 1.8;
  font-size: 1rem;
}

.post-body h1, .post-body h2 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--fg);
  margin: 36px 0 14px;
  line-height: 1.2;
}

.post-body h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--fg);
  margin: 28px 0 10px;
}

.post-body p {
  margin-bottom: 18px;
  color: #c8d4c8;
}

.post-body ul, .post-body ol {
  margin: 0 0 18px 20px;
}

.post-body li {
  margin-bottom: 6px;
  color: #c8d4c8;
}

.post-body strong {
  color: var(--fg);
  font-weight: 600;
}

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

/* ============================================
   POST SIDEBAR
   ============================================ */
.post-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 76px;
}

.sidebar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.sidebar-label {
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin-bottom: 14px;
}

.sidebar-action {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  color: var(--fg-muted);
  text-decoration: none;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
  transition: color 0.15s;
}

.sidebar-action:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.sidebar-action:first-of-type {
  padding-top: 0;
}

.sidebar-action:hover {
  color: var(--fg);
}

.sidebar-action-icon {
  font-size: 1rem;
  opacity: 0.6;
  flex-shrink: 0;
}

.sidebar-keywords {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-keyword {
  font-size: 0.82rem;
  color: var(--fg-muted);
  padding: 6px 10px;
  background: var(--bg);
  border-radius: 3px;
  border: 1px solid var(--border-subtle);
}

.sidebar-biz-name {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 4px;
}

.sidebar-biz-meta {
  font-size: 0.8rem;
  color: var(--fg-muted);
  margin-bottom: 6px;
}

.sidebar-biz-tone {
  font-size: 0.78rem;
  color: var(--accent-dim);
  font-style: italic;
  text-transform: capitalize;
}

/* ============================================
   POST ACTIONS BOTTOM
   ============================================ */
.post-actions-bottom {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 56px;
  padding-top: 32px;
  border-top: 1px solid var(--border-subtle);
}

/* ============================================
   POSTS LIST (posts.ejs)
   ============================================ */
.posts-toolbar {
  margin-bottom: 28px;
}

.posts-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.post-card {
  display: block;
  padding: 20px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 8px;
}

.post-card:hover {
  border-color: rgba(61, 220, 132, 0.2);
  background: var(--surface-raised);
}

.post-card-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}

.post-card-desc {
  font-size: 0.875rem;
  color: var(--fg-muted);
  line-height: 1.55;
  margin-bottom: 12px;
}

.post-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.post-card-topic {
  font-size: 0.78rem;
  color: var(--fg-dim);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.post-card-date {
  font-family: var(--font-display);
  font-size: 0.72rem;
  color: var(--fg-dim);
  flex-shrink: 0;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.empty-icon {
  font-size: 2.4rem;
  opacity: 0.3;
}

.empty-text {
  font-size: 1rem;
  color: var(--fg-muted);
  max-width: 320px;
  line-height: 1.6;
}

/* ============================================
   APP FOOTER
   ============================================ */
.app-footer {
  padding: 24px 48px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
  .post-layout {
    grid-template-columns: 1fr;
  }
  .post-sidebar {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
  }
  .sidebar-card {
    flex: 1;
    min-width: 220px;
  }
}

@media (max-width: 768px) {
  .app-nav {
    padding: 0 20px;
  }
  .app-main {
    padding: 32px 20px 60px;
  }
  .app-footer {
    padding: 20px;
  }
  .form-row {
    flex-direction: column;
  }
  .post-actions-bottom {
    flex-direction: column;
    align-items: flex-start;
  }
}
