/* templates.css — styling for the Templates page (gallery + sidebar).
 *
 * Owned by `pages/templates.js`. Tokens consumed from `tokens.css`.
 * Goals:
 *   - Per-template icons render at a stable 28px inside the card and
 *     20px inside the side-panel category rows. Unconstrained SVG
 *     children were filling the parent and dominating the layout.
 *   - Cards have a subtle Monero-orange-tinted icon plate so the
 *     visual rhythm distinguishes "Dark Contract" cards from
 *     "Sovereign site" cards at a glance.
 *   - Hover lifts the card 1px and saturates the icon plate. Same
 *     150ms ease-out the rest of the IDE uses.
 *   - Detail modal header uses a slightly larger 36px icon so the
 *     focused template feels like a hero.
 */

.templates-page {
  padding: 24px 32px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.templates-page > header h2 {
  margin: 0 0 4px;
  font-size: var(--fs-2xl);
  font-weight: 600;
  color: var(--text-primary);
}

.templates-page > header p {
  margin: 0;
  color: var(--text-secondary);
  font-size: var(--fs-base);
}

/* Gallery grid — auto-fit so the gallery comfortably reflows
 * between the desktop wide-canvas (~3 columns) and the narrow
 * tablet / split-window cases (1-2 columns).
 */
.templates-grid,
.template-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* Empty-state when the search filters out every card. */
.template-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

/* ─── Card ─────────────────────────────────────────────────────── */

.template-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 18px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition:
    transform 150ms ease-out,
    border-color 150ms ease-out,
    box-shadow 150ms ease-out;
  outline: none;
}

.template-card:hover,
.template-card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--border-focus);
  box-shadow: var(--shadow-elev-2);
}

.template-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Icon plate — 44x44 rounded square holding a fixed-size SVG.
 * Subtle accent gradient gives every card a Monero-orange highlight;
 * the icon stroke uses `--accent` so it pops against the dark plate.
 */
.card-icon {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: linear-gradient(135deg,
    rgba(255, 102, 0, 0.18) 0%,
    rgba(255, 102, 0, 0.06) 100%);
  border: 1px solid rgba(255, 102, 0, 0.18);
  color: var(--accent);
  transition: background 150ms ease-out, transform 150ms ease-out;
}

.template-card:hover .card-icon {
  background: linear-gradient(135deg,
    rgba(255, 102, 0, 0.28) 0%,
    rgba(255, 102, 0, 0.10) 100%);
  transform: scale(1.04);
}

/* Hard-cap the SVG size; unconstrained children were filling the card. */
.card-icon svg {
  width: 24px;
  height: 24px;
  display: block;
}

/* Slight tonal differentiator for sovereign-site cards — a
 * cooler cyan-tinted plate so the kind reads visually.
 */
.template-card[data-tpl-kind="site"] .card-icon {
  background: linear-gradient(135deg,
    rgba(56, 189, 248, 0.18) 0%,
    rgba(56, 189, 248, 0.06) 100%);
  border-color: rgba(56, 189, 248, 0.18);
  color: var(--info);
}

.template-card[data-tpl-kind="site"]:hover .card-icon {
  background: linear-gradient(135deg,
    rgba(56, 189, 248, 0.28) 0%,
    rgba(56, 189, 248, 0.10) 100%);
}

.card-kind {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 500;
}

.card-name {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-primary);
  line-height: var(--lh-tight);
}

.card-blurb {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: 1.45;
  flex: 1;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
  margin-top: 4px;
}

.card-footer .file-count {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ─── Side-panel categories ────────────────────────────────────── */

.templates-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 12px;
}

.templates-side .form-row {
  margin: 0;
}

.templates-side .search-input {
  width: 100%;
  background: var(--bg-popover);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: var(--fs-sm);
  outline: none;
  transition: border-color 120ms ease-out;
}

.templates-side .search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

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

.category-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  text-align: left;
  width: 100%;
  transition: background 120ms ease-out, color 120ms ease-out;
}

.category-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.category-item.active {
  background: var(--bg-active);
  color: var(--text-primary);
  border-color: rgba(255, 102, 0, 0.25);
}

/* Inline category icon — strictly 16x16 so it sits inline. The
 * unconstrained SVG was rendering at 100% and dominating the side
 * panel layout.
 */
.category-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.category-item .count {
  margin-left: auto;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.templates-help {
  margin-top: 8px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.templates-help details {
  cursor: pointer;
}

.templates-help summary {
  padding: 6px 0;
  color: var(--text-secondary);
}

.templates-help summary:hover {
  color: var(--text-primary);
}

/* ─── Detail modal ─────────────────────────────────────────────── */

.template-detail {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.detail-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.detail-icon {
  width: 56px;
  height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: linear-gradient(135deg,
    rgba(255, 102, 0, 0.22) 0%,
    rgba(255, 102, 0, 0.08) 100%);
  border: 1px solid rgba(255, 102, 0, 0.22);
  color: var(--accent);
  flex-shrink: 0;
}

.detail-icon svg {
  width: 30px;
  height: 30px;
}

/* ──────────────────────────────────────────────────────────────────────
 * Reference side panel — styles for `pages/reference.js`'s doc picker
 * (DSOL Language / Dark Contracts ABI / Sovereign Sites ABI / Changelog)
 * and the per-doc table-of-contents that follows it.
 *
 * Pre-fix these classes had no styles, so the buttons flowed inline
 * and the TOC anchors ran together as one block of text — illegible
 * on mobile AND desktop. Adding the styles here (in the same file
 * as the Templates side panel) keeps the side-content surface
 * consistent across activities.
 * ────────────────────────────────────────────────────────────────────── */

.reference-side {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 14px 12px 24px;
}

.ref-doc-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ref-doc {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: var(--text-primary);
  font-family: inherit;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease-out),
              border-color var(--t-fast) var(--ease-out);
}

.ref-doc:hover {
  background: var(--bg-hover, rgba(255, 255, 255, 0.04));
  border-color: var(--border-subtle);
}

.ref-doc.active {
  background: var(--accent-soft, rgba(255, 102, 0, 0.10));
  border-color: rgba(255, 102, 0, 0.30);
}

.ref-doc-label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.ref-doc-blurb {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  line-height: 1.4;
  margin-top: 2px;
}

.ref-toc-section .section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 8px;
  padding: 0 4px;
}

.ref-toc {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ref-toc-item {
  display: block;
  padding: 6px 10px;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  line-height: 1.3;
  transition: background var(--t-fast) var(--ease-out),
              color var(--t-fast) var(--ease-out);
}

.ref-toc-item:hover {
  background: var(--bg-hover, rgba(255, 255, 255, 0.03));
  color: var(--text-primary);
}

.ref-toc-l1 { padding-left: 10px; font-weight: 600; color: var(--text-primary); }
.ref-toc-l2 { padding-left: 18px; }
.ref-toc-l3 { padding-left: 28px; font-size: var(--fs-xs); }
.ref-toc-l4,
.ref-toc-l5,
.ref-toc-l6 { padding-left: 36px; font-size: var(--fs-xs); }

.ref-toc-empty {
  padding: 8px 10px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

/* Reference page (the article body in the editor-area) gets a comfortable
 * reading width on wide screens, then expands to full-width on mobile so
 * code blocks don't horizontal-scroll inside a constrained column.
 */
.reference-page {
  padding: 24px 32px 48px;
  max-width: 880px;
  margin: 0 auto;
}

.reference-head {
  margin-bottom: 14px;
}

@media (max-width: 768px) {
  .reference-page {
    padding: 16px 14px 36px;
  }
  .reference-side {
    padding: 12px 10px 20px;
  }
}

/* ──────────────────────────────────────────────────────────────────────
 * Settings side panel — styles for `pages/settings.js`'s section
 * picker (Indexer / Editor / Storage / Keyboard / About). Same
 * pattern as `.ref-doc`: a button with a bold label + muted blurb,
 * stacked vertically, with an orange accent on the active section.
 *
 * Pre-fix the buttons had no styles and flowed inline as a wall of
 * comma-separated text. Tested with the same browser-preview pass
 * that fixed the Reference side panel.
 * ────────────────────────────────────────────────────────────────────── */

.settings-side {
  display: flex;
  flex-direction: column;
  padding: 14px 12px 24px;
}

.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: var(--text-primary);
  font-family: inherit;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease-out),
              border-color var(--t-fast) var(--ease-out);
}

.settings-item:hover {
  background: var(--bg-hover, rgba(255, 255, 255, 0.04));
  border-color: var(--border-subtle);
}

.settings-item.active {
  background: var(--accent-soft, rgba(255, 102, 0, 0.10));
  border-color: rgba(255, 102, 0, 0.30);
}

.settings-item .label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.settings-item .blurb {
  display: block;
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  line-height: 1.4;
  margin-top: 2px;
}

@media (max-width: 768px) {
  .settings-side {
    padding: 12px 10px 20px;
  }
}
