/* TRON Wiki — Components */

/* ── Buttons ── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 38px;
  padding: 0 var(--space-5);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast),
    box-shadow var(--duration-fast),
    transform var(--duration-fast);
  text-decoration: none;
}

.btn:active { transform: scale(0.98); }

.btn--primary {
  background: var(--color-accent);
  color: #fff;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.12);
}

.btn--primary:hover {
  background: var(--color-accent-hover);
  color: #fff;
  text-decoration: none;
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.12);
}

.btn--secondary {
  background: var(--bg-surface);
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--shadow-xs);
}

.btn--secondary:hover {
  background: var(--bg-sidebar);
  border-color: var(--color-muted-light);
  color: var(--text);
  text-decoration: none;
}

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn--ghost:hover {
  background: var(--color-line-subtle);
  color: var(--text);
  text-decoration: none;
}

.btn--sm { height: 32px; padding: 0 var(--space-3); font-size: var(--text-xs); }
.btn--lg { height: 44px; padding: 0 var(--space-6); font-size: var(--text-base); }

.btn svg { width: 16px; height: 16px; }

/* ── Badges & tags ── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: 22px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
  font-size: 0.6875rem;
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  border: 1px solid transparent;
}

.badge--accent { background: var(--color-accent-soft); color: var(--color-accent-ink); border-color: var(--color-accent-muted); }
.badge--brand { background: var(--color-brand-soft); color: #B91C1C; border-color: var(--color-brand-muted); }
.badge--success { background: var(--color-success-soft); color: var(--color-success-ink); }
.badge--warning { background: var(--color-warning-soft); color: var(--color-warning-ink); }
.badge--neutral { background: var(--color-line-subtle); color: var(--text-muted); border-color: var(--border); }

.tag {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  transition: border-color var(--duration-fast), background var(--duration-fast);
}

.tag:hover {
  border-color: var(--color-muted-light);
  background: var(--color-line-subtle);
  text-decoration: none;
  color: var(--text);
}

.tag--link { cursor: pointer; }

/* ── Alerts / callouts ── */

.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  border: 1px solid;
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
  margin-bottom: var(--space-6);
}

.alert__icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 2px;
}

.alert__content {
  flex: 1;
  min-width: 0;
}

.alert__title {
  display: block;
  font-weight: var(--weight-semibold);
  color: inherit;
  margin-bottom: var(--space-1);
}

.alert__body { color: inherit; opacity: 0.9; }
.alert__body p { margin: 0; color: inherit; }

.alert--info {
  background: var(--color-info-soft);
  border-color: #BAE6FD;
  color: var(--color-info-ink);
}

.alert--success {
  background: var(--color-success-soft);
  border-color: #A7F3D0;
  color: var(--color-success-ink);
}

.alert--warning {
  background: var(--color-warning-soft);
  border-color: #FDE68A;
  color: var(--color-warning-ink);
}

.alert--danger {
  background: var(--color-danger-soft);
  border-color: #FECACA;
  color: var(--color-danger-ink);
}

/* ── Cards ── */

.card {
  position: relative;
  display: block;
  padding: var(--space-5);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  transition:
    border-color var(--duration-normal) var(--ease-out),
    box-shadow var(--duration-normal) var(--ease-out),
    transform var(--duration-normal) var(--ease-out);
  text-decoration: none;
  color: inherit;
  overflow: hidden;
}

.card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, transparent 40%, var(--color-accent-muted) 100%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-out);
  pointer-events: none;
}

.card:hover {
  border-color: transparent;
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  text-decoration: none;
  color: inherit;
}

.card:hover::after { opacity: 1; }

.card__eyebrow {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.card__title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text);
  line-height: var(--leading-snug);
  margin-bottom: var(--space-2);
}

.card__desc {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: var(--leading-normal);
  margin-bottom: var(--space-4);
}

.card__meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.card__arrow {
  margin-left: auto;
  color: var(--color-accent);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity var(--duration-fast), transform var(--duration-fast);
}

.card:hover .card__arrow {
  opacity: 1;
  transform: translateX(0);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

/* Stat cards */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-10);
}

.stat-card {
  position: relative;
  padding: var(--space-5);
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast), transform var(--duration-fast);
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--color-brand), var(--color-accent));
  opacity: 0;
  transition: opacity var(--duration-fast);
}

.stat-card:hover {
  border-color: var(--color-muted-light);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.stat-card:hover::before { opacity: 1; }

.stat-card__value {
  display: block;
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  color: var(--text);
  line-height: 1;
  margin-bottom: var(--space-2);
}

.stat-card__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

/* Featured panel */

.featured {
  position: relative;
  padding: var(--space-8);
  margin-bottom: var(--space-10);
  background: linear-gradient(135deg, var(--bg-sidebar) 0%, var(--bg-surface) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.featured::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, var(--color-accent) 0%, #60A5FA 100%);
  border-radius: 4px 0 0 4px;
}

.featured__label {
  margin-bottom: var(--space-3);
}

.featured__title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  margin-bottom: var(--space-3);
}

.featured__desc {
  font-size: var(--text-base);
  color: var(--text-muted);
  max-width: 48rem;
  margin-bottom: var(--space-6);
  line-height: var(--leading-relaxed);
}

.featured__desc p { margin: 0; color: inherit; }

/* Hub cards */

.hub-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-10);
}

.hub-card {
  padding: var(--space-6);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.hub-card__title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-2);
}

.hub-card__desc {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-4);
  line-height: var(--leading-normal);
}

.hub-card__list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.hub-card__list li {
  margin: 0;
  border-top: 1px solid var(--border-subtle);
}

.hub-card__list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) 0;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
}

.hub-card__list a:hover {
  color: var(--color-accent);
  text-decoration: none;
}

.hub-card__list span {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: var(--weight-normal);
}

/* ── Article list ── */

.article-list { margin-bottom: var(--space-10); }

.article-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border-subtle);
}

.article-list__item:first-child { border-top: 1px solid var(--border-subtle); }

.article-list__title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--text);
}

.article-list__title a {
  color: inherit;
}

.article-list__title a:hover {
  color: var(--color-accent);
  text-decoration: none;
}

.article-list__meta {
  flex-shrink: 0;
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── Section headings ── */

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}

.section-title h2 {
  margin: 0;
  padding: 0;
  border: none;
  font-size: var(--text-xl);
}

.section-title a {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  white-space: nowrap;
}

.section-title a:hover { color: var(--color-accent); text-decoration: none; }

/* ── Code blocks ── */

.code-block {
  position: relative;
  margin: var(--space-6) 0;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: #FAFBFC;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.code-block__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-4);
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
}

.code-block__copy {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  font-size: var(--text-xs);
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast);
}

.code-block__copy:hover {
  background: var(--color-line-subtle);
  color: var(--text);
}

.code-block pre {
  margin: 0;
  padding: var(--space-5);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.65;
  color: var(--color-ink-soft);
  tab-size: 2;
}

.code-block .tok-key { color: #0550AE; }
.code-block .tok-str { color: #0A3069; }
.code-block .tok-cmt { color: var(--text-muted); font-style: italic; }
.code-block .tok-fn { color: #8250DF; }

/* ── TOC (on-page) ── */

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

.toc__label {
  font-size: 0.6875rem;
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

.toc__list {
  list-style: none;
  padding: 0;
  margin: 0;
  border-left: 1px solid var(--border);
}

.toc__link {
  display: block;
  padding: var(--space-2) 0 var(--space-2) var(--space-4);
  margin-left: -1px;
  border-left: 2px solid transparent;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  line-height: var(--leading-snug);
  transition: color var(--duration-fast), border-color var(--duration-fast);
}

.toc__link:hover {
  color: var(--text);
  text-decoration: none;
}

.toc__link.is-active {
  color: var(--color-accent-ink);
  border-left-color: var(--color-accent);
  font-weight: var(--weight-semibold);
}

.toc__link--h3 {
  padding-left: var(--space-6);
  font-size: var(--text-xs);
  font-weight: var(--weight-normal);
}

/* ── Article meta ── */

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.article-meta__sep { color: var(--color-line); }

/* ── Newsletter ── */

.newsletter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-8);
  flex-wrap: wrap;
  padding: var(--space-8);
  margin-top: var(--space-12);
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
}

.newsletter__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-1);
}

.newsletter__desc {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin: 0;
}

.newsletter__form {
  display: flex;
  gap: var(--space-2);
}

.newsletter__input {
  height: 40px;
  width: 240px;
  padding: 0 var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  font-size: var(--text-sm);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}

.newsletter__input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: var(--shadow-focus);
}

/* ── Glossary row ── */

.glossary {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-8);
}

/* ── Steps (numbered) ── */

.steps { counter-reset: step; margin: var(--space-8) 0; }

.step {
  position: relative;
  padding-left: var(--space-12);
  margin-bottom: var(--space-8);
  counter-increment: step;
}

.step::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: var(--color-accent-soft);
  color: var(--color-accent-ink);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-accent-muted);
}

.step__title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-2);
}

/* ── Prev / next nav ── */

.article-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-top: var(--space-12);
  padding-top: var(--space-8);
  border-top: 1px solid var(--border);
  width: 100%;
}

.article-nav__item {
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}

.article-nav__item:hover {
  border-color: var(--color-accent-muted);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}

.article-nav__label {
  display: block;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-bottom: var(--space-2);
}

.article-nav__title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text);
}

.article-nav__item--next { text-align: right; }

/* ── Styleguide helpers ── */

.sg-section {
  margin-bottom: var(--space-16);
  padding-bottom: var(--space-12);
  border-bottom: 1px solid var(--border);
}

.sg-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}

.sg-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.sg-swatch {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

/* ── Responsive component tweaks ── */

@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .card-grid, .hub-grid { grid-template-columns: 1fr; }
  .newsletter { flex-direction: column; align-items: stretch; }
  .newsletter__form { flex-direction: column; }
  .newsletter__input { width: 100%; }
  .article-nav { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
}

/* ── Back to top button ── */
:root {
  --to-top-size: 42px;
  --to-top-gap: var(--space-5);
  --to-top-clearance: calc(var(--to-top-size) + var(--to-top-gap) + var(--space-3));
}

.to-top {
  position: fixed;
  right: var(--to-top-gap);
  bottom: var(--to-top-gap);
  z-index: calc(var(--z-topbar) + 2);
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity var(--duration-normal) var(--ease-out), transform var(--duration-normal) var(--ease-out), visibility var(--duration-normal), bottom var(--duration-normal) var(--ease-out);
}

.to-top .lucide {
  width: 18px;
  height: 18px;
}

.to-top:hover {
  border-color: var(--color-muted-light);
  background: var(--bg-sidebar);
}

.to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.to-top.to-top--footer-near {
  bottom: calc(var(--to-top-gap) + 68px);
}

/* ── Tools UI ── */
.tool-panel {
  margin-top: var(--space-8);
  padding: var(--space-6);
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
}

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

.tool-fields {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
  align-items: end;
}

.tool-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.tool-field__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
}

.tool-field__input {
  width: 100%;
  height: 42px;
  padding: 0 var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text);
  outline: none;
  transition: box-shadow var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);
}

.tool-field__input:focus {
  box-shadow: var(--shadow-focus);
  border-color: transparent;
}

.tool-actions {
  grid-column: span 2;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-top: var(--space-2);
}

.tool-result {
  border: 1px solid var(--border);
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  min-height: 120px;
}

.tool-result__placeholder {
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

.tool-result__status {
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-4);
}

.tool-result__status.is-valid { color: var(--color-success-ink); }
.tool-result__status.is-invalid { color: var(--color-danger-ink); }

.tool-result__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

.tool-result__kv {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.tool-result__block {
  padding: var(--space-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-sidebar);
}

.tool-result__k {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  margin-bottom: var(--space-2);
  font-weight: var(--weight-semibold);
}

.tool-result__v {
  font-size: var(--text-sm);
  color: var(--text);
  font-weight: var(--weight-semibold);
  line-height: 1.2;
}

.tool-result__hint {
  margin-top: var(--space-4);
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

.tool-note {
  margin-top: var(--space-4);
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

@media (max-width: 900px) {
  .tool-fields { grid-template-columns: 1fr; }
  .tool-actions { grid-column: auto; }
}
