/**
 * Shared UI primitives + Ops style guide components.
 * Depends on /design-system/design-tokens.css (load first).
 */

/* --- Styleguide page chrome --- */
.guide-nav {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 48px;
  display: flex;
  position: sticky;
  top: 0;
  z-index: 50;
}
.nav-item {
  padding: 14px 16px;
  font-size: var(--type-body-size);
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  user-select: none;
  font-weight: 400;
  letter-spacing: -0.01em;
  transition: color 0.12s;
  background: transparent;
  font-family: var(--font-ui);
}
.nav-item:hover {
  color: var(--text-primary);
}
.nav-item.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: 500;
}
.guide-body {
  padding: 48px;
  max-width: 860px;
}
.page-section {
  display: none;
}
.page-section.active {
  display: block;
}
.section {
  margin-bottom: 64px;
}
.section-header {
  margin-bottom: 28px;
}
.section-num {
  font-size: var(--type-sm-size);
  font-weight: 500;
  color: var(--brand);
  letter-spacing: 0.3px;
  margin-bottom: 5px;
}
.section-title {
  font-size: var(--type-page-heading-size);
  font-weight: var(--type-page-heading-weight);
  color: var(--text-primary);
  letter-spacing: var(--type-page-heading-tracking);
  font-family: var(--font-display);
  line-height: 1.15;
}
.section-desc {
  font-size: var(--type-body-size);
  color: var(--text-muted);
  margin-top: 7px;
  line-height: 1.65;
  max-width: 560px;
}
.sub {
  margin-bottom: 32px;
}
.sub-label {
  font-size: var(--type-label-size);
  font-weight: var(--type-label-weight);
  color: var(--text-hint);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 14px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--border-faint);
}
.swatch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
  gap: 8px;
}
.swatch {
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}
.swatch-color {
  height: 52px;
}
.swatch-info {
  background: var(--bg-card);
  padding: 9px 12px;
}
.swatch-name {
  font-size: var(--type-sm-size);
  font-weight: 500;
  color: var(--text-primary);
}
.swatch-hex {
  font-size: var(--type-xs-size);
  color: var(--text-muted);
  margin-top: 2px;
}
.swatch-use {
  font-size: var(--type-xs-size);
  color: var(--text-hint);
  margin-top: 3px;
  line-height: 1.4;
}
.cdot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 8px;
  flex-shrink: 0;
}
.tone-strip {
  display: flex;
  gap: 6px;
}
.tone-chip {
  flex: 1;
  height: 72px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 8px 10px;
}
.tone-chip-label {
  font-size: var(--type-xs-size);
  color: var(--text-hint);
}
.tone-chip-hex {
  font-size: var(--type-sm-size);
  color: var(--text-secondary);
  margin-top: 2px;
}
.preview-box {
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 24px;
  margin-bottom: 8px;
}
.code {
  font-size: var(--type-sm-size);
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  line-height: 1.75;
  overflow-x: auto;
  margin-top: 6px;
}
.note {
  font-size: var(--type-body-sm-size);
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 14px;
}
.font-block {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 22px 24px;
}
.font-block-tag {
  font-size: var(--type-xs-size);
  color: var(--text-hint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}
.space-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 9px;
}
.space-bar {
  background: var(--bg-inset);
  border-radius: 2px;
  height: 16px;
  border: 1px solid rgba(33, 78, 89, 0.12);
  flex-shrink: 0;
}
.radius-grid {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.radius-item {
  text-align: center;
}
.radius-box {
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
}
.radius-label {
  font-size: var(--type-sm-size);
  color: var(--text-muted);
  margin-top: 6px;
}
.radius-val {
  font-size: var(--type-xs-size);
  color: var(--text-hint);
  margin-top: 1px;
}
.do-dont {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.do-box {
  background: var(--do-bg);
  border: 1px solid var(--do-border);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.dont-box {
  background: var(--dont-bg);
  border: 1px solid var(--dont-border);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.do-tag {
  font-size: var(--type-xs-size);
  font-weight: 600;
  color: var(--do-text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 7px;
}
.dont-tag {
  font-size: var(--type-xs-size);
  font-weight: 600;
  color: var(--dont-text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 7px;
}
.do-box p,
.dont-box p {
  font-size: var(--type-body-sm-size);
  color: var(--text-secondary);
  line-height: 1.6;
}
.bal-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-faint);
}
.bal-row:last-child {
  border-bottom: none;
}
.bal-val {
  font-size: var(--type-card-title-size);
  font-weight: 500;
  width: 110px;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}
.bal-desc {
  font-size: var(--type-body-sm-size);
  color: var(--text-muted);
}

/* --- Field grid --- */
.c-fields {
  display: grid;
  grid-template-columns: var(--field-grid-columns);
  gap: var(--field-grid-gap-row) var(--field-grid-gap-col);
}

.c-fields > .c-field-full,
.c-fields > [data-field-span="full"] {
  grid-column: 1 / -1;
}

.c-fl {
  font-family: var(--font-ui);
  font-size: var(--type-field-label-size);
  font-weight: var(--type-field-label-weight);
  color: var(--text-muted);
  text-transform: var(--type-field-label-transform);
  letter-spacing: var(--type-field-label-tracking);
  margin-bottom: var(--type-field-label-margin-bottom);
}

.c-fv {
  font-family: var(--font-ui);
  font-size: var(--type-field-value-size);
  font-weight: var(--type-field-value-weight);
  letter-spacing: var(--type-field-value-tracking);
  color: var(--text-primary);
}

.c-fv.money {
  color: var(--brand-text);
  font-weight: 500;
}

/* --- Type specimen table --- */
.type-table {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.type-row {
  padding: 13px 20px;
  display: flex;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid var(--border-faint);
}

.type-row:last-child {
  border-bottom: none;
}

.type-meta {
  width: 148px;
  flex-shrink: 0;
}

.type-role {
  font-size: var(--type-sm-size);
  color: var(--text-hint);
  font-family: var(--font-ui);
}

.type-spec {
  font-size: var(--type-xs-size);
  color: var(--text-hint);
  margin-top: 3px;
  font-family: var(--font-ui);
  line-height: 1.6;
}

.type-sample {
  flex: 1;
  color: var(--text-primary);
  font-family: var(--font-ui);
}

/* --- Badges (outline system) --- */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: var(--type-sm-size);
  font-weight: 500;
  padding: var(--badge-padding-y) var(--badge-padding-x);
  border-radius: var(--badge-radius);
  white-space: nowrap;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  font-family: var(--font-ui);
}
.b-informative {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--text-primary);
}
.b-dormant {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border-medium);
}
.b-active {
  background: transparent;
  color: var(--brand);
  border-color: var(--brand);
}
.b-complete {
  background: var(--brand);
  color: var(--text-on-brand);
  border-color: var(--brand);
}
.b-danger {
  background: transparent;
  color: var(--secondary);
  border-color: var(--secondary);
}
.badge-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

/* --- Buttons --- */
.c-btn {
  border: 1px solid var(--border-medium);
  background: var(--bg-card);
  border-radius: var(--radius-pill);
  padding: 7px 16px;
  font-size: var(--type-body-size);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  letter-spacing: -0.01em;
  font-weight: 400;
}
.c-btn.primary {
  background: var(--brand);
  color: var(--text-on-brand);
  border-color: var(--brand);
  font-weight: 500;
}
/* Secondary = neutral outline (formerly .ghost); .ghost kept as alias */
.c-btn.secondary,
.c-btn.ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-medium);
}
.c-btn.destructive {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger-light);
}

/* Button hover / focus (single source; .c-btn--hover-demo mirrors for styleguide) */
.c-btn:hover:not(:disabled),
.c-btn:focus-visible:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-medium);
  color: var(--text-secondary);
}
.c-btn:focus-visible:not(:disabled) {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.c-btn.primary:hover:not(:disabled),
.c-btn.primary:focus-visible:not(:disabled),
.c-btn.primary.c-btn--hover-demo:not(:disabled) {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  color: var(--text-on-brand);
}
.c-btn.secondary:hover:not(:disabled),
.c-btn.secondary:focus-visible:not(:disabled),
.c-btn.secondary.c-btn--hover-demo:not(:disabled),
.c-btn.ghost:hover:not(:disabled),
.c-btn.ghost:focus-visible:not(:disabled),
.c-btn.ghost.c-btn--hover-demo:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-medium);
  color: var(--text-secondary);
}
.c-btn.destructive:hover:not(:disabled),
.c-btn.destructive:focus-visible:not(:disabled),
.c-btn.destructive.c-btn--hover-demo:not(:disabled) {
  background: var(--danger-bg);
  border-color: var(--danger-light);
  color: var(--danger);
}

.btn-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

/* --- Chips --- */
.c-chip {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  font-size: var(--type-body-sm-size);
  color: var(--text-secondary);
  display: inline-block;
  font-family: var(--font-ui);
}
.chip-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* --- Inputs (neutral focus) --- */
.c-input {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--font-ui);
  font-size: var(--type-body-size);
  padding: 10px 12px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
}
.c-input::placeholder {
  color: var(--text-hint);
}
.c-input:focus {
  outline: none;
  border-color: var(--border-strong);
}

/* --- Labeled field (label + .c-input) --- */
.c-field {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  box-sizing: border-box;
}
.c-field__label {
  font-family: var(--font-ui);
  font-size: var(--type-field-label-size);
  font-weight: var(--type-field-label-weight);
  color: var(--text-muted);
  text-transform: var(--type-field-label-transform);
  letter-spacing: var(--type-field-label-tracking);
  margin-bottom: var(--type-field-label-margin-bottom);
}
.c-field__control {
  width: 100%;
  min-width: 0;
}
.c-field--labelcaps .c-field__label {
  font-size: var(--type-label-size);
  font-weight: var(--type-label-weight);
  color: var(--text-muted);
  letter-spacing: var(--type-label-tracking);
  text-transform: var(--type-label-transform);
  margin-bottom: 8px;
}

/* --- Text link (inline CTAs; styleguide Links section) --- */
.c-text-link,
.text-link-guide {
  color: var(--secondary);
  font-size: var(--type-link-size);
  font-weight: var(--type-link-weight);
  text-decoration: none;
  font-family: var(--font-ui);
}
.c-text-link:hover,
.text-link-guide:hover {
  color: var(--secondary-dark);
}

/* --- AI bar --- */
.c-ai-bar {
  background: var(--bg-card);
  border: 1px solid var(--brand);
  border-radius: var(--radius-sm);
  padding: 4px 5px 4px 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.c-ai-spark {
  width: 26px;
  height: 26px;
  background: color-mix(in srgb, var(--brand) 16%, var(--bg-card));
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--type-body-sm-size);
  flex-shrink: 0;
  color: var(--brand);
}
.c-ai-text {
  flex: 1;
  font-size: 14px;
  color: var(--text-hint);
  font-family: var(--font-ui);
}
.c-send {
  background: var(--brand);
  color: var(--text-on-brand);
  border: none;
  border-radius: var(--radius-xs);
  padding: 7px 14px;
  font-size: var(--type-body-sm-size);
  font-weight: 500;
  font-family: var(--font-ui);
  letter-spacing: -0.01em;
  cursor: pointer;
}

/* --- Card --- */
.c-card {
  background: var(--bg-card);
  border: 1px solid var(--border-on-elevated);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.c-card-header {
  padding: 11px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.c-card-title {
  font-size: var(--type-card-title-size);
  font-weight: var(--type-card-title-weight);
  color: var(--text-primary);
  letter-spacing: var(--type-card-title-tracking);
  font-family: var(--type-card-title-font-family);
  text-transform: var(--type-card-title-transform, none);
}
.c-card-sub {
  font-size: var(--type-body-sm-size);
  color: var(--text-muted);
  margin-top: 2px;
  font-family: var(--font-ui);
}
.c-card-body {
  border-top: 1px solid var(--border-on-elevated);
  padding: 13px 14px;
}

/* --- Nested card --- */
.c-nc {
  background: var(--bg-inset);
  border: 1px solid var(--border-on-inset);
  border-radius: var(--radius-card);
  padding: 9px 12px;
}
.c-nc-head {
  display: flex;
  align-items: center;
  gap: 9px;
}
.c-nc-title {
  font-size: var(--type-body-size);
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  font-family: var(--font-ui);
}
.c-nc-sub {
  font-size: var(--type-sm-size);
  color: var(--text-muted);
  font-family: var(--font-ui);
}

/* --- Dropdown --- */
.c-dd {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 4px;
  width: 192px;
  box-shadow: var(--shadow-dd);
}
.c-ddi {
  padding: 7px 12px;
  font-size: var(--type-body-size);
  color: var(--text-primary);
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  letter-spacing: -0.01em;
  font-family: var(--font-ui);
  cursor: default;
}
.c-ddi:hover {
  background: var(--bg-hover);
}
.c-ddi.danger {
  color: var(--danger);
}
.c-ddiv {
  height: 1px;
  background: var(--border-faint);
  margin: 3px 0;
}

/* --- Thinking --- */
.c-thinking {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--type-body-size);
  color: var(--text-muted);
  font-family: var(--font-ui);
}

/* --- Loader: staggered dots --- */
.c-dots,
.dots {
  display: flex;
  gap: 4px;
}
.c-dot,
.dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--brand);
  animation: cl-pulse 1.2s infinite ease-in-out;
}
.c-dot:nth-child(2),
.dot:nth-child(2) {
  animation-delay: 0.2s;
}
.c-dot:nth-child(3),
.dot:nth-child(3) {
  animation-delay: 0.4s;
}

.c-dots.lg .c-dot {
  width: 7px;
  height: 7px;
}

.c-dots.on-muted .c-dot {
  background: var(--text-muted);
}
@keyframes cl-pulse {
  0%,
  100% {
    opacity: 0.25;
  }
  50% {
    opacity: 1;
  }
}

/* --- Tables --- */
.styled-table {
  width: 100%;
  border-collapse: collapse;
}
.styled-table th {
  text-align: left;
  font-size: var(--type-xs-size);
  font-weight: 600;
  color: var(--text-hint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 0 9px;
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-ui);
}
.styled-table td {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-faint);
  vertical-align: middle;
  font-size: var(--type-body-size);
  font-family: var(--font-ui);
}
.styled-table tr:last-child td {
  border-bottom: none;
}

/* --- Shared copyright footer (HTML shells + Ops) --- */
.site-footer {
  flex-shrink: 0;
  margin-top: auto;
  text-align: center;
  font-size: var(--type-sm-size);
  color: var(--text-muted);
  padding: 12px 16px 20px;
  letter-spacing: 0.02em;
  font-family: var(--font-ui);
}
