/* ==========================================================================
   RailsPress Documentation - Reusable UI Components
   ==========================================================================
   Every component includes an HTML structure comment so the sync-docs skill
   knows exactly how to generate markup. All values reference --rp-* variables
   from variables.css.
   ========================================================================== */


/* -----------------------------------------------------------------------
   1. Code Blocks
   -----------------------------------------------------------------------

   HTML Structure:
   <div class="code-block">
     <div class="code-header">
       <span class="code-lang">ruby</span>
       <button class="copy-btn">Copy</button>
     </div>
     <pre class="code-content"><code>...</code></pre>
   </div>

   ----------------------------------------------------------------------- */

.code-block {
  background: var(--rp-code-bg);
  border-radius: var(--rp-radius);
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.code-header,
.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--rp-space-sm) var(--rp-space-md);
  background: var(--rp-code-surface);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.code-block-header span {
  font-family: var(--rp-font-mono);
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 0.01em;
}

.code-lang {
  font-family: var(--rp-font-mono);
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 0.01em;
}

.copy-btn {
  font-family: var(--rp-font-mono);
  font-size: 0.75rem;
  color: var(--rp-text-light);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  transition: all var(--rp-transition-fast);
}

.copy-btn:hover {
  color: var(--rp-code-text);
  border-color: rgba(255, 255, 255, 0.2);
}

.copy-btn.copied {
  color: var(--rp-code-string);
  border-color: var(--rp-code-string);
}

/* Scrollbar on the actual scrolling elements, not the container.
   padding-bottom on <code> (not <pre>) ensures scrollbar hugs bottom edge.
   Requires <pre><code>...</code></pre> structure. */

.code-content {
  padding: 1.25rem 1.5rem 0;
  margin: 0;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.code-content code {
  display: block;
  padding-bottom: 1.25rem;
  font-family: var(--rp-font-mono);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--rp-code-text);
}

/* pre/code inside code-block (when not wrapped in .code-content) */
.code-block > pre {
  padding: 1.25rem 1.5rem 0;
  margin: 0;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.code-block > pre code {
  display: block;
  padding-bottom: 1.25rem;
  font-family: var(--rp-font-mono);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--rp-code-text);
}

/* Syntax Highlighting Classes */
.code-keyword { color: var(--rp-code-keyword); }
.code-string  { color: var(--rp-code-string); }
.code-class   { color: var(--rp-code-class); }
.code-comment { color: var(--rp-code-comment); font-style: italic; }
.code-tag     { color: var(--rp-code-tag); }
.code-url     { color: var(--rp-code-url); }
.code-prompt  { color: var(--rp-code-comment); user-select: none; }

/* Custom Scrollbar — WebKit (targets the actual scrolling elements) */
.code-content::-webkit-scrollbar,
.code-block > pre::-webkit-scrollbar {
  height: 6px;
}

.code-content::-webkit-scrollbar-track,
.code-block > pre::-webkit-scrollbar-track {
  background: transparent;
}

.code-content::-webkit-scrollbar-thumb,
.code-block > pre::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.code-content::-webkit-scrollbar-thumb:hover,
.code-block > pre::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}


/* -----------------------------------------------------------------------
   1b. Code Window (hero / showcase variant)
   -----------------------------------------------------------------------

   HTML Structure:
   <div class="code-window">
     <div class="code-header">
       <div class="code-dots">
         <span></span><span></span><span></span>
       </div>
       <span class="code-filename">app/models/post.rb</span>
     </div>
     <pre class="code-content"><code>...</code></pre>
   </div>

   ----------------------------------------------------------------------- */

.code-window {
  background: var(--rp-code-bg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--rp-shadow-lg);
}

.code-window .code-header {
  display: flex;
  align-items: center;
  gap: var(--rp-space-md);
  padding: var(--rp-space-md) var(--rp-space-lg);
  background: var(--rp-code-surface);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.code-dots {
  display: flex;
  gap: 6px;
}

.code-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.code-dots span:first-child  { background: #f87171; }
.code-dots span:nth-child(2) { background: #fbbf24; }
.code-dots span:last-child   { background: #4ade80; }

.code-filename {
  font-family: var(--rp-font-mono);
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
}


/* -----------------------------------------------------------------------
   2. Callouts
   -----------------------------------------------------------------------

   HTML Structure:
   <div class="callout callout-info">
     <div class="callout-title">Note</div>
     <div class="callout-content"><p>...</p></div>
   </div>

   Variants: callout-info, callout-warning, callout-tip

   ----------------------------------------------------------------------- */

.callout {
  padding: var(--rp-space-lg);
  border-radius: var(--rp-radius);
  border-left: 3px solid var(--rp-border);
  margin-bottom: var(--rp-space-xl);
}

.callout-title {
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: var(--rp-space-xs);
}

.callout-content p {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--rp-text-muted);
  line-height: 1.6;
}

/* Info variant */
.callout-info {
  border-left-color: var(--rp-primary);
  background: var(--rp-info-light);
}

.callout-info .callout-title {
  color: var(--rp-primary);
}

/* Warning variant */
.callout-warning {
  border-left-color: #d97706;
  background: #fffbeb;
}

.callout-warning .callout-title {
  color: #92400e;
}

/* Tip variant */
.callout-tip {
  border-left-color: var(--rp-success);
  background: var(--rp-success-light);
}

.callout-tip .callout-title {
  color: var(--rp-success);
}

/* Dark mode callout overrides */
[data-theme="dark"] .callout-warning {
  background: rgba(217, 119, 6, 0.08);
}

[data-theme="dark"] .callout-warning .callout-title {
  color: #fbbf24;
}


/* -----------------------------------------------------------------------
   3. Cards
   -----------------------------------------------------------------------

   HTML Structure:
   <div class="card-grid">
     <a href="..." class="card">
       <h3>Title</h3>
       <p>Description</p>
     </a>
   </div>

   ----------------------------------------------------------------------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--rp-space-lg);
}

.card {
  background: var(--rp-bg-elevated);
  border: 1px solid var(--rp-border);
  border-radius: var(--rp-radius);
  padding: var(--rp-space-xl);
  box-shadow: var(--rp-shadow-sm);
  text-decoration: none;
  transition: border-color var(--rp-transition-fast),
              transform var(--rp-transition-fast),
              box-shadow var(--rp-transition-fast);
}

.card:hover {
  border-color: var(--rp-border-light);
  transform: translateY(-2px);
  box-shadow: var(--rp-shadow-md);
}

.card h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: var(--rp-space-sm);
  color: var(--rp-text);
  display: flex;
  align-items: center;
  gap: var(--rp-space-sm);
}

.card h3::before {
  content: "";
  width: 4px;
  height: 1em;
  background: var(--rp-primary);
  border-radius: 2px;
  flex-shrink: 0;
}

.card p {
  font-size: 0.9375rem;
  color: var(--rp-text-muted);
  line-height: 1.5;
  margin: 0;
}


/* -----------------------------------------------------------------------
   4. Feature Cards (landing page, extends card)
   -----------------------------------------------------------------------

   HTML Structure:
   <div class="feature-card">
     <div class="feature-icon">
       <svg>...</svg>
     </div>
     <h3>Feature Title</h3>
     <p>Feature description text.</p>
   </div>

   Variant:
   <div class="feature-card feature-card-highlight">
     <div class="feature-icon">
       <svg>...</svg>
     </div>
     <h3>Highlighted Feature</h3>
     <p>Description of highlighted feature.</p>
   </div>

   ----------------------------------------------------------------------- */

.feature-card {
  background: var(--rp-bg-elevated);
  border: 1px solid var(--rp-border);
  border-radius: var(--rp-radius);
  padding: var(--rp-space-xl);
  transition: border-color var(--rp-transition-base),
              transform var(--rp-transition-base),
              box-shadow var(--rp-transition-base);
}

.feature-card:hover {
  border-color: var(--rp-border-light);
  transform: translateY(-4px);
  box-shadow: var(--rp-shadow-lg);
}

.feature-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--rp-primary-light);
  border-radius: 10px;
  margin-bottom: var(--rp-space-lg);
  color: var(--rp-primary);
}

.feature-card h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: var(--rp-space-sm);
  color: var(--rp-text);
}

.feature-card p {
  font-size: 0.9375rem;
  color: var(--rp-text-muted);
  line-height: 1.6;
  margin: 0;
}

/* Highlighted feature card variant */
.feature-card-highlight {
  background: linear-gradient(135deg, var(--rp-bg-elevated) 0%, var(--rp-bg-subtle) 100%);
  border-color: var(--rp-primary-light);
  position: relative;
  overflow: hidden;
}

.feature-card-highlight::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--rp-primary) 0%, transparent 100%);
}

.feature-card-highlight:hover {
  border-color: var(--rp-primary);
}

.feature-card-highlight .feature-icon {
  background: var(--rp-primary);
  color: #ffffff;
}


/* -----------------------------------------------------------------------
   5. Image Placeholders
   -----------------------------------------------------------------------

   HTML Structure:
   <div class="image-placeholder">
     <span class="image-placeholder-label">Screenshot: Creating a new post</span>
   </div>

   ----------------------------------------------------------------------- */

.image-placeholder {
  min-height: 200px;
  border: 2px dashed var(--rp-border);
  background: var(--rp-bg-subtle);
  border-radius: var(--rp-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--rp-space-xl);
}

.image-placeholder-label {
  font-size: 0.875rem;
  color: var(--rp-text-light);
  font-style: italic;
}


/* -----------------------------------------------------------------------
   6. Buttons
   -----------------------------------------------------------------------

   HTML Structure:
   <button class="btn btn-primary">Primary Action</button>
   <button class="btn btn-secondary">Secondary Action</button>

   ----------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--rp-space-sm);
  padding: var(--rp-space-sm) var(--rp-space-lg);
  font-family: var(--rp-font-mono);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--rp-radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--rp-transition-fast);
  text-decoration: none;
}

.btn-primary {
  background: var(--rp-primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--rp-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--rp-shadow-md);
}

.btn-secondary {
  background: transparent;
  color: var(--rp-text-muted);
  border-color: var(--rp-border);
}

.btn-secondary:hover {
  color: var(--rp-text);
  border-color: var(--rp-text-light);
  background: var(--rp-bg-elevated);
}


/* -----------------------------------------------------------------------
   7. Badges
   -----------------------------------------------------------------------

   HTML Structure:
   <span class="badge badge-draft">Draft</span>
   <span class="badge badge-published">Published</span>
   <span class="badge badge-scheduled">Scheduled</span>

   ----------------------------------------------------------------------- */

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  font-size: 0.6875rem;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.badge-draft {
  background: var(--rp-bg-subtle);
  color: var(--rp-text-light);
}

.badge-published {
  background: var(--rp-success-light);
  color: var(--rp-success);
}

.badge-scheduled {
  background: var(--rp-info-light);
  color: var(--rp-primary);
}


/* -----------------------------------------------------------------------
   8. Steps
   -----------------------------------------------------------------------

   HTML Structure:
   <div class="steps">
     <div class="step">
       <div class="step-number">01</div>
       <div class="step-content">
         <h4>Title</h4>
         <div class="code-block">...</div>
       </div>
     </div>
   </div>

   ----------------------------------------------------------------------- */

.steps {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-left: 2px solid var(--rp-border);
  margin-left: var(--rp-space-md);
  padding-left: 0;
}

.step {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--rp-space-md);
  padding: var(--rp-space-md) 0 var(--rp-space-lg) 0;
  position: relative;
}

.step:not(:last-child) {
  border-bottom: 1px solid var(--rp-border);
}

.step-number {
  font-family: var(--rp-font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--rp-bg);
  background: var(--rp-primary);
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: calc(-1 * var(--rp-space-md) - 1rem - 1px);
  line-height: 1;
  flex-shrink: 0;
}

.step-content {
  padding-top: 0.25rem;
}

.prose .step-content h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 0;
  margin-bottom: var(--rp-space-xs);
  color: var(--rp-text);
}

.step-content p {
  margin-top: 0;
  color: var(--rp-text-muted);
}
