/* Motion (DESIGN.md section 11): purposeful entrance transitions, driven
   by assets/js/motion-utils.js. Reduced motion is handled entirely by
   theme.css zeroing --transition-slow, not by a separate media query
   here, so this stays correct automatically. */

.fade-in-up {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity var(--transition-slow), transform var(--transition-slow);
}

.fade-in-up.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Sidebar (DESIGN.md section 4.1) */

.sidebar {
  width: var(--sidebar-width);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border-default);
  height: 100vh;
  overflow-y: auto;
  min-height: 0;
  padding: var(--space-6) var(--space-4);
}

.sidebar-group {
  margin-bottom: var(--space-2);
}

.sidebar-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  padding: var(--space-2) var(--space-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.sidebar-group-toggle:hover {
  background: var(--color-surface-inset);
  color: var(--color-text-primary);
}

.sidebar-group-toggle svg {
  transition: transform var(--transition-base);
  flex-shrink: 0;
}

.sidebar-group.is-expanded .sidebar-group-toggle svg {
  transform: rotate(90deg);
}

.sidebar-group-list {
  list-style: none;
  margin: var(--space-1) 0 var(--space-3) 0;
  padding: 0;
  display: none;
}

.sidebar-group.is-expanded .sidebar-group-list {
  display: block;
}

.sidebar-link {
  display: block;
  padding: var(--space-2) var(--space-3);
  margin: 0 0 var(--space-1) 0;
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.sidebar-link:hover {
  background: var(--color-surface-inset);
  color: var(--color-text-primary);
  text-decoration: none;
}

.sidebar-link.is-active {
  background: var(--color-accent-muted);
  color: var(--color-accent);
  font-weight: var(--font-weight-medium);
}

/* Sidebar toggle button, mobile and tablet only (DESIGN.md section 6.1) */

.nav-toggle {
  display: none;
  align-items: center;
  gap: var(--space-2);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  color: var(--color-text-primary);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  position: fixed;
  top: var(--space-4);
  left: var(--space-4);
  z-index: 50;
}

/* Content area (DESIGN.md section 4.2) */

/* min-width: 0 because .content is a flex item in the wiki layout, and a flex
   item's automatic minimum size is its content-based minimum, not zero. Without
   this it refuses to shrink below the widest thing inside it: a demo stage or a
   table then pushes the whole column past the viewport instead of scrolling
   inside its own box, which is what .demo-stage and .table-wrap already ask for.
   See DESIGN.md section 8 and the lesson in 02-layout-and-structure. */
.content {
  min-width: 0;
  max-width: var(--content-max-width);
  padding: var(--space-10) var(--space-6);
}

.content > *:last-child {
  margin-bottom: 0;
}

.eyebrow {
  display: block;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}

/* Code block (DESIGN.md section 4.3) */

pre {
  background: var(--color-surface-inset);
  border: 1px solid var(--color-border-muted);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  overflow-x: auto;
  margin: 0 0 var(--space-6) 0;
}

code {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
}

p code,
li code {
  background: var(--color-surface-inset);
  border: 1px solid var(--color-border-muted);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.4em;
}

/* Callout (DESIGN.md section 4.4) */

.callout {
  display: flex;
  gap: var(--space-2);
  background: var(--color-surface);
  border-left: 4px solid var(--color-accent);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  padding: var(--space-4);
  margin: 0 0 var(--space-6) 0;
}

.callout svg {
  flex-shrink: 0;
  margin-top: 0.15em;
}

.callout--warning {
  border-left-color: var(--color-warning);
}

.callout--caution {
  border-left-color: var(--color-danger);
}

.callout p:last-child {
  margin-bottom: 0;
}

/* Button (DESIGN.md section 4.8) */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 40px;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color var(--transition-base), color var(--transition-base);
}

.button--primary {
  background: var(--color-accent);
  color: var(--color-on-accent);
}

.button--primary:hover {
  background: var(--color-accent-emphasis);
  text-decoration: none;
}

.button--secondary {
  background: transparent;
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.button--secondary:hover {
  background: var(--color-accent-muted);
  text-decoration: none;
}

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

.button--ghost:hover {
  color: var(--color-text-primary);
  text-decoration: none;
}

/* Demo container (DESIGN.md section 4.5) */

.demo-container {
  position: relative;
  background: var(--color-surface);
  border: 1px dashed var(--color-border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-8) var(--space-6) var(--space-6);
  margin: 0 0 var(--space-6) 0;
}

.demo-label {
  position: absolute;
  top: var(--space-3);
  left: var(--space-4);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.demo-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.demo-stage {
  background: var(--color-surface-inset);
  border: 1px solid var(--color-border-muted);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  overflow-x: auto;
}

.demo-readout {
  margin-top: var(--space-4);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.demo-readout strong {
  color: var(--color-text-primary);
}

/* Interactive control (DESIGN.md section 4.6) */

.control-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

input[type="range"] {
  accent-color: var(--color-accent);
}

input[type="text"],
input[type="email"],
input[type="color"] {
  background: var(--color-surface-inset);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  color: var(--color-text-primary);
  font-family: inherit;
  font-size: var(--font-size-sm);
}

input[type="color"] {
  padding: var(--space-1);
  width: 48px;
  height: 36px;
}

.tab-row {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.tab-button {
  background: var(--color-surface-inset);
  border: 1px solid var(--color-border-strong);
  color: var(--color-text-secondary);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.tab-button.is-active {
  background: var(--color-accent-muted);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* Card (DESIGN.md section 4.7) */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

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

/* Table (DESIGN.md section 4.9) */

.table-wrap {
  overflow-x: auto;
  margin: 0 0 var(--space-6) 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

th,
td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--color-border-muted);
}

th {
  background: var(--color-surface);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
}

td {
  color: var(--color-text-secondary);
}

.difficulty {
  display: inline-block;
  padding: 0.15em 0.6em;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  background: var(--color-accent-muted);
  color: var(--color-accent);
}

/* Web safe color chart (education/03-typography-and-color/web-safe-colors.html) */

.ws-help {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-4);
}

.ws-chart {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
}

.ws-panel-label {
  display: block;
  margin-bottom: var(--space-1);
  color: var(--color-text-secondary);
  font-size: var(--font-size-xs);
}

.ws-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 2px;
}

.ws-swatch {
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 2px;
  cursor: pointer;
}

.ws-swatch:hover {
  outline: 2px solid var(--color-text-primary);
  outline-offset: 1px;
}

.ws-swatch:focus-visible,
.ws-swatch[aria-pressed="true"] {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  position: relative;
  z-index: 1;
}

.ws-detail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4) var(--space-6);
  margin-top: var(--space-6);
  padding: var(--space-4);
  background: var(--color-surface-inset);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-md);
}

.ws-detail-swatch,
.ws-snap-swatch {
  width: 72px;
  height: 72px;
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-md);
}

.ws-detail-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: var(--space-2) var(--space-4);
  flex: 1 1 320px;
  margin: 0;
}

.ws-detail-list dt {
  color: var(--color-text-secondary);
  font-size: var(--font-size-xs);
}

.ws-detail-list dd {
  margin: 0;
  font-size: var(--font-size-sm);
}

.ws-snap-label.demo-label {
  position: static;
  display: block;
  margin: var(--space-8) 0 var(--space-3);
}

.ws-snap {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin: var(--space-4) 0;
}

.ws-snap-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
}

.ws-snap-arrow {
  color: var(--color-text-secondary);
  font-size: var(--font-size-xl);
}

@media (max-width: 700px) {
  .ws-chart {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .ws-chart {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Data Visualization and E-commerce UX demos (Modules 08 and 09, M23).
   Every color is a site token or a Color Standard role, so the demos
   follow the visitor's light or dark mode. */

.dv-chart {
  display: block;
  width: 100%;
  max-width: 480px;
  height: auto;
  margin: 0 auto;
}

.dv-axis {
  stroke: var(--color-border-strong);
  stroke-width: 1;
}

.dv-bar,
.dv-point {
  fill: var(--color-accent);
}

.dv-line {
  fill: none;
  stroke: var(--color-accent);
  stroke-width: 2.5;
}

.dv-slice {
  stroke: var(--color-surface);
  stroke-width: 2;
}

.dv-slice-0 { fill: var(--color-accent); }
.dv-slice-1 { fill: var(--ti-blue-50); }
.dv-slice-2 { fill: var(--ti-purple-50); }
.dv-slice-3 { fill: var(--ti-gray-50); }

.dv-label,
.dv-value {
  fill: var(--color-text-secondary);
  font-family: var(--font-body);
  font-size: 11px;
}

.dv-value {
  fill: var(--color-text-primary);
  font-weight: var(--font-weight-semibold);
}

.dv-ok,
.dv-no {
  font-weight: var(--font-weight-semibold);
}

.dv-ok { color: var(--color-success); }
.dv-no { color: var(--color-danger); }

.dc-check,
.ec-toggles label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 32px;
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
}

.dc-title {
  margin: 0 0 var(--space-2);
  color: var(--color-text-primary);
  font-weight: var(--font-weight-semibold);
  text-align: center;
}

.dc-bar.dc-neutral { fill: var(--ti-gray-40); }
.dc-bar.dc-accent { fill: var(--color-accent); }
.dc-hue-0 { fill: var(--ti-red-50); background: var(--ti-red-50); }
.dc-hue-1 { fill: var(--ti-yellow-30); background: var(--ti-yellow-30); }
.dc-hue-2 { fill: var(--ti-green-50); background: var(--ti-green-50); }
.dc-hue-3 { fill: var(--ti-blue-50); background: var(--ti-blue-50); }
.dc-hue-4 { fill: var(--ti-purple-50); background: var(--ti-purple-50); }
/* Grayscale preview: the five hues above at their own lightness. */
.dc-gray-0 { fill: #767676; background: #767676; }
.dc-gray-1 { fill: #a4a4a4; background: #a4a4a4; }
.dc-gray-2 { fill: #757575; background: #757575; }
.dc-gray-3 { fill: #757575; background: #757575; }
.dc-gray-4 { fill: #757575; background: #757575; }
.dc-neutral { background: var(--ti-gray-40); }
.dc-accent { background: var(--color-accent); }

.dc-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2) var(--space-4);
  margin: var(--space-3) 0 0;
  padding: 0;
  list-style: none;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
}

.dc-key {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: var(--space-2);
  border-radius: 2px;
  vertical-align: -1px;
}

.ec-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  margin: 0;
  padding: 0;
  border: 0;
}

.ec-toggles legend {
  flex-basis: 100%;
  padding: 0;
}

.ec-product {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: var(--space-4);
  max-width: 480px;
  margin: 0 auto;
}

.ec-photo {
  min-height: 160px;
  border-radius: var(--radius-md);
  background: linear-gradient(160deg, var(--ti-green-20), var(--ti-green-40));
}

.ec-body p {
  margin: 0 0 var(--space-2);
  font-size: var(--font-size-sm);
}

.ec-name {
  color: var(--color-text-primary);
  font-weight: var(--font-weight-semibold);
}

.ec-price {
  color: var(--color-text-primary);
  font-size: var(--font-size-lg) !important;
  font-weight: var(--font-weight-bold);
}

.ec-line {
  color: var(--color-text-secondary);
}

.ec-size {
  display: inline-block;
  min-width: 28px;
  padding: 0 var(--space-2);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  text-align: center;
}

.ec-size.is-chosen {
  border-color: var(--color-accent);
  color: var(--color-accent);
  font-weight: var(--font-weight-semibold);
}

.ec-size.is-out {
  border-style: dashed;
  color: var(--color-text-secondary);
}

.ec-buy {
  display: inline-block;
  margin-top: var(--space-2);
  pointer-events: none;
}

.co-steps {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0 0 var(--space-4);
  padding: 0;
  list-style: none;
  counter-reset: co;
}

.co-steps li {
  counter-increment: co;
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-full);
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
}

.co-steps li::before {
  content: counter(co) ". ";
  color: var(--color-text-secondary);
}

.co-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.co-fields li {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-canvas);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
}

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

  .ec-photo {
    min-height: 120px;
  }
}
