/* OCR-A Font Face - uses system font if installed */
@font-face {
  font-family: 'OCR-A';
  src: local('OCR-A'),
       local('OCRA'),
       local('OCR A Std'),
       local('OCRAStd'),
       local('OCR-A Std');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  min-height: 100vh;
  background: #f5f5f5;
  padding: 2rem 1rem;
}

.main-content {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
}

.hero-container {
  text-align: left;
  max-width: 1200px; /* Wider to accommodate longer words in flip mode */
  width: 100%;
  container-type: inline-size;
}

.hero-text {
  font-size: clamp(1rem, 7cqw, 5rem);
  font-weight: 700;
  color: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  flex-wrap: nowrap; /* Prevent wrapping to a new line */
  margin-bottom: 3rem;
}

.static-text {
  display: inline-block;
  white-space: nowrap;
  flex-shrink: 0; /* Prevent static text from shrinking */
  word-spacing: -0.333em; /* Tighter kerning for fixed text */
}

.word-rotator {
  position: relative;
  display: inline-block;
  min-width: 4em;
  height: 1.2em;
  perspective: 1000px;
  overflow: hidden;
  white-space: nowrap;
  vertical-align: middle; /* Align with static text */
  flex-shrink: 0; /* Prevent rotator from shrinking */
  margin-left: 0.333em; /* Match natural word spacing like between "MIND" and "THE" */
}

.word-rotator[data-mode="flip"] {
  min-width: 0; /* Let content determine width */
  width: fit-content; /* Fit exactly to content */
}

.word {
  position: absolute;
  left: 0;
  right: 0;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(100%);
  transition: none;
  color: #666666;
  font-weight: 800;
}

.word.active {
  opacity: 1;
  transform: translateY(0);
}

/* Wheel Mode Animations - Continuous slots rotation */
.word-rotator[data-mode="wheel"] {
  overflow: hidden;
}

.word-rotator[data-mode="wheel"] .word {
  transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
}

.word-rotator[data-mode="wheel"] .word.active {
  transform: translateY(0);
  opacity: 1;
}

.word-rotator[data-mode="wheel"] .word.exiting {
  transform: translateY(-100%);
  opacity: 0;
}

.word-rotator[data-mode="wheel"] .word.entering {
  transform: translateY(100%);
  opacity: 0;
}

/* Flip Card Mode Animations - Mid-Century Airport Style */
.word-rotator[data-mode="flip"] {
  perspective: 2000px;
  overflow: visible;
  height: 1.2em;
  vertical-align: middle;
  font-size: inherit; /* Ensure font size matches hero-text for consistent scaling */
}

/* Board container holds all letter flaps */
.flip-board {
  display: flex;
  gap: 3px;
  height: 100%;
  padding: 4px 3px; /* Reduced horizontal padding to minimize extra space */
  background: #0a0a0a;
  border-radius: 6px;
  box-shadow: 
    0 4px 12px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.05);
  width: fit-content; /* Fit exactly to content */
}

/* Individual letter flap container */
.letter-flap {
  position: relative;
  width: 0.7em;
  height: 100%;
  perspective: 500px;
  font-family: 'Source Code Pro', monospace;
  font-weight: 900;
  text-transform: uppercase;
  font-size: inherit; /* Ensure font size inherits from hero-text for consistent scaling */
}

.flap {
  position: absolute;
  left: 0;
  width: 100%;
  height: 50%;
  overflow: hidden;
  background: #1a1a1a;
}

.top-static {
  top: 0;
  border-radius: 3px 3px 0 0;
  z-index: 1;
}

.bottom-static {
  bottom: 0;
  border-radius: 0 0 3px 3px;
  z-index: 0;
}

.flap-leaf {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 50%;
  z-index: 5;
  transform-origin: bottom;
  transform-style: preserve-3d;
  transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

.flap-leaf.flipping {
  transform: rotateX(-180deg);
}

.flap-leaf-front, .flap-leaf-back {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #1a1a1a;
  backface-visibility: hidden;
  overflow: hidden;
}

.flap-leaf-front {
  border-radius: 3px 3px 0 0;
  z-index: 2;
}

.flap-leaf-back {
  transform: rotateX(-180deg);
  border-radius: 0 0 3px 3px;
  z-index: 1;
}

/* Content positioning to create the split effect */
.flap-content {
  position: absolute;
  width: 100%;
  height: 200%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1em; /* Match parent font size for consistent scaling */
  font-family: inherit;
  letter-spacing: 0;
  color: #f0f0f0;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  line-height: 1;
}

/* Top halves show the top of the letter */
.top-static .flap-content,
.flap-leaf-front .flap-content {
  top: 0;
}

/* Bottom halves show the bottom of the letter */
.bottom-static .flap-content,
.flap-leaf-back .flap-content {
  bottom: 0;
}

.flap, .flap-leaf-front, .flap-leaf-back {
  background: linear-gradient(to bottom, #2a2a2a 0%, #1a1a1a 100%);
  transition: background 0.3s ease, border-color 0.3s ease;
}

/* Center dividing line on each letter flap */
.letter-flap::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10;
  pointer-events: none;
}

/* Background Modes - High Specificity */
[data-board-bg="white"] .flip-board {
  background: #e8e8e8 !important;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1) !important;
}
[data-board-bg="white"] .flap,
[data-board-bg="white"] .flap-leaf-front,
[data-board-bg="white"] .flap-leaf-back {
  background: #ffffff !important;
}
[data-board-bg="white"] .letter-flap::after {
  background: #cccccc !important;
}
[data-board-bg="white"] .flap-content {
  /* Color is set dynamically by JavaScript - don't override */
  text-shadow: 0 1px 1px rgba(255,255,255,0.5) !important;
}

[data-board-bg="invisible"] .flip-board {
  background: transparent !important;
  box-shadow: none !important;
}
[data-board-bg="invisible"] .flap,
[data-board-bg="invisible"] .flap-leaf-front,
[data-board-bg="invisible"] .flap-leaf-back {
  background: transparent !important;
}
[data-board-bg="invisible"] .letter-flap::after {
  background: rgba(0,0,0,0.1) !important;
}
[data-board-bg="invisible"] .flap-content {
  text-shadow: none !important;
}

[data-board-bg="black"] .flip-board {
  background: #0a0a0a !important;
}
[data-board-bg="black"] .flap,
[data-board-bg="black"] .flap-leaf-front,
[data-board-bg="black"] .flap-leaf-back {
  background: linear-gradient(to bottom, #2a2a2a 0%, #1a1a1a 100%) !important;
}

/* Controls */
.demo-controls {
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 2rem;
  margin-top: 3rem;
}

.control-section {
  margin-bottom: 2rem;
}

.control-section:last-child {
  margin-bottom: 0;
}

.control-section h3 {
  color: #333;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 1rem;
  text-transform: none;
  letter-spacing: 0;
}

.control-group {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.control-group.vertical {
  flex-direction: column;
  align-items: stretch;
}

.radio-label {
  color: #333;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.5rem 1rem;
  background: #f5f5f5;
  border-radius: 2px;
  transition: background 0.2s ease;
  border: 1px solid #e0e0e0;
}

.radio-label:hover {
  background: #ebebeb;
}

.radio-label input[type="radio"]:checked + span {
  font-weight: 600;
}

.radio-label input[type="radio"]:checked {
  accent-color: #666;
}

.radio-label input[type="radio"] {
  cursor: pointer;
  width: 18px;
  height: 18px;
}

.slider-label {
  color: #333;
  font-size: 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.slider-label span {
  font-weight: 600;
  color: #666;
}

.slider-label input[type="range"] {
  width: 100%;
  height: 2px;
  border-radius: 1px;
  background: #d0d0d0;
  outline: none;
  cursor: pointer;
}

.slider-label input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #333;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
  border: 1px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.slider-label input[type="range"]::-webkit-slider-thumb:hover {
  background: #1a1a1a;
  transform: scale(1.1);
}

.slider-label input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #333;
  cursor: pointer;
  border: 1px solid #fff;
  transition: background 0.15s ease, transform 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.slider-label input[type="range"]::-moz-range-thumb:hover {
  background: #1a1a1a;
  transform: scale(1.1);
}

#wordList {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #e0e0e0;
  border-radius: 2px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.875rem;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s ease;
  background: #fff;
  color: #333;
}

#wordList:focus {
  border-color: #999;
}

.text-input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #e0e0e0;
  border-radius: 2px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s ease;
  background: #fff;
  color: #333;
}

.text-input:focus {
  border-color: #999;
}

.color-control {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.color-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.color-input-group label {
  font-size: 0.75rem;
  color: #666;
  font-weight: 500;
}

.color-input {
  width: 100%;
  height: 32px;
  border: 1px solid #e0e0e0;
  border-radius: 2px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s ease;
}

.color-input:hover {
  border-color: #999;
}

.color-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-input::-webkit-color-swatch {
  border: none;
  border-radius: 1px;
}

.color-input::-moz-color-swatch {
  border: none;
  border-radius: 1px;
}

.btn-primary,
.btn-secondary {
  padding: 0.5rem 1rem;
  border: 1px solid #999;
  border-radius: 2px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
  text-transform: none;
  letter-spacing: 0;
}

.btn-primary {
  background: #333;
  color: #fff;
  border-color: #333;
}

.btn-primary:hover {
  background: #1a1a1a;
  border-color: #1a1a1a;
}

.btn-secondary {
  background: #fff;
  color: #333;
  border-color: #999;
}

.btn-secondary:hover {
  background: #f5f5f5;
  border-color: #666;
}

/* Code Generator Section */
.code-generator {
  max-width: 1200px;
  margin: 3rem auto;
  padding: 0 1.5rem;
}

.code-generator-header {
  text-align: center;
  margin-bottom: 2rem;
}

.code-generator-header h2 {
  font-size: 1.75rem;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.code-generator-header p {
  color: #666;
  font-size: 1rem;
}

.code-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #e5e5e5;
  margin-bottom: 0;
}

.code-tab {
  padding: 0.75rem 1.5rem;
  border: none;
  background: transparent;
  color: #666;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  transition: color 0.2s ease;
}

.code-tab:hover {
  color: #333;
}

.code-tab.active {
  color: #1a1a1a;
}

.code-tab.active::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: #ff0000;
}

.code-panels {
  background: #1e1e1e;
  border-radius: 0 0 12px 12px;
  overflow: hidden;
}

.code-panel {
  display: none;
}

.code-panel.active {
  display: block;
}

.code-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: #2d2d2d;
  border-bottom: 1px solid #404040;
}

.code-panel-header span {
  color: #999;
  font-size: 0.8125rem;
}

.copy-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: #404040;
  border: none;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.copy-btn:hover {
  background: #505050;
  color: #fff;
}

.copy-btn.copied {
  background: #22c55e;
  color: #fff;
}

.copy-btn svg {
  flex-shrink: 0;
}

.code-block {
  margin: 0;
  padding: 1.25rem;
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
}

.code-block code {
  display: block;
  font-family: 'Source Code Pro', 'Monaco', 'Consolas', monospace;
  font-size: 1.2rem;
  line-height: 1.6;
  color: #e0e0e0;
  white-space: pre;
}

/* Syntax highlighting */
.code-block .tag { color: #569cd6; }
.code-block .attr { color: #9cdcfe; }
.code-block .string { color: #ce9178; }
.code-block .comment { color: #6a9955; }
.code-block .keyword { color: #c586c0; }
.code-block .function { color: #dcdcaa; }
.code-block .number { color: #b5cea8; }

/* Responsive adjustments */
@media (max-width: 768px) {
  .demo-controls {
    padding: 1.5rem;
  }

  .control-group {
    flex-direction: column;
    align-items: stretch;
  }

  .radio-label {
    justify-content: center;
  }
}
