/* Hardware-is-Hard animations — shared base styles */

.hw-anim {
  --paper:       #f4ede0;
  --paper-edge:  #e4d9b8;
  --ink:         #3a2510;
  --dim:         #8a7a55;
  --amber:       #c77d2a;
  --amber-glow:  #ffa94d;
  --amber-deep:  #a5651c;
  --yellow-hub:  #f2c034;
  --yellow-dark: #b88618;
  --shadow:      rgba(0, 0, 0, 0.25);

  display: block;
  max-width: 720px;
  margin: 2rem auto;
  padding: 1.25rem;
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  border-radius: 10px;
  color: var(--ink);
  font-family: ui-serif, Georgia, "Times New Roman", serif;
}

.hw-anim svg {
  width: 100%;
  height: auto;
  display: block;
}

.hw-canvas-3d {
  width: 100%;
  height: 420px;
  border-radius: 8px;
  overflow: hidden;
  background: #f4ede0;
  position: relative;
}
@media (max-width: 480px) { .hw-canvas-3d { height: 320px; } }
.hw-canvas-3d canvas { display: block; width: 100% !important; height: 100% !important; }
.hw-canvas-3d .hw-canvas-loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-style: italic; color: var(--dim); font-family: ui-serif, Georgia, serif;
  font-size: 0.9rem;
}

.hw-anim figcaption {
  margin-top: 0.75rem;
  text-align: center;
  font-style: italic;
  color: var(--dim);
  font-size: 0.9rem;
}

.hw-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.hw-slider {
  flex: 1 1 200px;
  min-width: 160px;
  height: 44px;
  accent-color: var(--amber);
  touch-action: manipulation;
}

.hw-readout {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  color: var(--dim);
  min-width: 5ch;
  text-align: center;
}
.hw-readout.active { color: var(--amber); }

.hw-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 0.4rem 0.9rem;
  background: var(--paper);
  border: 1.5px solid var(--paper-edge);
  border-radius: 6px;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 120ms, border-color 120ms, box-shadow 120ms;
}
.hw-btn:hover  { border-color: var(--amber); }
.hw-btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.hw-btn[data-active="true"],
.hw-btn[aria-pressed="true"] {
  background: var(--amber);
  color: var(--paper);
  border-color: var(--amber-deep);
  box-shadow: 0 1px 3px var(--shadow) inset;
}

.hw-status {
  margin-top: 0.5rem;
  text-align: center;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  color: var(--dim);
}

/* Breathing idle used by anim-cell */
@keyframes hw-breathe {
  0%, 100% { opacity: 0.7; }
  50%      { opacity: 0.95; }
}
.hw-breathe { animation: hw-breathe 2s ease-in-out infinite; }

/* PWM animation — oscilloscope + wheel side-by-side */
.hw-pwm-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  width: 100%;
  overflow: hidden;
}
@media (max-width: 540px) {
  .hw-pwm-layout { grid-template-columns: 1fr; }
}

.hw-pwm-scope {
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 0;
  border-radius: 8px;
  overflow: hidden;
  background: #1a1410;
  position: relative;
}

.hw-pwm-scope canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.hw-pwm-wheel {
  height: auto !important;
  min-height: 0 !important;
  aspect-ratio: 4 / 3;
}

.hw-pwm-wheel canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* Static SVG schematic (car-wiring) */
.hw-schematic svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: 760px;
  margin: 0 auto;
}

.hw-credits {
  margin-top: 0.3rem;
  text-align: right;
  font-family: ui-serif, Georgia, serif;
  font-size: 0.7rem;
  font-style: italic;
  color: var(--dim);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .hw-breathe { animation: none; opacity: 0.85; }
  .hw-anim .rotor { transform: none !important; }
}
