/* ============================================================
   Fearless Tools — API Docs page styles
   Covers: header nav, intro section, explainer cards,
   permissions matrix, Scalar integration, error banner.
   Brand tokens are in styles/tokens.css (imported via styles.css).
   ============================================================ */

/* ── Scalar CSS variable overrides — Fearless brand ── */
:root {
  --scalar-color-accent:   #5C3977;   /* purple — links, highlights */
  --scalar-font:           'Montserrat', sans-serif;
  --scalar-background-1:   #ffffff;
  --scalar-background-2:   #F3F3F4;
  --scalar-background-3:   #ECECED;
  --scalar-color-1:        #494F56;
  --scalar-color-2:        #5B6066;
  --scalar-color-3:        #7F8388;
  --scalar-border-color:   rgba(22, 10, 36, 0.09);
  --scalar-color-green:    #2e7d32;   /* GET  */
  --scalar-color-blue:     #1565c0;   /* POST */
  --scalar-color-orange:   #e65100;   /* PUT  */
  --scalar-color-red:      #c62828;   /* DELETE */
}

/* ── Error Banner ── */
.api-error-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff3e0;
  color: #bf360c;
  border-left: 4px solid #e65100;
  padding: 14px 24px;
  font-size: 14px;
  font-weight: 600;
}

/* ── Page Wrapper ── */
.api-page {
  background: var(--color-bg);
  min-height: calc(100vh - 64px);
}

/* ── Section inner (max-width container) ── */
.api-section-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 56px 40px;
}

.api-section-inner--flush {
  padding-bottom: 24px;
}

/* ── Section Headings ── */
.section-heading-row {
  margin-bottom: 32px;
}

.section-heading {
  font-size: 26px;
  font-weight: 700;
  color: var(--purple-deep);
  margin-bottom: 6px;
}

.section-subheading {
  font-size: 14px;
  color: var(--text-muted);
}

/* ── Intro Section ── */
.api-intro {
  background: var(--purple-deep);
  color: white;
  border-left: 6px solid var(--orange);
}

.api-intro-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 40px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  flex-wrap: wrap;
}

.api-intro h1 {
  font-size: 36px;
  font-weight: 700;
  font-family: 'Montserrat Alternates', 'Montserrat', sans-serif;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
  line-height: 1.15;
}

.api-intro-subtitle {
  font-size: 18px;
  font-weight: 600;
  color: var(--orange-fade);
  margin-bottom: 10px;
}

.api-intro-desc {
  font-size: 15px;
  color: var(--text-on-dark-muted);
  max-width: 520px;
  line-height: 1.6;
}

.api-intro-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
}

.api-updated-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-on-dark-dim);
}

.api-updated-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-on-dark-muted);
}

/* ── Explainer Section ── */
.api-explainer {
  background: white;
  border-bottom: 1px solid var(--color-border);
}

.explainer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}

.explainer-card {
  background: var(--neutral-100);
  border-radius: var(--radius-md);
  padding: 28px 32px;
  border-top: 3px solid var(--purple);
}

.explainer-card p + p {
  margin-top: 10px;
}

.explainer-card-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--purple-deep);
  margin-bottom: 14px;
}

.explainer-sub-heading {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 16px 0 8px;
}

.explainer-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 4px;
}

.explainer-table th {
  text-align: left;
  padding: 6px 10px;
  background: var(--purple);
  color: white;
  font-weight: 600;
}

.explainer-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--neutral-300);
  color: var(--neutral-900);
}

.explainer-table tr:last-child td {
  border-bottom: none;
}

.explainer-steps {
  padding-left: 20px;
  font-size: 14px;
  line-height: 1.7;
}

.explainer-steps li {
  margin-bottom: 4px;
}

.explainer-contact {
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-muted);
}

.explainer-contact a {
  color: var(--purple);
  font-weight: 600;
}

code {
  font-family: 'SFMono-Regular', 'Consolas', monospace;
  font-size: 0.875em;
  background: var(--neutral-300);
  color: var(--purple-dark);
  padding: 1px 5px;
  border-radius: 3px;
}

/* ── Access Request Form Section ── */
.api-request-section {
  background: white;
  border-bottom: 1px solid var(--color-border);
}

.request-form-wrap {
  max-width: 720px;
}

.request-success {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: #e8f5e9;
  border: 1px solid #a5d6a7;
  border-radius: var(--radius-md);
  padding: 20px 24px;
  color: #1b5e20;
  font-size: 14px;
  flex-wrap: wrap;
}

.request-success svg {
  color: #2e7d32;
  flex-shrink: 0;
  margin-top: 1px;
}

.request-success strong {
  display: block;
  margin-bottom: 2px;
}

.btn-link {
  background: none;
  border: none;
  color: var(--purple);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  text-decoration: underline;
  margin-top: 8px;
  width: 100%;
  text-align: left;
}

.request-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-row--2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

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

.form-field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--purple-deep);
}

.required {
  color: var(--orange);
}

.form-field input[type="text"],
.form-field input[type="email"],
.form-field textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--neutral-900);
  background: white;
  border: 1px solid var(--neutral-400);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
  width: 100%;
}

.form-field input:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: var(--shadow-focus-purple);
}

.form-field textarea {
  resize: vertical;
  min-height: 80px;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  padding: 12px 0 4px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 400;
  color: var(--neutral-900);
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--purple);
  cursor: pointer;
  flex-shrink: 0;
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 0;
}

.radio-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 400;
  color: var(--neutral-900);
}

.radio-label input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--purple);
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 2px;
}

.form-error {
  background: #fce4e4;
  border: 1px solid var(--orange-fade);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--orange-dark);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-primary {
  background: var(--purple);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  padding: 11px 24px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--duration-fast);
}

.btn-primary:hover { background: var(--purple-dark); }
.btn-primary:disabled { background: var(--purple-wash); cursor: not-allowed; }

/* ── Permissions Section ── */
.api-permissions {
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

/* Loading dots */
.matrix-loading,
.scalar-loading {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 32px 0;
  color: var(--text-muted);
  font-size: 13px;
}

.loading-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--purple-wash);
  animation: dot-pulse 1.2s infinite ease-in-out;
  display: inline-block;
}

.loading-dot:nth-child(2) { animation-delay: 0.2s; }
.loading-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-pulse {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); }
  40%           { opacity: 1;    transform: scale(1);    }
}

.loading-label {
  margin-left: 4px;
}

/* Matrix table wrapper — horizontal scroll on mobile */
.matrix-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.permissions-matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  color: var(--neutral-900);
  background: white;
  min-width: 560px;
}

.permissions-matrix thead tr {
  background: var(--purple);
  color: white;
}

.permissions-matrix thead th {
  padding: 13px 18px;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.permissions-matrix tbody tr:nth-child(even) {
  background: var(--neutral-100);
}

.permissions-matrix tbody tr:hover {
  background: #f0ecf5;
}

.permissions-matrix tbody td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--neutral-300);
  vertical-align: top;
}

.permissions-matrix tbody tr:last-child td {
  border-bottom: none;
}

.app-name-cell {
  font-weight: 600;
  min-width: 180px;
}

.app-desc {
  display: block;
  font-weight: 400;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.app-owner-cell {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

.perm-cell {
  text-align: center;
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
}

.perm-none {
  color: var(--neutral-400);
}

.perm-read {
  color: #1b5e20;
  background: rgba(46, 125, 50, 0.1);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
}

.perm-readwrite {
  color: #bf360c;
  background: rgba(230, 81, 0, 0.1);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
}

/* ── API Reference Section ── */
.api-reference-section {
  background: white;
  padding-bottom: 0;
}

.scalar-wrap {
  border-top: 1px solid var(--color-border);
}

/* Scalar container */
#api-reference {
  display: block;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .api-intro-inner {
    padding: 36px 24px;
    flex-direction: column;
    align-items: flex-start;
  }

  .api-intro h1 { font-size: 28px; }
  .api-intro-subtitle { font-size: 16px; }

  .api-intro-meta {
    align-items: flex-start;
  }

  .api-section-inner {
    padding: 40px 24px;
  }

  .explainer-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .header-nav {
    display: none; /* mobile: hide nav (header already collapses) */
  }
}

@media (max-width: 600px) {
  .api-section-inner {
    padding: 32px 16px;
  }

  .api-intro-inner {
    padding: 28px 16px;
  }

  .api-intro h1 { font-size: 24px; }
}
