/* tape.css - The Turing Machine UI (Fixed Layout) */

/* 1. The Container */
.surface {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100vh;
  background-color: var(--body-bg-base);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  display: flex; flex-direction: column; align-items: center;
  padding-top: 1rem; padding-bottom: 1rem;
  z-index: 1000;
}

.tape-assembly {
  width: var(--nav-width); max-width: var(--max-width);
  margin-bottom: 0.5rem;
  display: flex; justify-content: center; align-items: center; flex-shrink: 0;
}

#nav-tape-viewport {
  position: relative; width: 100%; height: var(--nav-assembly-height);
  background-color: var(--paper-bg);
  background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilterViewport'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilterViewport)' opacity='0.045'/%3E%3C/svg%3E");
  display: flex; align-items: center; justify-content: center;
  padding: 5px 0; border-radius: 12px;
  box-shadow: inset 1px 1px 2px rgba(0,0,0,0.05), inset -1px -1px 2px rgba(255,255,255,0.4);
  overflow: hidden; perspective: 800px;
}

.surface nav#nav-text {
  display: flex; flex-wrap: nowrap; align-items: center; justify-content: center;
  width: auto; height: var(--slot-size);
  position: relative; z-index: 5; font-family: var(--font-mono);
}

/* 2. Links & Chars (CRITICAL FIX: Added inline-flex) */
.surface nav a.nav-link-word {
  display: inline-flex; /* <--- THIS WAS MISSING */
  align-items: center;
  text-decoration: none; 
  border-radius: 2px; 
  transition: opacity 0.3s ease; 
  padding: 0.05rem;
}
.surface nav a.nav-link-word:hover { opacity: 0.8; }

.surface nav .char-slot {
  display: flex; justify-content: center; align-items: center;
  width: var(--slot-size); height: var(--slot-size); margin: 0 var(--slot-gap);
  font-size: var(--nav-font-size); color: var(--text-color);
  position: relative; transform-style: preserve-3d; overflow: hidden;
}

.surface nav .char-slot .char {
  display: flex; align-items: center; justify-content: center; width: 100%; height: 100%;
  transition: color 0.05s linear, font-weight 0.05s linear;
  backface-visibility: hidden; text-align: center;
}
.surface nav .char-slot .char.is-active { font-weight: 700; color: var(--text-color); }

/* Separators */
.surface nav .nav-separator {
  display: inline-flex; /* Ensure separators align too */
  align-items: center;
}
.nav-separator .char-slot { font-weight: bold; }

/* 3. The Mechanism */
#tm-read-head {
  position: absolute;
  border: 1px solid rgba(0,0,0,0.15);
  background-color: rgba(254, 251, 247, 0.75);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  border-radius: 3px; z-index: 10;
  display: flex; flex-direction: column; align-items: center;
  transition: left var(--read-head-move-speed) linear, width 0.05s ease-in-out, top 0.05s ease-in-out, height 0.05s ease-in-out, opacity 0.25s ease-in-out, background-color 0.02s ease-in-out;
  transform: translateX(-50%); opacity: 0;
}
.nav-mechanism-overlay.mechanism-active #tm-read-head { opacity: 1; }
#tm-read-head.is-engaged {
  box-shadow: 0 0 2px rgba(0,0,0,0.2), inset 0 0 1px rgba(0,0,0,0.15);
  background-color: rgba(254, 251, 247, 0.25);
}

.nav-mechanism-overlay {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.3s ease-in-out, opacity 0.25s ease-in-out;
  transform: translateY(0); opacity: 0; z-index: 7; pointer-events: none;
}
.nav-mechanism-overlay.mechanism-active { opacity: 1; }
.nav-mechanism-overlay.tape-hidden { transform: translateY(-105%); opacity: 0; }

.moving-ribbon {
  width: 100%; height: var(--minimal-ribbon-height);
  background-color: var(--minimal-ribbon-color);
  position: absolute; left: 0; z-index: 1;
  transition: background-position-x var(--read-head-move-speed) linear;
}
.moving-ribbon.top-ribbon { top: calc(50% - (var(--slot-size) / 2) - var(--minimal-ribbon-height) - 2px); }
.moving-ribbon.bottom-ribbon { bottom: calc(50% - (var(--slot-size) / 2) - var(--minimal-ribbon-height) - 2px); }